private void bt_DelSys_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { //删除服务器 if (this.gridView1.FocusedRowHandle < 0) { MessageBox.Show("请选择一个要删除的服务器记录!", "系统提示"); } else { SystemStateItem _item = this.gridView1.GetRow(this.gridView1.FocusedRowHandle) as SystemStateItem; if (MessageBox.Show(string.Format("您确认要删除监控服务器[{0}]吗?", _item.SystemName), "系统提示", MessageBoxButtons.YesNo) == System.Windows.Forms.DialogResult.Yes) { string _delNodeName = _item.SystemName; byte[] _callbytes = WcfDataCompressControl.Compress(_delNodeName); string _ret = SinoCommandExcute.Do(SessionCache.CurrentTokenString, "DelWatchNode", "", _callbytes); if (_ret == "TRUE") { this.gridView1.BeginDataUpdate(); SystemItems.Remove(_item); this.gridView1.EndDataUpdate(); MessageBox.Show("删除成功!" + _ret, "系统提示"); } else { MessageBox.Show("删除失败!" + _ret, "系统提示"); } } } }
private void bt_AddSys_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { //添加服务器 Dialog_AddNode _f = new Dialog_AddNode(); if (_f.ShowDialog() == System.Windows.Forms.DialogResult.OK) { SystemStateItem _item = _f.GetSystemStateItem(); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(SystemStateItem)); MemoryStream stream = new MemoryStream(); serializer.WriteObject(stream, _item); stream.Position = 0; StreamReader sr = new StreamReader(stream); string resultStr = sr.ReadToEnd(); sr.Close(); stream.Close(); byte[] _callbytes = WcfDataCompressControl.Compress(resultStr); string _ret = SinoCommandExcute.Do(SessionCache.CurrentTokenString, "AddWatchNode", "", _callbytes); if (_ret == "TRUE") { MessageBox.Show("添加成功!" + _ret, "系统提示"); } else { MessageBox.Show("添加失败!" + _ret, "系统提示"); } } }
public static string Do <T>(string Token, string CommandName, string DesServer, T ParamData) { try { DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(T)); MemoryStream stream = new MemoryStream(); serializer.WriteObject(stream, ParamData); stream.Position = 0; StreamReader sr = new StreamReader(stream); string resultStr = sr.ReadToEnd(); sr.Close(); stream.Close(); byte[] _callbytes = WcfDataCompressControl.Compress(resultStr); using (SinoMoniterCommand.SinoMonitorCommandClient _sc = new SinoMoniterCommand.SinoMonitorCommandClient()) { byte[] _ret = _sc.DoCommand(Token, CommandName, DesServer, _callbytes); string _decodeDate = WcfDataCompressControl.UnCompress(_ret); return(_decodeDate); } } catch (Exception ex) { throw ex; } }
private void tb_ModiSys_ItemClick(object sender, DevExpress.XtraBars.ItemClickEventArgs e) { //修改服务器 if (this.gridView1.FocusedRowHandle < 0) { MessageBox.Show("请选择一个服务器记录!", "系统提示"); } else { SystemStateItem _citem = this.gridView1.GetRow(this.gridView1.FocusedRowHandle) as SystemStateItem; Dialog_AddNode _f = new Dialog_AddNode(_citem); if (_f.ShowDialog() == System.Windows.Forms.DialogResult.OK) { SystemStateItem _item = _f.GetSystemStateItem(); DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(SystemStateItem)); MemoryStream stream = new MemoryStream(); serializer.WriteObject(stream, _item); stream.Position = 0; StreamReader sr = new StreamReader(stream); string resultStr = sr.ReadToEnd(); sr.Close(); stream.Close(); byte[] _callbytes = WcfDataCompressControl.Compress(resultStr); string _ret = SinoCommandExcute.Do(SessionCache.CurrentTokenString, "ModifyWatchNode", "", _callbytes); if (_ret == "TRUE") { this.gridView1.BeginDataUpdate(); SystemItems.Remove(_citem); this.gridView1.EndDataUpdate(); MessageBox.Show("修改成功!" + _ret, "系统提示"); } else { MessageBox.Show("修改失败!" + _ret, "系统提示"); } } } }
public byte[] DoCommand(string UserPass, string CommandName, string DesServer, byte[] ParameterData) { byte[] _retbytes; string _retstr = ""; if (!ServerCommon.DataBaseConnection) { _retstr = "错误:服务端连接数据库失败!不可访问!"; _retbytes = WcfDataCompressControl.Compress(_retstr); return(_retbytes); } else { try { bool _tokenIsOK = CheckUserPass(UserPass); if (_tokenIsOK) { CommandParse _cp = new CommandParse(); _retbytes = _cp.DoCommand(CommandName, DesServer, ParameterData); } else { _retstr = "身份认证失败!不可访问!"; _retbytes = WcfDataCompressControl.Compress(_retstr); } return(_retbytes); } catch (Exception ex) { _retstr = "发生错误:" + ex.Message; _retbytes = WcfDataCompressControl.Compress(_retstr); return(_retbytes); } } }
public byte[] DoCommand(string CommandName, string DesServer, byte[] ParameterData) { byte[] _retbytes; string _retstr; string[] CmdStrs = CommandName.Split('.'); switch (CmdStrs[0]) { case "GetSystemList": _retstr = WatchSystemLib.GetJsonData(); _retbytes = WcfDataCompressControl.Compress(_retstr); break; case "AddWatchNode": _retstr = SystemNodeAccessor.AddSystem(ParameterData); _retbytes = WcfDataCompressControl.Compress(_retstr); break; case "DelWatchNode": _retstr = SystemNodeAccessor.DelSystem(ParameterData); _retbytes = WcfDataCompressControl.Compress(_retstr); break; case "ModifyWatchNode": _retstr = SystemNodeAccessor.ModifySystem(ParameterData); _retbytes = WcfDataCompressControl.Compress(_retstr); break; case "GetNodeCheckMsg": _retstr = DoGetNodeCheckMsg(DesServer, ParameterData); _retbytes = WcfDataCompressControl.Compress(_retstr); break; case "GetNodePluginVersion": _retstr = DoGetNodePluginVersion(DesServer, ParameterData); _retbytes = WcfDataCompressControl.Compress(_retstr); break; case "RemoveAppPlugin": _retstr = DoRemoveAppPlugin(DesServer, ParameterData); _retbytes = WcfDataCompressControl.Compress(_retstr); break; case "UpLoadFilePlugin": _retstr = DoUpLoadFilePlugin(DesServer, ParameterData); _retbytes = WcfDataCompressControl.Compress(_retstr); break; case "LoadAppPlugin": _retstr = DoLoadAppPlugin(DesServer, ParameterData); _retbytes = WcfDataCompressControl.Compress(_retstr); break; case "GetAppPluginList": _retstr = DoGetAppPluginList(DesServer, ParameterData); _retbytes = WcfDataCompressControl.Compress(_retstr); break; case "ExcuteNodeCommand": _retstr = DoExcuteNodeCommand(CommandName, DesServer, ParameterData); _retbytes = WcfDataCompressControl.Compress(_retstr); break; case "ExcuteNodeCommandWithByte": _retbytes = DoExcuteNodeCommandWithByte(CommandName, DesServer, ParameterData); break; default: _retstr = string.Format("命令[{0}]无法识别!", CommandName); _retbytes = WcfDataCompressControl.Compress(_retstr); break; } return(_retbytes); }