コード例 #1
0
        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, "系统提示");
                    }
                }
            }
        }
コード例 #2
0
        protected void UpdateShutdownItems()
        {
            ISettingsManager       sm = ServiceRegistration.Get <ISettingsManager>();
            List <SystemStateItem> systemStateItems = sm.Load <SystemStateDialogSettings>().ShutdownItemList;

            bool timerActive = false;

            Models.SleepTimerModel stm = ServiceRegistration.Get <IWorkflowManager>().GetModel(Consts.WF_STATE_ID_SLEEP_TIMER_MODEL) as Models.SleepTimerModel;
            if (stm != null && stm.IsSleepTimerActive == true)
            {
                timerActive = true;
            }

            _shutdownItems.Clear();
            if (systemStateItems != null)
            {
                for (int i = 0; i < systemStateItems.Count; i++)
                {
                    SystemStateItem systemStateItem = systemStateItems[i];
                    if (!systemStateItem.Enabled)
                    {
                        continue;
                    }
                    ListItem item = new ListItem(Consts.KEY_NAME, Consts.GetResourceIdentifierForMenuItem(systemStateItem.Action, timerActive));
                    item.Command = new MethodDelegateCommand(() => DoAction(systemStateItem.Action));
                    _shutdownItems.Add(item);
                }
            }
            _shutdownItems.FireChange();
        }
コード例 #3
0
        private void backgroundWorker1_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            List <SystemStateItem> _states = e.Result as List <SystemStateItem>;

            this.gridView1.BeginDataUpdate();
            foreach (SystemStateItem _item in _states)
            {
                var _v = from _c in SystemItems
                         where _c.SystemName == _item.SystemName
                         select _c;
                SystemStateItem _citem = _v.FirstOrDefault();
                if (_citem == null)
                {
                    SystemItems.Add(_item);
                }
                else
                {
                    _citem.NodeState       = _item.NodeState;
                    _citem.Connected       = _item.Connected;
                    _citem.ConnectErrorMsg = _item.ConnectErrorMsg;
                    _citem.DBState         = _item.DBState;
                }
            }
            this.gridView1.EndDataUpdate();
            this.panelWait.Visible = false;
            this.timer1.Enabled    = true;
            if (CurrentInfo != null)
            {
                CurrentInfo.RefreshData();
            }
        }
コード例 #4
0
        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, "系统提示");
                }
            }
        }
コード例 #5
0
        private void DoExport(string _type, SystemStateItem StateItem)
        {
            SaveFileDialog _dialog = new SaveFileDialog();

            _dialog.Filter           = "日志格式(*.log)|*.log";
            _dialog.InitialDirectory = Utils.ExeDir;
            _dialog.FileName         = "IIS_Logs.log";
            if (_dialog.ShowDialog() == DialogResult.OK)
            {
                byte[] _ret = SinoCommandExcute.DoNoCompressed(SessionCache.CurrentTokenString, "ExcuteNodeCommandWithByte.WatchApplicationServerPlugin.IIS_Export", StateItem.SystemName, _type);
                if (_ret != null)
                {
                    //解压缩

                    if (File.Exists(_dialog.FileName))
                    {
                        File.Delete(_dialog.FileName);
                    }
                    byte[] _filebytes = WcfDataCompressControl.UnCompressByts(_ret);
                    File.WriteAllBytes(_dialog.FileName, _filebytes);
                }
                else
                {
                    MessageBox.Show("导出失败!", "系统提示");
                }
            }
        }
コード例 #6
0
        public void DoCommand(string CommandName, SystemStateItem StateItem)
        {
            switch (CommandName)
            {
            case "IIS_Export_all":
                DoExport("ALL", StateItem);
                break;

            case "IIS_Export_Warning":
                DoExport("WARNING", StateItem);
                break;

            case "IIS_Export_Error":
                DoExport("ERROR", StateItem);
                break;

            case "ModifyBlockedList":
                DoModify(StateItem);
                break;

            default:
                MessageBox.Show(CommandName, "提示");
                break;
            }
        }
コード例 #7
0
ファイル: ServerCommon.cs プロジェクト: aehyok/Monitor
        void _w_DoWork(object sender, DoWorkEventArgs e)
        {
            SystemStateItem _el = e.Argument as SystemStateItem;

            object[] _plist = new object[3] {
                "OK", "GetCurrentState", null
            };
            try
            {
                object _ret     = ExecuteWCF.ExecuteMethod <SysWatchService.ISWCommandService>(_el.SystemURL, "DoCommand", _plist);
                byte[] _byteret = _ret as byte[];
                string _msg     = Encoding.Unicode.GetString(_byteret);
                _el.Connected       = true;
                _el.ConnectErrorMsg = "";
                _el.NodeState       = new WatchNodeState(_msg);
                e.Result            = _el;
            }
            catch (Exception ex)
            {
                _el.Connected       = false;
                _el.ConnectErrorMsg = ex.Message;
                _el.NodeState       = new WatchNodeState("00000");
                e.Result            = _el;
            }
        }
コード例 #8
0
        /// <summary>
        /// Loads shutdown actions from the settings.
        /// </summary>
        private void GetShutdownActionsFromSettings()
        {
            SystemStateDialogSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <SystemStateDialogSettings>();

            _shutdownItemList = settings.ShutdownItemList;

            // Add the SleepTimer, if the Element is missing in the current configuration
            bool foundSleepTimer = false;

            foreach (SystemStateItem item in _shutdownItemList)
            {
                if (item.Action == SystemStateAction.SleepTimer)
                {
                    foundSleepTimer = true;
                    break;
                }
            }
            if (foundSleepTimer == false)
            {
                // Add the SleepTimerItem after "Shutdown"
                SystemStateItem sleepTimerItem = new SystemStateItem(SystemStateAction.SleepTimer, true);
                int             index          = 0;
                foreach (SystemStateItem item in _shutdownItemList)
                {
                    index++;
                    if (item.Action == SystemStateAction.Shutdown)
                    {
                        break;
                    }
                }
                _shutdownItemList.Insert(index, sleepTimerItem);
            }
        }
コード例 #9
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);
            }
        }
コード例 #10
0
ファイル: C_DetailPanel.cs プロジェクト: aehyok/Monitor
 public void StartRefresh(SystemStateItem item)
 {
     CurrentItem         = item;
     this.timer1.Enabled = false;
     this._initFinished  = true;
     this.backgroundWorker1.RunWorkerAsync();
 }
コード例 #11
0
        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;
            }
        }
コード例 #12
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);
            }
        }
コード例 #13
0
        static void Main(string[] args)
        {
            Application.EnableVisualStyles();
            Application.SetCompatibleTextRenderingDefault(false);

            try
            {
                SystemConfigSection CurrentSysList = (SystemConfigSection)ConfigurationManager.GetSection("SystemList");
                foreach (SystemConfigurationElement _el in CurrentSysList.PluginCollection)
                {
                    SystemStateItem _item = new SystemStateItem(_el.Name, _el.URL, _el.Description);
                    WatchSystemLib.AddSystem(_item);
                }

                if (args.Length == 0)
                {
#if DEBUG
                    Application.Run(new frmMain());
#else
                    System.ServiceProcess.ServiceBase[] ServicesToRun;
                    ServicesToRun = new System.ServiceProcess.ServiceBase[] { new SinoMonitorCenterService() };
                    System.ServiceProcess.ServiceBase.Run(ServicesToRun);
#endif
                }
                else if (args[0].ToLower() == "/f" || args[0].ToLower() == "-f")
                {
                    Application.Run(new frmMain());
                }
            }
            catch (Exception ex)
            {
                EventLogSystemLog _log = new EventLogSystemLog("SinoMonitorCenterServiceLog");
                _log.WriteLog(ex.Message, EventLogEntryType.Error);
            }
        }
コード例 #14
0
ファイル: Dialog_AddNode.cs プロジェクト: aehyok/Monitor
 public Dialog_AddNode(SystemStateItem item)
 {
     InitializeComponent();
     this.te_Name.EditValue           = item.SystemName;
     this.te_Name.Properties.ReadOnly = true;
     this.te_Des.EditValue            = item.SystemDescription;
     this.te_URL.EditValue            = item.SystemURL;
 }
コード例 #15
0
ファイル: ServerCommon.cs プロジェクト: aehyok/Monitor
        void _w_RunWorkerCompleted(object sender, RunWorkerCompletedEventArgs e)
        {
            SystemStateItem _s = e.Result as SystemStateItem;

            if (application != null)
            {
                application.WriteMessage(string.Format("系统:{0} 的状态:{1}", _s.SystemName, _s.NodeState.ToString()), EventLogEntryType.Information);
            }
        }
コード例 #16
0
ファイル: InfoShowBase.cs プロジェクト: aehyok/Monitor
 public void DoCommand(string CommandName, SystemStateItem StateItem)
 {
     switch (CommandName)
     {
     default:
         MessageBox.Show(CommandName, "提示");
         break;
     }
 }
コード例 #17
0
ファイル: Dialog_AddNode.cs プロジェクト: aehyok/Monitor
        public SystemStateItem GetSystemStateItem()
        {
            string          _name = this.te_Name.EditValue.ToString();
            string          _url  = this.te_URL.EditValue.ToString();
            string          _des  = this.te_Des.EditValue.ToString();
            SystemStateItem _item = new SystemStateItem(_name, _url, _des);

            return(_item);
        }
コード例 #18
0
 private void tb_SysDetial_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;
         FrmServerNodeDetail _f    = new FrmServerNodeDetail(_item);
         _f.ShowDialog();
     }
 }
コード例 #19
0
 private void gridView1_FocusedRowChanged(object sender, DevExpress.XtraGrid.Views.Base.FocusedRowChangedEventArgs e)
 {
     if (this.gridView1.FocusedRowHandle >= 0)
     {
         SystemStateItem _item = this.gridView1.GetRow(this.gridView1.FocusedRowHandle) as SystemStateItem;
         C_SystemInfo    _c    = new C_SystemInfo(_item);
         _c.Dock                = DockStyle.Fill;
         CurrentInfo            = _c;
         this.panelData.Visible = false;
         this.panelData.Controls.Clear();
         this.panelData.Controls.Add(_c);
         this.panelData.Visible = true;
     }
 }
コード例 #20
0
        private void DoModify(SystemStateItem StateItem)
        {
            string _ret = SinoCommandExcute.Do(SessionCache.CurrentTokenString, "ExcuteNodeCommand.WatchApplicationServerPlugin.IIS_GetBlockedList", StateItem.SystemName, null);

            if (_ret != null)
            {
                Dialog_IIS_BlockedList _f = new Dialog_IIS_BlockedList(_ret);
                if (_f.ShowDialog() == DialogResult.OK)
                {
                    string _saveresult = SinoCommandExcute.Do(SessionCache.CurrentTokenString, "ExcuteNodeCommand.WatchApplicationServerPlugin.IIS_SaveBlockedList", StateItem.SystemName, _f.BlockedList);
                    if (_saveresult == "TRUE")
                    {
                        MessageBox.Show("保存IIS日志过滤列表成功!", "系统提示");
                    }
                }
            }
        }
コード例 #21
0
        public void DoCommand(string CommandName, SystemStateItem StateItem)
        {
            switch (CommandName)
            {
            case "SystemLog_Export_ALL":
                DoExport("ALL", StateItem);
                break;

            case "SystemLog_Export_ERROR":
                DoExport("ERROR", StateItem);
                break;

            default:
                MessageBox.Show(CommandName, "提示");
                break;
            }
        }
コード例 #22
0
        /// <summary>
        /// Loads shutdown actions from the settings.
        /// </summary>
        private void GetShutdownActionsFromSettings()
        {
            SystemStateDialogSettings settings = ServiceRegistration.Get <ISettingsManager>().Load <SystemStateDialogSettings>();

            _shutdownItemList = settings.ShutdownItemList;

            // Add the SleepTimer, if the Element is missing in the current configuration
            bool foundSleepTimer = false;

            foreach (SystemStateItem item in _shutdownItemList)
            {
                if (item.Action == SystemStateAction.SleepTimer)
                {
                    foundSleepTimer = true;
                    break;
                }
            }
            if (foundSleepTimer == false)
            {
                // Add the SleepTimerItem after "Shutdown"
                SystemStateItem sleepTimerItem = new SystemStateItem(SystemStateAction.SleepTimer, true);
                int             index          = 0;
                foreach (SystemStateItem item in _shutdownItemList)
                {
                    index++;
                    if (item.Action == SystemStateAction.Shutdown)
                    {
                        break;
                    }
                }
                _shutdownItemList.Insert(index, sleepTimerItem);
            }

            // Check if there were new items added and append them to list
            var allShutdownItems = SystemStateDialogSettings.CreateDefaultShutdownMenu();

            foreach (SystemStateItem item in allShutdownItems)
            {
                if (!_shutdownItemList.Exists(i => i.Action == item.Action))
                {
                    _shutdownItemList.Add(item);
                }
            }
        }
コード例 #23
0
        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, "系统提示");
                    }
                }
            }
        }
コード例 #24
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);
            }
        }
コード例 #25
0
        public void DoCommand(string CommandName, SystemStateItem StateItem)
        {
            switch (CommandName)
            {
            case "HDSpace_Status":
                SaveFileDialog _dialog = new SaveFileDialog();
                _dialog.Filter           = "XML格式(*.xml)|*.xml";
                _dialog.InitialDirectory = Utils.ExeDir;
                _dialog.FileName         = "ExportHDSpaceStatus.xml";
                if (_dialog.ShowDialog() == DialogResult.OK)
                {
                    string _s = DataConvert.Serializer(typeof(List <HardDiskPartition>), this._status);
                    File.WriteAllText(_dialog.FileName, _s);
                }
                break;

            default:
                MessageBox.Show(CommandName, "提示");
                break;
            }
        }
コード例 #26
0
        private void UpdateShutdownItems()
        {
            _shutdownItems.Clear();
            if (_shutdownItemList != null)
            {
                for (int i = 0; i < _shutdownItemList.Count; i++)
                {
                    SystemStateItem si = _shutdownItemList[i];

                    ListItem item = new ListItem();
                    item.SetLabel(Consts.KEY_NAME, Consts.GetResourceIdentifierForMenuItem(si.Action));

                    item.AdditionalProperties[Consts.KEY_IS_CHECKED]             = si.Enabled;
                    item.AdditionalProperties[Consts.KEY_IS_DOWN_BUTTON_FOCUSED] = i == _focusedDownButton;
                    item.AdditionalProperties[Consts.KEY_IS_UP_BUTTON_FOCUSED]   = i == _focusedUpButton;
                    item.AdditionalProperties[Consts.KEY_INDEX] = i;
                    _shutdownItems.Add(item);
                }
                _focusedDownButton = -1;
                _focusedUpButton   = -1;
            }
            _shutdownItems.FireChange();
        }
コード例 #27
0
        private void UpdateShutdownItems()
        {
            _shutdownItems.Clear();
            if (ShutdownItemList != null)
            {
                for (int i = 0; i < ShutdownItemList.Count; i++)
                {
                    SystemStateItem si = ShutdownItemList[i];

                    // hide disabled items
                    if (!si.Enabled)
                    {
                        continue;
                    }

                    ListItem item = new ListItem();
                    item.SetLabel(Consts.KEY_NAME, Consts.GetResourceIdentifierForMenuItem(si.Action));

                    item.AdditionalProperties[Consts.KEY_INDEX] = i;
                    _shutdownItems.Add(item);
                }
            }
            _shutdownItems.FireChange();
        }
コード例 #28
0
 /// <summary>
 /// Loads shutdown actions from the settings.
 /// </summary>
 private void GetShutdownActionsFromSettings()
 {
   SystemStateDialogSettings settings = ServiceRegistration.Get<ISettingsManager>().Load<SystemStateDialogSettings>();
   _shutdownItemList = settings.ShutdownItemList;
   
   // Add the SleepTimer, if the Element is missing in the current configuration
   bool foundSleepTimer = false;
   foreach(SystemStateItem item in _shutdownItemList)
   {
     if(item.Action == SystemStateAction.SleepTimer)
     {
       foundSleepTimer = true;
       break;
     }
   }
   if(foundSleepTimer == false)
   {
     // Add the SleepTimerItem after "Shutdown"
     SystemStateItem sleepTimerItem = new SystemStateItem(SystemStateAction.SleepTimer, true);
     int index = 0;
     foreach (SystemStateItem item in _shutdownItemList)
     {
       index++;
       if (item.Action == SystemStateAction.Shutdown)
         break;
     }
     _shutdownItemList.Insert(index, sleepTimerItem);
   }
 }
コード例 #29
0
        public void DoCommand(string CommandName, SystemStateItem StateItem)
        {
            switch (CommandName)
            {
                case "DBConn_Add": //添加数据库连接
                    Dialog_AddDBConnection _f = new Dialog_AddDBConnection();
                    if (_f.ShowDialog() == DialogResult.OK)
                    {
                        //DBConnectSet _st = new DBConnectSet();
                        //_st.ConnectionName = _f.ConnectionName;
                        //_st.ConnectionString = _f.ConnectionString;
                        //_st.ConnectionType = _f.ConnectionType;

                        dynamic _st = new ExpandoObject();
                        _st.ConnectionName = _f.ConnectionName;
                        _st.ConnectionString = _f.ConnectionString;
                        _st.ConnectionType = _f.ConnectionType;
                        string _ret = SinoCommandExcute.Do(SessionCache.CurrentTokenString, "ExcuteNodeCommand.WatchDataBaseServerPlugin.DBConn_Add", StateItem.SystemName, _st);
                        if (_ret == "TRUE")
                        {
                            MessageBox.Show(string.Format("添加数据库连[{0}]的监控成功,但添加结果需要过几分钟后才能生效,请耐心等待一下。", _st.ConnectionName), "系统提示");

                        }
                    }
                    break;
                case "DBConn_Del": //删除服务
                    if (CurrentGridView != null && CurrentGridView.FocusedRowHandle >= 0)
                    {
                        dynamic _ws = CurrentGridView.GetRow(CurrentGridView.FocusedRowHandle) as ExpandoObject;
                        if (_ws != null)
                        {
                            if (MessageBox.Show(string.Format("是否要移除监控数据库连接[{0}]?", _ws.ConnectionName), "系统提示", MessageBoxButtons.YesNo)
                                == DialogResult.Yes)
                            {
                                string _ret = SinoCommandExcute.Do(SessionCache.CurrentTokenString, "ExcuteNodeCommand.WatchDataBaseServerPlugin.DBConn_Del", StateItem.SystemName, _ws.ConnectionName);
                                if (_ret == "TRUE")
                                {
                                    //CurrentGridView.DeleteRow(CurrentGridView.FocusedRowHandle);
                                    MessageBox.Show(string.Format("删除监控数据库连接[{0}]成功,但删除结果需要过几分钟后才能生效,请耐心等待一下。", _ws.ConnectionName), "系统提示");
                                }
                            }
                        }
                    }
                    break;
                case "DATABASE_Status":
                    SaveFileDialog _dialog = new SaveFileDialog();
                    _dialog.Filter = "XML格式(*.xml)|*.xml";
                    _dialog.InitialDirectory = Utils.ExeDir;
                    _dialog.FileName = "ExportDataBaseStatus.xml";
                    if (_dialog.ShowDialog() == DialogResult.OK)
                    {
                        string _s = DataConvert.Serializer(typeof(List<DBConnectStatus>), this.CurrentData);
                        File.WriteAllText(_dialog.FileName, _s);
                    }
                    break;

                default:
                    MessageBox.Show(CommandName, "提示");
                    break;
            }
        }
コード例 #30
0
ファイル: C_SystemInfo.cs プロジェクト: aehyok/Monitor
 public C_SystemInfo(SystemStateItem item)
 {
     InitializeComponent();
     CurrentItem = item;
     LoadData();
 }
コード例 #31
0
ファイル: FrmServerNodeDetail.cs プロジェクト: aehyok/Monitor
 public FrmServerNodeDetail(SystemStateItem item)
 {
     InitializeComponent();
     CurrentItem = item;
 }