Beispiel #1
0
 public object Clone()
 {
     FeedJobSettings setting = new FeedJobSettings();
     setting.Enable = Enable;
     setting.ExecuteTime = ExecuteTime;
     setting.Day = Day;
     setting.Count = Count;
     return setting;
 }
Beispiel #2
0
        public object Clone()
        {
            FeedJobSettings setting = new FeedJobSettings();

            setting.Enable      = Enable;
            setting.ExecuteTime = ExecuteTime;
            setting.Day         = Day;
            setting.Count       = Count;
            return(setting);
        }
        private void SaveSetting()
        {
            MessageDisplay msgDisplay = CreateMessageDisplay("executetime", "clearMode");

            FeedJobSettings setting = new FeedJobSettings();

            setting.Enable = _Request.Get<bool>("enableJob", Method.Post, false);

            string valueString = _Request.Get("executetime", Method.Post, string.Empty);
            int value;
            if (!int.TryParse(valueString, out value))
            {
                msgDisplay.AddError("executetime", Lang_Error.Feed_FeedJobExecuteTimeFormatError);
            }
            else if (value < 0 || value > 23)
            {
                msgDisplay.AddError("executetime", Lang_Error.Feed_FeedJobInvalidExecuteTimeError);
            }
            else
            {
                setting.ExecuteTime = value;
            }

            JobDataClearMode clearMode = _Request.Get<JobDataClearMode>("clearMode", Method.Post, JobDataClearMode.ClearByDay);

            if (clearMode == JobDataClearMode.ClearByDay)
            {
                valueString = _Request.Get("days1", Method.Post, string.Empty);
                if (!int.TryParse(valueString, out value))
                {
                    msgDisplay.AddError("clearMode", Lang_Error.Feed_FeedJobDayFormatError);
                }
                else if (value < 0)
                {
                    msgDisplay.AddError("clearMode", Lang_Error.Feed_FeedJobDayFormatError);
                }
                else
                {
                    setting.Day = value;
                }
            }
            else
            {
                string error = null;
                valueString = _Request.Get("count", Method.Post, string.Empty);
                if (!int.TryParse(valueString, out value))
                {
                    error = "保留条数必须为整数";
                }
                else if (value < 0)
                {
                    error = "保留条数不能小于0";
                }
                else
                {
                    setting.Count = value;
                }

                bool isCombinMode = _Request.Get<bool>("CombinMode", Method.Post, false);
                if (isCombinMode)
                {
                    valueString = _Request.Get("days2", Method.Post, string.Empty);
                    if (!int.TryParse(valueString, out value))
                    {
                        if (error != null)
                            error += "," + Lang_Error.Feed_FeedJobDayFormatError;
                        else
                            error += Lang_Error.Feed_FeedJobDayFormatError;
                    }
                    else if (value < 0)
                    {
                        if (error != null)
                            error += "," + Lang_Error.Feed_FeedJobDayFormatError;
                        else
                            error += Lang_Error.Feed_FeedJobDayFormatError;
                    }
                    else
                    {
                        setting.Day = value;
                    }
                }

                if (isCombinMode)
                    clearMode = JobDataClearMode.CombinMode;

                if (error != null)
                    msgDisplay.AddError("clearMode", error);
            }

            if (msgDisplay.HasAnyError())
                return;

            try
            {
                using (new ErrorScope())
                {
                    setting.ClearMode = clearMode;
                    bool success = SettingManager.SaveSettings(setting);

                    if (!success)
                    {
                        CatchError<ErrorInfo>(delegate(ErrorInfo error)
                        {
                            msgDisplay.AddError(error);
                        });
                    }
                    else
                    {
                        //msgDisplay.ShowInfo(this);
                        _Request.Clear(Method.Post);
                    }

                }
            }
            catch (Exception ex)
            {
                msgDisplay.AddError(ex.Message);
            }
        }