/// <summary> /// 远程项目备份按钮点击事件 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void button7_Click(object sender, EventArgs e) { try { //检查是否选中了服务项 string servername = cb_remoteServer.Text; if (servername == null || string.Empty.Equals(servername) || cb_remoteServer.SelectedIndex == 0) { MessageBox.Show("请先指定需要备份的远程项目!", "提示", MessageBoxButtons.OK, MessageBoxIcon.Asterisk); cb_remoteServer.Focus(); return; } //禁用此按钮,避免重复请求. 此时还应当禁用MD5校验,和覆盖上传按钮 button7.Enabled = false; button2.Enabled = false; button1.Enabled = false; //因为线上文件一般较大,因此在用户进行此操作时应当做适当的提醒 DialogResult result = MessageBox.Show("由于线上项目文件较大,因此备份(ZIP)过程会因为比较漫长而导致页面假死. 请耐心等待", "备份", MessageBoxButtons.OKCancel, MessageBoxIcon.Asterisk); if (result == DialogResult.OK) { string requestjson = "{\"requestid\":\"" + CommonUtil.GetRandomRequiredRequestID() + "\",\"message\":\"" + servername + "\",\"headingcode\":\"ed9ea8907f1963430bc8be4689d446b4\"}"; string response = SocketUtil.socket(ClientCache.GetCurrentServerIP(), Convert.ToInt32(ClientCache.GetInterflowPort()), requestjson); JSONUtil json = new JSONUtil(response); string message = Convert.ToString(json.GetJObject()["message"]); if ("failed".Equals(message)) { MessageBox.Show(servername + "压缩失败,请通过查看前后端日志以了解或解决此问题!"); } else { MessageBox.Show("压缩成功,文件已保存至服务器:" + message); } } button7.Enabled = true; button2.Enabled = true; button1.Enabled = true; } catch (Exception ex) { MessageBox.Show(ex.Message, "异常", MessageBoxButtons.OK, MessageBoxIcon.Error); } }
private void Comparison_Load(object sender, EventArgs e) { try { //初始化远程服务器项目列表到下拉列表 string json = "{\"requestid\":100011111,\"message\":\"这是客户端传入的message\",\"headingcode\":\"b1bb0e5951a6a8f3ff7524cd0ad92ff1\"}"; string response = SocketUtil.socket(ClientCache.GetCurrentServerIP(), Convert.ToInt32(ClientCache.GetInterflowPort()), json); JSONUtil jsonUtil = new JSONUtil(response); JObject jObject = jsonUtil.GetJObject(); JArray array = (JArray)jObject["data"]["projects"]; cb_remoteServer.Items.Add("-- 请选择服务器项目 --"); for (int i = 0; i < array.Count; i++) { cb_remoteServer.Items.Add(array[i]["name"].ToString()); } cb_remoteServer.SelectedIndex = 0; } catch (Exception ex) { MessageBox.Show("获取服务器端在线列表出现错误" + ex.Message, "在线获取", MessageBoxButtons.OK, MessageBoxIcon.Error); } }