internal async Task BeginTaskLoopAsync() { while (!CancellationToken.IsCancellationRequested) { try { if (TaskFlow.Count > 0 && TaskFlow[0] != null) { TaskFlow[0](); TaskFlow.RemoveAt(0); } await Task.Delay(2); } catch (Exception) { } } }
protected void btn_Submit_Click(object sender, EventArgs e) { try { TaskFlow model = db.TaskFlow.FirstOrDefault(t => t.ID == TaskFlowID); if (model != null) { if (DateTime.Now > model.EndDate) { model.ApplyType = ApplyTypeEnums.迟交; } else { model.ApplyType = ApplyTypeEnums.正常; } model.AuditMessage = this.txt_AuditMessage.Text.ToString(); model.AuditResult = (AuditResult)Convert.ToInt32(this.rdo_AuditResult.SelectedValue.ToString()); model.ApplyDate = DateTime.Now; db.SaveChanges(); ShowMessage(); new SysLogDAO().AddLog(LogType.操作日志_其他, "审核" + model.AuditResult + "任务信息", UserID); } } catch (Exception ex) { ShowMessage(ex.Message); new SysLogDAO().AddLog(LogType.系统日志, ex.Message, UserID); return; } }
public async Task TestTaskAsync() { var task = Task.Run(async() => { await Task.Delay(100); return(100); }); var flow1 = new TaskFlow <int>(task); flow1.ResultTo(r => { Assert.AreEqual(100, r); }); flow1.ResultTo(r => { Assert.AreEqual(100, r); }); flow1.Catch <InvalidOperationException>(ex => { Assert.Fail("It should not throw any exception."); }); var flow2 = flow1.Then(r => { throw new InvalidOperationException("test"); #pragma warning disable CS0162 return(string.Empty); #pragma warning restore CS0162 }); flow2.Catch <InvalidOperationException>(ex => { Assert.AreEqual("test", ex.Message); }); flow2.ResultTo(r => { Assert.Fail("It should not return any result."); }); flow2.Catch <InvalidOperationException>(ex => { Assert.AreEqual("test", ex.Message); }); Assert.AreEqual(100, await flow1.ResultAsync()); try { await flow2.WaitAsync(); Assert.Fail("It should throw an exception."); } catch (InvalidOperationException ex) { Assert.AreEqual("test", ex.Message); } }
internal void HardLog(string text) { Action action = new Action(() => { Lock(LogOptions.HardLogFilePath, (fileStream) => { try { using (StreamWriter streamWriter = new StreamWriter(fileStream)) { streamWriter.WriteLine(text); streamWriter.Flush(); } } catch (IOException ioe) { Log.Exception(ioe); } }); }); TaskFlow.Add(action); }
protected void btn_Submit_Click(object sender, EventArgs e) { int seluserid = Convert.ToInt32(ddl_User.SelectedValue); try { using (TransactionScope ts = new TransactionScope()) { try { if (this.rp_List.Items.Count > 0) { IFMPLibrary.Entities.Table model = new IFMPLibrary.Entities.Table(); model.TaskID = TaskID; model.TableTypeID = TType; model.CreateDate = DateTime.Now; model.CreateUserID = seluserid; model.FlowID = FlowID; db.Table.Add(model); db.SaveChanges(); TextBox txt_TextName; RadioButtonList rdo_Name; HiddenField hf_DictionaryID; HiddenField hf_HintDictionaryID; HiddenField hf_DType; HiddenField hf_TableColumnID; Literal ltl_RegexData; //设置报警的审核人 List <User> UserList = db.User.Where(t => t.IsDel != true && t.UserState != UserState.离职 && db.TaskFlow.Where(m => m.TaskID == TaskID && db.Flow.Where(l => l.IsAudit == true && l.TableTypeID == TType).Select(l => l.ID).Contains(m.FlowID)).Select(m => m.UserID).Contains(t.ID)).Distinct().ToList(); List <TableColumn> TableColumnList = db.TableColumn.Where(t => t.TableTypeID == TType).ToList(); TableType TableType = db.TableType.FirstOrDefault(t => t.ID == TType); BaseClass BaseClass = db.BaseClass.FirstOrDefault(t => t.ID == BaseClassID); User User = db.User.FirstOrDefault(t => t.ID == seluserid); List <Flow> FlowList = db.Flow.Where(t => t.TableTypeID == TType).ToList(); List <TaskFlow> TaskFlowList = db.TaskFlow.Where(t => t.TaskID == TaskID).ToList(); for (int i = 0; i < this.rp_List.Items.Count; i++) { TableData tabledata = new TableData(); tabledata.IsAlert = false; hf_DType = (HiddenField)rp_List.Items[i].FindControl("hf_DType"); int displaytype = Convert.ToInt32(hf_DType.Value); hf_TableColumnID = (HiddenField)rp_List.Items[i].FindControl("hf_TableColumnID"); int columnid = Convert.ToInt32(hf_TableColumnID.Value); ltl_RegexData = (Literal)rp_List.Items[i].FindControl("ltl_RegexData"); TableColumn tablecolumn = TableColumnList.FirstOrDefault(t => t.ID == columnid); if ((DictionaryTypeEnums)displaytype == DictionaryTypeEnums.单选) { rdo_Name = (RadioButtonList)rp_List.Items[i].FindControl("rdo_Name"); tabledata.Data = rdo_Name.SelectedValue.ToString(); //这里也要加一个验证 hf_HintDictionaryID = (HiddenField)rp_List.Items[i].FindControl("hf_HintDictionaryID"); if (!string.IsNullOrEmpty(hf_HintDictionaryID.Value)) { int hintdictID = Convert.ToInt32(hf_HintDictionaryID.Value); int selid = Convert.ToInt32(tabledata.Data); string defaultdata = db.TableColumn.FirstOrDefault(t => t.ID == columnid).DefaultData; string seldata = db.DictionaryData.FirstOrDefault(t => t.ID == selid).Data; if (defaultdata.Length > 0) { if (!defaultdata.Split('|').Contains(seldata)) { tabledata.IsAlert = true; if (UserList.Count > 0) { foreach (User NoticeUser in UserList) { new NoticeDAO().SendDDNotice( NoticeUser.DDID, new NoticeDAO().GetUrl(Request.Url.AbsoluteUri.ToString(), TaskID, TaskFlowList.FirstOrDefault(t => t.UserID == NoticeUser.ID).FlowID), Request.Url.AbsoluteUri.ToString(), "报警", tablecolumn.ColumnName + "存在异常", "请及时去现场查看情况", new NoticeDAO().BuildFormList(TableType.Name, tablecolumn.ColumnName, tabledata.Data, BaseClass.Name, User.RealName)); } } //new NoticeDAO().SendDDNotice(); } } //List<DictionaryData> DictionaryDataList = db.DictionaryData.Where(t => t.DictionaryID == hintdictID).ToList(); } } else { txt_TextName = (TextBox)rp_List.Items[i].FindControl("txt_TextName"); tabledata.Data = txt_TextName.Text.ToString(); if (string.IsNullOrEmpty(tabledata.Data)) { ShowMessage("请确认已填写所有的数据"); ts.Dispose(); return; } //验证合法性 hf_DictionaryID = (HiddenField)rp_List.Items[i].FindControl("hf_DictionaryID"); if (!string.IsNullOrEmpty(hf_DictionaryID.Value)) { int dictID = Convert.ToInt32(hf_DictionaryID.Value); Dictionary diction = db.Dictionary.FirstOrDefault(t => t.ID == dictID); if (diction != null) { if (new BaseUtils().GetRegex(tabledata.Data, diction.RegexType.Value) == false) { ShowMessage("【" + tabledata.Data + "】数据填写错误,请填写【" + diction.RegexType + "】"); ts.Dispose(); return; } } } hf_HintDictionaryID = (HiddenField)rp_List.Items[i].FindControl("hf_HintDictionaryID"); if (!string.IsNullOrEmpty(hf_HintDictionaryID.Value)) { int hintdictID = Convert.ToInt32(hf_HintDictionaryID.Value); Dictionary hintdiction = db.Dictionary.FirstOrDefault(t => t.ID == hintdictID); if (hintdiction != null) { if (hintdiction.RegexType == RegexType.范围的数字 || hintdiction.RegexType == RegexType.范围的度数) { if (new BaseUtils().GetRegex(tabledata.Data.Split('°')[0], hintdiction.RegexType.Value, hintdiction.RegexData) == false) { tabledata.IsAlert = true; if (UserList.Count > 0) { foreach (User NoticeUser in UserList) { new NoticeDAO().SendDDNotice( NoticeUser.DDID, new NoticeDAO().GetUrl(Request.Url.AbsoluteUri.ToString(), TaskID, TaskFlowList.FirstOrDefault(t => t.UserID == NoticeUser.ID).FlowID), Request.Url.AbsoluteUri.ToString(), "报警", tablecolumn.ColumnName + "存在异常", "请及时去现场查看情况", new NoticeDAO().BuildFormList(TableType.Name, tablecolumn.ColumnName, tabledata.Data, BaseClass.Name, User.RealName)); } } } } else { if (new BaseUtils().GetRegex(tabledata.Data, hintdiction.RegexType.Value) == false) { tabledata.IsAlert = true; if (UserList.Count > 0) { foreach (User NoticeUser in UserList) { new NoticeDAO().SendDDNotice( NoticeUser.DDID, new NoticeDAO().GetUrl(Request.Url.AbsoluteUri.ToString(), TaskID, TaskFlowList.FirstOrDefault(t => t.UserID == NoticeUser.ID).FlowID), Request.Url.AbsoluteUri.ToString(), "报警", tablecolumn.ColumnName + "存在异常", "请及时去现场查看情况", new NoticeDAO().BuildFormList(TableType.Name, tablecolumn.ColumnName, tabledata.Data, BaseClass.Name, User.RealName)); } } } } } } } tabledata.TableID = model.ID; tabledata.TableColumnID = columnid; tabledata.CreateDate = DateTime.Now; tabledata.CreateUserID = seluserid; db.TableData.Add(tabledata); db.SaveChanges(); } //添加可能存在的不填写内容 List <TableColumn> NotFillColumnList = db.TableColumn.Where(t => t.IsFill == false && t.TableTypeID == model.TableTypeID).ToList(); foreach (TableColumn NotFillColumn in NotFillColumnList) { TableData tabledata = new TableData(); tabledata.CreateDate = DateTime.Now; tabledata.CreateUserID = seluserid; tabledata.TableColumnID = NotFillColumn.ID; tabledata.TableID = model.ID; //获取数值和合法性 tabledata.Data = new ColumnDAO().GetData(model.ID, NotFillColumn).ToString(); //需要报警 tabledata.IsAlert = false; if (NotFillColumn.HintDictionaryID != null) { Dictionary hintdiction = db.Dictionary.FirstOrDefault(t => t.ID == NotFillColumn.HintDictionaryID); if (hintdiction != null) { if (hintdiction.RegexType == RegexType.范围的数字 || hintdiction.RegexType == RegexType.范围的度数) { if (new BaseUtils().GetRegex(tabledata.Data.Split('°')[0], hintdiction.RegexType.Value, hintdiction.RegexData) == false) { tabledata.IsAlert = true; if (UserList.Count > 0) { foreach (User NoticeUser in UserList) { new NoticeDAO().SendDDNotice( NoticeUser.DDID, new NoticeDAO().GetUrl(Request.Url.AbsoluteUri.ToString(), TaskID, TaskFlowList.FirstOrDefault(t => t.UserID == NoticeUser.ID).FlowID), Request.Url.AbsoluteUri.ToString(), "报警", NotFillColumn.ColumnName + "存在异常", "请及时去现场查看情况", new NoticeDAO().BuildFormList(TableType.Name, NotFillColumn.ColumnName, tabledata.Data, BaseClass.Name, User.RealName)); } } } } else { if (new BaseUtils().GetRegex(tabledata.Data, hintdiction.RegexType.Value) == false) { tabledata.IsAlert = true; if (UserList.Count > 0) { foreach (User NoticeUser in UserList) { new NoticeDAO().SendDDNotice( NoticeUser.DDID, new NoticeDAO().GetUrl(Request.Url.AbsoluteUri.ToString(), TaskID, TaskFlowList.FirstOrDefault(t => t.UserID == NoticeUser.ID).FlowID), Request.Url.AbsoluteUri.ToString(), "报警", NotFillColumn.ColumnName + "存在异常", "请及时去现场查看情况", new NoticeDAO().BuildFormList(TableType.Name, NotFillColumn.ColumnName, tabledata.Data, BaseClass.Name, User.RealName)); } } } } } } db.TableData.Add(tabledata); db.SaveChanges(); } #region 更新taskflow表信息 TaskFlow taskflow = db.TaskFlow.FirstOrDefault(t => t.TaskID == TaskID && t.FlowID == FlowID && t.UserID == seluserid); if (taskflow != null) { taskflow.ApplyDate = DateTime.Now; if (DateTime.Now > taskflow.EndDate) { taskflow.ApplyType = ApplyTypeEnums.迟交; } else { taskflow.ApplyType = ApplyTypeEnums.正常; } } db.SaveChanges(); #endregion } else { ShowMessage("暂无表单信息,无需提交"); ts.Dispose(); return; } ShowMessagePad(); new SysLogDAO().AddLog(LogType.操作日志_添加, "成功填写【" + this.ltl_TableType.Text + "】表单信息", seluserid); ts.Complete(); } catch { ShowMessage("提交失败"); new SysLogDAO().AddLog(LogType.操作日志_添加, "填写【" + this.ltl_TableType.Text + "】表单信息时出错", seluserid); ts.Dispose(); return; } } } catch (Exception ex) { ShowMessage(ex.Message); new SysLogDAO().AddLog(LogType.系统日志, ex.Message, seluserid); return; } }
public override void SetModel(TaskFlow task) { Model = (Cmd)task; }
public abstract void SetModel(TaskFlow task);
public override void SetModel(TaskFlow task) { Model = (DownloadTfs)task; }
protected void rp_List_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { int clatype = Convert.ToInt32(this.ddl_ClassType.SelectedValue.ToString()); //班次类型 int tabtype = Convert.ToInt32(this.ddl_TableType.SelectedValue.ToString()); //表单类型 HiddenField hfFlowID = (HiddenField)e.Item.FindControl("hf_FlowID"); int flowid = Convert.ToInt32(hfFlowID.Value); CheckBoxList chk = (CheckBoxList)e.Item.FindControl("chk_ClassList"); TextBox txt_SysUser = (TextBox)e.Item.FindControl("txt_SysUser"); Literal ltl_Content = (Literal)e.Item.FindControl("ltl_Content"); TextBox txt_BeginDate = (TextBox)e.Item.FindControl("txt_BeginDate"); TextBox txt_EndDate = (TextBox)e.Item.FindControl("txt_EndDate"); TextBox txt_RemindDate = (TextBox)e.Item.FindControl("txt_RemindDate"); //根据班次类型获取所有班次信息 List <BaseClass> classlist = db.BaseClass.Where(t => t.ClassType == (ClassTypeEnums)clatype && t.IsDel != true).ToList(); List <BaseClassUser> bassclassuserlist = db.BaseClassUser.ToList(); List <object> list = new List <object>(); if (classlist.Count > 0) { List <User> UserList = db.User.Where(t => t.IsDel != true).ToList(); foreach (BaseClass bclass in classlist) { //根据班次ID和流程ID获取班次人员信息,绑定CheckBoxlist string name = ""; List <BaseClassUser> classuserlist = bassclassuserlist.Where(t => t.BaseClassID == bclass.ID && t.FlowID == flowid).ToList(); if (classuserlist.Count > 0) { foreach (BaseClassUser classuser in classuserlist) { name += UserList.FirstOrDefault(t => t.ID == classuser.UserID) == null ? "" : (UserList.FirstOrDefault(t => t.ID == classuser.UserID).RealName + ","); } } name = name.TrimEnd(',').TrimStart(','); list.Add(new { Name = bclass.Name + "(" + name + ")", bclass.ID }); } } if (list.Count > 0) { chk.DataTextField = "Name"; chk.DataValueField = "ID"; chk.DataSource = list; chk.DataBind(); } StringBuilder sb = new StringBuilder(""); string a = MList(flowid); sb.Append("<script type='text/javascript'>"); sb.Append(" $(function () {"); sb.Append(" $('#" + txt_SysUser.ClientID + "').combotree({"); sb.Append(" data: [ "); sb.Append(a); sb.Append("],"); sb.Append("multiple: true,"); sb.Append("multiline: true,"); sb.Append("onlyLeafCheck:'true',"); sb.Append("lines: true,"); sb.Append("});"); sb.Append(" }); </script>"); ltl_Content.Text = sb.ToString(); //添加绑定 if (TaskID == -1) { BaseDateFlow dateflow = db.BaseDateFlow.FirstOrDefault(t => t.FlowID == flowid && t.ClassType == (ClassTypeEnums)clatype && t.TableTypeID == tabtype); if (dateflow != null) { txt_BeginDate.Text = new BaseUtils().GetTodayDate(DateTime.Now.AddDays(1), dateflow.BeginDate).ToString("yyyy-MM-dd HH:mm:ss"); txt_EndDate.Text = new BaseUtils().GetTodayDate(DateTime.Now.AddDays(1), dateflow.EndDate).ToString("yyyy-MM-dd HH:mm:ss"); txt_RemindDate.Text = new BaseUtils().GetTodayDate(DateTime.Now.AddDays(1), dateflow.RemindDate).ToString("yyyy-MM-dd HH:mm:ss"); } } else {//编辑绑定 List <TaskFlow> taskflowlist = db.TaskFlow.Where(t => t.TaskID == TaskID && t.FlowID == flowid).ToList(); if (taskflowlist.Count > 0) { //获取taskflow表的班次信息 var testlist = taskflowlist.Where(t => t.BaseClassID != null).Select(t => t.BaseClassID).Distinct().ToList(); for (int i = 0; i < testlist.Count; i++) { int classid = Convert.ToInt32(testlist[i].ToString()); for (int j = 0; j < chk.Items.Count; j++) { if (chk.Items[j].Value == classid.ToString()) { chk.Items[j].Selected = true; } } TaskFlow taskflow = taskflowlist.FirstOrDefault(t => t.BaseClassID == classid); if (taskflow != null) { //txt_BeginDate.Text = new BaseUtils().GetTodayDate(DateTime.Now.AddDays(1), taskflow.BeginDate).ToString("yyyy-MM-dd HH:mm:ss"); //txt_EndDate.Text = new BaseUtils().GetTodayDate(DateTime.Now.AddDays(1), taskflow.EndDate).ToString("yyyy-MM-dd HH:mm:ss"); //txt_RemindDate.Text = new BaseUtils().GetTodayDate(DateTime.Now.AddDays(1), taskflow.RemindDate).ToString("yyyy-MM-dd HH:mm:ss"); txt_BeginDate.Text = taskflow.BeginDate.ToString("yyyy-MM-dd HH:mm:ss"); txt_EndDate.Text = taskflow.EndDate.ToString("yyyy-MM-dd HH:mm:ss"); txt_RemindDate.Text = taskflow.RemindDate.ToString("yyyy-MM-dd HH:mm:ss"); } } string ids = ""; List <TaskFlow> flowlist = taskflowlist.Where(t => t.BaseClassID == null).ToList(); foreach (TaskFlow taskflow in flowlist) { ids += taskflow.UserID + ","; } txt_SysUser.Text = ids.TrimEnd(',').TrimStart(','); } } } }
protected void btn_Submit_Click(object sender, EventArgs e) { using (TransactionScope ts = new TransactionScope()) { try { CheckBoxList chk_ClassList; HiddenField hf_FlowID; TextBox txt_BeginDate; TextBox txt_EndDate; TextBox txt_RemindDate; TextBox txt_SysUser; Task task = db.Task.FirstOrDefault(t => t.ID == TaskID); if (task == null) { task = new Task(); task.TaskName = this.txt_TaskName.Text.ToString(); task.ClassType = (ClassTypeEnums)Convert.ToInt32(this.ddl_ClassType.SelectedValue.ToString()); task.TableTypeID = Convert.ToInt32(this.ddl_TableType.SelectedValue.ToString()); task.IsDel = false; task.CreateDate = DateTime.Now; task.CreateUserID = UserID; if (db.Task.FirstOrDefault(t => t.TaskName == task.TaskName && t.IsDel != true) != null) { ShowMessage("任务名称已存在,请修改后重新提交"); return; } //string[] cid=classid.TrimEnd(',').Split(','); //for (int i = 0; i < cid.Length; i++) //{ // task.BaseClassID = Convert.ToInt32(cid[i].ToString()); db.Task.Add(task); db.SaveChanges(); //} string classid = ""; for (int i = 0; i < this.cbl_Select.Items.Count; i++) { if (this.cbl_Select.Items[i].Selected) { classid += this.cbl_Select.Items[i].Value + ","; } } if (classid == "") { ShowMessage("请至少选择一个基础班次"); ts.Dispose(); return; } for (int i = 0; i < this.rp_List.Items.Count; i++) { chk_ClassList = (CheckBoxList)rp_List.Items[i].FindControl("chk_ClassList"); hf_FlowID = (HiddenField)rp_List.Items[i].FindControl("hf_FlowID"); int flowid = Convert.ToInt32(hf_FlowID.Value.ToString()); txt_BeginDate = (TextBox)rp_List.Items[i].FindControl("txt_BeginDate"); txt_EndDate = (TextBox)rp_List.Items[i].FindControl("txt_EndDate"); txt_RemindDate = (TextBox)rp_List.Items[i].FindControl("txt_RemindDate"); txt_SysUser = (TextBox)rp_List.Items[i].FindControl("txt_SysUser"); TaskFlow taskflow = new TaskFlow(); taskflow.TaskID = task.ID; taskflow.FlowID = flowid; taskflow.ApplyType = ApplyTypeEnums.未交; taskflow.IsReminded = false; if (txt_BeginDate.Text.ToString() == "" || txt_EndDate.Text.ToString() == "" || txt_RemindDate.Text.ToString() == "") { ShowMessage("时间设置有误,请手动修改时间或在【基础时间设置】模块设置好后重新提交"); ts.Dispose(); return; } taskflow.BeginDate = Convert.ToDateTime(txt_BeginDate.Text.ToString()); taskflow.EndDate = Convert.ToDateTime(txt_EndDate.Text.ToString()); taskflow.RemindDate = Convert.ToDateTime(txt_RemindDate.Text.ToString()); for (int j = 0; j < chk_ClassList.Items.Count; j++) { if (chk_ClassList.Items[j].Selected) { int baseclassid = Convert.ToInt32(chk_ClassList.Items[j].Value.ToString()); List <BaseClassUser> classuserlist = db.BaseClassUser.Where(t => t.BaseClassID == baseclassid && t.FlowID == flowid).ToList(); if (classuserlist.Count > 0) { foreach (BaseClassUser classuser in classuserlist) { taskflow.UserID = classuser.UserID; taskflow.BaseClassID = baseclassid; db.TaskFlow.Add(taskflow); db.SaveChanges(); } } else { Flow flow = db.Flow.FirstOrDefault(t => t.ID == flowid); BaseClass baseclass = db.BaseClass.FirstOrDefault(t => t.ID == baseclassid); ShowMessage("流程:【" + flow.Name + "】班次:【" + baseclass.Name + "】人员未设置,请在【基础班次设置】模块设置好后重新提交"); ts.Dispose(); return; } } } if (txt_SysUser.Text != "") { foreach (string id in txt_SysUser.Text.Split(',')) { int uid = Convert.ToInt32(id); taskflow.UserID = uid; //taskflow.BaseClassID = -1; db.TaskFlow.Add(taskflow); db.SaveChanges(); } } } new SysLogDAO().AddLog(LogType.操作日志_添加, "成功添加任务信息", UserID); } else { //string classid = ""; task.TaskName = this.txt_TaskName.Text.ToString(); //for (int i = 0; i < this.cbl_Select.Items.Count; i++) //{ // if (this.cbl_Select.Items[i].Selected) // { // classid += this.cbl_Select.Items[i].Value + ","; // } //} //task.BaseClassID = Convert.ToInt32(classid); task.ClassType = (ClassTypeEnums)Convert.ToInt32(this.ddl_ClassType.SelectedValue.ToString()); task.TableTypeID = Convert.ToInt32(this.ddl_TableType.SelectedValue.ToString()); if (db.Task.FirstOrDefault(t => t.TaskName == task.TaskName && t.IsDel != true && t.ID != TaskID) != null) { ShowMessage("任务名称已存在,请修改后重新提交"); return; } db.SaveChanges(); //删除原有taskflow数据 db.TaskFlow.RemoveRange(db.TaskFlow.Where(t => t.TaskID == TaskID)); for (int i = 0; i < this.rp_List.Items.Count; i++) { chk_ClassList = (CheckBoxList)rp_List.Items[i].FindControl("chk_ClassList"); hf_FlowID = (HiddenField)rp_List.Items[i].FindControl("hf_FlowID"); int flowid = Convert.ToInt32(hf_FlowID.Value.ToString()); txt_BeginDate = (TextBox)rp_List.Items[i].FindControl("txt_BeginDate"); txt_EndDate = (TextBox)rp_List.Items[i].FindControl("txt_EndDate"); txt_RemindDate = (TextBox)rp_List.Items[i].FindControl("txt_RemindDate"); txt_SysUser = (TextBox)rp_List.Items[i].FindControl("txt_SysUser"); TaskFlow taskflow = new TaskFlow(); taskflow.TaskID = task.ID; taskflow.FlowID = flowid; taskflow.ApplyType = ApplyTypeEnums.未交; taskflow.IsReminded = false; taskflow.BeginDate = Convert.ToDateTime(txt_BeginDate.Text.ToString()); taskflow.EndDate = Convert.ToDateTime(txt_EndDate.Text.ToString()); taskflow.RemindDate = Convert.ToDateTime(txt_RemindDate.Text.ToString()); for (int j = 0; j < chk_ClassList.Items.Count; j++) { if (chk_ClassList.Items[j].Selected) { int baseclassid = Convert.ToInt32(chk_ClassList.Items[j].Value.ToString()); List <BaseClassUser> classuserlist = db.BaseClassUser.Where(t => t.BaseClassID == baseclassid && t.FlowID == flowid).ToList(); if (classuserlist.Count > 0) { foreach (BaseClassUser classuser in classuserlist) { taskflow.UserID = classuser.UserID; taskflow.BaseClassID = baseclassid; db.TaskFlow.Add(taskflow); db.SaveChanges(); } } } } if (txt_SysUser.Text != "") { foreach (string id in txt_SysUser.Text.Split(',')) { int uid = Convert.ToInt32(id); taskflow.UserID = uid; db.TaskFlow.Add(taskflow); db.SaveChanges(); } } } new SysLogDAO().AddLog(LogType.操作日志_修改, "成功修改任务信息", UserID); } ts.Complete(); ShowMessage(); } catch (Exception ex) { ShowMessage("提交失败请检查填写数据"); ts.Dispose(); new SysLogDAO().AddLog(LogType.系统日志, ex.Message, UserID); } } }
public Task TaskBuilder() => TaskFlow.SumOfOddSquares(_data);
protected void rp_TableList_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { HiddenField hfFlowID = (HiddenField)e.Item.FindControl("hf_FID"); int flowid = Convert.ToInt32(hfFlowID.Value); HiddenField hf_TableID = (HiddenField)e.Item.FindControl("hf_TableID"); HiddenField hf_CreateUser = (HiddenField)e.Item.FindControl("hf_CreateUser"); Repeater rp_ColList = (Repeater)e.Item.FindControl("rp_ColList"); Repeater rp_AuditList = (Repeater)e.Item.FindControl("rp_AuditList"); System.Web.UI.HtmlControls.HtmlTableRow trnull = (System.Web.UI.HtmlControls.HtmlTableRow)e.Item.FindControl("trnull"); System.Web.UI.HtmlControls.HtmlTableRow tr_result = (System.Web.UI.HtmlControls.HtmlTableRow)e.Item.FindControl("tr_result"); System.Web.UI.HtmlControls.HtmlTableRow tr_message = (System.Web.UI.HtmlControls.HtmlTableRow)e.Item.FindControl("tr_message"); int tableid = Convert.ToInt32(hf_TableID.Value); int createuser = Convert.ToInt32(hf_CreateUser.Value); Flow flowmodel = db.Flow.FirstOrDefault(t => t.ID == flowid); if (flowmodel.IsAudit == true)//审核流程 { rp_ColList.Visible = false; TaskFlow taskflowmodel = db.TaskFlow.FirstOrDefault(t => t.TaskID == TaskID && t.FlowID == flowid && t.UserID == createuser && t.ApplyType != ApplyTypeEnums.未交); Literal ltl_AuditResult = (Literal)e.Item.FindControl("ltl_AuditResult"); Literal ltl_AuditMessage = (Literal)e.Item.FindControl("ltl_AuditMessage"); if (taskflowmodel != null) { tr_result.Visible = true; tr_message.Visible = true; ltl_AuditResult.Text = taskflowmodel.AuditResult.ToString(); ltl_AuditMessage.Text = taskflowmodel.AuditMessage; trnull.Visible = false; } else { tr_result.Visible = false; tr_message.Visible = false; trnull.Visible = true; } } else//填写流程 { var list = from tabledata in db.TableData join tablecolumn in db.TableColumn on tabledata.TableColumnID equals tablecolumn.ID //join dictionary in db.Dictionary on tablecolumn.DictionaryID equals dictionary.ID where tabledata.TableID == tableid && tabledata.CreateUserID == createuser orderby tablecolumn.Order select new { Data = db.Dictionary.FirstOrDefault(t => t.ID == tablecolumn.DictionaryID) == null ? tabledata.Data : db.Dictionary.FirstOrDefault(t => t.ID == tablecolumn.DictionaryID).DisplayType == DictionaryTypeEnums.单选 ? db.DictionaryData.FirstOrDefault(t => t.ID.ToString() == tabledata.Data).Data : tabledata.Data, tablecolumn.ColumnName, }; if (list.Count() > 0) { trnull.Visible = false; } else { trnull.Visible = true; } rp_ColList.DataSource = list.ToList(); rp_ColList.DataBind(); } } }
protected void rp_List_ItemDataBound(object sender, RepeaterItemEventArgs e) { if (e.Item.ItemType == ListItemType.AlternatingItem || e.Item.ItemType == ListItemType.Item) { Task model = db.Task.FirstOrDefault(t => t.ID == TaskID); int clatype = Convert.ToInt32(model.ClassType); //班次类型 int tabtype = Convert.ToInt32(model.TableTypeID); //表单类型 HiddenField hfFlowID = (HiddenField)e.Item.FindControl("hf_FlowID"); int flowid = Convert.ToInt32(hfFlowID.Value); CheckBoxList chk = (CheckBoxList)e.Item.FindControl("chk_ClassList"); Literal ltl_SysUser = (Literal)e.Item.FindControl("ltl_SysUser"); Literal ltl_BeginDate = (Literal)e.Item.FindControl("ltl_BeginDate"); Literal ltl_EndDate = (Literal)e.Item.FindControl("ltl_EndDate"); Literal ltl_RemindDate = (Literal)e.Item.FindControl("ltl_RemindDate"); //根据班次类型获取所有班次信息 List <BaseClass> classlist = db.BaseClass.Where(t => t.ClassType == (ClassTypeEnums)clatype && t.IsDel != true).ToList(); List <BaseClassUser> bassclassuserlist = db.BaseClassUser.ToList(); List <object> list = new List <object>(); if (classlist.Count > 0) { List <User> UserList = db.User.Where(t => t.IsDel != true).ToList(); foreach (BaseClass bclass in classlist) {//根据班次ID和流程ID获取班次人员信息,绑定CheckBoxlist string name = ""; List <BaseClassUser> classuserlist = bassclassuserlist.Where(t => t.BaseClassID == bclass.ID && t.FlowID == flowid).ToList(); if (classuserlist.Count > 0) { foreach (BaseClassUser classuser in classuserlist) { name += UserList.FirstOrDefault(t => t.ID == classuser.UserID) == null ? "" : (UserList.FirstOrDefault(t => t.ID == classuser.UserID).RealName + ","); } } name = name.TrimEnd(',').TrimStart(','); list.Add(new { Name = bclass.Name + "(" + name + ")", bclass.ID }); } } if (list.Count > 0) { chk.DataTextField = "Name"; chk.DataValueField = "ID"; chk.DataSource = list; chk.DataBind(); } List <TaskFlow> taskflowlist = db.TaskFlow.Where(t => t.TaskID == TaskID && t.FlowID == flowid).ToList(); if (taskflowlist.Count > 0) { //获取taskflow表的班次信息 var testlist = taskflowlist.Where(t => t.BaseClassID != null).Select(t => t.BaseClassID).Distinct().ToList(); for (int i = 0; i < testlist.Count; i++) { int classid = Convert.ToInt32(testlist[i].ToString()); for (int j = 0; j < chk.Items.Count; j++) { if (chk.Items[j].Value == classid.ToString()) { chk.Items[j].Selected = true; } } TaskFlow taskflow = taskflowlist.FirstOrDefault(t => t.BaseClassID == classid); if (taskflow != null) { ltl_BeginDate.Text = taskflow.BeginDate.ToString("yyyy-MM-dd HH:mm:ss"); ltl_EndDate.Text = taskflow.EndDate.ToString("yyyy-MM-dd HH:mm:ss"); ltl_RemindDate.Text = taskflow.RemindDate.ToString("yyyy-MM-dd HH:mm:ss"); } } string name = ""; List <TaskFlow> flowlist = taskflowlist.Where(t => t.BaseClassID == null).ToList(); foreach (TaskFlow taskflow in flowlist) { name += db.User.FirstOrDefault(t => t.ID == taskflow.UserID && t.IsDel != true) == null ? "" : (db.User.FirstOrDefault(t => t.ID == taskflow.UserID && t.IsDel != true).RealName + ","); } ltl_SysUser.Text = name.TrimEnd(',').TrimStart(','); } Repeater rp_TableList = (Repeater)e.Item.FindControl("rp_TableList"); List <object> lists = new List <object>(); if (taskflowlist != null) { foreach (TaskFlow tflist in taskflowlist) { IFMPLibrary.Entities.Table table = db.Table.FirstOrDefault(t => t.TaskID == TaskID && t.TableTypeID == tabtype && t.CreateUserID == tflist.UserID); if (table != null) { lists.Add(new { table.ID, CreateUser = table.CreateUserID, UserName = db.User.FirstOrDefault(t => t.ID == table.CreateUserID).RealName, table.CreateDate }); } else { lists.Add(new { ID = -2, CreateUser = tflist.UserID, UserName = db.User.FirstOrDefault(t => t.ID == tflist.UserID).RealName, CreateDate = "" }); } } } if (lists.Count() > 0) { rp_TableList.DataSource = lists.ToList(); rp_TableList.DataBind(); } } }
public async ValueTask TaskBuilder() => await TaskFlow.SumOfOddSquares(_data);
public void TestMethod1() { try { using (IFMPDBContext db = new IFMPDBContext()) { int BaseClass = 5; int adddays = 1; ClassTypeEnums ClassType = ClassTypeEnums.早班; List <TableType> TableTypeList = db.TableType.Where(t => t.IsDel != true).ToList(); List <Flow> FlowList = db.Flow.ToList(); FlowList = FlowList.Where(t => TableTypeList.Select(m => m.ID).Contains(t.TableTypeID)).ToList(); List <BaseClassUser> BaseClassUserList = db.BaseClassUser.ToList(); List <BaseDateFlow> BaseDateFlowList = db.BaseDateFlow.ToList(); //TASK 添加 foreach (TableType TableType in TableTypeList) { Task Task = new Task(); Task.ClassType = ClassType; Task.CreateDate = DateTime.Now; Task.CreateUserID = 290; Task.IsDel = false; Task.TableTypeID = TableType.ID; Task.TaskName = DateTime.Now.AddDays(adddays).ToString("MM-dd") + Enum.GetName(typeof(ClassTypeEnums), Task.ClassType) + TableType.Name; db.Task.Add(Task); db.SaveChanges(); List <Flow> SelFlowList = FlowList.Where(t => t.TableTypeID == TableType.ID).ToList(); foreach (Flow SelFlow in SelFlowList) { List <BaseClassUser> SelBaseClassUserList = BaseClassUserList.Where(t => t.FlowID == SelFlow.ID && t.BaseClassID == BaseClass).ToList(); BaseDateFlow BaseDateFlow = BaseDateFlowList.FirstOrDefault(t => t.ClassType == ClassType && t.FlowID == SelFlow.ID); foreach (BaseClassUser SelBaseClassUser in SelBaseClassUserList) { TaskFlow TaskFlow = new TaskFlow(); //TaskFlow. TaskFlow.ApplyType = ApplyTypeEnums.未交; TaskFlow.BaseClassID = SelBaseClassUser.BaseClassID; TaskFlow.BeginDate = new BaseUtils().GetTodayDate(DateTime.Now.AddDays(adddays), BaseDateFlow.BeginDate); TaskFlow.EndDate = new BaseUtils().GetTodayDate(DateTime.Now.AddDays(adddays), BaseDateFlow.EndDate); if (TaskFlow.EndDate < TaskFlow.BeginDate) { TaskFlow.EndDate = TaskFlow.EndDate.AddDays(1); } TaskFlow.FlowID = SelFlow.ID; TaskFlow.IsReminded = false; TaskFlow.TaskID = Task.ID; TaskFlow.RemindDate = new BaseUtils().GetTodayDate(DateTime.Now.AddDays(adddays), BaseDateFlow.RemindDate); if (TaskFlow.RemindDate < TaskFlow.BeginDate) { TaskFlow.RemindDate = TaskFlow.RemindDate.AddDays(1); } TaskFlow.UserID = SelBaseClassUser.UserID; db.TaskFlow.Add(TaskFlow); } } db.SaveChanges(); } //List<User> UserList = db.User.Where(t=>); //BaseUtils test = new BaseUtils(); //bool result = test.GetRegex("23.7°", RegexType.度数); //result = test.GetRegex("23.7", RegexType.度数); //result = test.GetRegex("我°", RegexType.度数); //result = test.GetRegex("°", RegexType.度数); //result = test.GetRegex("23.7°°", RegexType.度数); //List<BaseDateFlow> BaseDateFlowList = db.BaseDateFlow.Where(t => t.FlowID > 107 && t.FlowID < 118).ToList(); //foreach (BaseDateFlow BaseDateFlow in BaseDateFlowList) //{ // BaseDateFlow newdata = new BaseDateFlow(); // BaseUtils.DeepCopy(newdata, BaseDateFlow); // if (BaseDateFlow.FlowID != 117) // { // newdata.FlowID = (newdata.FlowID + 24) > 137 ? (newdata.FlowID + 25) : (newdata.FlowID + 24); // } // else // { // newdata.FlowID = 140; // } // newdata.TableTypeID = 20; // db.BaseDateFlow.Add(newdata); //} //db.SaveChanges(); //List<TableColumn> TableColumnList = db.TableColumn.Where(t => t.TableTypeID == 4).ToList(); //foreach (TableColumn TableColumn in TableColumnList) //{ // TableColumn NewTableColumn = new TableColumn(); // BaseUtils.DeepCopy(NewTableColumn, TableColumn); // NewTableColumn.TableTypeID = 23; // db.TableColumn.Add(NewTableColumn); //} //db.SaveChanges(); //List<Flow> FlowList = db.Flow.Where(t => t.TableTypeID == 17).ToList(); //foreach (Flow Flow in FlowList) //{ // Flow NewFlow = new Flow(); // BaseUtils.DeepCopy(NewFlow, Flow); // NewFlow.TableTypeID = 20; // db.Flow.Add(NewFlow); //} //db.SaveChanges(); //flow 43-47删除 //DDUtils test = new DDUtils(); //test.NewPostFile(); //TaskNotice(); } } catch { } }
public static void SeedSampleData(this MyMellowContext context) { var now = DateTime.UtcNow; var shit = new Task { Name = "Shit" }; var shower = new Task { Name = "Shower" }; var shave = new Task { Name = "Shave" }; var morningFlow = new TaskFlow { Name = "Morning Flow", TaskInTaskFlowMaps = new List <TaskInTaskFlowMap> { new TaskInTaskFlowMap { Task = shit, OrderNumber = 1 }, new TaskInTaskFlowMap { Task = shower, OrderNumber = 2 }, new TaskInTaskFlowMap { Task = shave, OrderNumber = 3 } } }; var eveningFlow = new TaskFlow { Name = "Evening Flow" }; // var dailyFlow = new TaskFlow // { // Name = "Daily Flows", // ChildMaps = new List<TaskFlowInTaskFlowMap> // { // new TaskFlowInTaskFlowMap // { // Parent = morningFlow, // OrderNumber = 1 // }, // new TaskFlowInTaskFlowMap // { // Parent = eveningFlow, // OrderNumber = 2 // } // } // }; var doMorningStuff = new Task { Name = "Do Morning Stuff", Schedules = new List <TaskSchedule> { new TaskSchedule { Schedule = new Schedule { StartAt = new DateTime(now.Year, now.Month, now.Day, 7, 0, 0, DateTimeKind.Utc), // 7:00am EndAt = new DateTime(now.Year, now.Month, now.Day, 8, 10, 0, DateTimeKind.Utc), // 8:10am } } }, ParentTaskFlowMaps = new List <TaskFlowForTaskMap> { new TaskFlowForTaskMap { ChildFlow = morningFlow }, new TaskFlowForTaskMap { ChildFlow = eveningFlow } } }; var doEveningStuff = new Task { Name = "Do Evening Stuff", ParentTaskFlowMaps = new List <TaskFlowForTaskMap> { new TaskFlowForTaskMap { ChildFlow = eveningFlow } } }; var organizeDay = new Task { Name = "Do Daily Things", Schedules = new List <TaskSchedule> { new TaskSchedule { Schedule = new Schedule { StartAt = DateTime.UtcNow, // 5:00am EndAt = DateTime.UtcNow, // 4:59am next day RepeatEvery = TimeSpan.FromDays(1) // single day } } }, }; var childTaskMaps = new List <TaskMap> { new TaskMap { Child = doMorningStuff, Parent = organizeDay }, new TaskMap { Child = doEveningStuff, Parent = organizeDay } }; context.Task.Add(organizeDay); context.TaskMap.AddRange(childTaskMaps); context.SaveChanges(); }