private void ConnectToService() { ClientHelper helper = m_windowsServiceClient?.Helper; ClientBase remotingClient = m_windowsServiceClient?.Helper?.RemotingClient; if (!(helper is null)) { helper.ReceivedServiceResponse -= Helper_ReceivedServiceResponse; } if (!(remotingClient is null)) { remotingClient.ConnectionTerminated -= RemotingClient_ConnectionTerminated; remotingClient.ConnectionEstablished -= RemotingClient_ConnectionEstablished; } m_windowsServiceClient = CommonFunctions.GetWindowsServiceClient(); helper = m_windowsServiceClient?.Helper; remotingClient = m_windowsServiceClient?.Helper?.RemotingClient; if (m_windowsServiceClient is null || helper is null || remotingClient is null) { return; } helper.ReceivedServiceResponse += Helper_ReceivedServiceResponse; remotingClient.ConnectionEstablished += RemotingClient_ConnectionEstablished; remotingClient.ConnectionTerminated += RemotingClient_ConnectionTerminated; SetConnectionStatus(remotingClient.CurrentState == ClientState.Connected ? Status.Connected : Status.Disconnected); }
private void WindowsServiceClient_ReceivedServiceResponse(object sender, EventArgs <ServiceResponse> e) { WindowsServiceClient windowsServiceClient = CommonFunctions.GetWindowsServiceClient(); ServiceResponse response = e.Argument; if ((object)response != null) { string sourceCommand; bool responseSuccess; if (ClientHelper.TryParseActionableResponse(response, out sourceCommand, out responseSuccess) && responseSuccess) { if (!string.IsNullOrWhiteSpace(sourceCommand) && string.Compare(sourceCommand.Trim(), "INVOKE", true) == 0) { List <object> attachments = response.Attachments; // A GetHighestSeverityAlarms INVOKE will have two attachments: an alarm array, item 0, and the original command arguments, item 1 if ((object)attachments != null && attachments.Count > 1) { Arguments arguments = attachments[1] as Arguments; // Check the method that was invoked - the second argument after the adapter ID if ((object)arguments != null && string.Compare(arguments["OrderedArg2"], "ImportCertificate", true) == 0) { m_dataContext.CurrentItem.RemoteCertificateFile = attachments[0] as string; // Release waiting thread once desired response has been received windowsServiceClient.Helper.ReceivedServiceResponse -= WindowsServiceClient_ReceivedServiceResponse; m_certificateWaitHandle.Set(); } } } } } }
private void GenerateReport() { WindowsServiceClient serviceClient = null; try { m_responseComplete.Reset(); serviceClient = CommonFunctions.GetWindowsServiceClient(); serviceClient.Helper.SendRequest(string.Format("GenerateReport {0:yyyy-MM-dd}", m_reportDate)); // Wait for command response allowing for processing time if ((object)m_responseComplete != null) { if (!m_responseComplete.Wait(5000)) { throw new TimeoutException("Timed-out after 5 seconds waiting for service response."); } } ListReports(); } catch (Exception ex) { string message = string.Format("Unable to generate report: {0}", ex.Message); Popup(message, "GenerateReport", MessageBoxImage.Error); } }
private void ChangeReportingEnabled() { WindowsServiceClient serviceClient = null; try { m_responseComplete.Reset(); serviceClient = CommonFunctions.GetWindowsServiceClient(); if (ReportingEnabled) { serviceClient.Helper.SendRequest("Unschedule Reporting -save"); } else { serviceClient.Helper.SendRequest(string.Format("Reschedule Reporting \"{0} {1} * * *\" -save", m_reportGenerationTime.Minute, m_reportGenerationTime.Hour)); } CheckSchedules(serviceClient); } catch (Exception ex) { string message = string.Format("Unable to {0} reporting services: {1}", m_reportingEnabled ? "disable" : "enable", ex.Message); Popup(message, "ChangeReportingEnabled Error", MessageBoxImage.Error); } }
void HomePage_Loaded(object sender, RoutedEventArgs e) { m_activityWindow = new ActivityWindow("Loading Data... Please Wait..."); #if !SILVERLIGHT ((MasterLayoutWindow)Window.GetWindow(this)).UserControlSelectNode.ComboboxNode.SelectionChanged += new SelectionChangedEventHandler(ComboboxNode_SelectionChanged); m_activityWindow.Owner = Window.GetWindow(this); m_activityWindow.WindowStartupLocation = WindowStartupLocation.CenterOwner; #endif m_activityWindow.Show(); GetDevices(); #if !SILVERLIGHT GetInterconnectionStatus(); GetDeviceDistributionList(); //GetTimeSeriesData(((App)Application.Current).TimeSeriesDataServiceUrl + "/timeseriesdata/read/historic/" + ((Measurement)ComboBoxMeasurements.SelectedItem).PointID.ToString() + "/*-30S/*/XML"); WindowsServiceClient serviceClient = ((App)Application.Current).ServiceClient; if (serviceClient == null || serviceClient.Helper.RemotingClient.CurrentState != TVA.Communication.ClientState.Connected || !((App)Application.Current).Principal.IsInRole("Administrator")) { ButtonRestartOpenPDC.IsEnabled = false; } #endif //if (!string.IsNullOrEmpty(((App)Application.Current).NodeValue)) //m_client.GetDevicesAsync(DeviceType.NonConcentrator, ((App)Application.Current).NodeValue, false); //else //{ // ReconnectToService(); // if (m_activityWindow != null) // m_activityWindow.Close(); //} }
private void ConnectToService() { if ((object)m_windowsServiceClient != null && (object)m_windowsServiceClient.Helper != null && (object)m_windowsServiceClient.Helper.RemotingClient != null) { m_windowsServiceClient.Helper.RemotingClient.ConnectionEstablished -= RemotingClient_ConnectionEstablished; m_windowsServiceClient.Helper.RemotingClient.ConnectionTerminated -= RemotingClient_ConnectionTerminated; } m_windowsServiceClient = CommonFunctions.GetWindowsServiceClient(); if ((object)m_windowsServiceClient != null) { m_windowsServiceClient.Helper.RemotingClient.ConnectionEstablished += RemotingClient_ConnectionEstablished; m_windowsServiceClient.Helper.RemotingClient.ConnectionTerminated += RemotingClient_ConnectionTerminated; if (m_windowsServiceClient.Helper.RemotingClient.CurrentState == GSF.Communication.ClientState.Connected) { EllipseConnectionState.Dispatcher.BeginInvoke((Action) delegate() { EllipseConnectionState.Fill = Application.Current.Resources["GreenRadialGradientBrush"] as RadialGradientBrush; ToolTipService.SetToolTip(EllipseConnectionState, "Connected to the service"); }); } else { EllipseConnectionState.Dispatcher.BeginInvoke((Action) delegate() { EllipseConnectionState.Fill = Application.Current.Resources["RedRadialGradientBrush"] as RadialGradientBrush; ToolTipService.SetToolTip(EllipseConnectionState, "Disconnected from the service"); }); } } }
private void ConnectToService() { EllipseConnectionState.Fill = Application.Current.Resources["RedRadialGradientBrush"] as RadialGradientBrush; ToolTipService.SetToolTip(EllipseConnectionState, "Disconnected from openPDC Service"); if (!string.IsNullOrEmpty(((App)Application.Current).RemoteStatusServiceUrl)) { try { // Disconnect from existsing connection if active if (m_serviceClient != null) { DisconnectFromService(); } Dictionary <string, string> settings = ((App)Application.Current).RemoteStatusServiceUrl.ToLower().ParseKeyValuePairs(); if (settings.ContainsKey("server")) { m_serviceClient = new WindowsServiceClient("server=" + settings["server"].Replace("{", "").Replace("}", "")); m_serviceClient.Helper.RemotingClient.ConnectionEstablished += RemotingClient_ConnectionEstablished; m_serviceClient.Helper.RemotingClient.ConnectionTerminated += RemotingClient_ConnectionTerminated; m_serviceClient.Helper.RemotingClient.ConnectionAttempt += RemotingClient_ConnectionAttempt; // Start connection cycle System.Threading.ThreadPool.QueueUserWorkItem(ConnectAsync, null); ((App)Application.Current).ServiceClient = m_serviceClient; } else { SystemMessages sm = new SystemMessages(new Message() { UserMessage = "Please provide proper Remote Status Service Url value for node.", SystemMessage = "Remote Status Service Url value is not set properly for " + ((App)Application.Current).NodeName + " node." + Environment.NewLine + "Please go to Manage => Nodes screen to configure node settings." + Environment.NewLine + "For example: Server=localhost:8500", UserMessageType = MessageType.Error }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.ShowPopup(); } } catch (Exception ex) { CommonFunctions.LogException(null, "MasterLayoutWindow_Loaded", new InvalidOperationException("Exception encountered while attempting to establish openPDC connection: " + ex.Message, ex)); ((App)Application.Current).ServiceClient = null; } } else { SystemMessages sm = new SystemMessages(new Message() { UserMessage = "Please provide Remote Status Service Url value for node.", SystemMessage = "Remote Status Service Url value is not set for " + ((App)Application.Current).NodeName + " node." + Environment.NewLine + "Please go to Manage => Nodes screen to configure node settings." + Environment.NewLine + "For example: Server=localhost:8500", UserMessageType = MessageType.Error }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.ShowPopup(); } }
private void RefreshServiceClientList(object obj) { System.Diagnostics.Debug.WriteLine("Refreshing Service Clients List"); nodeList = CommonFunctions.GetNodeList(null, true); //For each node defined in the database, we need to have a TCP client created to listen to the events. foreach (Node node in nodeList) { lock (serviceClientList) { if (serviceClientList.ContainsKey(node.ID)) { if (node.RemoteStatusServiceUrl != serviceClientList[node.ID].Helper.RemotingClient.ConnectionString) { System.Diagnostics.Debug.WriteLine("Resetting Service Client for Node: " + node.ID); serviceClientList[node.ID].Helper.ReceivedServiceUpdate -= ClientHelper_ReceivedServiceUpdate; serviceClientList[node.ID].Helper.ReceivedServiceResponse -= ClientHelper_ReceivedServiceResponse; serviceClientList[node.ID].Dispose(); if (!string.IsNullOrEmpty(node.RemoteStatusServiceUrl)) { System.Diagnostics.Debug.WriteLine("Reconnecting Service Client for Node: " + node.ID); serviceClientList[node.ID] = null; serviceClient = new WindowsServiceClient(node.RemoteStatusServiceUrl); serviceClient.Helper.RemotingClient.MaxConnectionAttempts = 10; serviceClientList[node.ID] = serviceClient; serviceClient.Helper.ReceivedServiceUpdate += ClientHelper_ReceivedServiceUpdate; serviceClient.Helper.ReceivedServiceResponse += ClientHelper_ReceivedServiceResponse; ThreadPool.QueueUserWorkItem(ConnectWindowsServiceClient, serviceClient); } else { System.Diagnostics.Debug.WriteLine("Removing Service Client for Node: " + node.ID); serviceClientList.Remove(node.ID); } } else if (!serviceClientList[node.ID].Helper.RemotingClient.Enabled) { ThreadPool.QueueUserWorkItem(ConnectWindowsServiceClient, serviceClientList[node.ID]); } } else { if (!string.IsNullOrEmpty(node.RemoteStatusServiceUrl)) { System.Diagnostics.Debug.WriteLine("Adding New Service Client for Node: " + node.ID); serviceClient = new WindowsServiceClient(node.RemoteStatusServiceUrl); serviceClient.Helper.RemotingClient.MaxConnectionAttempts = 10; serviceClientList.Add(node.ID, serviceClient); serviceClient.Helper.ReceivedServiceUpdate += ClientHelper_ReceivedServiceUpdate; serviceClient.Helper.ReceivedServiceResponse += ClientHelper_ReceivedServiceResponse; ThreadPool.QueueUserWorkItem(ConnectWindowsServiceClient, serviceClient); } } } } }
private void GetReport(DateTime reportDate) { WindowsServiceClient serviceClient = null; FileDialog fileDialog; try { fileDialog = new SaveFileDialog(); fileDialog.DefaultExt = "pdf"; fileDialog.Filter = "PDF files|*.pdf|All files|*.*"; fileDialog.FileName = string.Format("{0} {1:yyyy-MM-dd}.pdf", m_reportTitle, reportDate); if (fileDialog.ShowDialog() == true) { m_responseComplete.Reset(); serviceClient = CommonFunctions.GetWindowsServiceClient(); serviceClient.Helper.SendRequest(string.Format("GetReport {0:yyyy-MM-dd}", reportDate)); // Wait for command response allowing for processing time if ((object)m_responseComplete != null) { if (!m_responseComplete.Wait(5000)) { throw new TimeoutException("Timed-out after 5 seconds waiting for service response."); } } if ((object)m_reportData != null) { File.WriteAllBytes(fileDialog.FileName, m_reportData); m_reportData = null; try { using (Process.Start(fileDialog.FileName)) { } } catch (Exception ex) { string message = string.Format("Report saved, but unable to open: {0}", ex.Message); Popup(message, "GetReport", MessageBoxImage.Error); } ListReports(); } } } catch (Exception ex) { string message = string.Format("Unable to download report: {0}", ex.Message); Popup(message, "GetReport", MessageBoxImage.Error); } }
private void GetReportingConfiguration() { WindowsServiceClient serviceClient = null; Arguments args; string reportLocation; string idleReportLifetimeArg; double idleReportLifetime; try { m_responseComplete.Reset(); serviceClient = CommonFunctions.GetWindowsServiceClient(); serviceClient.Helper.SendRequest("ReportingConfig"); // Wait for command response allowing for processing time if ((object)m_responseComplete != null) { if (!m_responseComplete.Wait(5000)) { throw new TimeoutException("Timed-out after 5 seconds waiting for service response."); } } if (!string.IsNullOrEmpty(m_reportingConfiguration)) { args = new Arguments(m_reportingConfiguration); m_reportTitle = args["title"].ToNonNullString().Trim(); reportLocation = args["reportLocation"]; idleReportLifetimeArg = args["idleReportLifetime"]; if (!string.IsNullOrEmpty(reportLocation)) { ReportLocation = reportLocation.Trim(); OriginalReportLocation = m_reportLocation; } if (!string.IsNullOrEmpty(idleReportLifetimeArg) && double.TryParse(idleReportLifetimeArg, out idleReportLifetime)) { IdleReportLifetime = idleReportLifetime; OriginalIdleReportLifetime = idleReportLifetime; } m_reportingConfiguration = null; } } catch (Exception ex) { string message = string.Format("Unable to retrieve reporting services configuration: {0}", ex.Message); Popup(message, "GetReportingConfiguration Error", MessageBoxImage.Error); } }
public void ReconnectToService() { //m_serviceClient = new WindowsServiceClient(((App)Application.Current).RemoteStatusServiceUrl); //m_serviceClient.Helper.RemotingClient.MaxConnectionAttempts = 10; m_serviceClient = ((App)Application.Current).ServiceClient; if (m_serviceClient != null) { m_serviceClient.Helper.ReceivedServiceUpdate += new EventHandler <TVA.EventArgs <UpdateType, string> >(Helper_ReceivedServiceUpdate); // += ClientHelper_ReceivedServiceUpdate; m_serviceClient.Helper.ReceivedServiceResponse += new EventHandler <TVA.EventArgs <ServiceResponse> >(Helper_ReceivedServiceResponse); //+= ClientHelper_ReceivedServiceResponse; ConnectWindowsServiceClient(m_serviceClient); } }
void Initialize() { serviceClient = ((App)Application.Current).ServiceClient; if (((App)Application.Current).Principal.IsInRole("Administrator, Editor")) { ButtonSave.IsEnabled = true; ButtonInitialize.IsEnabled = true; } else { ButtonSave.IsEnabled = false; ButtonInitialize.IsEnabled = false; } }
private void GetSchedules() { WindowsServiceClient serviceClient = null; try { m_responseComplete.Reset(); serviceClient = CommonFunctions.GetWindowsServiceClient(); CheckSchedules(serviceClient); } catch (Exception ex) { string message = string.Format("Unable to determine whether reporting services are enabled: {0}", ex.Message); Popup(message, "GetSchedules Error", MessageBoxImage.Error); } }
private void ApplyReportingConfig() { WindowsServiceClient serviceClient = null; DateTime reportGenerationTime; try { serviceClient = CommonFunctions.GetWindowsServiceClient(); if (m_reportingEnabled && DateTime.TryParseExact(m_reportGenerationTimeText, "HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out reportGenerationTime) && reportGenerationTime != m_originalReportGenerationTime) { m_responseComplete.Reset(); serviceClient.Helper.SendRequest(string.Format("Reschedule Reporting \"{0} {1} * * *\" -save", reportGenerationTime.Minute, reportGenerationTime.Hour)); CheckSchedules(serviceClient); } if (m_idleReportLifetime != m_originalIdleReportLifetime || !string.Equals(m_reportLocation, m_originalReportLocation, StringComparison.OrdinalIgnoreCase)) { m_responseComplete.Reset(); serviceClient.Helper.SendRequest(string.Format("ReportingConfig -set --reportLocation=\" {0} \" --idleReportLifetime=\" {1} \"", m_reportLocation.Replace("\"", "\\\""), m_idleReportLifetime)); // Wait for command response allowing for processing time if ((object)m_responseComplete != null) { if (!m_responseComplete.Wait(5000)) { throw new TimeoutException("Timed-out after 5 seconds waiting for service response."); } } if ((object)m_reportingConfiguration != null) { OriginalReportLocation = m_reportLocation; OriginalIdleReportLifetime = m_idleReportLifetime; m_reportingConfiguration = null; ListReports(); } } } catch (Exception ex) { string message = string.Format("Unable to modify reporting services configuration: {0}", ex.Message); Popup(message, "UpdateReportingConfig Error", MessageBoxImage.Error); } }
private void ListReports() { WindowsServiceClient serviceClient = null; try { if (m_serviceConnected) { serviceClient = CommonFunctions.GetWindowsServiceClient(); serviceClient.Helper.SendRequest("ListReports"); } } catch (Exception ex) { SetListReportsErrorMessage(ex.Message); } }
private void CheckSchedules(WindowsServiceClient serviceClient = null) { Match match; int hour; int minute; if ((object)serviceClient == null) { serviceClient = CommonFunctions.GetWindowsServiceClient(); } serviceClient.Helper.SendRequest("Schedules"); // Wait for command response allowing for processing time if ((object)m_responseComplete != null) { if (!m_responseComplete.Wait(5000)) { throw new TimeoutException("Timed-out after 5 seconds waiting for service response."); } } if ((object)m_responseMessage != null) { match = Regex.Match(m_responseMessage, "^Reporting +(?<Minute>[^ ]+) +(?<Hour>[^ ]+)", RegexOptions.Multiline); if (match.Success) { ReportingEnabled = true; if (int.TryParse(match.Groups["Hour"].Value, out hour) && int.TryParse(match.Groups["Minute"].Value, out minute)) { ReportGenerationTime = DateTime.ParseExact(string.Format("{0:00}:{1:00}", hour, minute), "HH:mm", CultureInfo.InvariantCulture); m_originalReportGenerationTime = m_reportGenerationTime; OnPropertyChanged("OriginalReportGenerationTimeText"); } } else { ReportingEnabled = false; } m_responseMessage = null; } }
private void DisconnectFromService() { try { if (m_serviceClient != null) { m_serviceClient.Helper.RemotingClient.ConnectionEstablished -= RemotingClient_ConnectionEstablished; m_serviceClient.Helper.RemotingClient.ConnectionTerminated -= RemotingClient_ConnectionTerminated; m_serviceClient.Helper.RemotingClient.ConnectionAttempt -= RemotingClient_ConnectionAttempt; m_serviceClient.Dispose(); } m_serviceClient = null; } catch (Exception ex) { CommonFunctions.LogException(null, "WPF.DisconnectFromService", new InvalidOperationException("Exception encountered while attempting to disconnect from openPDC: " + ex.Message, ex)); } }
private void UpdateServiceConnectivity() { WindowsServiceClient serviceClient = CommonFunctions.GetWindowsServiceClient(); ClientHelper clientHelper = ((object)serviceClient != null) ? serviceClient.Helper : null; IClient remotingClient = ((object)clientHelper != null) ? clientHelper.RemotingClient : null; if ((object)remotingClient == null || remotingClient.CurrentState != ClientState.Connected) { // If remoting client is not connected, make the message visible Dispatcher.BeginInvoke(new Action(() => ViewModel.ServiceConnected = false)); } else { // If remoting client is connected, hide the message and attach to connection terminated event remotingClient.ConnectionTerminated += RemotingClient_ConnectionTerminated; Dispatcher.BeginInvoke(new Action(() => ViewModel.ServiceConnected = true)); } }
/// <summary> /// Connects to backend windows service and attaches to it's events. /// </summary> private void SetupServiceConnection() { m_serviceClient = null; try { m_serviceClient = CommonFunctions.GetWindowsServiceClient(); if (m_serviceClient != null && m_serviceClient.Helper != null && m_serviceClient.Helper.RemotingClient != null && m_serviceClient.Helper.RemotingClient.CurrentState == ClientState.Connected) { TextBlockServiceStatus.Dispatcher.BeginInvoke(new DisplayHelper(RefreshStatusText), new object[] { UpdateType.Information, m_serviceClient.CachedStatus }); m_serviceClient.Helper.ReceivedServiceResponse += Helper_ReceivedServiceResponse; m_serviceClient.Helper.ReceivedServiceUpdate += Helper_ReceivedServiceUpdate; } } catch (Exception ex) { TextBlockServiceStatus.Dispatcher.BeginInvoke(new DisplayHelper(RefreshStatusText), new object[] { UpdateType.Alarm, "Failed to connect to windows service." + Environment.NewLine + ex.Message }); } }
private void ButtonRestartOpenPDC_Click(object sender, RoutedEventArgs e) { #if SILVERLIGHT #else SystemMessages sm1 = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Do you want to restart openPDC service?", SystemMessage = "", UserMessageType = openPDCManager.Utilities.MessageType.Confirmation }, ButtonType.YesNo); sm1.Closed += new EventHandler(delegate(object popupWindow, EventArgs eargs) { if ((bool)sm1.DialogResult) { WindowsServiceClient serviceClient = ((App)Application.Current).ServiceClient; if (serviceClient != null && serviceClient.Helper.RemotingClient.CurrentState == TVA.Communication.ClientState.Connected) { CommonFunctions.SendCommandToWindowsService(serviceClient, "Restart"); SystemMessages sm = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Successfully sent RESTART command to openPDC", SystemMessage = "", UserMessageType = openPDCManager.Utilities.MessageType.Success }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); } else { SystemMessages sm = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Failed to send RESTART command to openPDC", SystemMessage = "Application is disconnected from the openPDC Service.", UserMessageType = openPDCManager.Utilities.MessageType.Error }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); } } }); sm1.Owner = Window.GetWindow(this); sm1.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm1.ShowPopup(); #endif }
private void CheckTemporalSupport() { WindowsServiceClient windowsServiceClient = null; try { s_responseWaitHandle = new ManualResetEvent(false); windowsServiceClient = CommonFunctions.GetWindowsServiceClient(); if (windowsServiceClient != null && windowsServiceClient.Helper != null && windowsServiceClient.Helper.RemotingClient != null && windowsServiceClient.Helper.RemotingClient.CurrentState == ClientState.Connected) { windowsServiceClient.Helper.ReceivedServiceResponse += Helper_ReceivedServiceResponse; CommonFunctions.SendCommandToService("TemporalSupport -system"); if (!s_responseWaitHandle.WaitOne(10000)) { TemporalSupportEnabled = false; //throw new ApplicationException("Response timeout occured. Waited 10 seconds for response."); } } else { //throw new ApplicationException("Connection timeout occured. Tried 10 times to connect to windows service."); } } catch (Exception ex) { Popup("ERROR: " + ex.Message, "Request Configuration", MessageBoxImage.Error); } finally { if (windowsServiceClient != null) { windowsServiceClient.Helper.ReceivedServiceResponse -= Helper_ReceivedServiceResponse; } } }
private void StatusUserControl_Loaded(object sender, RoutedEventArgs e) { if (!CommonFunctions.CurrentPrincipal.IsInRole("Administrator")) { ButtonRestart.IsEnabled = false; } if (!CommonFunctions.CurrentPrincipal.IsInRole("Administrator,Editor")) { ButtonInputWizard.IsEnabled = false; } m_windowsServiceClient = CommonFunctions.GetWindowsServiceClient(); if (m_windowsServiceClient == null || m_windowsServiceClient.Helper.RemotingClient.CurrentState != ClientState.Connected) { ButtonRestart.IsEnabled = false; } else { m_windowsServiceClient.Helper.ReceivedServiceResponse += Helper_ReceivedServiceResponse; CommonFunctions.SendCommandToService("Version -actionable"); CommonFunctions.SendCommandToService("Time -actionable"); CommonFunctions.SendCommandToService("ReportingConfig completeness -actionable"); m_eventHandlerRegistered = true; } m_refreshTimer = new DispatcherTimer(); m_refreshTimer.Interval = TimeSpan.FromSeconds(5); m_refreshTimer.Tick += RefreshTimer_Tick; m_refreshTimer.Start(); if (IntPtr.Size == 8) { TextBlockInstance.Text = "64-bit"; } else { TextBlockInstance.Text = "32-bit"; } TextBlockLocalTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); Version appVersion = AssemblyInfo.EntryAssembly.Version; TextBlockManagerVersion.Text = appVersion.Major + "." + appVersion.Minor + "." + appVersion.Build + ".0"; try { using (AdoDataConnection database = new AdoDataConnection(CommonFunctions.DefaultSettingsCategory)) { TextBlockDatabaseType.Text = database.DatabaseType.ToString(); try { if (database.IsSqlite || database.IsJetEngine) { // Extract database file name from connection string for file centric databases TextBlockDatabaseName.Text = FilePath.GetFileName(database.Connection.ConnectionString.ParseKeyValuePairs()["Data Source"]); } else if (database.IsOracle) { // Extract user name from connection string for Oracle databases TextBlockDatabaseName.Text = database.Connection.ConnectionString.ParseKeyValuePairs()["User Id"]; } else { TextBlockDatabaseName.Text = database.Connection.Database; } } catch { // Fall back on database name if file anything fails TextBlockDatabaseName.Text = database.Connection.Database; } } } catch { TextBlockDatabaseName.Text = "Not Available"; } try { using (UserInfo info = new UserInfo(CommonFunctions.CurrentUser)) { if (info.Exists) { TextBlockUser.Text = info.LoginID; } else { TextBlockUser.Text = CommonFunctions.CurrentUser; } } } catch { TextBlockUser.Text = CommonFunctions.CurrentUser; } CreateGridTextItem(0, 1, HorizontalAlignment.Right, (DateTime.Today - TimeSpan.FromDays(1)).ToString("MM/dd"), CompletenessGrid); CreateGridTextItem(0, 2, HorizontalAlignment.Right, DateTime.Now.ToString("MM/dd"), CompletenessGrid); CreateGridTextItem(1, 0, HorizontalAlignment.Left, "L4: Good", CompletenessGrid); CreateGridTextItem(2, 0, HorizontalAlignment.Left, "L3: Fair", CompletenessGrid); CreateGridTextItem(3, 0, HorizontalAlignment.Left, "L2: Poor", CompletenessGrid); CreateGridTextItem(4, 0, HorizontalAlignment.Left, "L1: Offline", CompletenessGrid); CreateGridTextItem(5, 0, HorizontalAlignment.Left, "L0: Failed", CompletenessGrid); CreateGridTextItem(6, 0, HorizontalAlignment.Left, "", CompletenessGrid); CreateGridTextItem(7, 0, HorizontalAlignment.Left, "Total", CompletenessGrid); CreateGridTextItem(0, 1, HorizontalAlignment.Right, (DateTime.Today - TimeSpan.FromDays(1)).ToString("MM/dd"), CorrectnesssGrid); CreateGridTextItem(0, 2, HorizontalAlignment.Right, DateTime.Now.ToString("MM/dd"), CorrectnesssGrid); CreateGridTextItem(1, 0, HorizontalAlignment.Left, "Good", CorrectnesssGrid); CreateGridTextItem(2, 0, HorizontalAlignment.Left, "Latched", CorrectnesssGrid); CreateGridTextItem(3, 0, HorizontalAlignment.Left, "Unreasonable", CorrectnesssGrid); }
void SaveMeasurement(Measurement measurement, bool isNew) { SystemMessages sm; try { string result = CommonFunctions.SaveMeasurement(null, measurement, isNew); sm = new SystemMessages(new Message() { UserMessage = result, SystemMessage = string.Empty, UserMessageType = MessageType.Success }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); if (m_deviceID > 0) { GetMeasurementsByDevice(); } else { GetMeasurementList(); } //make this newly added or updated item as default selected. So user can click initialize right away. ListBoxMeasurementList.SelectedItem = (m_measurementList).Find(c => c.SignalReference == measurement.SignalReference); //Update Metadata in the openPDC Service. try { if (measurement.HistorianID != null) { string runtimeID = CommonFunctions.GetRuntimeID(null, "Historian", (int)measurement.HistorianID); WindowsServiceClient serviceClient = ((App)Application.Current).ServiceClient; if (serviceClient.Helper.RemotingClient.CurrentState == TVA.Communication.ClientState.Connected) { CommonFunctions.SendCommandToWindowsService(serviceClient, "Invoke " + runtimeID + " RefreshMetadata"); CommonFunctions.SendCommandToWindowsService(serviceClient, "RefreshRoutes"); } } } catch (Exception ex) { CommonFunctions.LogException(null, "SaveMeasurement.RefreshMetadata", ex); } //ClearForm(); } catch (Exception ex) { CommonFunctions.LogException(null, "WPF.SaveMeasurement", ex); sm = new SystemMessages(new Message() { UserMessage = "Failed to Save Measurement Information", SystemMessage = ex.Message, UserMessageType = MessageType.Error }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); } }
void SavePhasor(Phasor phasor, bool isNew) { SystemMessages sm; DataConnection connection = new DataConnection(); ; try { string result = CommonFunctions.SavePhasor(connection, phasor, isNew); //ClearForm(); sm = new SystemMessages(new Message() { UserMessage = result, SystemMessage = string.Empty, UserMessageType = MessageType.Success }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); GetPhasors(); GetPhasorList(); //make this newly added or updated item as default selected. So user can click initialize right away. ListBoxPhasorList.SelectedItem = ((List <Phasor>)ListBoxPhasorList.ItemsSource).Find(c => c.Label == phasor.Label); //Update Metadata in the openPDC Service. try { Device device = CommonFunctions.GetDeviceByDeviceID(connection, phasor.DeviceID); WindowsServiceClient serviceClient = ((App)Application.Current).ServiceClient; if (serviceClient != null && serviceClient.Helper.RemotingClient.CurrentState == TVA.Communication.ClientState.Connected) { if (device.HistorianID != null) { string runtimeID = CommonFunctions.GetRuntimeID(connection, "Historian", (int)device.HistorianID); CommonFunctions.SendCommandToWindowsService(serviceClient, "Invoke " + runtimeID + " RefreshMetadata"); } if (device.Enabled) //if device is enabled then send initialize command otherwise send reloadconfig command. { if (device.ParentID == null) { CommonFunctions.SendCommandToWindowsService(serviceClient, "Initialize " + CommonFunctions.GetRuntimeID(connection, "Device", device.ID)); } else { CommonFunctions.SendCommandToWindowsService(serviceClient, "Initialize " + CommonFunctions.GetRuntimeID(connection, "Device", (int)device.ParentID)); } } else { CommonFunctions.SendCommandToWindowsService(serviceClient, "ReloadConfig"); //we do this to make sure all statistical measurements are in the system. } CommonFunctions.SendCommandToWindowsService(serviceClient, "RefreshRoutes"); } else { sm = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Failed to Perform Configuration Changes", SystemMessage = "Application is disconnected from the openPDC Service.", UserMessageType = openPDCManager.Utilities.MessageType.Information }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); } } catch (Exception ex) { sm = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Failed to Perform Configuration Changes", SystemMessage = ex.Message, UserMessageType = openPDCManager.Utilities.MessageType.Information }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); CommonFunctions.LogException(null, "SavePhasor.RefreshMetadata", ex); } } catch (Exception ex) { CommonFunctions.LogException(connection, "WPF.SavePhasor", ex); sm = new SystemMessages(new Message() { UserMessage = "Failed to Save Phasor Information", SystemMessage = ex.Message, UserMessageType = MessageType.Error }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); } finally { if (connection != null) { connection.Dispose(); } } }
void SaveWizardConfigurationInfo(string nodeID, ObservableCollection <WizardDeviceInfo> wizardDeviceInfoList, string connectionString, int?protocolID, int?companyID, int?historianID, int?interconnectionID, int?parentID, bool skipDisableRealTimeData) { SystemMessages sm; try { string result = CommonFunctions.SaveWizardConfigurationInfo(null, nodeID, new List <WizardDeviceInfo>(wizardDeviceInfoList), connectionString, protocolID, companyID, historianID, interconnectionID, parentID, skipDisableRealTimeData); if (m_activityWindow != null) { m_activityWindow.Close(); } sm = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = result, SystemMessage = string.Empty, UserMessageType = openPDCManager.Utilities.MessageType.Success }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); //Update Metadata in the openPDC Service. try { WindowsServiceClient serviceClient = ((App)Application.Current).ServiceClient; if (serviceClient != null && serviceClient.Helper.RemotingClient.CurrentState == TVA.Communication.ClientState.Connected) { //Send Initialize command to openPDC windows service. if (parentID != null) // devices are being added to PDC then initialize PDC only and not individual devices. { string runtimeID = CommonFunctions.GetRuntimeID(null, "Device", (int)parentID); CommonFunctions.SendCommandToWindowsService(serviceClient, "Initialize " + runtimeID); } else //Otherwise go through the list and intialize each device by retrieving its runtime ID from database. { foreach (WizardDeviceInfo deviceInfo in wizardDeviceInfoList) { if (deviceInfo.Include) { Device device = CommonFunctions.GetDeviceByAcronym(null, deviceInfo.Acronym); if (device != null) { string runtimeID = CommonFunctions.GetRuntimeID(null, "Device", device.ID); CommonFunctions.SendCommandToWindowsService(serviceClient, "Initialize " + runtimeID); } } } } if (historianID != null) { string runtimeID = CommonFunctions.GetRuntimeID(null, "Historian", (int)historianID); CommonFunctions.SendCommandToWindowsService(serviceClient, "Invoke " + runtimeID + " RefreshMetadata"); } // Also update Stat historian metadata. Historian statHistorian = CommonFunctions.GetHistorianByAcronym(null, "STAT"); if (statHistorian != null) { string statRuntimeID = CommonFunctions.GetRuntimeID(null, "Historian", statHistorian.ID); CommonFunctions.SendCommandToWindowsService(serviceClient, "Invoke " + statRuntimeID + " RefreshMetadata"); } // Issue reload statistics command for CommonPhasorServices to pick up change in statistics measurement if any. CommonFunctions.SendCommandToWindowsService(serviceClient, "Invoke 0 ReloadStatistics"); CommonFunctions.SendCommandToWindowsService(serviceClient, "RefreshRoutes"); } else { sm = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Failed to Perform Configuration Changes", SystemMessage = "Application is disconnected from the openPDC Service.", UserMessageType = openPDCManager.Utilities.MessageType.Information }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); } //navigate to browse devices screen. BrowseDevicesUserControl browseDevices = new BrowseDevicesUserControl(); ((MasterLayoutWindow)Window.GetWindow(this)).ContentFrame.Navigate(browseDevices); } catch (Exception ex) { if (m_activityWindow != null) { m_activityWindow.Close(); } sm = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Failed to Perform Configuration Changes", SystemMessage = ex.Message, UserMessageType = openPDCManager.Utilities.MessageType.Information }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); CommonFunctions.LogException(null, "SaveWizardConfigurationInfo.RefreshMetadata", ex); } } catch (Exception ex) { CommonFunctions.LogException(null, "WPF.SaveWizardConfigurationInfo", ex); sm = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Failed to Save Configuration Information", SystemMessage = ex.Message, UserMessageType = openPDCManager.Utilities.MessageType.Error }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); } nextButtonClicked = false; if (m_activityWindow != null) { m_activityWindow.Close(); } }
void ButtonSave_Click(object sender, RoutedEventArgs e) { SystemMessages sm; if (((App)Application.Current).Principal.IsInRole("Administrator, Editor")) { try { Device device = new Device(); device = ((Button)sender).DataContext as Device; string result = CommonFunctions.SaveDevice(null, device, false, 0, 0); sm = new SystemMessages(new Message() { UserMessage = result, SystemMessage = string.Empty, UserMessageType = MessageType.Success }, ButtonType.OkOnly); //Update Metadata in the openPDC Service. try { WindowsServiceClient serviceClient = ((App)Application.Current).ServiceClient; if (serviceClient != null && serviceClient.Helper.RemotingClient.CurrentState == TVA.Communication.ClientState.Connected) { if (device.Enabled) //if device is enabled then send initialize command otherwise send reloadconfig command. { if (device.ParentID == null) { CommonFunctions.SendCommandToWindowsService(serviceClient, "Initialize " + CommonFunctions.GetRuntimeID(null, "Device", device.ID)); } else { CommonFunctions.SendCommandToWindowsService(serviceClient, "Initialize " + CommonFunctions.GetRuntimeID(null, "Device", (int)device.ParentID)); } } else { CommonFunctions.SendCommandToWindowsService(serviceClient, "ReloadConfig"); //we do this to make sure all statistical measurements are in the system. } if (device.HistorianID != null) { string runtimeID = CommonFunctions.GetRuntimeID(null, "Historian", (int)device.HistorianID); CommonFunctions.SendCommandToWindowsService(serviceClient, "Invoke " + runtimeID + " RefreshMetadata"); } //now also update Stat historian metadata. Historian statHistorian = CommonFunctions.GetHistorianByAcronym(null, "STAT"); if (statHistorian != null) { string statRuntimeID = CommonFunctions.GetRuntimeID(null, "Historian", statHistorian.ID); CommonFunctions.SendCommandToWindowsService(serviceClient, "Invoke " + statRuntimeID + " RefreshMetadata"); } CommonFunctions.SendCommandToWindowsService(serviceClient, "Invoke 0 ReloadStatistics"); CommonFunctions.SendCommandToWindowsService(serviceClient, "RefreshRoutes"); } else { SystemMessages sm2 = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Failed to Perform Configuration Changes", SystemMessage = "Application is disconnected from the openPDC Service.", UserMessageType = openPDCManager.Utilities.MessageType.Information }, ButtonType.OkOnly); sm2.Owner = Window.GetWindow(this); sm2.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm2.ShowPopup(); } } catch (Exception ex) { SystemMessages sm1 = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Failed to Perform Configuration Changes", SystemMessage = ex.Message, UserMessageType = openPDCManager.Utilities.MessageType.Information }, ButtonType.OkOnly); sm1.Owner = Window.GetWindow(this); sm1.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm1.ShowPopup(); CommonFunctions.LogException(null, "ButtonSave_Click.RefreshMetadata", ex); } } catch (Exception ex) { CommonFunctions.LogException(null, "WPF.SaveDevice", ex); sm = new SystemMessages(new Message() { UserMessage = "Failed to Save Device Information", SystemMessage = ex.Message, UserMessageType = MessageType.Error }, ButtonType.OkOnly); } sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); RefreshDeviceList(); } else { sm = new SystemMessages(new Message() { UserMessage = "Unauthorized Access", SystemMessage = "You are not authorized to perform this operation.", UserMessageType = MessageType.Warning }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); } }
void ButtonDelete_Click(object sender, RoutedEventArgs e) { SystemMessages sm; if (((App)Application.Current).Principal.IsInRole("Administrator, Editor")) { try { string result; Device device = new Device(); device = ((Button)sender).DataContext as Device; if (device.IsConcentrator) { sm = new SystemMessages(new Message() { UserMessage = "Do you want to delete concentrator device?", SystemMessage = "Device Acronym: " + device.Acronym + Environment.NewLine + "Deleting concentrator will also delete " + CommonFunctions.GetDeviceListByParentID(null, device.ID).Count() + " associated device(s).", UserMessageType = MessageType.Confirmation }, ButtonType.YesNo); } else { sm = new SystemMessages(new Message() { UserMessage = "Do you want to delete device?", SystemMessage = "Device Acronym: " + device.Acronym, UserMessageType = MessageType.Confirmation }, ButtonType.YesNo); } sm.Closed += new EventHandler(delegate(object popupWindow, EventArgs eargs) { if ((bool)sm.DialogResult) { try { if (device.IsConcentrator) { List <Device> deviceList = CommonFunctions.GetDeviceListByParentID(null, device.ID); foreach (Device d in deviceList) { CommonFunctions.DeleteDevice(null, d.ID); } result = CommonFunctions.DeleteDevice(null, device.ID); } else { result = CommonFunctions.DeleteDevice(null, device.ID); } SystemMessages sm1 = new SystemMessages(new Message() { UserMessage = result, SystemMessage = string.Empty, UserMessageType = MessageType.Success }, ButtonType.OkOnly); sm1.Owner = Window.GetWindow(this); sm1.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm1.ShowPopup(); RefreshDeviceList(); } catch (Exception ex) { SystemMessages sm1 = new SystemMessages(new Message() { UserMessage = "Failed to Delete Device", SystemMessage = ex.Message, UserMessageType = MessageType.Error }, ButtonType.OkOnly); sm1.Owner = Window.GetWindow(this); sm1.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm1.ShowPopup(); CommonFunctions.LogException(null, "ButtonDelete_Click", ex); } //Update Metadata in the openPDC Service. try { WindowsServiceClient serviceClient = ((App)Application.Current).ServiceClient; if (serviceClient != null && serviceClient.Helper.RemotingClient.CurrentState == TVA.Communication.ClientState.Connected) { if (device.ParentID == null) { CommonFunctions.SendCommandToWindowsService(serviceClient, "ReloadConfig"); } else { CommonFunctions.SendCommandToWindowsService(serviceClient, "Initialize " + CommonFunctions.GetRuntimeID(null, "Device", (int)device.ParentID)); } } } catch (Exception ex) { CommonFunctions.LogException(null, "ButtonDelete_Click.RefreshMetadata", ex); } } }); } catch (Exception ex) { CommonFunctions.LogException(null, "WPF.DeleteDevice", ex); sm = new SystemMessages(new Message() { UserMessage = "Failed to Delete Device", SystemMessage = ex.Message, UserMessageType = MessageType.Error }, ButtonType.OkOnly); } sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); } else { sm = new SystemMessages(new Message() { UserMessage = "Unauthorized Access", SystemMessage = "You are not authorized to perform this operation.", UserMessageType = MessageType.Warning }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); } }
private void CheckSchedules(WindowsServiceClient serviceClient = null) { Match match; int hour; int minute; if ((object)serviceClient == null) serviceClient = CommonFunctions.GetWindowsServiceClient(); serviceClient.Helper.SendRequest("Schedules"); // Wait for command response allowing for processing time if ((object)m_responseComplete != null) { if (!m_responseComplete.Wait(5000)) throw new TimeoutException("Timed-out after 5 seconds waiting for service response."); } if ((object)m_responseMessage != null) { match = Regex.Match(m_responseMessage, string.Format("^{0} +(?<Minute>[^ ]+) +(?<Hour>[^ ]+)", ScheduledProcessName), RegexOptions.Multiline); if (match.Success) { ReportingEnabled = true; if (int.TryParse(match.Groups["Hour"].Value, out hour) && int.TryParse(match.Groups["Minute"].Value, out minute)) { ReportGenerationTime = DateTime.ParseExact(string.Format("{0:00}:{1:00}", hour, minute), "HH:mm", CultureInfo.InvariantCulture); m_originalReportGenerationTime = m_reportGenerationTime; OnPropertyChanged("OriginalReportGenerationTimeText"); } } else { ReportingEnabled = false; } m_responseMessage = null; } }
/// <summary> /// Connects to backend windows service and attaches to it's events. /// </summary> private void SetupServiceConnection() { m_serviceClient = null; try { m_serviceClient = CommonFunctions.GetWindowsServiceClient(); if (m_serviceClient != null && m_serviceClient.Helper != null && m_serviceClient.Helper.RemotingClient != null && m_serviceClient.Helper.RemotingClient.CurrentState == ClientState.Connected) { TextBlockServiceStatus.Dispatcher.BeginInvoke(new DisplayHelper(RefreshStatusText), new object[] { UpdateType.Information, m_serviceClient.CachedStatus }); m_serviceClient.Helper.ReceivedServiceResponse += Helper_ReceivedServiceResponse; m_serviceClient.Helper.ReceivedServiceUpdate += Helper_ReceivedServiceUpdate; } } catch (Exception ex) { TextBlockServiceStatus.Dispatcher.BeginInvoke(new DisplayHelper(RefreshStatusText), new object[] { UpdateType.Alarm, "Failed to connect to windows service." + Environment.NewLine + ex.Message }); } }
private void HomeUserControl_Loaded(object sender, RoutedEventArgs e) { if (!CommonFunctions.CurrentPrincipal.IsInRole("Administrator,Editor")) { ButtonInputWizard.IsEnabled = false; } m_windowsServiceClient = CommonFunctions.GetWindowsServiceClient(); if (m_windowsServiceClient == null || m_windowsServiceClient.Helper.RemotingClient.CurrentState != ClientState.Connected) { // TODO: Disable any buttons here that will not function without service connectivity } else { m_windowsServiceClient.Helper.ReceivedServiceResponse += Helper_ReceivedServiceResponse; CommonFunctions.SendCommandToService("Health -actionable"); CommonFunctions.SendCommandToService("Version -actionable"); CommonFunctions.SendCommandToService("Status -actionable"); CommonFunctions.SendCommandToService("Time -actionable"); m_eventHandlerRegistered = true; } m_refreshTimer = new DispatcherTimer(); m_refreshTimer.Interval = TimeSpan.FromSeconds(5); m_refreshTimer.Tick += RefreshTimer_Tick; m_refreshTimer.Start(); if (IntPtr.Size == 8) { TextBlockInstance.Text = "64-bit"; } else { TextBlockInstance.Text = "32-bit"; } TextBlockLocalTime.Text = DateTime.Now.ToString("yyyy-MM-dd HH:mm:ss.fff"); Version appVersion = AssemblyInfo.EntryAssembly.Version; TextBlockManagerVersion.Text = appVersion.Major + "." + appVersion.Minor + "." + appVersion.Build + ".0"; try { using (AdoDataConnection database = new AdoDataConnection(CommonFunctions.DefaultSettingsCategory)) { TextBlockDatabaseType.Text = database.DatabaseType.ToString(); try { if (database.IsSqlite || database.IsJetEngine) { // Extract database file name from connection string for file centric databases TextBlockDatabaseName.Text = FilePath.GetFileName(database.Connection.ConnectionString.ParseKeyValuePairs()["Data Source"]); } else if (database.IsOracle) { // Extract user name from connection string for Oracle databases TextBlockDatabaseName.Text = database.Connection.ConnectionString.ParseKeyValuePairs()["User Id"]; } else { TextBlockDatabaseName.Text = database.Connection.Database; } } catch { // Fall back on database name if file anything fails TextBlockDatabaseName.Text = database.Connection.Database; } } } catch { TextBlockDatabaseName.Text = "Not Avaliable"; } try { using (UserInfo info = new UserInfo(CommonFunctions.CurrentUser)) { if (info.Exists) { TextBlockUser.Text = info.LoginID; } else { TextBlockUser.Text = CommonFunctions.CurrentUser; } } } catch { TextBlockUser.Text = CommonFunctions.CurrentUser; } ((HorizontalAxis)ChartPlotterDynamic.MainHorizontalAxis).LabelProvider.LabelStringFormat = ""; //Remove legend on the right. Panel legendParent = (Panel)ChartPlotterDynamic.Legend.ContentGrid.Parent; if (legendParent != null) { legendParent.Children.Remove(ChartPlotterDynamic.Legend.ContentGrid); } ChartPlotterDynamic.NewLegendVisible = false; m_xAxisDataCollection = new int[NumberOfPointsToPlot]; for (int i = 0; i < NumberOfPointsToPlot; i++) { m_xAxisDataCollection[i] = i; } m_xAxisBindingCollection = new EnumerableDataSource <int>(m_xAxisDataCollection); m_xAxisBindingCollection.SetXMapping(x => x); LoadComboBoxDeviceAsync(); }