/// <summary> /// Insert or Update scheduler /// </summary> /// <param name="sender"></param> /// <param name="e"></param> protected void InsertOrUpdate(object sender, DirectEventArgs e) { // init model var model = new SchedulerModel(null); // check id if (!string.IsNullOrEmpty(hdfId.Text) && Convert.ToInt32(hdfId.Text) > 0) { var result = SchedulerController.GetById(Convert.ToInt32(hdfId.Text)); if (result != null) { model = result; } } // set new props for model model.Name = txtName.Text; model.Description = txtDescription.Text; model.Arguments = txtArguments.Text; model.IntervalTime = !string.IsNullOrEmpty(txtIntervalTime.Text) ? Convert.ToInt32(txtIntervalTime.Text) : 0; model.ExpiredAfter = !string.IsNullOrEmpty(txtExpiredAfter.Text) ? Convert.ToInt32(txtExpiredAfter.Text) : 0; model.Enabled = chkEnable.Checked; model.SchedulerTypeId = Convert.ToInt32(hdfSchedulerType.Text); model.RepeatType = (SchedulerRepeatType)Enum.Parse(typeof(SchedulerRepeatType), hdfSchedulerRepeatType.Text); model.Scope = (SchedulerScope)Enum.Parse(typeof(SchedulerScope), hdfSchedulerScope.Text); model.Status = (SchedulerStatus)Enum.Parse(typeof(SchedulerStatus), hdfSchedulerStatus.Text); model.NextRunTime = DateTime.TryParseExact(txtNextRuntime.Text, "yyyy/MM/dd HH:mm", CultureInfo.InvariantCulture, DateTimeStyles.None, out var nextRunTime) ? nextRunTime : DateTime.Now; // check model id if (model.Id > 0) { // update SchedulerController.Update(model); } else { // insert SchedulerController.Create(model); } // hide window wdSetting.Hide(); // reload data gpScheduler.Reload(); }