private async void oPBSettings_Save_Click(object sender, RoutedEventArgs e) { cmSettings.ShowMessageProcess(); ((SettingsVM)tiSettings.DataContext).Password_ForAPIBasicAuthentication = pbHTTPSAuthentication.Password; ((SettingsVM)tiSettings.DataContext).Tcp_Password = pbTCPAuthentication.Password; OPCBackEndConfig oPCBackEndConfig = ((SettingsVM)tiSettings.DataContext).ToOPCBackEndConfig(); try { var res = await WCFChannel.TrySaveSettings(oPCBackEndConfig); if (res.Success) { await Task.Delay(500); SettingsVM settingsVM = new SettingsVM(oPCBackEndConfig); tiSettings.DataContext = settingsVM; cmSettings.ShowMessageSuccess(); } else { cmSettings.ShowMessageError("Save Failed!"); Logger.Log("Save settings failed\r\n" + res.ExStr, true); } } catch (Exception ex) { cmSettings.ShowMessageError("Save Failed!"); Logger.Log("Save settings failed\r\n" + ex.ToString(), true); } }
public SettingsVM(OPCBackEndConfig oPCBackEndConfig) { this.EnableAPI_Http = oPCBackEndConfig.EnableAPI_Http; this.EnableAPI_Https = oPCBackEndConfig.EnableAPI_Https; this.Https_Port = oPCBackEndConfig.Https_Port; this.Http_Port = oPCBackEndConfig.Http_Port; this.OPCClassic_SubscriptionGroupSizeLimit = oPCBackEndConfig.OPCClassic_SubscriptionGroupSizeLimit; this.OPCUA_SubscriptionGroupSizeLimit = oPCBackEndConfig.OPCCUA_SubscriptionGroupSizeLimit; this.Username_ForAPIBasicAuthentication = oPCBackEndConfig.Username_ForAPIBasicAuthentication; this.Password_ForAPIBasicAuthentication = oPCBackEndConfig.Password_ForAPIBasicAuthentication; this.RequireAPIBasicAuthentication = oPCBackEndConfig.RequireAPIBasicAuthentication; this.SubjectAlternativeNames_ForHTTPSCert = oPCBackEndConfig.SubjectAlternativeNames_ForHTTPSCert; }
public bool TryGetSettings(out OPCBackEndConfig OPCBackEndConfig) { OPCBackEndConfig = null; try { OPCBackEndConfig = (OPCBackEndConfig)Global.Product.Config; return(true); } catch { return(false); } }
public Task <ResTryGetSettings> TryGetSettings() { OPCBackEndConfig OPCBackEndConfig = null; try { OPCBackEndConfig = (OPCBackEndConfig)Global.Product.Config; return(Task.FromResult(new ResTryGetSettings(OPCBackEndConfig))); } catch (Exception ex) { return(Task.FromResult(new ResTryGetSettings(ex.ToString()))); } }
public OPCBackEndConfig ToOPCBackEndConfig() { OPCBackEndConfig oPCBackEndConfig = new OPCBackEndConfig() { EnableAPI_Http = this.EnableAPI_Http, EnableAPI_Https = this.EnableAPI_Https, Https_Port = this.Https_Port, Http_Port = this.Http_Port, OPCClassic_SubscriptionGroupSizeLimit = this.OPCClassic_SubscriptionGroupSizeLimit, OPCCUA_SubscriptionGroupSizeLimit = this.OPCUA_SubscriptionGroupSizeLimit, Password_ForAPIBasicAuthentication = this.Password_ForAPIBasicAuthentication, Username_ForAPIBasicAuthentication = this.Username_ForAPIBasicAuthentication, RequireAPIBasicAuthentication = this.RequireAPIBasicAuthentication, SubjectAlternativeNames_ForHTTPSCert = this.SubjectAlternativeNames_ForHTTPSCert }; return(oPCBackEndConfig); }
private void oPBSettings_Save_Click(object sender, RoutedEventArgs e) { cmSettings.ShowMessageProcess(); ((SettingsVM)tiSettings.DataContext).Password_ForAPIBasicAuthentication = pbHTTPSAuthentication.Password; OPCBackEndConfig oPCBackEndConfig = ((SettingsVM)tiSettings.DataContext).ToOPCBackEndConfig(); ThreadPool.QueueUserWorkItem(delegate { if (WCFChannel != null && WCFChannel.TrySaveSettings(oPCBackEndConfig)) { Thread.Sleep(1000); this.Dispatcher.BeginInvoke(new Action(() => { SettingsVM settingsVM = new SettingsVM(oPCBackEndConfig); tiSettings.DataContext = settingsVM; cmSettings.ShowMessageSuccess(); })); } }); }
public OPCBackEndConfig ToOPCBackEndConfig() { OPCBackEndConfig oPCBackEndConfig = new OPCBackEndConfig() { Enable_WebAPI_Http = this.EnableAPI_Http, Enable_WebAPI_Https = this.EnableAPI_Https, Https_Port = this.Https_Port, Http_Port = this.Http_Port, OPCClassic_SubscriptionGroupSizeLimit = this.OPCClassic_SubscriptionGroupSizeLimit, OPCCUA_SubscriptionGroupSizeLimit = this.OPCUA_SubscriptionGroupSizeLimit, WebAPI_Password = this.Password_ForAPIBasicAuthentication, WebAPI_Username = this.Username_ForAPIBasicAuthentication, Enable_WebAPI_BasicAuthentication = this.Enable_APIBasicAuthentication, SubjectAlternativeNames_ForHTTPSCert = this.SubjectAlternativeNames_ForHTTPSCert, Tcp_Port = this.Tcp_Port, Enable_Tcp_Authentication = this.Enable_Tcp_Authentication, Tcp_Username = this.Tcp_Username, Tcp_Password = this.Tcp_Password }; return(oPCBackEndConfig); }
public Task <Res> TrySaveSettings(OPCBackEndConfig OPCBackEndConfig) { try { Logger.Log("Saving and applying OPC Service Back End Configuration..."); bool ChangeOccured = false; OPCBackEndConfig CurrentOPCBackEndConfig = (OPCBackEndConfig)Global.Product.Config; //HTTP Settings if (CurrentOPCBackEndConfig.Enable_WebAPI_Http != OPCBackEndConfig.Enable_WebAPI_Http || CurrentOPCBackEndConfig.Http_Port != OPCBackEndConfig.Http_Port) { ChangeOccured = true; if (OPCBackEndConfig.Enable_WebAPI_Http) { OPCBackEnd.WCFHost_Http?.Stop(); OPCBackEnd.EnableHttp(); } else { OPCBackEnd.WCFHost_Http?.Stop(); } } //HTTPS Settings if (CurrentOPCBackEndConfig.Enable_WebAPI_Https != OPCBackEndConfig.Enable_WebAPI_Https || CurrentOPCBackEndConfig.Https_Port != OPCBackEndConfig.Https_Port || CurrentOPCBackEndConfig.Enable_WebAPI_BasicAuthentication != OPCBackEndConfig.Enable_WebAPI_BasicAuthentication || CurrentOPCBackEndConfig.WebAPI_Username != OPCBackEndConfig.WebAPI_Username || CurrentOPCBackEndConfig.WebAPI_Password != OPCBackEndConfig.WebAPI_Password || CurrentOPCBackEndConfig.SubjectAlternativeNames_ForHTTPSCert != OPCBackEndConfig.SubjectAlternativeNames_ForHTTPSCert) { ChangeOccured = true; if (OPCBackEndConfig.Enable_WebAPI_Https) { OPCBackEnd.WCFHost_Https?.Stop(); OPCBackEnd.EnableHttps(); } else { OPCBackEnd.WCFHost_Https?.Stop(); } } //Tcp Settings if (CurrentOPCBackEndConfig.Enable_Tcp_Authentication != OPCBackEndConfig.Enable_Tcp_Authentication || CurrentOPCBackEndConfig.Tcp_Port != OPCBackEndConfig.Tcp_Port || CurrentOPCBackEndConfig.Tcp_Username != OPCBackEndConfig.Tcp_Username || CurrentOPCBackEndConfig.Tcp_Password != OPCBackEndConfig.Tcp_Password) { ChangeOccured = true; OPCBackEnd.WCFHost_Tcp?.Stop(); OPCBackEnd.WCFHost_Tcp.ListeningPort = OPCBackEndConfig.Tcp_Port; OPCBackEnd.WCFHost_Tcp.EnableUserAuthentication = OPCBackEndConfig.Enable_Tcp_Authentication && !(OPCBackEndConfig.Tcp_Username.IsNullOrEmpty() && OPCBackEndConfig.Tcp_Password.IsNullOrEmpty()); OPCBackEnd.WCFHost_Tcp.Start(); } //OPC Settings if (CurrentOPCBackEndConfig.OPCClassic_SubscriptionGroupSizeLimit != OPCBackEndConfig.OPCClassic_SubscriptionGroupSizeLimit) { ChangeOccured = true; OPCBackEnd.OPCClassicBrowserEngine.OPCGroupSizeLimit = OPCBackEndConfig.OPCClassic_SubscriptionGroupSizeLimit.ToInt(40); } if (CurrentOPCBackEndConfig.OPCCUA_SubscriptionGroupSizeLimit != OPCBackEndConfig.OPCCUA_SubscriptionGroupSizeLimit) { ChangeOccured = true; OPCBackEnd.OPCUABrowserEngine.OPCGroupSizeLimit = OPCBackEndConfig.OPCCUA_SubscriptionGroupSizeLimit.ToInt(40); } if (ChangeOccured) { OPCBackEnd.Config = OPCBackEndConfig; Global.Product.Config = OPCBackEndConfig; Global.Product.Config.TrySaveConfigFile(out string ExStrC); Logger.Log("Successfully saved OPC Service Back End Configuration at '" + Global.Product.ConfigFilePath + "'"); } else { Logger.Log("Save did not execute as there were no changes made!"); } return(Task.FromResult(new Res())); } catch (Exception ex) { return(Task.FromResult(new Res(ex.ToString())));; } }
public bool TrySaveSettings(OPCBackEndConfig OPCBackEndConfig) { try { Logger.Log("Saving and applying Vlix OPC New Back End Configuration..."); bool ChangeOccured = false; OPCBackEndConfig CurrentOPCBackEndConfig = (OPCBackEndConfig)Global.Product.Config; //HTTP Settings if (CurrentOPCBackEndConfig.EnableAPI_Http != OPCBackEndConfig.EnableAPI_Http || CurrentOPCBackEndConfig.Http_Port != OPCBackEndConfig.Http_Port) { ChangeOccured = true; if (OPCBackEndConfig.EnableAPI_Http) { OPCBackEnd.WCFHost_Http?.Stop(); OPCBackEnd.EnableHttp(); } else { OPCBackEnd.WCFHost_Http?.Stop(); } } //HTTPS Settings if (CurrentOPCBackEndConfig.EnableAPI_Https != OPCBackEndConfig.EnableAPI_Https || CurrentOPCBackEndConfig.Https_Port != OPCBackEndConfig.Https_Port || CurrentOPCBackEndConfig.RequireAPIBasicAuthentication != OPCBackEndConfig.RequireAPIBasicAuthentication || CurrentOPCBackEndConfig.Username_ForAPIBasicAuthentication != OPCBackEndConfig.Username_ForAPIBasicAuthentication || CurrentOPCBackEndConfig.Password_ForAPIBasicAuthentication != OPCBackEndConfig.Password_ForAPIBasicAuthentication || CurrentOPCBackEndConfig.SubjectAlternativeNames_ForHTTPSCert != OPCBackEndConfig.SubjectAlternativeNames_ForHTTPSCert) { ChangeOccured = true; if (OPCBackEndConfig.EnableAPI_Https) { OPCBackEnd.WCFHost_Https?.Stop(); OPCBackEnd.EnableHttps(); } else { OPCBackEnd.WCFHost_Https?.Stop(); } } //OPC Settings if (CurrentOPCBackEndConfig.OPCClassic_SubscriptionGroupSizeLimit != OPCBackEndConfig.OPCClassic_SubscriptionGroupSizeLimit) { ChangeOccured = true; OPCBackEnd.OPCClassicBrowserEngine.OPCGroupSizeLimit = OPCBackEndConfig.OPCClassic_SubscriptionGroupSizeLimit.ToInt(40); } if (CurrentOPCBackEndConfig.OPCCUA_SubscriptionGroupSizeLimit != OPCBackEndConfig.OPCCUA_SubscriptionGroupSizeLimit) { ChangeOccured = true; OPCBackEnd.OPCUABrowserEngine.OPCGroupSizeLimit = OPCBackEndConfig.OPCCUA_SubscriptionGroupSizeLimit.ToInt(40); } if (ChangeOccured) { OPCBackEnd.Config = OPCBackEndConfig; Global.Product.Config = OPCBackEndConfig; Global.Product.Config.TrySaveConfigFile(out string ExStrC); Logger.Log("Successfully saved Vlix OPC Back End Configuration at '" + Global.Product.ConfigFilePath + "'"); } else { Logger.Log("Save did not execute as there were no changes made!"); } return(true); } catch { return(false); } }