/// <summary> /// Sets the options according to the controls. /// </summary> private void ControlsToOptions() { // connection MqttConnectionOptions connectionOptions = options.ConnectionOptions; connectionOptions.Server = txtServer.Text; connectionOptions.Port = Convert.ToInt32(numPort.Value); connectionOptions.ClientID = txtClientID.Text; connectionOptions.Username = txtUsername.Text; connectionOptions.Password = txtPassword.Text; connectionOptions.Timeout = Convert.ToInt32(numTimeout.Value); connectionOptions.ProtocolVersion = (MqttProtocolVersion)cbProtocolVersion.SelectedIndex; // publishing PublishOptions publishOptions = options.PublishOptions; publishOptions.RootTopic = txtRootTopic.Text; publishOptions.UndefinedValue = txtUndefinedValue.Text; publishOptions.PublishFormat = txtPublishFormat.Text; publishOptions.QosLevel = cbQosLevel.SelectedIndex; publishOptions.Retain = chkRetain.Checked; publishOptions.MaxQueueSize = Convert.ToInt32(numMaxQueueSize.Value); publishOptions.DataLifetime = Convert.ToInt32(numDataLifetime.Value); publishOptions.DetailedLog = publishOptions.DetailedLog; publishOptions.DeviceFilter.Clear(); publishOptions.DeviceFilter.AddRange(ScadaUtils.ParseRange(txtDeviceFilter.Text, true, true)); options.AddToOptionList(dataSourceConfig.CustomOptions); }
/// <summary> /// Loads the settings from the XML node. /// </summary> public override void LoadFromXml(XmlNode xmlNode) { base.LoadFromXml(xmlNode); RestartServer = xmlNode.GetChildAsBool("RestartServer"); RestartComm = xmlNode.GetChildAsBool("RestartComm"); RestartWeb = xmlNode.GetChildAsBool("RestartWeb"); SetObjectFilter(ScadaUtils.ParseRange(xmlNode.GetChildAsString("ObjectFilter"), true, true)); }
/// <summary> /// Initializes a new instance of the class. /// </summary> public OpcUaServerDSO(OptionList options) { AutoAccept = options.GetValueAsBool("AutoAccept"); Username = options.GetValueAsString("Username"); Password = ScadaUtils.Decrypt(options.GetValueAsString("Password")); ConfigFileName = options.GetValueAsString("ConfigFileName"); DeviceFilter = new List <int>(); DeviceFilter.AddRange(ScadaUtils.ParseRange(options.GetValueAsString("DeviceFilter"), true, true)); }
/// <summary> /// Validates the form controls. /// </summary> private bool ValidateControls() { if (!ScadaUtils.ParseRange(txtDeviceFilter.Text, true, true, out _)) { ScadaUiUtils.ShowError(CommonPhrases.ValidRangeRequired); return(false); } return(true); }
/// <summary> /// Initializes a new instance of the class. /// </summary> public ScadaServerDSO(OptionList options) { Connection = options.GetValueAsString("Connection"); ClientLogEnabled = options.GetValueAsBool("ClientLogEnabled", false); MaxQueueSize = options.GetValueAsInt("MaxQueueSize", 1000); MaxCurDataAge = options.GetValueAsInt("MaxCurDataAge", 60); DataLifetime = options.GetValueAsInt("DataLifetime", 3600); DeviceFilter = new List <int>(); DeviceFilter.AddRange(ScadaUtils.ParseRange(options.GetValueAsString("DeviceFilter"), true, true)); }
/// <summary> /// Sets the options according to the controls. /// </summary> private void ControlsToOptions() { options.AutoAccept = chkAutoAccept.Checked; options.Username = txtUsername.Text; options.Password = txtPassword.Text; options.ConfigFileName = txtConfigFileName.Text; options.DeviceFilter.Clear(); options.DeviceFilter.AddRange(ScadaUtils.ParseRange(txtDeviceFilter.Text, true, true)); options.AddToOptionList(dataSourceConfig.CustomOptions); }
private void btnSelectDevices_Click(object sender, EventArgs e) { // show dialog to select devices ScadaUtils.ParseRange(txtDeviceFilter.Text, true, true, out IList <int> deviceNums); FrmEntitySelect frmEntitySelect = new(configDataset.DeviceTable) { SelectedIDs = deviceNums }; if (frmEntitySelect.ShowDialog() == DialogResult.OK) { txtDeviceFilter.Text = frmEntitySelect.SelectedIDs.ToRangeString(); } }
/// <summary> /// Sets the options according to the controls. /// </summary> private void ControlsToOptions() { options.UseDefaultConn = chkUseDefaultConn.Checked; options.Connection = cbConnection.Text; options.MaxQueueSize = Convert.ToInt32(numMaxQueueSize.Value); options.MaxCurDataAge = Convert.ToInt32(numMaxCurDataAge.Value); options.DataLifetime = Convert.ToInt32(numDataLifetime.Value); options.ClientLogEnabled = chkClientLogEnabled.Checked; options.DeviceFilter.Clear(); options.DeviceFilter.AddRange(ScadaUtils.ParseRange(txtDeviceFilter.Text, true, true)); options.AddToOptionList(dataSourceConfig.CustomOptions); }
/// <summary> /// Initializes a new instance of the class. /// </summary> public PublishOptions(OptionList options) { RootTopic = options.GetValueAsString("RootTopic", "Communicator/"); UndefinedValue = options.GetValueAsString("UndefinedValue", "NaN"); PublishFormat = options.GetValueAsString("PublishFormat"); QosLevel = options.GetValueAsInt("QosLevel"); Retain = options.GetValueAsBool("Retain"); MaxQueueSize = options.GetValueAsInt("MaxQueueSize", 1000); DataLifetime = options.GetValueAsInt("DataLifetime", 60); DetailedLog = options.GetValueAsBool("DetailedLog"); DeviceFilter = new List <int>(); DeviceFilter.AddRange(ScadaUtils.ParseRange(options.GetValueAsString("DeviceFilter"), true, true)); }
/// <summary> /// Loads the options from the XML node. /// </summary> public void LoadFromXml(XmlNode xmlNode) { if (xmlNode == null) { throw new ArgumentNullException(nameof(xmlNode)); } UnrelIfInactive = xmlNode.GetChildAsInt("UnrelIfInactive", UnrelIfInactive); GenerateAckCmd = xmlNode.GetChildAsBool("GenerateAckCmd", GenerateAckCmd); DisableFormulas = xmlNode.GetChildAsBool("DisableFormulas", DisableFormulas); EnableFormulasObjNums = ScadaUtils.ParseRange( xmlNode.GetChildAsString("EnableFormulasObjNums"), true, true); MaxLogSize = xmlNode.GetChildAsInt("MaxLogSize", MaxLogSize); }
private void btnSelectObj_Click(object sender, EventArgs e) { // show a dialog to select objects if (configDatabase != null) { ScadaUtils.ParseRange(txtObjFilter.Text, true, false, out IList <int> objNums); FrmEntitySelect frmEntitySelect = new(configDatabase.ObjTable) { SelectedIDs = objNums }; if (frmEntitySelect.ShowDialog() == DialogResult.OK) { txtObjFilter.Text = frmEntitySelect.SelectedIDs.ToRangeString(); } } } }
/// <summary> /// Validates the form controls. /// </summary> public bool ValidateControls() { if (Empty) { ScadaUiUtils.ShowError(AppPhrases.ConfigNotSelected); return(false); } if (!ScadaUtils.ParseRange(txtObjFilter.Text, true, true, out _)) { ScadaUiUtils.ShowError(AppPhrases.InvalidObjectFilter); return(false); } return(true); }
/// <summary> /// Validates the form controls. /// </summary> private bool ValidateControls() { if (!string.IsNullOrEmpty(txtConfigFileName.Text) && !File.Exists(Path.Combine(appDirs.ConfigDir, txtConfigFileName.Text))) { ScadaUiUtils.ShowError(CommonPhrases.FileNotFound); return(false); } if (!ScadaUtils.ParseRange(txtDeviceFilter.Text, true, true, out _)) { ScadaUiUtils.ShowError(CommonPhrases.ValidRangeRequired); return(false); } return(true); }
private void btnSelectObjects_Click(object sender, EventArgs e) { // show a dialog to select objects if (adminContext.CurrentProject != null) { ScadaUtils.ParseRange(txtEnableFormulasObjNums.Text, true, false, out IList <int> objNums); FrmEntitySelect frmEntitySelect = new(adminContext.CurrentProject.ConfigDatabase.ObjTable) { SelectedIDs = objNums }; if (frmEntitySelect.ShowDialog() == DialogResult.OK) { chkDisableFormulas.Checked = true; txtEnableFormulasObjNums.Text = frmEntitySelect.SelectedIDs.ToRangeString(); } } }
/// <summary> /// Sets the configuration according to the controls. /// </summary> private void ControlsToConfing() { // general options GeneralOptions generalOptions = serverConfig.GeneralOptions; generalOptions.UnrelIfInactive = decimal.ToInt32(numUnrelIfInactive.Value); generalOptions.GenerateAckCmd = chkGenerateAckCmd.Checked; generalOptions.MaxLogSize = decimal.ToInt32(numMaxLogSize.Value); generalOptions.DisableFormulas = chkDisableFormulas.Checked; generalOptions.EnableFormulasObjNums = ScadaUtils.ParseRange(txtEnableFormulasObjNums.Text, true, true); // listener options ListenerOptions listenerOptions = serverConfig.ListenerOptions; listenerOptions.Port = decimal.ToInt32(numPort.Value); listenerOptions.Timeout = decimal.ToInt32(numTimeout.Value); listenerOptions.SecretKey = ScadaUtils.HexToBytes(txtSecretKey.Text.Trim()); }
/// <summary> /// Sets the options according to the controls. /// </summary> public void ControlsToOptions(TransferOptions transferOptions) { if (transferOptions == null) { throw new ArgumentNullException(nameof(transferOptions)); } transferOptions.IncludeBase = chkIncludeBase.Checked; transferOptions.IncludeView = chkIncludeView.Checked; transferOptions.IncludeServer = chkIncludeServer.Checked; transferOptions.IncludeComm = chkIncludeComm.Checked; transferOptions.IncludeWeb = chkIncludeWeb.Checked; transferOptions.IgnoreRegKeys = chkIgnoreRegKeys.Checked; if (transferOptions is UploadOptions uploadOptions) { uploadOptions.RestartServer = chkRestartServer.Checked; uploadOptions.RestartComm = chkRestartComm.Checked; uploadOptions.RestartWeb = chkRestartWeb.Checked; uploadOptions.SetObjectFilter(ScadaUtils.ParseRange(txtObjFilter.Text, true, true)); } }
/// <summary> /// Checks channel access rights. /// </summary> private bool CheckChannelAccess(string cnlNumsStr) { if (!string.IsNullOrEmpty(cnlNumsStr)) { IList <int> cnlNums = ScadaUtils.ParseRange(cnlNumsStr, true, true); foreach (int cnlNum in cnlNums) { Cnl cnl = webContext.ConfigDatabase.CnlTable.GetItem(cnlNum); if (cnl == null) { return(false); // no rights on undefined channel } else if (!userContext.Rights.GetRightByObj(cnl.ObjNum).View) { return(false); } } } return(true); }
/// <summary> /// Validates the form controls. /// </summary> private bool ValidateControls() { StringBuilder sbError = new(); if (string.IsNullOrWhiteSpace(txtServer.Text)) { sbError.AppendError(lblServer, CommonPhrases.NonemptyRequired); } if (!ScadaUtils.ParseRange(txtDeviceFilter.Text, true, true, out _)) { sbError.AppendError(lblDeviceFilter, CommonPhrases.ValidRangeRequired); } if (sbError.Length > 0) { ScadaUiUtils.ShowError(CommonPhrases.CorrectErrors + Environment.NewLine + sbError); return(false); } else { return(true); } }
/// <summary> /// Validates the form controls. /// </summary> private bool ValidateControls() { StringBuilder sbError = new(); if (!ScadaUtils.ParseRange(txtEnableFormulasObjNums.Text, true, true, out _)) { sbError.AppendLine(ExtensionPhrases.InvalidObjectRange); } if (!ScadaUtils.HexToBytes(txtSecretKey.Text.Trim(), out _)) { sbError.AppendLine(CommonPhrases.InvalidSecretKey); } if (sbError.Length > 0) { ScadaUiUtils.ShowError(CommonPhrases.CorrectErrors + Environment.NewLine + sbError); return(false); } else { return(true); } }
/// <summary> /// Converts the given value to the type of this converter. /// </summary> public override object ConvertFrom(ITypeDescriptorContext context, CultureInfo culture, object value) { return(new IdList(ScadaUtils.ParseRange(value == null ? "" : value.ToString(), true, true))); }