protected IDateTimeSetting GetDateTimeSetting(int key, DateTime defaultValue) { var setting = new DateTimeSetting(this.data.DateTimeValues, key, defaultValue); this.settings.Add(setting); return(setting); }
/// <summary> /// Sets a DateTime-valued setting. /// </summary> /// <param name="Key">Key name.</param> /// <param name="Value">New value.</param> /// <returns>If the setting was saved (true). If the setting existed, and had the same value, false is returned.</returns> public static async Task <bool> SetAsync(string Key, DateTime Value) { await synchObject.BeginWrite(); try { DateTimeSetting Setting = await Database.FindFirstDeleteRest <DateTimeSetting>(new FilterFieldEqualTo("Key", Key)); if (Setting is null) { Setting = new DateTimeSetting(Key, Value); await Database.Insert(Setting); return(true); } else { if (Setting.Value != Value) { Setting.Value = Value; await Database.Update(Setting); return(true); } else { return(false); } } } finally { await synchObject.EndWrite(); } }
/// <summary> /// Sets a DateTime-valued setting. /// </summary> /// <param name="Key">Key name.</param> /// <param name="Value">New value.</param> /// <returns>If the setting was saved (true). If the setting existed, and had the same value, false is returned.</returns> public static async Task <bool> SetAsync(string Key, DateTime Value) { foreach (DateTimeSetting Setting in await Database.Find <DateTimeSetting>(new FilterFieldEqualTo("Key", Key))) { if (Setting.Value != Value) { Setting.Value = Value; await Database.Update(Setting); //Log.Informational("Setting updated.", Key, new KeyValuePair<string, object>("Value", Value)); return(true); } else { return(false); } } DateTimeSetting NewSetting = new DateTimeSetting(Key, Value); await Database.Insert(NewSetting); //Log.Informational("Setting created.", Key, new KeyValuePair<string, object>("Value", Value)); return(true); }
/// <summary> /// Sets a DateTime-valued setting. /// </summary> /// <param name="Key">Key name.</param> /// <param name="Value">New value.</param> /// <returns>If the setting was saved (true). If the setting existed, and had the same value, false is returned.</returns> public static async Task <bool> SetAsync(string Key, DateTime Value) { using (Semaphore Semaphore = await Semaphores.BeginWrite("setting:" + Key)) { DateTimeSetting Setting = await Database.FindFirstDeleteRest <DateTimeSetting>(new FilterFieldEqualTo("Key", Key)); if (Setting is null) { Setting = new DateTimeSetting(Key, Value); await Database.Insert(Setting); return(true); } else { if (Setting.Value != Value) { Setting.Value = Value; await Database.Update(Setting); return(true); } else { return(false); } } } }
/// <summary> /// Sets a DateTime-valued setting. /// </summary> /// <param name="Key">Key name.</param> /// <param name="Value">New value.</param> /// <returns>If the setting was saved (true). If the setting existed, and had the same value, false is returned.</returns> public static async Task <bool> SetAsync(string Key, DateTime Value) { using (Semaphore Semaphore = await Semaphores.BeginWrite("setting:" + Key)) { DateTimeSetting Setting = await Database.FindFirstDeleteRest <DateTimeSetting>(new FilterFieldEqualTo("Key", Key)); return(await SetAsyncLocked(Key, Value, Setting)); } }
public int CheckInput() { DateTimeSetting dateTimeSetting = conditionInputTypeSettingObject as DateTimeSetting; dateTimeSetting.SystemValueType = cmbDateTimeSystemValueTypes.SelectedSystemValueType; dateTimeSetting.AddOrSub = cmbAddOrSub.Text; dateTimeSetting.Day = (int)numDay.Value; dateTimeSetting.Hour = (int)numHour.Value; dateTimeSetting.Min = (int)numMin.Value; dateTimeSetting.Sec = (int)numSec.Value; dateTimeSetting.UseFixedValue = cbUseFixedValue.Checked; dateTimeSetting.FixedValue = dtFixedValue.Value; dateTimeSetting.CustomFormat = dtFixedValue.CustomFormat; dateTimeSetting.ActionAfterEnterKeyDown = cmbActionAfterEnterKeyDown.ActionAfterEnterKeyDown; return(1); }
private static DateTimeSetting ParseDateTimeSetting(string line, string prefix) { var result = new DateTimeSetting(); var strret = ParseStringSetting(line, prefix); if (strret.IsValid) { string text = strret.Value; DateTime value = DateTime.MinValue; if (DateTime.TryParse(text, out value)) { result.IsValid = true; result.Value = value; } } return(result); }
/// <summary> /// コンストラクタ /// </summary> /// <param name="mode">モード</param> /// <param name="dt">開始時刻</param> public SetStartTimeSettingCommand(ModeEnum mode, DateTimeSetting dt) { m_DateTime = dt; if (mode == ModeEnum.Kusakari) { m_SendLParam = 2; } else if (mode == ModeEnum.Yakei) { m_SendLParam = 3; } else { // nop. } }
private static async Task <bool> SetAsyncLocked(string Key, DateTime Value, DateTimeSetting Setting) { if (Setting is null) { Setting = new DateTimeSetting(Key, Value); await Database.Insert(Setting); return(true); } else { if (Setting.Value != Value) { Setting.Value = Value; await Database.Update(Setting); return(true); } else { return(false); } } }
public void DbAppSetting_DateTime() { DateTimeSetting setting = new DateTimeSetting(); Assert.IsTrue(setting.InitialValue == DateTime.Today); Assert.IsTrue(setting.InternalValue == DateTime.Today); DbAppSettingDto settingDto = new DbAppSettingDto() { Key = setting.FullSettingName, Value = DateTime.Today.AddDays(1).ToString(), Type = setting.TypeString }; setting.From(settingDto); Assert.IsTrue(setting.InitialValue == DateTime.Today); Assert.IsTrue(setting.InternalValue == DateTime.Today.AddDays(1)); DbAppSettingDto toDto = setting.ToDto(); Assert.IsTrue(toDto.ApplicationKey == settingDto.ApplicationKey); Assert.IsTrue(toDto.Key == settingDto.Key); Assert.IsTrue(toDto.Type == settingDto.Type); Assert.IsTrue(toDto.Value.Equals(settingDto.Value, StringComparison.InvariantCultureIgnoreCase)); }
/// <summary> /// Gets a DateTime-valued setting. /// </summary> /// <param name="Key">Key name.</param> /// <param name="DefaultValue">Default value, if not found.</param> /// <returns>Setting value.</returns> public static async Task <DateTime> GetAsync(string Key, DateTime DefaultValue) { DateTimeSetting Setting = await GetAsync <DateTimeSetting>(Key); return(Setting?.Value ?? DefaultValue); }
/// <summary> /// 設定変更ボタンクリックイベント /// </summary> /// <param name="sender">sender</param> /// <param name="e">e</param> private void btnSettingChange_Click(object sender, EventArgs e) { SettingData setting = SettingData.GetInstance(); DoubleText verticalText = null; DoubleText horizontalText = null; verticalText = (DoubleText)pnlSetting.Controls[0]; horizontalText = (DoubleText)pnlSetting.Controls[1]; if ((verticalText.Value != setting.RobotSize.Vertical) || (horizontalText.Value != setting.RobotSize.Horizontal)) { SizeData size = new SizeData(); size.Vertical = verticalText.Value; size.Horizontal = horizontalText.Value; SetRobotSizeSettingCommand command = new SetRobotSizeSettingCommand(size); command.OnAnalyzed += evRobotSizeSettingChanged; usrCommControl.Send(command); } verticalText = (DoubleText)pnlSetting.Controls[2]; horizontalText = (DoubleText)pnlSetting.Controls[3]; if ((verticalText.Value != setting.FarmSize.Vertical) || (horizontalText.Value != setting.FarmSize.Horizontal)) { SizeData size = new SizeData(); size.Vertical = verticalText.Value; size.Horizontal = horizontalText.Value; SetFarmSizeSettingCommand command = new SetFarmSizeSettingCommand(size); command.OnAnalyzed += evFarmSizeSettingChanged; usrCommControl.Send(command); } if ((setting.KusakariStart.DayOfWeek != (DateTimeSetting.DayOfWeekEnum)usrKusakariStart.DayOfWeek) || (setting.KusakariStart.Hour != usrKusakariStart.Hour) || (setting.KusakariStart.Minulte != usrKusakariStart.Minute)) { DateTimeSetting dt = new DateTimeSetting(); dt.DayOfWeek = (DateTimeSetting.DayOfWeekEnum)usrKusakariStart.DayOfWeek; dt.Hour = usrKusakariStart.Hour; dt.Minulte = usrKusakariStart.Minute; SetStartTimeSettingCommand command = new SetStartTimeSettingCommand(SetStartTimeSettingCommand.ModeEnum.Kusakari, dt); command.OnAnalyzed += evKusakariStartSettingChanged; usrCommControl.Send(command); } if ((setting.YakeiStart.DayOfWeek != (DateTimeSetting.DayOfWeekEnum)usrYakeiStart.DayOfWeek) || (setting.YakeiStart.Hour != usrYakeiStart.Hour) || (setting.YakeiStart.Minulte != usrYakeiStart.Minute)) { DateTimeSetting dt = new DateTimeSetting(); dt.DayOfWeek = (DateTimeSetting.DayOfWeekEnum)usrYakeiStart.DayOfWeek; dt.Hour = usrYakeiStart.Hour; dt.Minulte = usrYakeiStart.Minute; SetStartTimeSettingCommand command = new SetStartTimeSettingCommand(SetStartTimeSettingCommand.ModeEnum.Yakei, dt); command.OnAnalyzed += evYakeiStartSettingChanged; usrCommControl.Send(command); } FloatText moveEndRateText = (FloatText)pnlSetting.Controls[4]; float rate = moveEndRateText.Value / 100.0F; if (setting.MoveEndRate != rate) { SetMoveEndRateCommand command = new SetMoveEndRateCommand(rate); command.OnAnalyzed += evMoveEndRateSettingChanged; usrCommControl.Send(command); } }