Example #1
0
        private string SendCommandToNode(string DesServer, string CommandName, byte[] ParamData)
        {
            SystemStateItem _el = WatchSystemLib.GetSystem(DesServer);

            if (_el.Connected)
            {
                object[] _plist = new object[3] {
                    "OK", CommandName, ParamData
                };
                try
                {
                    object _ret     = ExecuteWCF.ExecuteMethod <SysWatchService.ISWCommandService>(_el.SystemURL, "DoCommand", _plist);
                    byte[] _byteret = _ret as byte[];
                    string _msg     = Encoding.Unicode.GetString(_byteret);
                    return(_msg);
                }
                catch (Exception ex)
                {
                    string _error = string.Format("从{0}中取当前状态出错!{1}", DesServer, ex.Message);
                    throw new Exception(_error);
                }
            }
            else
            {
                string _error = string.Format("服务器[{0}]暂时尚未连接!", DesServer);
                throw new Exception(_error);
            }
        }
Example #2
0
        public static string ModifySystem(byte[] ParameterData)
        {
            try
            {
                string _decodeItem = WcfDataCompressControl.UnCompress(ParameterData);
                DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(SystemStateItem));
                MemoryStream    ms    = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(_decodeItem.ToCharArray()));
                SystemStateItem _item = (SystemStateItem)serializer.ReadObject(ms);
                ms.Close();

                //插入配置
                Configuration              cfa            = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                SystemConfigSection        CurrentSysList = (SystemConfigSection)cfa.GetSection("SystemList");
                SystemConfigurationElement _el            = CurrentSysList.PluginCollection[_item.SystemName];
                _el.Description = _item.SystemDescription;
                _el.URL         = _item.SystemURL;
                cfa.Save();
                //插入缓存
                SystemStateItem _c = WatchSystemLib.GetSystem(_item.SystemName);
                _c.SystemURL         = _item.SystemURL;
                _c.SystemDescription = _item.SystemDescription;
                return("TRUE");
            }
            catch (Exception ex)
            {
                return("False!" + ex.Message);
            }
        }
Example #3
0
        private string DoGetNodeCheckMsg(string DesServer, byte[] ParameterData)
        {
            SystemStateItem _el = WatchSystemLib.GetSystem(DesServer);

            object[] _plist = new object[3] {
                "OK", "GetNodeCheckMsg", null
            };
            try
            {
                object _ret     = ExecuteWCF.ExecuteMethod <SysWatchService.ISWCommandService>(_el.SystemURL, "DoCommand", _plist);
                byte[] _byteret = _ret as byte[];
                string _msg     = Encoding.Unicode.GetString(_byteret);
                return(_msg);
            }
            catch (Exception ex)
            {
                string _error = string.Format("从{0}中取当前状态出错!{1}", DesServer, ex.Message);
                throw new Exception(_error);
            }
        }