/// <summary> 启动云平台服务 /// </summary> /// <param name="state"></param> private void _StartCloundService(object state) { //鉴权码、授权码、公司名称、机器码 DataTable dt = DBHelper.GetTable("获取注册信息", GlobalStaticObj_Server.DbPrefix + GlobalStaticObj_Server.CommAccCode, "tb_signing_info", "*", "", "", ""); if (dt != null && dt.Rows.Count > 0) { if (dt.Columns.Contains("authentication")) { GlobalStaticObj_Server.Instance.LicenseCode = dt.Rows[0]["authentication"].ToString(); } if (dt.Columns.Contains("sign_id")) { GlobalStaticObj_Server.Instance.StationID = dt.Rows[0]["sign_id"].ToString(); } if (dt.Columns.Contains("s_user")) { GlobalStaticObj_Server.Instance.Cloud_UserId = dt.Rows[0]["s_user"].ToString(); } if (dt.Columns.Contains("s_pwd")) { GlobalStaticObj_Server.Instance.Cloud_Password = dt.Rows[0]["s_pwd"].ToString(); } } if (ServiceAgent.ServiceTest() || FileAgent.ServiceTest()) { AutoTask.Start(); } this.Invoke(this.uiHandler); }
public void StartAutoTask(AutoTask task) { try { switch (task.AutoTaskType.Name) { case "多线程": if (!handlerByThreadRunningList.ContainsKey(task.Code)) { switch (task.Code) { //case "CompanyOrderHandler": // handlerByThreadRunningList.Add(task.Code, new Thread(new ThreadStart(new CompanyOrderHandler().HandleAutoTask))); // handlerByThreadRunningList[task.Code].Start(); // break; case "EmailHandler": handlerByThreadRunningList.Add(task.Code, new Thread(new ThreadStart(new EmailHandler().HandleAutoTask))); handlerByThreadRunningList[task.Code].Start(); break; } } break; default: break; } } catch (Exception e) { throw e; } }
public async Task when_octohook_header_doesnt_exists_then_adds_it_automatically() { var github = new Mock<IGitHubClient>(); var task = new Issue { Number = 1, Title = "Issue with story link", Body = "Story #2", }; github.SetupGet(repository, task); github.SetupGet(repository, new Issue { Number = 2, Title = "Story" }); var linker = new AutoTask(github.Object); await linker.ProcessAsync(new Octokit.Events.IssuesEvent { Action = IssuesEvent.IssueAction.Opened, Issue = task, Repository = repository, Sender = repository.Owner }); github.Verify(x => x.Issue.Update(repository.Owner.Login, repository.Name, 2, It.Is<IssueUpdate>(u => u.Body.Contains(AutoTask.header)))); }
public async Task when_task_list_link_doesnt_exists_then_adds_it_automatically() { var github = new Mock<IGitHubClient>(); var task = new Issue { Number = 1, Title = "Issue with story link", Body = "Story #2", }; github.SetupGet(repository, task); github.SetupGet(repository, new Issue { Number = 2, Title = "Story" }); var expectedLink = OctoHook.Properties.Strings.FormatTask(" ", "#" + task.Number, task.Title); var linker = new AutoTask(github.Object); await linker.ProcessAsync(new Octokit.Events.IssuesEvent { Action = IssuesEvent.IssueAction.Opened, Issue = task, Repository = repository, Sender = repository.Owner }); github.Verify(x => x.Issue.Update(repository.Owner.Login, repository.Name, 2, It.Is<IssueUpdate>(u => u.Body.Contains(expectedLink)))); }
public void ItemClick(string type, AutoTask mod) { // 1:查看 2:删除 3:禁用 if (type == "1") { View.TaskEdit vTask = new View.TaskEdit(); vTask.ID = mod.Id; vTask.ShowDialog(); } else if (type == "2") { MessageBoxResult mbr = MessageBox.Show("确定删除?", "警告", MessageBoxButton.YesNo, MessageBoxImage.Warning); if (mbr == MessageBoxResult.Yes) { try { _bllTask.Delete(" Id=" + mod.Id); MessageBox.Show("操作成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information); } catch (Exception ex) { MessageBox.Show("操作成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information); Log.SaveLog("MainWindow DropList 删除选中项", ex.ToString()); } } } else if (type == "3") { mod.Enable = (mod.Enable == "0") ? "1" : "0"; _bllTask.Update(mod, " Id=" + mod.Id); MessageBox.Show("操作成功!", "提示", MessageBoxButton.OK, MessageBoxImage.Information); } }
private void btnClose_Click(object sender, EventArgs e) { AutoTask.Stop(); this.btnLink.Enabled = true; this.btnClose.Enabled = false; this.btnLink.Text = "连接"; }
/// <summary> /// 启动程序 /// </summary> /// <param name="name">任务名称</param> /// <param name="proccessName">进程名</param> /// <param name="path">程序路径</param> /// <param name="startParameters">启动参数</param> /// <returns>是否启动成功</returns> public bool StartApp(AutoTask model, string proccessName) { //杀死 Helper.Instance.EndApp(proccessName); //启动 System.Threading.Thread.Sleep(2000); if (!File.Exists(model.ApplicationPath))//不存在 { return(false); } try { if (model.StartParameters.Length > 0) { System.Diagnostics.Process.Start(model.ApplicationPath, model.StartParameters); } else { System.Diagnostics.Process.Start(model.ApplicationPath); } } catch (Exception ex) { string msg = "程序启动错误,路径:" + model.ApplicationPath + (model.StartParameters.Length == 0 ? "" : ",参数为:" + model.StartParameters) + ex.ToString(); Log.SaveLog("Task StartApplication", msg); } TimedTask.Model.SysLog log = new TimedTask.Model.SysLog(); log.TaskId = model.Id; log.Title = model.Title; log.IsRun = "0"; log.RunType = model.RunType; log.TaskType = model.TaskType; log.CreateDate = DateTime.Now; #region 检测程序启动信息 foreach (System.Diagnostics.Process p in System.Diagnostics.Process.GetProcesses()) { if (proccessName == p.ProcessName) { log.IsRun = "1"; this._bllLog.Add(log); return(true); } } return(false); #endregion }
private void btnSend_Click(object sender, EventArgs e) { string msg = this.tbSendMsg.Text.Trim(); if (msg.Length == 0) { return; } AutoTask.SetLogin(); this.SendMessage(msg); //ThreadPool.QueueUserWorkItem(new WaitCallback(this.SendMessage), msg); }
/// <summary> 定时器(一分钟) /// </summary> private void timerCheckConn_Tick(object sender, EventArgs e) { btnDb_Click(null, null); if (!WcfServiceProxy.WcfServiceProxy.Instance.CheckWcfFerviceRuning()) { btnServer.Text = "启用"; btnServer_Click(null, null); } DataSources.EnumTaskStatus status = AutoTask.GetStatus(); if (status == DataSources.EnumTaskStatus.Suspend) { btnStartOrStop_Click(null, null); } }
private void InitCloundService() { DataSources.EnumTaskStatus status = AutoTask.GetStatus(); if (status == DataSources.EnumTaskStatus.Not_Started || status == DataSources.EnumTaskStatus.Suspend) { picCloadPlat.Image = HXCServerWinForm.Properties.Resources.stop; this.btnStartOrStop.Text = "启动"; } else if (status == DataSources.EnumTaskStatus.Runing) { picCloadPlat.Image = HXCServerWinForm.Properties.Resources.runing; this.btnStartOrStop.Text = "挂起"; } }
private void btnLink_Click(object sender, EventArgs e) { if (this.tbIp.Text.Trim().Length == 0 || this.tbIp.Text.Trim().Length == 0) { MessageBox.Show("IP and Port is required!"); return; } int port = 0; if (!int.TryParse(this.tbPort.Text.Trim(), out port)) { MessageBox.Show("Port must be number!"); return; } ServiceAgent.SetParas(this.tbIp.Text.Trim(), port); if (int.TryParse(this.tbFilePort.Text.Trim(), out port)) { FileAgent.SetParas(this.tbIp.Text.Trim(), port); } GlobalStaticObj_Server.Instance.StationID = this.tbSendMsg.Text.Split('$')[0]; if (ServiceAgent.ServiceTest() || FileAgent.ServiceTest()) { if (this.startFlag) { this.startFlag = false; AutoTask.StartTest(this.dateTimePicker1.Value.Ticks); } else { AutoTask.Continue(); } this.btnLink.Text = "已连接"; this.btnLink.Enabled = false; this.btnClose.Enabled = true; } }
/// <summary> 定时器(一分钟) /// </summary> private void timerCheckConn_Tick(object sender, EventArgs e) { try { btnDb_Click(null, null); if (!WcfServiceProxy.WcfServiceProxy.Instance.CheckWcfFerviceRuning()) { btnServer.Text = "启用"; btnServer_Click(null, null); } DataSources.EnumTaskStatus status = AutoTask.GetStatus(); if (status == DataSources.EnumTaskStatus.Suspend) { btnStartOrStop_Click(null, null); } } catch (Exception ex) { GlobalStaticObj_Server.GlobalLogService.WriteLog("服务管理", ex); } }
/// <summary> 停止或者启动 /// </summary> private void btnStartOrStop_Click(object sender, EventArgs e) { DataSources.EnumTaskStatus status = AutoTask.GetStatus(); if (status == DataSources.EnumTaskStatus.Not_Started) { AutoTask.Start(); picCloadPlat.Image = HXCServerWinForm.Properties.Resources.runing; this.btnStartOrStop.Text = "挂起"; } else if (status == DataSources.EnumTaskStatus.Runing) { AutoTask.Stop(); picCloadPlat.Image = HXCServerWinForm.Properties.Resources.runing; this.btnStartOrStop.Text = "挂起"; } else if (status == DataSources.EnumTaskStatus.Suspend) { AutoTask.Continue(); picCloadPlat.Image = HXCServerWinForm.Properties.Resources.stop; this.btnStartOrStop.Text = "启动"; } }
public void StopAutoTask(AutoTask task) { try { switch (task.AutoTaskType.Name) { case "多线程": if (handlerByThreadRunningList[task.Code] != null) { handlerByThreadRunningList[task.Code].Abort(); handlerByThreadRunningList.Remove(task.Code); } break; default: break; } } catch (Exception e) { throw e; } }
private void InitCloundService() { try { DataSources.EnumTaskStatus status = AutoTask.GetStatus(); if (status == DataSources.EnumTaskStatus.Not_Started || status == DataSources.EnumTaskStatus.Suspend) { picCloadPlat.Image = HXCServerWinForm.Properties.Resources.stop; this.btnStartOrStop.Text = "启动"; } else if (status == DataSources.EnumTaskStatus.Runing) { picCloadPlat.Image = HXCServerWinForm.Properties.Resources.runing; this.btnStartOrStop.Text = "挂起"; this.btnStartOrStop.Enabled = false; } } catch (Exception ex) { GlobalStaticObj_Server.GlobalLogService.WriteLog("UCHomePage", ex); } }
/// <summary> 停止或者启动 /// </summary> private void btnStartOrStop_Click(object sender, EventArgs e) { try { DataSources.EnumTaskStatus status = AutoTask.GetStatus(); if (status == DataSources.EnumTaskStatus.Not_Started) { AutoTask.Start(); picCloadPlat.Image = HXCServerWinForm.Properties.Resources.runing; this.btnStartOrStop.Text = "挂起"; this.btnStartOrStop.Enabled = false; } else if (status == DataSources.EnumTaskStatus.Runing) { AutoTask.Stop(); picCloadPlat.Image = HXCServerWinForm.Properties.Resources.runing; this.btnStartOrStop.Text = "挂起"; this.btnStartOrStop.Enabled = false; } else if (status == DataSources.EnumTaskStatus.Suspend) { AutoTask.Continue(); picCloadPlat.Image = HXCServerWinForm.Properties.Resources.stop; this.btnStartOrStop.Text = "启动"; this.btnStartOrStop.Enabled = true; } } catch (Exception ex) { GlobalStaticObj_Server.GlobalLogService.WriteLog("UCHomePage", ex); if (sender == null) { MessageBoxEx.ShowWarning("慧联云平台链接启用失败"); } } }
public async Task when_link_comes_from_task_list_then_does_not_process_it() { var github = new Mock<IGitHubClient>(MockBehavior.Strict); var task = new Issue { Number = 1, Title = "Issue with story link", Body = "- [ ] #2 A Story", }; github.SetupGet(repository, task); var linker = new AutoTask(github.Object); var update = new IssueUpdate(); await linker.ProcessAsync(new Octokit.Events.IssuesEvent { Action = IssuesEvent.IssueAction.Opened, Issue = task, Repository = repository, Sender = repository.Owner }); }
public async Task when_task_list_link_doesnt_exists_then_adds_it_automatically_integration() { var github = new GitHubClient(new ProductHeaderValue("octohook"), new InMemoryCredentialStore(credentials)); var story = await github.Issue.Create("kzu", "sandbox", new NewIssue("Story")); var task = await github.Issue.Create("kzu", "sandbox", new NewIssue("Issue with story link") { Body = "Story #" + story.Number, }); var expectedLink = OctoHook.Properties.Strings.FormatTask(" ", "#" + task.Number, task.Title); var linker = new AutoTask(github); var update = new IssueUpdate(); await linker.ProcessAsync(new Octokit.Events.IssuesEvent { Action = IssuesEvent.IssueAction.Opened, Issue = task, Repository = new Repository { Name = "sandbox", Owner = new User { Login = "******" }, }, Sender = new User { Login = "******" } }); var updated = await github.Issue.Get("kzu", "sandbox", story.Number); Assert.True(updated.Body.Contains(expectedLink)); await github.Issue.Update("kzu", "sandbox", task.Number, new IssueUpdate { State = ItemState.Closed }); await github.Issue.Update("kzu", "sandbox", story.Number, new IssueUpdate { State = ItemState.Closed }); }
/// <summary> /// 开始提醒 /// </summary> /// <param name="taskType">任务类别</param> /// <param name="title">标题</param> /// <param name="remark">任务说明</param> /// <param name="audioName">声音名称</param> /// <param name="isTest">是否测试,测试关机时只提醒不关机</param> /// <returns></returns> public bool StartWarn(AutoTask model, bool isTest) { bool result = true; string msg = ""; string command = ""; bool isShutdown = false;//是否关机 TimedTask.Model.SysLog modLog = new TimedTask.Model.SysLog(); modLog.TaskId = model.Id; modLog.TaskType = model.TaskType; modLog.RunType = model.RunType; modLog.IsRun = "1"; modLog.Title = model.Title; modLog.CreateDate = DateTime.Now; #region 关机/显示器/锁屏 if (model.TaskType == ((Int32)TaskType.Shutdown).ToString())//关机 { msg = "系统将于 120 秒后关闭,此操作不能撤销,请保存好您的工作!"; command = "shutdown -s -t 120"; isShutdown = true; } else if (model.TaskType == ((Int32)TaskType.TurnOffMonitor).ToString())//关闭显示器 { Helper.Instance.CloseMonitor(); this._bllLog.Add(modLog); return(true); } else if (model.TaskType == ((Int32)TaskType.TurnOnMonitor).ToString())//打开显示器 { Helper.Instance.OpenMonitor(); this._bllLog.Add(modLog); return(true); } else if (model.TaskType == ((Int32)TaskType.LockMonitor).ToString())//锁屏 { if (!TimedTask.Model.PM.IsScreenLock) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { View.ScreenLock lockScreen = new View.ScreenLock(); lockScreen.IsTest = isTest; lockScreen.PointText = model.Remark.Contains("⊙") ? model.Remark.Split('⊙')[1] : model.Remark; lockScreen.ShowDialog(); })); } this._bllLog.Add(modLog); return(true); } #endregion #region 声音 POP提醒 try { if (model.AudioEnable == null) { model.AudioEnable = "0"; } if (model.AudioEnable == "1" || model.AudioEnable.Equals("True", StringComparison.CurrentCultureIgnoreCase)) { //创建异步线程 System.Threading.Tasks.Task.Factory.StartNew(() => { Helper.Instance.PalyAudio(model.AudioPath, model.AudioVolume); }); } if (!isShutdown) { System.Windows.Application.Current.Dispatcher.Invoke(new Action(() => { View.PopUP pop = new View.PopUP(); if (model.Remark.Contains(TimedTask.Model.PM.SpiderChar)) { pop.Subject = model.Remark.Split(TimedTask.Model.PM.SpiderChar)[0]; pop.Info = model.Remark.Split(TimedTask.Model.PM.SpiderChar)[1] + msg; } else { pop.Subject = model.Remark + msg; } pop.PopTitle = model.Title; pop.Show(); })); } } catch (Exception ex) { Log.SaveLog("Task StartWarn", ex.ToString()); result = false; modLog.IsRun = "0"; } #endregion #region 关机 if (!isTest) { MainWindow.TaskIcon.ShowBalloonTip("温馨提示", msg, Hardcodet.Wpf.TaskbarNotification.BalloonIcon.Info); Helper.Instance.Run(command); } #endregion this._bllLog.Add(modLog); return(result); }
public async Task when_linked_task_is_closed_then_doesnt_reopen_it_integration() { var github = new GitHubClient(new ProductHeaderValue("octohook"), new InMemoryCredentialStore(credentials)); var parent = await github.Issue.Create("kzu", "sandbox", new NewIssue("Parent")); var child = await github.Issue.Create("kzu", "sandbox", new NewIssue("Issue with link to parent") { Body = "Related to #" + parent.Number, }); // Close the parent. await github.Issue.Update("kzu", "sandbox", parent.Number, new IssueUpdate { State = ItemState.Closed }); try { Assert.Equal(ItemState.Closed, github.Issue.Get("kzu", "sandbox", parent.Number).Result.State); var expectedLink = OctoHook.Properties.Strings.FormatTask(" ", "#" + child.Number, child.Title); var tasker = new AutoTask(github); await tasker.ProcessAsync(new Octokit.Events.IssuesEvent { Action = IssuesEvent.IssueAction.Opened, Issue = child, Repository = new Repository { Name = "sandbox", Owner = new User { Login = "******" }, }, Sender = new User { Login = "******" } }); var updated = await github.Issue.Get("kzu", "sandbox", parent.Number); Assert.Equal(ItemState.Closed, updated.State); } finally { github.Issue.Update("kzu", "sandbox", child.Number, new IssueUpdate { State = ItemState.Closed }).Wait(); github.Issue.Update("kzu", "sandbox", parent.Number, new IssueUpdate { State = ItemState.Closed }).Wait(); } }
//保存 private void btnOK_Click(object sender, RoutedEventArgs e) { string path = this.txtPath.Text.Trim(); string title = this.txtTitle.Text.Trim(); string remark = this.txtRemark.Text.Trim(); string startParameter = this.txtStartParameter.Text.Trim(); string startDate = "", stopDate = "", nextStartDate = "";//起始 停止 下次启动时间 if (this.rbtMonth.IsChecked == true) { _timeType = TimeType.Month; } if (this.rbtDay.IsChecked == true) { _timeType = TimeType.Day; } if (this.rbtHour.IsChecked == true) { _timeType = TimeType.Hour; } if (this.rbtMinute.IsChecked == true) { _timeType = TimeType.Minute; } if (this.rbtOnce.IsChecked == true) { _timeType = TimeType.Once; } AutoTask model = new AutoTask(); try { bool flag = ID == 0 ? true : false;//是否是新增 if (this.cboTaskType.SelectedIndex == 0) { if (path.Length == 0 || !path.EndsWith(".exe")) { _statusText = "不是可执行文件或文件路径不能为空!"; return; } } startDate = this.dp_StartDate.Text + " " + ((DateTime)this.dp_StartTime.Value).ToString("HH:mm:00"); stopDate = this.dp_StopDate.Text + " " + Convert.ToDateTime(this.dp_StopTime.Value).ToString("HH:mm:00"); nextStartDate = GetFirstStartDate(); model.StartParameters = startParameter; model.ApplicationPath = path; model.Title = title; model.Enable = (bool)this.cboEnable.IsChecked ? "1" : "0"; model.StartDate = Convert.ToDateTime(startDate); model.StopDate = Convert.ToDateTime(stopDate); model.Remark = remark; model.AudioPath = this._audio; model.TaskType = this.cboTaskType.SelectedIndex.ToString(); model.Status = ""; model.TimeType = ((int)_timeType).ToString(); model.Interval = (this.rbtMinute.IsChecked == true) ? Convert.ToInt32(this.cboMinute.SelectedValue.ToString()) : 0; model.Dayth = (this.rbtMonth.IsChecked == true) ? Convert.ToInt32(this.cboDay.SelectedValue.ToString()) : 0; model.NextStartDate = Convert.ToDateTime(nextStartDate); if (!flag)//修改 { dalAutoTask.Update(model, " Id=" + ID); _statusText = "保存设置成功!"; } else//新增 { TimedTask.Dal.AutoTask dalTask = new Dal.AutoTask(); dalTask.Add(model); _statusText = "新增成功!"; } } catch (Exception ex) { _statusText = "保存设置失败,可能原因是:未找到指定的配置文件!"; Log.SaveLog("TaskDetail btnOK_Click", _statusText + ex.ToString()); } }
/// <summary> 接收保存数据 /// </summary> /// <param name="state"></param> /// <returns></returns> private static void SaveData(object state) { if (state is AnnounceProtocol) { AnnounceProtocol protocol = state as AnnounceProtocol; DataTable dt = JsonHelper.JsonToDataTable(protocol.Json, TableName, true); if (dt == null || dt.Rows.Count == 0) { return; } bool result = false; string id = "announcement_id"; Dictionary <string, string> dicFileds = new Dictionary <string, string>(); foreach (DataColumn dc in dt.Columns) { if (dc.ColumnName != id) { dicFileds.Add(dc.ColumnName, dt.Rows[0][dc.ColumnName].ToString()); } } if (protocol.Operation.Equals(DataSources.EnumOperationType.Add.ToString("d"))) { if (dt.Columns.Contains(id)) { dicFileds.Add(id, dt.Rows[0][id].ToString()); } foreach (string db in AutoTask.GetDatabaseList()) { //添加数据 result = DBHelper.Submit_AddOrEdit("添加云平台公告信息", db, dt.TableName, "", "", dicFileds); } } else if (protocol.Operation.Equals(DataSources.EnumOperationType.Update.ToString("d"))) { if (dt.Columns.Contains(id)) { foreach (string db in AutoTask.GetDatabaseList()) { //修改数据 result = DBHelper.Submit_AddOrEdit("修改云平台公告信息", db, dt.TableName, id, dt.Rows[0][id].ToString(), dicFileds); } } } ResultProtocol rp = new ResultProtocol(); rp.StationId = protocol.StationId; rp.SerialNumber = protocol.SerialNumber; rp.MessageId = protocol.MessageId; rp.SubMessageId = protocol.SubMessageId; rp.TimeSpan = protocol.TimeSpan; rp.SerialNumberLock = true; if (result) { rp.Result = DataSources.EnumResultType.Success.ToString("d"); } else { rp.Result = DataSources.EnumResultType.Fail.ToString("d"); } ServiceAgent.AddSendQueue(rp); } }
public async Task when_task_list_link_exists_and_matches_then_does_not_update() { var github = new Mock<IGitHubClient>(); var task = new Issue { Number = 1, Title = "Issue with story link", Body = "Story #2", }; github.SetupGet(repository, task); github.SetupGet(repository, new Issue { Number = 2, Title = "Story", Body = OctoHook.Properties.Strings.FormatTask(" ", "#" + task.Number, task.Title) }); var linker = new AutoTask(github.Object); var update = new IssueUpdate(); await linker.ProcessAsync(new Octokit.Events.IssuesEvent { Action = IssuesEvent.IssueAction.Opened, Issue = task, Repository = repository, Sender = repository.Owner }); github.Verify(x => x.Issue.Update(repository.Owner.Login, repository.Name, 2, It.IsAny<IssueUpdate>()), Times.Never()); }
//保存 private void btnOK_Click(object sender, RoutedEventArgs e) { string path = this.txtPath.Text.Trim(); string title = this.txtTitle.Text.Trim(); string remark = this.txtRemark.Text.Trim(); string startParameter = this.txtStartParameter.Text.Trim(); string startDate = "", stopDate = "", nextStartDate = "";//起始 停止 下次启动时间 if (this.rbtWeek.IsChecked == true && GetWeeks().Length == 0) { this._statusText = "保存失败,没有星期被选中!"; return; } AutoTask model = new AutoTask(); model.Weeks = ""; if (this.rbtMonth.IsChecked == true) { this._runType = RunType.Month; } if (this.rbtDay.IsChecked == true) { this._runType = RunType.Day; } if (this.rbtHour.IsChecked == true) { this._runType = RunType.Hour; } if (this.rbtMinute.IsChecked == true) { this._runType = RunType.Minute; } if (this.rbtOnce.IsChecked == true) { this._runType = RunType.Once; } if (this.rbtWeek.IsChecked == true) { this._runType = RunType.Week; model.Weeks = GetWeeks(); } try { bool flag = ID == 0 ? true : false;//是否是新增 if (this.cboTaskType.SelectedIndex == 0) { if (path.Length == 0 || !path.EndsWith(".exe")) { this._statusText = "不是可执行文件或文件路径不能为空!"; return; } } this._startTime = this.cboStartHour.SelectedValue + ":" + this.cboStartMinute.Text + ":00"; this._stopTime = this.cboStopHour.SelectedValue + ":" + this.cboStopMinute.Text + ":00"; startDate = this.dp_StartDate.Text + " " + this._startTime; stopDate = this.dp_StopDate.Text + " " + this._stopTime; nextStartDate = GetFirstStartDate(); model.StartParameters = startParameter; model.ApplicationPath = path; model.Title = title; model.Enable = (bool)this.cboEnable.IsChecked ? "1" : "0"; model.StartDate = Convert.ToDateTime(startDate); model.StopDate = Convert.ToDateTime(stopDate); model.Remark = remark; model.AudioPath = this._audio; model.TaskType = this.cboTaskType.SelectedIndex.ToString(); model.Status = ""; model.RunType = ((int)this._runType).ToString(); model.Interval = (this.rbtMinute.IsChecked == true) ? Convert.ToInt32(this.cboMinute.SelectedValue.ToString()) : 0; model.Dayth = (this.rbtMonth.IsChecked == true) ? Convert.ToInt32(this.cboDay.SelectedValue.ToString()) : 0; model.NextStartDate = Convert.ToDateTime(nextStartDate); if (!flag)//修改 { this._bllTask.Update(model, " Id=" + ID); this._statusText = "保存设置成功!" + (DateTime.Now > model.StopDate ? " 警告:任务已过期!" : ""); } else//新增 { Bll.AutoTask bllTask = new Bll.AutoTask(); bllTask.Add(model); this._statusText = "新增成功!" + (DateTime.Now > model.StopDate ? " 警告:任务已过期!" : ""); btnReset_Click(null, null); } } catch (Exception ex) { _statusText = "保存设置失败,可能原因是:未找到指定的配置文件!"; Log.SaveLog("TaskEdit btnOK_Click", _statusText + ex.ToString()); } }
public async Task when_task_list_exists_then_appends_to_list() { var github = new Mock<IGitHubClient>(); var task = new Issue { Number = 1, Title = "Issue with story link", Body = "Story #2", }; github.SetupGet(repository, task); github.SetupGet(repository, new Issue { Number = 2, Title = "Story", Body = AutoTask.header + OctoHook.Properties.Strings.FormatTask(" ", "#5", "Existing task5") + Environment.NewLine + OctoHook.Properties.Strings.FormatTask(" ", "#6", "Existing task6") }); var body = ""; github.Setup(x => x.Issue.Update(It.IsAny<string>(), It.IsAny<string>(), It.IsAny<int>(), It.IsAny<IssueUpdate>())) .Callback<string, string, int, IssueUpdate>((_, __, ___, update) => body = update.Body) .ReturnsAsync(null); var expectedLink = OctoHook.Properties.Strings.FormatTask(" ", "#" + task.Number, task.Title); var linker = new AutoTask(github.Object); await linker.ProcessAsync(new Octokit.Events.IssuesEvent { Action = IssuesEvent.IssueAction.Opened, Issue = task, Repository = repository, Sender = repository.Owner }); github.Verify(x => x.Issue.Update(repository.Owner.Login, repository.Name, 2, It.Is<IssueUpdate>(u => Regex.Matches(u.Body, @"- \[ \]").Count == 3))); }