/// <summary> /// 保存本地设置 /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void krpbChangeLocal_Click(object sender, EventArgs e) { if (string.IsNullOrWhiteSpace(krptServerIP.Text.Trim())) { KryptonMessageBox.Show(this, string.Format(Resources.GetRes().GetString("LoginValid"), Resources.GetRes().GetString("ServerIpAddress2")), Resources.GetRes().GetString("Warn"), MessageBoxButtons.OK, MessageBoxIcon.Warning); return; } int lang = Resources.GetRes().GetLangByLangName(krpcLanguage.SelectedItem.ToString()).LangIndex; string cashDrawerValue = (krpcbCashDrawer.Text == Resources.GetRes().GetString("None") ? "" : krpcbCashDrawer.Text); string priceMonitorValue = (krpcbPriceMonitor.Text == Resources.GetRes().GetString("None") ? "" : krpcbPriceMonitor.Text); string barcodeReaderValue = (krpcbBarcodeReader.Text == Resources.GetRes().GetString("None") ? "" : krpcbBarcodeReader.Text); string cardReaderValue = (krpcbCardReader.Text == Resources.GetRes().GetString("None") ? "" : krpcbCardReader.Text); if (Config.GetConfig().SetConfig(lang, krptServerIP.Text.Trim(), krpcIsLocalPrint.Checked, IsOnlyLocal, cashDrawerValue, priceMonitorValue, barcodeReaderValue, cardReaderValue)) { string msg = ""; if (IsOnlyLocal) { msg = Resources.GetRes().GetString("OperateSuccess"); } else { msg = Resources.GetRes().GetString("OperateChangeNextStartup"); } KryptonMessageBox.Show(this, string.Format(msg, Resources.GetRes().GetString("Change")), Resources.GetRes().GetString("Information"), MessageBoxButtons.OK, MessageBoxIcon.Information); if (krpcLanguage.SelectedIndex != lastLangIndex && IsOnlyLocal) { Resources.GetRes().ReloadResources(lang); PaletteBlue.GetSelf().Reload(); //重新加载文字 ConfigString.GetConfigString().Config(); SetLang(); if (null != ChangeLang) { ChangeLang(null, null); } } if (null != ChangeLocalSet) { ChangeLocalSet(null, null); } if (IsOnlyLocal) { this.Close(); } } else { KryptonMessageBox.Show(this, string.Format(Resources.GetRes().GetString("OperateFaild"), krpbChangeLocal.Text), Resources.GetRes().GetString("Error"), MessageBoxButtons.OK, MessageBoxIcon.Stop); } }
private AFValues filterValues(AFValues baseReturnVals) { AFValues filteredReturnVals = new AFValues(); if (ConfigString.Split(';')[2] == "convertRadio") { filteredReturnVals = baseReturnVals; } else //formatRadio { //filter out values where the next value is within 1 second //this eliminates the problem where the date and time PLC addresses change at slightly different times within 1 second //e.g. the date changes to 10/10 right before the time changes to 11:15 from 12:00, then you have an extra filldate of 10/10 12:00 am that is not valid for (int i = 0; i < baseReturnVals.Count - 1; i++) { if ((baseReturnVals[i + 1].Timestamp - baseReturnVals[i].Timestamp) > new TimeSpan(0, 0, 1)) { filteredReturnVals.Add(baseReturnVals[i]); } } //always add the last value since there is nothing to compare it to filteredReturnVals.Add(baseReturnVals[baseReturnVals.Count - 1]); } return(filteredReturnVals); }
public override void SetContext(HandlerContext value) { if (!hasContext) { dynamic configString = new ConfigString(value.HandlerConfig.ConfigStr); if (string.IsNullOrEmpty(configString.TopicId)) { throw ExceptionHelper.ArgumentNullException("TopicId"); } if (string.IsNullOrEmpty(configString.TaskId)) { throw ExceptionHelper.ArgumentNullException("TaskId"); } strTopicId = configString.topicId; strTaskId = configString.taskId; } // set context. this.Context = value; // Set local context flag. this.hasContext = true; }
public LoginWindow() { InitializeComponent(); krpManagerLogin.GlobalPaletteMode = PaletteModeManager.Custom; krpManagerLogin.GlobalPalette = PaletteBlue.GetSelf(); //加载文字 ConfigString.GetConfigString().Config(); this.Visible = false; //加载配置文件 Config.GetConfig().GetConfigs(true); this.Tag = "Main"; SetLang(); Assembly asm = Assembly.LoadFrom(System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Res.dll")); this.Icon = new Icon(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.Login.ico")); krpbSetting.StateCommon.Back.Image = Image.FromStream(asm.GetManifestResourceStream(@"Oybab.Res.Resources.Images.PC.ChangeSet.png")); krpbSetting.StateCommon.Back.ImageStyle = PaletteImageStyle.Stretch; krpbSetting.StateCommon.Back.Draw = InheritBool.True; if (int.Parse(Resources.GetRes().GetString("HightFix")) != 0) { krptAdminNo.Location = new Point(krptAdminNo.Location.X, krptAdminNo.Location.Y + int.Parse(Resources.GetRes().GetString("HightFix")).RecalcMagnification2()); krptPassword.Location = new Point(krptPassword.Location.X, krptPassword.Location.Y + int.Parse(Resources.GetRes().GetString("HightFix")).RecalcMagnification2()); } // 这个先在这里预先执行一下免得后续无法得到值 this.GetMagnification(); Common.GetCommon().ReadBak(); krptAdminNo.Text = Resources.GetRes().LastLoginAdminNo; if (!string.IsNullOrWhiteSpace(krptAdminNo.Text)) { krptPassword.Select(); } this.Shown += (x, y) => { if (!_isLoaded) { _isLoaded = true; this.WindowState = FormWindowState.Normal; System.Windows.Size size = new System.Windows.Size(); System.Windows.Forms.Screen screen = System.Windows.Forms.Screen.FromRectangle(new System.Drawing.Rectangle(this.Location.X, this.Location.Y, this.Width, this.Height)); size.Width = screen.WorkingArea.Width; size.Height = screen.WorkingArea.Height; Res.Resources.GetRes().setSize(size); } }; }
public BrainHeart() { lastSignal = currentSignal = false; config = ConfigString.GetInstance(); config.GetALLNeedDataFromIni(); opcClient = new OPCClient(config.OPC_Read_Address); tcpClient = new TCPCommunication(config.IP); ScanTask = new Task(ScanReadImageSignal); }
private void HideSlackConfig() { const Int32 SHOW_LENGTH = 6; String[] tokens = SlackConfigs.WebhookUrl.Split('/'); String showString = $@".../{tokens[tokens.Length - 1].HideString(SHOW_LENGTH, true)}"; ConfigString = ConfigString.Replace(SlackConfigs.WebhookUrl, showString); ConfigStringPretty = ConfigStringPretty.Replace(SlackConfigs.WebhookUrl, showString); }
private void HideAWSConfig() { const Int32 SHOW_LENGTH = 4; // 원본 대신에 복호화한 것을 부분적으로 보여준다. 원본도 보여주려 했는데 너무 길어서 보기가 좋지 않았다. String accessID = AWSs.DecryptedAccessID; String secretKey = AWSs.DecryptedSecretKey; String safeAccessID = accessID.HideString(SHOW_LENGTH, true); String safeSecretKey = secretKey.HideString(SHOW_LENGTH, true); ConfigString = ConfigString.Replace(AWSs.AccessID, $"{safeAccessID}").Replace(AWSs.SecretKey, $"{safeSecretKey}"); ConfigStringPretty = ConfigStringPretty.Replace(AWSs.AccessID, $"{safeAccessID}").Replace(AWSs.SecretKey, $"{safeSecretKey}"); }
public OPCClient(List <string> _readAddress) { config = ConfigString.GetInstance(); opc_address = _readAddress; opcItem = new OPCItem[opc_address.Count]; OPCServerString = config.OPC_Name; opcServer = new OPCServer(); ConnectOPCServer(); CreateReadGroup(); }
public static void MyMethod() { // Initiate the config Configuration config = new Configuration(); // Create some properties // new ConfigBool(name, defaultValue) ConfigBool autoSave = new ConfigBool("auto-save", false); // new ConfigString(name, defaultValue, min, max) ConfigString userName = new ConfigString("username", "joe12345", 6, 16); // new ConfigString(name, defaultValue, max) ConfigString firstName = new ConfigString("first-name", "Billy", 30); // Follows same parameters as string ConfigInt age = new ConfigInt("age", 25, 99); // Now let's create the user autoSave.Value = true; userName.Value = "billyNotBob123"; firstName.Value = "BillyBob"; age.Value = 69; // Set the properties config.Properties.Add(autoSave); config.Properties.Add(userName); config.Properties.Add(firstName); config.Properties.Add(age); // Save it, 1 of 3 ways config.Save("config.json", Formatting.Indented); // For pretty json printing config.Save("config.json"); // load it config = Configuration.Load("config.json", out bool defaults); if (defaults) // file doesn't exist or something went wrong. { config.LoadDefaults(); // Loads the defaults } // Display a property. ConfigInt savedAge = (ConfigInt)config.GetProperty("age"); ConfigString savedUsername = (ConfigString)config.GetProperty("username"); Console.WriteLine(savedAge.Value + " is " + savedAge.Value + " years old"); }
private void SetLang() { PaletteBlue.GetSelf().Reload(); //重新加载文字 ConfigString.GetConfigString().Config(); //加载语言 this.Font = new Font(Resources.GetRes().GetString("FontName2"), float.Parse(Resources.GetRes().GetString("FontSize"))); this.Text = Resources.GetRes().GetString("UserLogin"); krplAdminNo.Text = Resources.GetRes().GetString("AdminNo"); krplPassword.Text = Resources.GetRes().GetString("Password"); krpbLogin.Text = Resources.GetRes().GetString("Login"); krpbExit.Text = Resources.GetRes().GetString("Exit"); }
//calculate value of attribute public override AFValue GetValue(object context, object timeContext, AFAttributeList inputAttributes, AFValues inputValues) { string[] splitConfig = ConfigString.Split(';'); string selectedOption = splitConfig[2]; if (selectedOption == "convertRadio") { return(PLCTimeConvert(inputValues[0], splitConfig[0])); } else //selectedOption == "formatRadio" { AFValue dateVal = inputValues[0]; AFValue timeVal = inputValues[1]; return(PLCTimeFormatExecution(dateVal, timeVal)); } }
//bring in PIPoint attributes public override AFAttributeList GetInputs(object context) { AFAttributeList returnList = new AFAttributeList(); string[] splitConfig = ConfigString.Split(';'); string selectedOption = splitConfig[2]; if (selectedOption == "convertRadio") { //config string is "initial date;name of attribute" AFAttribute minSinceAttributeObj = GetAttribute(splitConfig[1]); returnList.Add(minSinceAttributeObj); } else //selectedOption == "formatRadio" { //config string is "name of date attribute;name of time attribute" AFAttribute dateAttributeObj = GetAttribute(splitConfig[0]); AFAttribute timeAttributeObj = GetAttribute(splitConfig[1]); returnList.Add(dateAttributeObj); returnList.Add(timeAttributeObj); } return(returnList); }
private void conectarBd() { ConfigString conf = new ConfigString(); con = new MySqlConnection(conf.obtConex()); }
public static string Get(ConfigString key) => Configuration[key.ToString()];