public void CompleteMonitorSetting(string monitorAlias, string subscribeIP) { var monitor = MonitorCollection.FirstOrDefault(m => m.MonitorAlias == monitorAlias); if (monitor == null) { return; } if (monitor.SubscribeInfos == null) { monitor.SubscribeInfos = new ObservableCollection <SubscribeInfoModel>(); } if (monitor.SubscribeInfos.Where(s => s.SubscribeIP == subscribeIP).Count() > 0) { return; } SubscribeInfoModel infoModel = new SubscribeInfoModel() { SubscribeIP = subscribeIP, CanConnect = true }; var collection = new ObservableCollection <SubscribeInfoModel>(); foreach (var subscribe in monitor.SubscribeInfos) { collection.Add(subscribe); } collection.Add(infoModel); monitor.SubscribeInfos = collection; ConfigHelper.Instance.SaveSettings(); }
public void RemoveMonitorSetting(string monitorAlias, string subscribeIP) { var monitor = MonitorCollection.FirstOrDefault(m => m.MonitorAlias == monitorAlias); if (monitor == null) { return; } if (monitor.SubscribeInfos == null || monitor.SubscribeInfos.Count == 0) { return; } var collection = new ObservableCollection <SubscribeInfoModel>(); foreach (var s in monitor.SubscribeInfos) { collection.Add(s); } var subscribes = monitor.SubscribeInfos.Where(s => s.SubscribeIP == subscribeIP).ToList(); foreach (var s in subscribes) { collection.Remove(s); } monitor.SubscribeInfos = collection; ConfigHelper.Instance.SaveSettings(); }
private void ExecuteDeleteMonitorSettingCommand(object deleteItem) { var monitorModel = deleteItem as MonitorModel; if (monitorModel == null) { return; } //检查发送标志位(若为true则不允许删除配置) if (!_monitorFlag) { MessageBox.Show("当前正在监控文件夹,不允许删除任何监控配置项!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //删除监控配置 MonitorCollection.Remove(monitorModel); ConfigHelper.Instance.SaveSettings(); if (monitorModel.SubscribeInfos == null || monitorModel.SubscribeInfos.Count == 0) { return; } //删除监控配置后通知相关订阅方,删除相关配置 Task.Factory.StartNew(() => { foreach (var subscribeInfo in monitorModel.SubscribeInfos) { SynchronousSocketManager.Instance.SendDeleteMonitorInfo(UtilHelper.Instance.GetIPEndPoint(subscribeInfo.SubscribeIP), monitorModel.MonitorAlias); } }); }
private void SaveSettings() { var monitors = MonitorCollection.ToList(); var subscribes = SubscribeCollection.ToList(); ConfigHelper.Instance.SaveSettings(monitors, subscribes, ListenPort, ScanPeriod, ExceptionSavePath); }
public void CompleteMonitorSetting(string subscribeIP, string monitorDirectory) { if (MonitorCollection.Any(m => m.MonitorDirectory == monitorDirectory && m.SubscribeIP == subscribeIP)) { return; } var monitor = MonitorCollection.FirstOrDefault(m => m.MonitorDirectory == monitorDirectory); if (monitor == null) { return; } if (string.IsNullOrEmpty(monitor.SubscribeIP)) { monitor.SubscribeIP = subscribeIP; } else { App.Current.Dispatcher.BeginInvoke(new Action(() => { MonitorCollection.Add(new MonitorModel() { MonitorDirectory = monitorDirectory, SubscribeIP = subscribeIP }); })); } }
public void DeserializeMonitors(MonitorCollection destination, XmlReader xmlReader) { int i = 1; if (xmlReader.Name.Equals("Monitors")) { if (!xmlReader.IsEmptyElement) { xmlReader.ReadStartElement("Monitors"); while (xmlReader.NodeType != XmlNodeType.EndElement) { Monitor display = DeserializeMonitor(xmlReader); if (display != null) { display.Name = "Monitor " + i++; destination.Add(display); } } xmlReader.ReadEndElement(); } else { xmlReader.Read(); } } }
private void ShowCompleteSendFile(string monitor) { MonitorCollection.Where(m => m.MonitorDirectory == monitor).ToList().ForEach(m => { m.TransferFileName = @""; m.TransferPercent = 0.0; }); }
private void ShowSendProgress(string monitor, string sendFile, double progerss) { MonitorCollection.Where(m => m.MonitorDirectory == monitor).ToList().ForEach(m => { m.TransferFileName = sendFile; m.TransferPercent = progerss; }); }
private void ExecuteClosedCommand() { var monitors = MonitorCollection.ToList(); var subscribes = SubscribeCollection.ToList(); ConfigHelper.Instance.SaveSettings(monitors, subscribes, ListenPort, ScanPeriod); SynchronousSocketManager.Instance.StopListening(); _logger.Info("主窗体卸载完毕!"); }
public void SerializeMonitors(MonitorCollection monitors, XmlWriter xmlWriter) { xmlWriter.WriteStartElement("Monitors"); foreach (Monitor display in monitors) { SerializeMonitor(display, xmlWriter); } xmlWriter.WriteEndElement(); }
private ProfileExplorerTreeItem(string name, MonitorCollection monitors, ProfileExplorerTreeItem parent, ProfileExplorerTreeItemType includeTypes) : this(name, "", parent, includeTypes) { _itemType = ProfileExplorerTreeItemType.Folder; foreach (Monitor monitor in monitors) { ProfileExplorerTreeItem monitorItem = new ProfileExplorerTreeItem(monitor, this, includeTypes); Children.Add(monitorItem); } }
private void ExecuteChangeMonitorCommand(string oldMonitorDirectory) { var monitor = MonitorCollection.First(m => m.MonitorDirectory == oldMonitorDirectory); var selectedPath = IOHelper.Instance.SelectFloder(@"请选择新的监控路径"); if (!string.IsNullOrEmpty(selectedPath) && selectedPath != oldMonitorDirectory) { monitor.MonitorDirectory = selectedPath; ConfigHelper.Instance.SaveSettings(); } }
public void ShowSendProgress(string monitor, string remote, string sendFile, double progerss) { var monitorModel = MonitorCollection.FirstOrDefault(m => m.MonitorAlias == monitor); if (monitorModel == null) { return; } monitorModel.SubscribeInfos.Where(s => s.SubscribeIP == remote).ToList().ForEach(s => { s.TransferFileName = sendFile; s.TransferPercent = progerss; }); }
public PreviewTabViewModel(IEventAggregator eventAggregator, DisplayManager DisplayManager) { this.DisplayManager = DisplayManager; MonitorCollection mc = DisplayManager.Displays; Monitor = mc[0]; ZoomCalibration = new CalibrationPointCollectionDouble(-10d, 0.1d, 2d, 2d); ZoomCalibration.Add(new CalibrationPointDouble(0d, 1d)); this.eventAggregator = eventAggregator; this.eventAggregator.Subscribe(this); Title = "Preview"; }
public TestMonitor(ILoggerService loggerService) { this.loggerService = loggerService; this.consoleMonitor = new ConsoleMonitor(); this.timeMonitor = new TimeMonitor(); this.unhandledExceptionMonitor = new UnhandledExceptionMonitor(); this.threadExceptionMonitor = new ThreadExceptionMonitor(loggerService); this.debugMonitor = new DebugMonitor(loggerService); this.loggerListener = new XmlLoggerListener(); this.monitors = new MonitorCollection(loggerService); this.monitors.Add(this.consoleMonitor); this.monitors.Add(this.timeMonitor); this.monitors.Add(this.unhandledExceptionMonitor); this.monitors.Add(this.threadExceptionMonitor); this.monitors.Add(this.debugMonitor); this.monitors.Add(new EnvironmentMonitor()); this.monitors.Add(new ThreadMonitor()); }
private void ExecuteDeleteMonitorCommand(object deleteItem) { var model1 = deleteItem as MonitorModel; if (model1 != null) { //检查发送标志位(若为true则不允许删除配置) if (SynchronousSocketManager.Instance.SendingFilesFlag) { MessageBox.Show("当前正在发送文件,不允许删除任何监控配置项!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //删除监控配置 MonitorCollection.Remove(model1); if (string.IsNullOrEmpty(model1.SubscribeIP)) { return; } //删除监控配置后通知相关订阅方,删除相关配置 SynchronousSocketManager.Instance.SendDeleteMonitorInfo(UtilHelper.Instance.GetIPEndPoint(model1.SubscribeIP), model1.MonitorDirectory); } else { var model2 = deleteItem as SubscribeModel; if (model2 == null) { return; } //检查接收标志位(若为true则不允许删除配置) if (SynchronousSocketManager.Instance.ReceivingFlag) { MessageBox.Show("当前正在接收,不允许删除任何接收配置项!", "警告", MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } //删除接收配置 SubscribeCollection.Remove(model2); //删除接收配置后,综合接收配置决定是否通知监控端删除订阅信息 if (SubscribeCollection.FirstOrDefault(s => s.MonitorIP == model2.MonitorIP) == null) { SynchronousSocketManager.Instance.SendUnregisterSubscribeInfo(UtilHelper.Instance.GetIPEndPoint(string.Format("{0}:{1}", model2.MonitorIP, model2.MonitorListenPort)), model2.MonitorDirectory); } } }
public PreviewViewModel(IEventAggregator eventAggregator, DisplayManager DisplayManager) { this.DisplayManager = DisplayManager; MonitorCollection mc = DisplayManager.Displays; Monitor = mc[0]; ZoomCalibration = new CalibrationPointCollectionDouble(-10d, 0.1d, 2d, 2d); ZoomCalibration.Add(new CalibrationPointDouble(0d, 1d)); this.eventAggregator = eventAggregator; this.eventAggregator.Subscribe(this); Title = "Preview"; IconName = "console-16.png"; IsVisible = false; //ZoomPanelVisibility = Visibility.Collapsed; }
public MonitorViewModel(IEventAggregator eventAggregator, IResolutionRoot resolutionRoot, FileSystem fileSystem, DisplayManager displayManager) { this.eventAggregator = eventAggregator; this.resolutionRoot = resolutionRoot; this.DisplayManager = displayManager; MonitorCollection mc = DisplayManager.Displays; Monitor = mc[0]; LayoutMonitor = new MonitorPropertyEditorViewModel(eventAggregator); this.fileSystem = fileSystem; this.eventAggregator.Publish(new MonitorViewStartedEvent(this)); eventAggregator.Publish(new DisplayPropertiesView1Event(new[] { LayoutMonitor })); this.eventAggregator.Subscribe(this); MyCockpitViewModels = new ObservableCollection <PluginModel>(); NbrSelected = 0; }
private void ExecuteAddMonitorCommand() { var dlg = new FolderBrowserDialog(); dlg.Description = @"请选择监控文件夹目录"; if (dlg.ShowDialog() == DialogResult.OK) { string selectedPath = dlg.SelectedPath; if (MonitorCollection.FirstOrDefault(m => m.MonitorDirectory == selectedPath) == null) { MonitorCollection.Add(new MonitorModel() { MonitorDirectory = selectedPath }); } else { MessageBox.Show("所选文件夹已在监控目录中!", "提醒", MessageBoxButtons.OK, MessageBoxIcon.Information); } } }
static void Main(string[] args) { Action <IMonitorOptions> setCommonOptions = (opt => { opt.AddEmailNotifyChannel(n => { n.Smtp = "mail.taichuan.com"; n.SenderAccout = "*****@*****.**"; n.SenderPassword = "******"; n.TargetEmails.Add("*****@*****.**"); }); opt.AddHttpNotifyChannel(n => { n.Uri = new Uri("http://www.baidu.com"); n.Header.Add(new KeyValuePair <string, string>("key", "value")); }); opt.Logger = new ConsoleLogger(); }); var services = new MonitorCollection() .AddServiceProcessMonitor("服务1", "serviceName", setCommonOptions) .AddProcessMonitor("程序1", "d:\\123.exe", setCommonOptions) .AddDriveInfoMonitor("C盘", "C", opt => { opt.MinFreeSpaceMB = 500; setCommonOptions(opt); }) .AddWebSiteMonitor("站点1", new Uri("http://iot.taichuan.net/404"), opt => { opt.HttpContentFilter = html => html != null && html.Contains("ok"); setCommonOptions(opt); }); services.Start(); Console.WriteLine("Hello XMonitor!"); Console.ReadLine(); }
public void RefreshConnectStatus(string monitorAlias, string subscribeIP, bool online = true) { var monitor = MonitorCollection.FirstOrDefault(m => m.MonitorAlias == monitorAlias); if (monitor == null) { return; } if (monitor.SubscribeInfos == null || monitor.SubscribeInfos.Count == 0) { return; } var subscribeInfo = monitor.SubscribeInfos.FirstOrDefault(s => s.SubscribeIP == subscribeIP); if (subscribeInfo == null) { return; } subscribeInfo.CanConnect = online; var collection = monitor.SubscribeInfos; monitor.SubscribeInfos = collection; }
public void Dispose() { this.Stop(); if (this.monitors != null) { this.monitors.Dispose(); this.monitors = null; } }
protected void Page_Load(object sender, EventArgs e) { // Settings table TableHeaderRow headerRow = new TableHeaderRow(); headerRow.Cells.Add(new TableHeaderCell { Text = "Name" }); headerRow.Cells.Add(new TableHeaderCell { Text = "Value" }); Settings.Rows.AddAt(0, headerRow); Type myType = typeof(ScoringDaemonSettings); PropertyInfo[] properties = myType.GetProperties( BindingFlags.Public | BindingFlags.Static | BindingFlags.DeclaredOnly); foreach (PropertyInfo property in properties) { // We dont want to show any secure attributes on the UI (stuff with passwords) if (property.GetCustomAttributes(true).OfType <SecureAttribute>().Any()) { continue; } TableRow tableRow = new TableRow(); tableRow.Cells.Add(new TableCell { Text = property.Name }); var propObj = property.GetValue(myType, null); tableRow.Cells.Add(new TableCell { Text = convertToString(propObj) }); Settings.Rows.Add(tableRow); } //hubInfo headerRow = new TableHeaderRow(); headerRow.Cells.Add(new TableHeaderCell { Text = "ClientName" }); headerRow.Cells.Add(new TableHeaderCell { Text = "Environment" }); headerRow.Cells.Add(new TableHeaderCell { Text = "DB IP" }); headerRow.Cells.Add(new TableHeaderCell { Text = "DB Name" }); headerRow.Cells.Add(new TableHeaderCell { Text = "Last Poll" }); headerRow.Cells.Add(new TableHeaderCell { Text = "Tasks Executed" }); headerRow.Cells.Add(new TableHeaderCell { Text = "Tasks Waiting" }); headerRow.Cells.Add(new TableHeaderCell { Text = "Min Task QDelay" }); headerRow.Cells.Add(new TableHeaderCell { Text = "Ave Task QDelay" }); headerRow.Cells.Add(new TableHeaderCell { Text = "Max Task QDelay" }); headerRow.Cells.Add(new TableHeaderCell { Text = "Min Task Execution Time" }); headerRow.Cells.Add(new TableHeaderCell { Text = "Ave Task Execution Time" }); headerRow.Cells.Add(new TableHeaderCell { Text = "Max Task Execution Time" }); HubInfo.Rows.AddAt(0, headerRow); foreach (ReponseRepoMonitor hub in MonitorCollection.GetAll()) { TableRow tableRow = new TableRow(); tableRow.Cells.Add(new TableCell { Text = hub.ClientName }); tableRow.Cells.Add(new TableCell { Text = hub.Environment }); tableRow.Cells.Add(new TableCell { Text = hub.DBIP }); tableRow.Cells.Add(new TableCell { Text = hub.DBName }); tableRow.Cells.Add(new TableCell { Text = hub.LastRun.ToString() }); ThreadPoolStats tpStats = hub.Stats; if (tpStats != null) { tableRow.Cells.Add(new TableCell { Text = tpStats.TasksExecuted.ToString() }); tableRow.Cells.Add(new TableCell { Text = tpStats.TasksInQCount.ToString() }); tableRow.Cells.Add(new TableCell { Text = tpStats.MinQDelay.ToString() }); tableRow.Cells.Add(new TableCell { Text = tpStats.AveQDelay.ToString() }); tableRow.Cells.Add(new TableCell { Text = tpStats.MaxQDelay.ToString() }); tableRow.Cells.Add(new TableCell { Text = tpStats.MinTaskExecutionTime.ToString() }); tableRow.Cells.Add(new TableCell { Text = tpStats.AveTaskExecutionTime.ToString() }); tableRow.Cells.Add(new TableCell { Text = tpStats.MaxTaskExecutionTime.ToString() }); } HubInfo.Rows.Add(tableRow); } // Item scoring callback headerRow = new TableHeaderRow(); headerRow.Cells.Add(new TableHeaderCell { Text = "Tasks Executed" }); headerRow.Cells.Add(new TableHeaderCell { Text = "Tasks Waiting" }); headerRow.Cells.Add(new TableHeaderCell { Text = "Min Task QDelay" }); headerRow.Cells.Add(new TableHeaderCell { Text = "Ave Task QDelay" }); headerRow.Cells.Add(new TableHeaderCell { Text = "Max Task QDelay" }); headerRow.Cells.Add(new TableHeaderCell { Text = "Min Task Execution Time" }); headerRow.Cells.Add(new TableHeaderCell { Text = "Ave Task Execution Time" }); headerRow.Cells.Add(new TableHeaderCell { Text = "Max Task Execution Time" }); CallBackInfo.Rows.AddAt(0, headerRow); ThreadPoolStats tpStats1 = ItemScoringCallbackHandler.Stats; if (tpStats1 != null) { TableRow tableRow = new TableRow(); tableRow.Cells.Add(new TableCell { Text = tpStats1.TasksExecuted.ToString() }); tableRow.Cells.Add(new TableCell { Text = tpStats1.TasksInQCount.ToString() }); tableRow.Cells.Add(new TableCell { Text = tpStats1.MinQDelay.ToString() }); tableRow.Cells.Add(new TableCell { Text = tpStats1.AveQDelay.ToString() }); tableRow.Cells.Add(new TableCell { Text = tpStats1.MaxQDelay.ToString() }); tableRow.Cells.Add(new TableCell { Text = tpStats1.MinTaskExecutionTime.ToString() }); tableRow.Cells.Add(new TableCell { Text = tpStats1.AveTaskExecutionTime.ToString() }); tableRow.Cells.Add(new TableCell { Text = tpStats1.MaxTaskExecutionTime.ToString() }); CallBackInfo.Rows.Add(tableRow); } }