Пример #1
0
        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;
            }
        }
Пример #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);
            }
        }
Пример #3
0
        public static T GetParamDataObj <T>(byte[] ParameterData)
        {
            string _decodeItem = WcfDataCompressControl.UnCompress(ParameterData);
            DataContractJsonSerializer serializer = new DataContractJsonSerializer(typeof(T));
            MemoryStream ms    = new MemoryStream(System.Text.Encoding.UTF8.GetBytes(_decodeItem.ToCharArray()));
            T            _item = (T)serializer.ReadObject(ms);

            ms.Close();
            return(_item);
        }
Пример #4
0
        public static string Do(string Token, string CommandName, string DesServer, byte[] ParamData)
        {
            using (SinoMoniterCommand.SinoMonitorCommandClient _sc = new SinoMoniterCommand.SinoMonitorCommandClient())
            {
                byte[] _ret = _sc.DoCommand(Token, CommandName, DesServer, ParamData);

                string _decodeDate = WcfDataCompressControl.UnCompress(_ret);
                return(_decodeDate);
            }
        }
Пример #5
0
        public static string DelSystem(byte[] ParameterData)
        {
            try
            {
                string _delName = WcfDataCompressControl.UnCompress(ParameterData);

                //删除配置
                Configuration       cfa            = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
                SystemConfigSection CurrentSysList = (SystemConfigSection)cfa.GetSection("SystemList");
                CurrentSysList.PluginCollection.Remove(_delName);
                cfa.Save();

                //删除缓存
                WatchSystemLib.RemoveSystem(_delName);
                return("TRUE");
            }
            catch (Exception ex)
            {
                return("False!" + ex.Message);
            }
        }