コード例 #1
0
ファイル: TimingTaskSetting.cs プロジェクト: khhily/bigken
 public bool Save(TimingTaskSetting setting)
 {
     return true;
 }
コード例 #2
0
ファイル: TimingTaskSetting.cs プロジェクト: khhily/bigken
        public TimingTaskSetting Load()
        {
            var result = new TimingTaskSetting()
            {
                FirstLoopTime = DateTime.Now,
                IntervalTime = 1,
                IntervalTimeUnit = TimeUnit.MINUTE,
                IsLoopTask = true,
                RetryCount = 0,
                TaskName = System.IO.Path.GetFileName(AppDomain.CurrentDomain.FriendlyName),
                WaitLastLoop = true
            };

            var config = System.Configuration.ConfigurationManager.OpenExeConfiguration(
               AppDomain.CurrentDomain.FriendlyName/*这里的APPDOMAIN就是这么设置的*/);

            if (config == null)
            {
                return result;
            }

            if (config.AppSettings.Settings.AllKeys.Contains("FirstLoopTime"))
            {
                result.FirstLoopTime = DateTime.Parse(config.AppSettings.Settings["FirstLoopTime"].Value);
            }

            if (config.AppSettings.Settings.AllKeys.Contains("IntervalTime"))
            {
                result.IntervalTime = int.Parse(config.AppSettings.Settings["IntervalTime"].Value);
            }

            if (config.AppSettings.Settings.AllKeys.Contains("IntervalTimeUnit"))
            {
                result.IntervalTimeUnit = (TimeUnit)Enum.Parse(typeof(TimeUnit), config.AppSettings.Settings["IntervalTimeUnit"].Value);
            }

            if (config.AppSettings.Settings.AllKeys.Contains("IsLoopTask"))
            {
                result.IsLoopTask = bool.Parse(config.AppSettings.Settings["IsLoopTask"].Value);
            }

            if (config.AppSettings.Settings.AllKeys.Contains("RetryCount"))
            {
                result.RetryCount = int.Parse(config.AppSettings.Settings["RetryCount"].Value);
            }

            if (config.AppSettings.Settings.AllKeys.Contains("TaskName"))
            {
                result.TaskName = config.AppSettings.Settings["TaskName"].Value;
            }

            if (config.AppSettings.Settings.AllKeys.Contains("WaitLastLoop"))
            {
                result.WaitLastLoop = bool.Parse(config.AppSettings.Settings["WaitLastLoop"].Value);
            }

            return result;
        }