void HyperlinkBrowseDevices_Click(object sender, RoutedEventArgs e) { #if !SILVERLIGHT BrowseDevicesUserControl devices = new BrowseDevicesUserControl(); ((MasterLayoutWindow)Window.GetWindow(this)).ContentFrame.Navigate(devices); #endif }
private void ButtonDevices_Click(object sender, RoutedEventArgs e) { #if SILVERLIGHT this.ParentPage.NavigationService.Navigate(new Uri("/Pages/Devices/Browse.xaml", UriKind.Relative)); //System.Windows.Browser.HtmlPage.Window.Navigate(new Uri("/Pages/Devices/Browse.xaml", UriKind.Relative)); #else BrowseDevicesUserControl browseDevices = new BrowseDevicesUserControl(); ((MasterLayoutWindow)Window.GetWindow(this)).ContentFrame.Navigate(browseDevices); #endif }
public void SaveDevice(Device device, bool isNew, int digitalCount, int analogCount) { SystemMessages sm; DataConnection connection = new DataConnection(); try { string result = CommonFunctions.SaveDevice(connection, device, isNew, digitalCount, analogCount); //get the ID of the new device added to the system so we can associate that ID to the phasors of the original device. int deviceID; if (isNew) { deviceID = CommonFunctions.GetDeviceByAcronym(connection, device.Acronym).ID; } else { deviceID = device.ID; } if (m_deviceToCopy != null && isNew) //if we are copying device then make sure we copy phasors also. { List <Phasor> phasorList = CommonFunctions.GetPhasorList(connection, m_deviceToCopy.ID); foreach (Phasor phasor in phasorList) { phasor.DeviceID = deviceID; CommonFunctions.SavePhasor(connection, phasor, true); } } 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(); //update statistic measurement for a device if device is being updated and acronym has changed. try { if (!isNew && !string.IsNullOrEmpty(m_oldAcronym) && m_oldAcronym != device.Acronym) { CommonFunctions.UpdateDeviceStatistics(connection, deviceID, m_oldAcronym, device.Acronym, m_oldDeviceName, device.Name); //also if acronym has changed then make those changes } } catch (Exception ex) { CommonFunctions.LogException(connection, "WPF.UpdateDeviceStatistics", ex); sm = new SystemMessages(new Message() { UserMessage = "Failed to Update Device Statistics", SystemMessage = ex.Message, UserMessageType = MessageType.Error }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); } //Update Metadata in the openPDC Service. try { 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. { CommonFunctions.SendCommandToWindowsService(serviceClient, "Initialize " + CommonFunctions.GetRuntimeID(connection, "Device", deviceID)); // Convert.ToInt32(TextBlockRuntimeID.Text)); } else { CommonFunctions.SendCommandToWindowsService(serviceClient, "ReloadConfig"); //we do this to make sure all statistical measurements are in the system. } if (device.HistorianID != null) //Update historian metadata { string runtimeID = CommonFunctions.GetRuntimeID(connection, "Historian", (int)device.HistorianID); CommonFunctions.SendCommandToWindowsService(serviceClient, "Invoke " + runtimeID + " RefreshMetadata"); } //now also update Stat historian metadata. Historian statHistorian = CommonFunctions.GetHistorianByAcronym(connection, "STAT"); if (statHistorian != null) { string statRuntimeID = CommonFunctions.GetRuntimeID(connection, "Historian", statHistorian.ID); CommonFunctions.SendCommandToWindowsService(serviceClient, "Invoke " + statRuntimeID + " RefreshMetadata"); } 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(); } } 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(connection, "SaveDevice.RefreshMetadata", ex); } ClearForm(); //Navigate to Browse screen upon successful save. BrowseDevicesUserControl browseDevices = new BrowseDevicesUserControl(); ((MasterLayoutWindow)Window.GetWindow(this)).ContentFrame.Navigate(browseDevices); } catch (Exception ex) { CommonFunctions.LogException(connection, "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(); } 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(); } }