//配置选项 private void lstTask_SelectionChanged(object sender, SelectionChangedEventArgs e) { if (this.lstTask.SelectedItems.Count > 0) { TimedTask.Model.AutoTask task = lstTask.SelectedItem as TimedTask.Model.AutoTask; this.ID = task.Id; OnInit(); } }
//窗体初始化 private void OnInit() { if (ID == 0) { this.btnOK.Content = "添加任务"; this.rbtMinute.IsChecked = true; this.cboEnable.IsChecked = true; rbtItem_Click(null, null); } else { this.btnOK.Content = "保 存"; this.cboMinute.SelectedIndex = 0; } this.dp_StartDate.Text = DateTime.Now.ToString("yyyy/MM/dd"); this.dp_StopDate.Text = DateTime.Now.AddDays(10).ToString("yyyy/MM/dd"); TimedTask.Model.AutoTask model = _bllTask.GetEntity(" Id=" + ID); if (model != null) { this.txtPath.Text = model.ApplicationPath; this.txtTitle.Text = model.Title; this.txtStartParameter.Text = model.StartParameters; this.cboEnable.IsChecked = model.Enable == "1" ? true : false; this.txtRemark.Text = model.Remark; this.cboTaskType.SelectedIndex = (model.TaskType == "" || model.TaskType == TaskType.TimingTask.ToString()) ? 0 : Convert.ToInt32(model.TaskType); this.cboAudio.SelectedItem = model.AudioPath.Length == 0 ? "无" : model.AudioPath; this.cboMinute.SelectedIndex = 0; this.cboDay.SelectedIndex = 0; switch (model.RunType) { case "1": this.rbtMonth.IsChecked = true; this._runType = RunType.Month; this.cboDay.SelectedValue = model.Dayth; break; case "2": this.rbtDay.IsChecked = true; this._runType = RunType.Day; break; case "3": this.rbtHour.IsChecked = true; this._runType = RunType.Hour; break; case "4": this.rbtMinute.IsChecked = true; this._runType = RunType.Minute; this.cboMinute.SelectedValue = model.Interval; break; case "5": this.rbtOnce.IsChecked = true; this._runType = RunType.Once; break; case "6": this.rbtWeek.IsChecked = true; this._runType = RunType.Week; if (model.Weeks != null) { if (model.Weeks.Contains("1")) { this.chkWeek1.IsChecked = true; } if (model.Weeks.Contains("2")) { this.chkWeek2.IsChecked = true; } if (model.Weeks.Contains("3")) { this.chkWeek3.IsChecked = true; } if (model.Weeks.Contains("4")) { this.chkWeek4.IsChecked = true; } if (model.Weeks.Contains("5")) { this.chkWeek5.IsChecked = true; } if (model.Weeks.Contains("6")) { this.chkWeek6.IsChecked = true; } if (model.Weeks.Contains("7")) { this.chkWeek7.IsChecked = true; } } break; } try { switch (this._runType) { case RunType.Once: this.rbtOnce.IsChecked = true; break; case RunType.Month: this.rbtMonth.IsChecked = true; break; case RunType.Day: this.rbtDay.IsChecked = true; break; case RunType.Hour: this.rbtHour.IsChecked = true; break; case RunType.Minute: this.rbtMinute.IsChecked = true; break; case RunType.Week: this.rbtWeek.IsChecked = true; break; } rbtItem_Click(null, null); this.dp_StartDate.Text = Convert.ToDateTime(model.StartDate).ToString("yyyy-MM-dd"); this.dp_StopDate.Text = Convert.ToDateTime(model.StopDate).ToString("yyyy-MM-dd"); } catch (Exception ex) { Log.SaveLog("TaskEdit OnInit", ex.ToString()); } } }