예제 #1
0
        protected IDateTimeSetting GetDateTimeSetting(int key, DateTime defaultValue)
        {
            var setting = new DateTimeSetting(this.data.DateTimeValues, key, defaultValue);

            this.settings.Add(setting);
            return(setting);
        }
예제 #2
0
        /// <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();
            }
        }
예제 #3
0
        /// <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);
        }
예제 #4
0
        /// <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);
                    }
                }
            }
        }
예제 #5
0
        /// <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));
            }
        }
예제 #6
0
        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);
        }
예제 #7
0
        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);
        }
예제 #8
0
        /// <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.
            }
        }
예제 #9
0
        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);
                }
            }
        }
예제 #10
0
        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));
        }
예제 #11
0
        /// <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);
        }
예제 #12
0
파일: frmMain.cs 프로젝트: ebihane/KalsKun
        /// <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);
            }
        }