public void DoCommand(string CommandName, SystemStateItem StateItem)
        {
            switch (CommandName)
            {
            case "WCFService_Add":     //添加服务
                Dialog_AddWCFServiceCheck _f = new Dialog_AddWCFServiceCheck();
                if (_f.ShowDialog() == DialogResult.OK)
                {
                    WCFServiceStatus _wss = new WCFServiceStatus();
                    _wss.Name        = _f.WCFSvcName;
                    _wss.Description = _f.WCFSvcDes;
                    _wss.WCFType     = _f.WCFSvcType;
                    _wss.URL         = _f.WCFSvcUrl;

                    string _ret = SinoCommandExcute.Do(SessionCache.CurrentTokenString, "ExcuteNodeCommand.WatchApplicationServerPlugin.WCFService_Add", StateItem.SystemName, _wss);
                    if (_ret == "TRUE")
                    {
                        //CurrentGridView.DeleteRow(CurrentGridView.FocusedRowHandle);
                        MessageBox.Show(string.Format("添加WCF服务[{0}]成功,但删除结果需要过几分钟后才能生效,请耐心等待一下。", _wss.Name), "系统提示");
                    }
                }
                break;

            case "WCFService_Del":     //删除服务
                if (CurrentGridView != null && CurrentGridView.FocusedRowHandle >= 0)
                {
                    dynamic _ws = CurrentGridView.GetRow(CurrentGridView.FocusedRowHandle) as ExpandoObject;
                    if (_ws != null)
                    {
                        if (MessageBox.Show(string.Format("是否要移除监控CurrentGridView[{0}]({1})?", _ws.Name, _ws.Description), "系统提示", MessageBoxButtons.YesNo)
                            == DialogResult.Yes)
                        {
                            string _ret = SinoCommandExcute.Do(SessionCache.CurrentTokenString, "ExcuteNodeCommand.WatchApplicationServerPlugin.WCFService_Del", StateItem.SystemName, _ws.Name);
                            if (_ret == "TRUE")
                            {
                                //CurrentGridView.DeleteRow(CurrentGridView.FocusedRowHandle);
                                MessageBox.Show(string.Format("删除监控WCF服务[{0}]成功,但删除结果需要过几分钟后才能生效,请耐心等待一下。", _ws.Name), "系统提示");
                            }
                        }
                    }
                }
                break;

            case "WCFService_Status":
                SaveFileDialog _dialog = new SaveFileDialog();
                _dialog.Filter           = "XML格式(*.xml)|*.xml";
                _dialog.InitialDirectory = Utils.ExeDir;
                _dialog.FileName         = "ExportWCFServiceStatus.xml";
                if (_dialog.ShowDialog() == DialogResult.OK)
                {
                    string _s = SinoSZJS.Base.Misc.DataConvert.Serializer(typeof(List <WCFServiceStatus>), this._status);
                    File.WriteAllText(_dialog.FileName, _s);
                }
                break;

            default:
                MessageBox.Show(CommandName, "提示");
                break;
            }
        }
 private string GetZTString(WCFServiceStatus _ws)
 {
     if (_ws.WcfStauts == 1)
     {
         return("连接成功!");
     }
     else
     {
         return(_ws.WcfError);
     }
 }
        private string GetFlag(WCFServiceStatus _ws)
        {
            switch (_ws.WcfStauts)
            {
            case 1:
                return("1");

            case 3:
                return("3");

            default:
                return("0");
            }
        }
Example #4
0
        private List<WCFServiceStatus> GetWCFStatus()
        {
            List<WCFServiceStatus> _ret = new List<WCFServiceStatus>();
            CheckWCFServiceConfigSection WcfServiceList = (CheckWCFServiceConfigSection)ConfigurationManager.GetSection("CheckWCFServiceList");
            foreach (CheckWCFServiceConfigurationElement _el in WcfServiceList.PluginCollection)
            {
                WCFServiceStatus _wss = new WCFServiceStatus();
                _wss.Name = _el.Name;
                _wss.Description = _el.Description;
                _wss.WCFType = _el.Type;
                string _err = "";
                _wss.WcfStauts = CheckWcfRequest_old(_el.Type, _el.URL, ref _err);
                _wss.WcfError = _err;
                _ret.Add(_wss);
            }

            return _ret;
        }
        private byte[] DoWCFService_Add(byte[] ParameterData)
        {
            WCFServiceStatus _wss = CommandCommon.GetParamDataObj <WCFServiceStatus>(ParameterData);

            Configuration cfa = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None);
            CheckWCFServiceConfigSection        CurrentSeviceList = (CheckWCFServiceConfigSection)cfa.GetSection("CheckWCFServiceList");
            CheckWCFServiceConfigurationElement _new = new CheckWCFServiceConfigurationElement();

            _new.Name        = _wss.Name;
            _new.Description = _wss.Description;
            _new.Type        = _wss.WCFType;
            _new.URL         = _wss.URL;
            CurrentSeviceList.PluginCollection.Add(_new);
            cfa.Save();

            ConfigurationManager.RefreshSection("CheckWCFServiceList");
            string _ret = "TRUE";

            TaskList.RunTaskImmediately("SystemSelfCheck");
            byte[] _data = Encoding.Unicode.GetBytes(_ret);
            return(_data);
        }