void AccordianWizard_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (AccordianWizard.SelectedIndex == 1) { } if (AccordianWizard.SelectedIndex == 2) { if ((bool)CheckboxConnectToPDC.IsChecked || m_wizardDeviceInfoList.Count > 1) { CheckboxConnectToPDC.IsChecked = true; if (!string.IsNullOrEmpty(TextBoxPDCAcronym.Text.Replace(" ", ""))) { GetDeviceByAcronym(TextBoxPDCAcronym.Text.Replace(" ", "").ToUpper()); } else { SystemMessages sm = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Please fill in required concentrator information.", SystemMessage = "The current configuration defines more than one device which means this connection is to a concentrated data stream. A unique concentrator acronym is required to identify the concentration device.", UserMessageType = openPDCManager.Utilities.MessageType.Error }, ButtonType.OkOnly); #if !SILVERLIGHT sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; #endif sm.ShowPopup(); m_goToPreviousAccordianItem = true; TextBoxPDCAcronym.Focus(); ChangeAccordianSelection(AccordianWizard.SelectedIndex - 1); } } } if (AccordianWizard.SelectedIndex == 0) { ButtonPrevious.Visibility = Visibility.Collapsed; ButtonNext.Tag = "Next"; } else if (AccordianWizard.SelectedIndex == AccordianWizard.Items.Count - 1) { ButtonPrevious.Visibility = Visibility.Visible; ButtonNext.Tag = "Finish"; } else { ButtonNext.Tag = "Next"; ButtonPrevious.Visibility = Visibility.Visible; } }
void client_GetWizardConfigurationInfoCompleted(object sender, GetWizardConfigurationInfoCompletedEventArgs e) { if (e.Error == null) { m_wizardDeviceInfoList = e.Result; ItemControlDeviceList.ItemsSource = m_wizardDeviceInfoList; if (m_wizardDeviceInfoList.Count > 1) { CheckboxConnectToPDC.IsChecked = true; SystemMessages sm = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Please fill in required concentrator information.", SystemMessage = "The current configuration defines more than one device which means this connection is to a concentrated data stream. A unique concentrator acronym is required to identify the concentration device.", UserMessageType = openPDCManager.Utilities.MessageType.Information }, ButtonType.OkOnly); sm.ShowPopup(); TextBoxPDCAcronym.Focus(); } else { CheckboxConnectToPDC.IsChecked = false; } } else { SystemMessages sm; if (e.Error is FaultException <CustomServiceFault> ) { FaultException <CustomServiceFault> fault = e.Error as FaultException <CustomServiceFault>; sm = new SystemMessages(new Message() { UserMessage = fault.Detail.UserMessage, SystemMessage = fault.Detail.SystemMessage, UserMessageType = MessageType.Error }, ButtonType.OkOnly); } else { sm = new SystemMessages(new Message() { UserMessage = "Failed to Parse Configuration File", SystemMessage = e.Error.Message, UserMessageType = MessageType.Error }, ButtonType.OkOnly); } sm.ShowPopup(); } if (m_activityWindow != null) { m_activityWindow.Close(); } m_configFileData.Close(); }
private void ButtonManualConfiguration_Click(object sender, RoutedEventArgs e) { #if !SILVERLIGHT ManualConfigurator configurator = new ManualConfigurator(CommonFunctions.s_configurationFrame); configurator.Closed += new EventHandler(delegate(object popupWindow, EventArgs eargs) { if ((bool)configurator.DialogResult) { m_wizardDeviceInfoList = new ObservableCollection <WizardDeviceInfo>(CommonFunctions.ParseConfigurationFrame(configurator.UserControlConfiguratorCreator.ConfigurationFrame)); ItemControlDeviceList.ItemsSource = m_wizardDeviceInfoList; if (m_wizardDeviceInfoList.Count > 1) { CheckboxConnectToPDC.IsChecked = true; SystemMessages sm = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Please fill in required concentrator information.", SystemMessage = "The current configuration defines more than one device which means this connection is to a concentrated data stream. A unique concentrator acronym is required to identify the concentration device.", UserMessageType = openPDCManager.Utilities.MessageType.Information }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); TextBoxPDCAcronym.Focus(); } else { CheckboxConnectToPDC.IsChecked = false; } ChangeSummaryVisibility(Visibility.Visible); } }); configurator.Owner = Window.GetWindow(this); configurator.WindowStartupLocation = WindowStartupLocation.CenterOwner; configurator.ShowDialog(); #endif }
void GetWizardConfigurationInfo(Stream data) { try { m_wizardDeviceInfoList = new ObservableCollection <WizardDeviceInfo>(CommonFunctions.GetWizardConfigurationInfo(data)); if (m_wizardDeviceInfoList.Count > 10) { m_bindingDevices = true; } else { m_bindingDevices = false; } ItemControlDeviceList.ItemsSource = m_wizardDeviceInfoList; if (m_activityWindow != null && !m_bindingDevices) { m_activityWindow.Close(); } if (m_wizardDeviceInfoList.Count > 1) { CheckboxConnectToPDC.IsChecked = true; if (m_deviceToBeUpdated == null) { SystemMessages sm = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Please fill in required concentrator information.", SystemMessage = "The current configuration defines more than one device which means this connection is to a concentrated data stream. A unique concentrator acronym is required to identify the concentration device.", UserMessageType = openPDCManager.Utilities.MessageType.Information }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); TextBoxPDCAcronym.Focus(); } } else { CheckboxConnectToPDC.IsChecked = false; } ChangeSummaryVisibility(Visibility.Visible); if (m_deviceToBeUpdated != null) { AccordianWizard.SelectedIndex = 2; } } catch (Exception ex) { if (m_activityWindow != null && !m_bindingDevices) { m_activityWindow.Close(); } CommonFunctions.LogException(null, "WPF.GetWizardConfigurationInfo", ex); SystemMessages sm = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Failed to Parse Configuration File", SystemMessage = ex.Message, UserMessageType = openPDCManager.Utilities.MessageType.Error }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); } }
void GetDeviceByAcronym(string acronym) { try { Device device = new Device(); device = CommonFunctions.GetDeviceByAcronym(null, acronym); if (device != null) { if (device.IsConcentrator) { m_parentID = device.ID; } else { SystemMessages sm = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Invalid PDC Acronym", SystemMessage = "A non-PDC device with the same acronym already exists. Please change PDC acronym to continue.", UserMessageType = openPDCManager.Utilities.MessageType.Error }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); TextBoxPDCAcronym.Focus(); m_goToPreviousAccordianItem = true; } } else { App app = (App)Application.Current; device = new Device(); device.Name = TextBoxPDCName.Text; device.Acronym = TextBoxPDCAcronym.Text; device.IsConcentrator = true; device.VendorDeviceID = ((KeyValuePair <int, string>)ComboboxPDCVendor.SelectedItem).Key == 0 ? (int?)null : ((KeyValuePair <int, string>)ComboboxPDCVendor.SelectedItem).Key; int accessID; device.AccessID = int.TryParse(TextBoxAccessID.Text, out accessID) ? accessID : m_wizardDeviceInfoList.Count > 0 ? m_wizardDeviceInfoList[0].ParentAccessID : 0; device.NodeID = app.NodeValue; device.ParentID = null; device.Longitude = -98.6m; device.Latitude = 37.5m; device.CompanyID = ((KeyValuePair <int, string>)ComboboxCompany.SelectedItem).Key == 0 ? (int?)null : ((KeyValuePair <int, string>)ComboboxCompany.SelectedItem).Key; device.ProtocolID = ((KeyValuePair <int, string>)ComboboxProtocol.SelectedItem).Key == 0 ? (int?)null : ((KeyValuePair <int, string>)ComboboxProtocol.SelectedItem).Key; device.HistorianID = ((KeyValuePair <int, string>)ComboboxHistorian.SelectedItem).Key == 0 ? (int?)null : ((KeyValuePair <int, string>)ComboboxHistorian.SelectedItem).Key; device.InterconnectionID = ((KeyValuePair <int, string>)ComboboxInterconnection.SelectedItem).Key == 0 ? (int?)null : ((KeyValuePair <int, string>)ComboboxInterconnection.SelectedItem).Key; device.ConnectionString = this.ConnectionString(); device.TimeZone = string.Empty; device.TimeAdjustmentTicks = 0; device.MeasuredLines = 1; //m_wizardDeviceInfoList.Count; device.LoadOrder = 0; device.ContactList = string.Empty; device.Enabled = true; device.FramesPerSecond = 30; device.DataLossInterval = 5; device.AllowedParsingExceptions = 10; device.ParsingExceptionWindow = 5; device.DelayedConnectionInterval = 5; device.AllowUseOfCachedConfiguration = true; device.AutoStartDataParsingSequence = true; device.MeasurementReportingInterval = 100000; SaveDevice(device, true, 0, 0); } } catch (Exception ex) { CommonFunctions.LogException(null, "WPF.GetDeviceByAcronym", ex); SystemMessages sm = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Failed to Retrieve Device Information by Acronym", SystemMessage = ex.Message, UserMessageType = openPDCManager.Utilities.MessageType.Error }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); } //m_client.GetDeviceByAcronymAsync(acronym); }
void RetrieveConfigurationFrame() { //this was done because activity window wasn't showing any message on the screen. So this function is called on a seperate thread and then brough back to UI thread. this.Dispatcher.BeginInvoke((Action) delegate() { SystemMessages sm; try { string connectionString = this.ConnectionString(); if (!connectionString.EndsWith(";")) { connectionString += ";"; } connectionString += "AccessID=" + TextBoxAccessID.Text; m_wizardDeviceInfoList = new ObservableCollection <WizardDeviceInfo>(CommonFunctions.RetrieveConfigurationFrame(((App)Application.Current).RemoteStatusServiceUrl, connectionString, ((KeyValuePair <int, string>)ComboboxProtocol.SelectedItem).Key)); if (m_wizardDeviceInfoList.Count > 10) { m_bindingDevices = true; } else { m_bindingDevices = false; } if (m_activityWindow != null && !m_bindingDevices) { m_activityWindow.Close(); } sm = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Retrieved Configuration Successfully!", SystemMessage = "", UserMessageType = openPDCManager.Utilities.MessageType.Success }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); ItemControlDeviceList.ItemsSource = m_wizardDeviceInfoList; if (m_wizardDeviceInfoList.Count > 1) { CheckboxConnectToPDC.IsChecked = true; if (m_deviceToBeUpdated == null) { SystemMessages sm1 = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Please fill in required concentrator information.", SystemMessage = "The current configuration defines more than one device which means this connection is to a concentrated data stream. A unique concentrator acronym is required to identify the concentration device.", UserMessageType = openPDCManager.Utilities.MessageType.Information }, ButtonType.OkOnly); sm1.Owner = Window.GetWindow(this); sm1.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm1.ShowPopup(); TextBoxPDCAcronym.Focus(); } } else { CheckboxConnectToPDC.IsChecked = false; } ChangeSummaryVisibility(Visibility.Visible); if (m_deviceToBeUpdated != null) { AccordianWizard.SelectedIndex = 2; } } catch (Exception ex) { if (m_activityWindow != null) { m_activityWindow.Close(); } CommonFunctions.LogException(null, "WPF.RetrieveConfigurationFrame", ex); sm = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Failed to Retrieve Configuration", SystemMessage = ex.Message, UserMessageType = openPDCManager.Utilities.MessageType.Error }, ButtonType.OkOnly); sm.Owner = Window.GetWindow(this); sm.WindowStartupLocation = WindowStartupLocation.CenterOwner; sm.ShowPopup(); } }); }
void client_GetDeviceByAcronymCompleted(object sender, GetDeviceByAcronymCompletedEventArgs e) { if (e.Error == null) { Device device = new Device(); device = e.Result; if (device != null) { if (device.IsConcentrator) { m_parentID = device.ID; } else { SystemMessages sm = new SystemMessages(new openPDCManager.Utilities.Message() { UserMessage = "Invalid PDC Acronym", SystemMessage = "A non-PDC device with the same acronym already exists. Please change PDC acronym to continue.", UserMessageType = openPDCManager.Utilities.MessageType.Error }, ButtonType.OkOnly); sm.ShowPopup(); TextBoxPDCAcronym.Focus(); m_goToPreviousAccordianItem = true; } } else // means PDC does not exist. if (parentID == null) { App app = (App)Application.Current; device = new Device(); device.Name = TextBoxPDCName.Text; device.Acronym = TextBoxPDCAcronym.Text; device.IsConcentrator = true; device.VendorDeviceID = ((KeyValuePair <int, string>)ComboboxPDCVendor.SelectedItem).Key == 0 ? (int?)null : ((KeyValuePair <int, string>)ComboboxPDCVendor.SelectedItem).Key; int accessID; device.AccessID = int.TryParse(TextBoxAccessID.Text, out accessID) ? accessID : m_wizardDeviceInfoList.Count > 0 ? m_wizardDeviceInfoList[0].ParentAccessID : 0; device.NodeID = app.NodeValue; device.ParentID = null; device.Longitude = -98.6m; device.Latitude = 37.5m; device.CompanyID = ((KeyValuePair <int, string>)ComboboxCompany.SelectedItem).Key == 0 ? (int?)null : ((KeyValuePair <int, string>)ComboboxCompany.SelectedItem).Key; device.ProtocolID = ((KeyValuePair <int, string>)ComboboxProtocol.SelectedItem).Key == 0 ? (int?)null : ((KeyValuePair <int, string>)ComboboxProtocol.SelectedItem).Key; device.HistorianID = ((KeyValuePair <int, string>)ComboboxHistorian.SelectedItem).Key == 0 ? (int?)null : ((KeyValuePair <int, string>)ComboboxHistorian.SelectedItem).Key; device.InterconnectionID = ((KeyValuePair <int, string>)ComboboxInterconnection.SelectedItem).Key == 0 ? (int?)null : ((KeyValuePair <int, string>)ComboboxInterconnection.SelectedItem).Key; device.ConnectionString = this.ConnectionString(); device.TimeZone = string.Empty; device.TimeAdjustmentTicks = 0; device.MeasuredLines = 1; //m_wizardDeviceInfoList.Count; device.LoadOrder = 0; device.ContactList = string.Empty; device.Enabled = true; device.FramesPerSecond = 30; device.DataLossInterval = 5; device.AllowedParsingExceptions = 10; device.ParsingExceptionWindow = 5; device.DelayedConnectionInterval = 5; device.AllowUseOfCachedConfiguration = true; device.AutoStartDataParsingSequence = true; device.MeasurementReportingInterval = 100000; SaveDevice(device, true, 0, 0); } } else { SystemMessages sm; if (e.Error is FaultException <CustomServiceFault> ) { FaultException <CustomServiceFault> fault = e.Error as FaultException <CustomServiceFault>; sm = new SystemMessages(new Message() { UserMessage = fault.Detail.UserMessage, SystemMessage = fault.Detail.SystemMessage, UserMessageType = MessageType.Error }, ButtonType.OkOnly); } else { sm = new SystemMessages(new Message() { UserMessage = "Failed to Retrieve Device Information by Acronym", SystemMessage = e.Error.Message, UserMessageType = MessageType.Error }, ButtonType.OkOnly); } sm.ShowPopup(); } }