/// <summary> /// 根据指定流程 选择的流转步骤创建任务 /// </summary> /// <param name="task">当前任务Dto</param> /// <param name="stepId">当前步骤Id</param> protected void CreatedNextTask(FlowExecuteDto task, short stepId) { foreach (var step in task.Steps) { //流转的下个步骤 var nextStep = FlowStepRepository.Entities.Single(p => p.StepId == step.Key && p.FlowDesignId == task.FlowId); foreach (var user in step.Value) { var uid = user.Key; var uname = user.Value; GetReceiver(task.FlowId, ref uid, ref uname); WorkFlowTask taskModel = new WorkFlowTask() { Id = CombHelper.NewComb(), PrevId = task.TaskId, FlowItemId = task.ItemId, PrevStepId = stepId, StepId = nextStep.StepId, StepName = nextStep.StepName, SenderId = task.SenderId, SenderName = task.SenderName, ReceiverId = uid, ReceiverName = uname, IsComment = nextStep.CountersignType == 0 ? false : true, IsSeal = nextStep.CountersignType == 2 ? true : false, IsArchive = nextStep.IsArchives, StepDay = nextStep.SpecifiedDay, Status = 1 }; FlowTaskRepository.Insert(taskModel); } } }
public object GetWorkFlowTaskById(int id) { object result = null; WorkFlowTask objWorkFlowTask = new WorkFlowTask(); try { using (_context) { objWorkFlowTask = _context.WorkFlowTask.FirstOrDefault(x => x.Id == id); result = new { objWorkFlowTask, error = "0", msg = "Success" }; } } catch (Exception ex) { ex.ToString(); result = new { objWorkFlowTask, error = "1", msg = "Error" }; } return(result); }
public object UpdateWorkFlowTask(int id, [FromBody] WorkFlowTask model) { object result = null; string message = ""; string errorcode = ""; string excp = ""; if (model == null) { return(BadRequest()); } using (_context) { using (var _ctxTransaction = _context.Database.BeginTransaction()) { try { var entityUpdate = _context.WorkFlowTask.FirstOrDefault(x => x.Id == id); if (entityUpdate != null) { entityUpdate.TaskName = model.TaskName; entityUpdate.Description = model.Description; entityUpdate.TaskOwner = model.TaskOwner; entityUpdate.DueDate = model.DueDate; entityUpdate.TemplateId = model.TemplateId; entityUpdate.FromAddress = model.FromAddress; entityUpdate.ToAddress = model.ToAddress; entityUpdate.Ccaddress = model.Ccaddress; entityUpdate.Bccaddress = model.Bccaddress; entityUpdate.ReplyToAddress = model.ReplyToAddress; entityUpdate.EmailSubject = model.EmailSubject; entityUpdate.Attachment = model.Attachment; entityUpdate.Message = model.Message; entityUpdate.CheckListId = model.CheckListId; entityUpdate.TaskOrder = model.TaskOrder; _context.SaveChanges(); } _ctxTransaction.Commit(); message = "Entry Updated"; errorcode = "0"; } catch (Exception e) { _ctxTransaction.Rollback(); e.ToString(); message = "Entry Update Failed!!"; errorcode = "1"; excp = e.ToString(); } result = new { error = errorcode, msg = message, excp = excp }; } } return(result); }
/// <summary> /// 设置当前任务状态 /// </summary> /// <param name="currentTask">任务实体</param> /// <param name="status">标记状态</param> /// <param name="Comment">提交意见</param> /// <param name="Note">任务说明</param> protected void CompletedTask(WorkFlowTask currentTask, short status, string Comment = "", string Note = "") { if (currentTask != null) { currentTask.CompletedTime = DateTime.Now; currentTask.Comment = Comment; if (Note != "") { currentTask.TaskNote = Note; } currentTask.Status = status; FlowTaskRepository.Update(currentTask); } }
/// <summary> /// 处理同级他人未完成的任务状态 /// </summary> /// <param name="currentTask">任务实体</param> /// <param name="status">标记状态</param> /// <param name="Comment">提交意见</param> /// <param name="Note">任务说明</param> protected void CompletedOtherSiblingTask(WorkFlowTask currentTask, short status, string Comment = "", string Note = "") { List <WorkFlowTask> OtherSiblingTaskList = FlowTaskRepository.Entities.Where(c => c.FlowItemId == currentTask.FlowItemId && c.StepId == currentTask.StepId && c.Id != currentTask.Id && (c.Status == 1 || c.Status == 2)).ToList(); //找同级步骤他人未完成的任务 if (OtherSiblingTaskList.Count > 0) { foreach (var task in OtherSiblingTaskList) { task.CompletedTime = DateTime.Now; task.Comment = Comment; task.TaskNote = Note; task.Status = status; FlowTaskRepository.Update(task); } } }
/// <summary> /// 创建第一个任务 /// </summary> /// <param name="task">当前任务Dto</param> /// <returns>业务操作结果</returns> protected OperationResult CreateFirstTask(FlowExecuteDto task) { OperationResult re = CheckFlow(task.FlowId, task.EntityId); if (re.ResultType == OperationResultType.Success) { var firstStep = FlowStepRepository.Entities.Where(c => c.FlowDesignId == task.FlowId && c.StepType == 0).Select(m => new { m.StepId, m.StepName }).SingleOrDefault(); //起始步骤 var flowItemId = CombHelper.NewComb(); var id = CombHelper.NewComb(); WorkFlowTask taskModel = new WorkFlowTask() { Id = id, FlowItemId = flowItemId, PrevStepId = -1, StepId = firstStep.StepId, StepName = firstStep.StepName, SenderId = task.SenderId, SenderName = task.SenderName, ReceiverId = task.SenderId, ReceiverName = task.SenderName, CreatedTime = DateTime.Now, IsComment = false, IsSeal = false, IsArchive = false, Status = 1 }; var model = new WorkFlowItem() { Id = flowItemId, FlowDesignId = task.FlowId, EntityId = task.EntityId, EntityName = task.Title, CreatorUserId = task.SenderId, CreatorUserName = task.SenderName, //StepDay,DelayDay,HandleDay 用触发器保证数据正确性 Status = 0 }; model.Tasks.Add(taskModel); FlowItemRepository.Insert(model); re = new OperationResult(OperationResultType.Success, "流程启动成功!"); //re.Data = taskModel; } return(re); }
public object CreateWorkFlowTask([FromBody] WorkFlowTask model) { object result = null; string message = ""; string errorcode = ""; string excp = ""; if (model == null) { return(BadRequest()); } using (_context) { using (var _ctxTransaction = _context.Database.BeginTransaction()) { try { _context.WorkFlowTask.Add(model); //await _ctx.SaveChangesAsync(); _context.SaveChanges(); _ctxTransaction.Commit(); message = "Saved Successfully"; errorcode = "0"; } catch (Exception e) { _ctxTransaction.Rollback(); e.ToString(); message = "Saved Error"; errorcode = "1"; excp = e.ToString(); } result = new { error = errorcode, msg = message, excp = excp }; } } return(result); }
/// <summary> /// 创建第一个任务 /// </summary> /// <param name="task">当前任务Dto</param> /// <returns>业务操作结果</returns> protected OperationResult CreateFirstTask(FlowExecuteDto task) { OperationResult re = CheckFlow(task.FlowId, task.EntityId); if (re.ResultType == OperationResultType.Success) { var firstStep = FlowStepRepository.Entities.Where(c => c.FlowDesignId == task.FlowId && c.StepType == 0).Select(m => new { m.StepId,m.StepName}).SingleOrDefault(); //起始步骤 var flowItemId = CombHelper.NewComb(); var id = CombHelper.NewComb(); WorkFlowTask taskModel = new WorkFlowTask() { Id = id, FlowItemId = flowItemId, PrevStepId = -1, StepId = firstStep.StepId, StepName = firstStep.StepName, SenderId = task.SenderId, SenderName=task.SenderName, ReceiverId = task.SenderId, ReceiverName = task.SenderName, CreatedTime=DateTime.Now, IsComment = false, IsSeal = false, IsArchive=false, Status = 1 }; var model = new WorkFlowItem() { Id = flowItemId, FlowDesignId = task.FlowId, EntityId = task.EntityId, EntityName = task.Title, CreatorUserId = task.SenderId, CreatorUserName=task.SenderName, //StepDay,DelayDay,HandleDay 用触发器保证数据正确性 Status = 0 }; model.Tasks.Add(taskModel); FlowItemRepository.Insert(model); re = new OperationResult(OperationResultType.Success, "流程启动成功!"); //re.Data = taskModel; } return re; }
/// <summary> /// 根据指定流程 选择的流转步骤创建任务 /// </summary> /// <param name="task">当前任务Dto</param> /// <param name="stepId">当前步骤Id</param> protected void CreatedNextTask(FlowExecuteDto task, short stepId) { foreach (var step in task.Steps) { //流转的下个步骤 var nextStep = FlowStepRepository.Entities.Single(p => p.StepId == step.Key && p.FlowDesignId==task.FlowId); foreach (var user in step.Value) { var uid=user.Key; var uname=user.Value; GetReceiver(task.FlowId,ref uid,ref uname); WorkFlowTask taskModel = new WorkFlowTask() { Id = CombHelper.NewComb(), PrevId = task.TaskId, FlowItemId = task.ItemId, PrevStepId = stepId, StepId = nextStep.StepId, StepName = nextStep.StepName, SenderId = task.SenderId, SenderName = task.SenderName, ReceiverId = uid, ReceiverName = uname, IsComment = nextStep.CountersignType == 0 ? false : true, IsSeal = nextStep.CountersignType == 2 ? true : false, IsArchive = nextStep.IsArchives, StepDay = nextStep.SpecifiedDay, Status = 1 }; FlowTaskRepository.Insert(taskModel); } } }
/// <summary> /// 设置当前任务状态 /// </summary> /// <param name="currentTask">任务实体</param> /// <param name="status">标记状态</param> /// <param name="Comment">提交意见</param> /// <param name="Note">任务说明</param> protected void CompletedTask(WorkFlowTask currentTask, short status, string Comment = "", string Note = "") { if (currentTask != null) { currentTask.CompletedTime = DateTime.Now; currentTask.Comment = Comment; if (Note!="") currentTask.TaskNote = Note; currentTask.Status = status; FlowTaskRepository.Update(currentTask); } }
/// <summary> /// 处理同级他人未完成的任务状态 /// </summary> /// <param name="currentTask">任务实体</param> /// <param name="status">标记状态</param> /// <param name="Comment">提交意见</param> /// <param name="Note">任务说明</param> protected void CompletedOtherSiblingTask(WorkFlowTask currentTask, short status, string Comment = "", string Note = "") { List<WorkFlowTask> OtherSiblingTaskList = FlowTaskRepository.Entities.Where(c => c.FlowItemId == currentTask.FlowItemId && c.StepId == currentTask.StepId && c.Id != currentTask.Id && (c.Status == 1 || c.Status == 2)).ToList(); //找同级步骤他人未完成的任务 if (OtherSiblingTaskList.Count > 0) foreach (var task in OtherSiblingTaskList) { task.CompletedTime = DateTime.Now; task.Comment = Comment; task.TaskNote = Note; task.Status = status; FlowTaskRepository.Update(task); } }
/// <summary> /// 退回任务 /// </summary> /// <param name="task">当前任务Dto</param> /// <returns>业务操作结果</returns> protected OperationResult ExecuteBack(FlowExecuteDto task) { OperationResult re = new OperationResult(OperationResultType.NoChanged, "退回未处理!"); var currentTask = FlowTaskRepository.Entities.Single(c => c.Id == task.TaskId); if (currentTask != null) { if (currentTask.Status != 1 && currentTask.Status != 2) { return(new OperationResult(OperationResultType.ValidError, "任务已经处理,不能进行退回!")); } var currentStep = FlowStepRepository.Entities.Where(c => c.FlowDesignId == task.FlowId && c.StepId == currentTask.StepId).Select(m => new { m.StepType, m.BackType, m.SpecifiedBackStep }).SingleOrDefault(); if (currentStep.StepType == 0) { return(new OperationResult(OperationResultType.ValidError, "流程的第一个步骤不能退回!")); } if (currentStep.BackType == 0) { return(new OperationResult(OperationResultType.ValidError, "当前步骤为不可退回步骤!")); } #region 退回处理 List <WorkFlowTask> backTasks = new List <WorkFlowTask>(); if (currentStep.BackType == 1) //退回到上一步 { backTasks.AddRange(FlowTaskRepository.Entities.Where(c => c.Id == currentTask.PrevId).ToList()); } else if (currentStep.BackType == 2) //退回到第一步 { var firstTack = FlowTaskRepository.Entities.Where(c => c.PrevStepId == -1 && c.FlowItemId == currentTask.FlowItemId).OrderByDescending(c => c.CreatedTime).ToList()[0]; firstTack.PrevId = task.TaskId; //上一个任务Id backTasks.Add(firstTack); } else //退回到指定步 { var backStep = FlowStepRepository.Entities.Where(c => c.FlowDesignId == task.FlowId && c.StepName == currentStep.SpecifiedBackStep).Select(c => new { c.StepId }).Single(); if (backStep == null) { return(new OperationResult(OperationResultType.ValidError, "当前流程步骤配置有误,不能退回!")); } var backtask = GetSiblingTask(currentTask.FlowItemId, backStep.StepId).OrderByDescending(c => c.SenderId).ThenByDescending(c => c.CreatedTime).ToList(); string senderId = ""; foreach (var item in backtask) //移除同一步骤中相同的发送人的以前的任务 { if (senderId == item.SenderId) { backtask.Remove(item); } senderId = item.SenderId; } backTasks.AddRange(backtask); } FlowTaskRepository.UnitOfWork.TransactionEnabled = true; //事务处理 foreach (var item in backTasks) { WorkFlowTask newTask = new WorkFlowTask(); newTask.Id = CombHelper.NewComb(); newTask.PrevId = item.PrevId; newTask.FlowItemId = item.FlowItemId; newTask.PrevStepId = item.PrevStepId; newTask.StepId = item.StepId; newTask.StepName = item.StepName; newTask.SenderId = task.SenderId; newTask.SenderName = task.SenderName; newTask.ReceiverId = item.ReceiverId; newTask.ReceiverName = item.ReceiverName; newTask.OpenedTime = null; newTask.CompletedTime = null; newTask.IsComment = item.IsComment; newTask.IsSeal = item.IsSeal; newTask.IsArchive = item.IsArchive; newTask.TaskNote = "退回的任务"; newTask.StepDay = item.StepDay; newTask.DelayDay = 0; newTask.Status = 1; FlowTaskRepository.Insert(newTask); } CompletedTask(currentTask, 20, task.Comment); CompletedOtherSiblingTask(currentTask, 40, "", "他人已退回"); FlowTaskRepository.UnitOfWork.SaveChanges(); re = new OperationResult(OperationResultType.Success, "退回成功!"); #endregion } else { re = new OperationResult(OperationResultType.ValidError, "您要退回的任务不存在!"); } return(re); }
/// <summary> /// 提交任务 /// </summary> /// <param name="task">当前任务Dto</param> /// <returns>业务操作结果</returns> protected OperationResult ExecuteSubmit(FlowExecuteDto task) { OperationResult re = new OperationResult(OperationResultType.Success, "处理成功!"); WorkFlowTask currentTask = FlowTaskRepository.Entities.SingleOrDefault(c => c.Id == task.TaskId); if (currentTask == null) { return(CreateFirstTask(task)); } var currentStep = FlowStepRepository.Entities.Where(c => c.FlowDesignId == task.FlowId && c.StepId == currentTask.StepId). Select(m => new { m.StepType, m.CountersignStrategy, m.CountersignPer, m.BackType }).SingleOrDefault(); #region 新增下级任务 if (currentStep != null) { if (currentTask.Status == 1 || currentTask.Status == 2) { FlowTaskRepository.UnitOfWork.TransactionEnabled = true; //事务处理 bool createNextTask = true; switch (currentStep.CountersignStrategy) { case 0: //所有步骤同意 int count = GetSiblingTask(currentTask.FlowItemId, currentTask.StepId).Where(c => c.Status < 10).Count(); if (count > 1) { createNextTask = false; } break; case 1: //一人同意即可 CompletedOtherSiblingTask(currentTask, 30, "", "他人已处理此任务!"); break; case 2: //比例同意即可 decimal percentage = currentStep.CountersignPer <= 0 ? 100 : currentStep.CountersignPer; IQueryable <WorkFlowTask> TaskQueryable = GetSiblingTask(currentTask.FlowItemId, currentTask.StepId).Where(c => c.PrevId == currentTask.PrevId); if (Math.Round((((decimal)(TaskQueryable.Where(p => p.Status == 10).Count() + 1) / (decimal)TaskQueryable.Where(p => p.Status <= 10).Count()) * 100), 2, MidpointRounding.AwayFromZero) < percentage) { createNextTask = false; } else { CompletedOtherSiblingTask(currentTask, 30, "", "他人已处理此任务!"); } break; } if (createNextTask) { CreatedNextTask(task, currentTask.StepId); } CompletedTask(currentTask, 10, task.Comment); FlowTaskRepository.UnitOfWork.SaveChanges(); //是否超期处理 } else { return(new OperationResult(OperationResultType.ValidError, "当前步骤已经由他人处理!")); } } else { re = new OperationResult(OperationResultType.ValidError, "找不到当前步骤!"); } #endregion return(re); }
public static void Hasten(string types, string users, string contents, RoadFlow.Data.Model.WorkFlowTask task, string othersParams = "") { if (!users.IsNullOrEmpty() && !types.IsNullOrEmpty() && task != null) { string[] array = users.Split(','); Guid guid = Guid.NewGuid(); List <RoadFlow.Data.Model.WorkFlowTask> list = new WorkFlowTask().GetNextTaskList(task.ID).FindAll((RoadFlow.Data.Model.WorkFlowTask p) => p.Status.In(0, 1)); string text = ""; text = ((!(HttpContext.Current.Request.Url != null) || !HttpContext.Current.Request.Url.AbsolutePath.EndsWith(".aspx", StringComparison.CurrentCultureIgnoreCase)) ? "/WorkFlowRun/Index" : "/Platform/WorkFlowRun/Default.aspx"); string[] array2 = types.Split(','); for (int i = 0; i < array2.Length; i++) { int test; if (array2[i].IsInt(out test)) { string[] array3 = array; foreach (string id in array3) { Guid userGuid; if (Users.RemovePrefix(id).IsGuid(out userGuid)) { RoadFlow.Data.Model.WorkFlowTask workFlowTask = list.Find((RoadFlow.Data.Model.WorkFlowTask p) => p.ReceiveID == userGuid); string linkUrl = (workFlowTask == null) ? "" : ("javascript:openApp('" + text + "?flowid=" + workFlowTask.FlowID + "&stepid=" + workFlowTask.StepID + "&instanceid=" + workFlowTask.InstanceID + "&taskid=" + workFlowTask.ID + "&groupid=" + workFlowTask.GroupID + "',0,'" + workFlowTask.Title.Replace1(",", "") + "','tab_" + workFlowTask.ID + "');closeMessage('" + guid + "');"); switch (test) { case 1: SMSLog.SendSMS(new Users().GetMobileNumber(userGuid), contents); break; case 2: Email.Send(userGuid, "任务催办", contents); break; case 3: { RoadFlow.Data.Model.Users users3 = new Users().Get(userGuid); if (users3 != null) { ShortMessage.Send(users3.ID, users3.Name, "任务催办", contents, 0, linkUrl, task.ID.ToString(), guid.ToString()); } break; } case 4: { RoadFlow.Data.Model.Users users2 = new Users().Get(userGuid); if (users2 != null) { new Message().SendText(contents, users2.Account, "", "", 0, new Agents().GetAgentIDByCode("weixinagents_waittasks"), true); } break; } } } } } } RoadFlow.Data.Model.HastenLog hastenLog = new RoadFlow.Data.Model.HastenLog(); hastenLog.Contents = contents; hastenLog.ID = Guid.NewGuid(); hastenLog.SendTime = DateTimeNew.Now; hastenLog.SendUser = Users.CurrentUserID; hastenLog.SendUserName = Users.CurrentUserName; hastenLog.OthersParams = (othersParams.IsNullOrEmpty() ? task.ID.ToString() : othersParams); hastenLog.Types = types; hastenLog.Users = users; new HastenLog().Add(hastenLog); } }
/// <summary> /// 退回任务 /// </summary> /// <param name="task">当前任务Dto</param> /// <returns>业务操作结果</returns> protected OperationResult ExecuteBack(FlowExecuteDto task) { OperationResult re = new OperationResult(OperationResultType.NoChanged, "退回未处理!"); var currentTask = FlowTaskRepository.Entities.Single(c => c.Id == task.TaskId); if (currentTask != null) { if (currentTask.Status != 1 && currentTask.Status != 2) { return new OperationResult(OperationResultType.ValidError, "任务已经处理,不能进行退回!"); } var currentStep = FlowStepRepository.Entities.Where(c => c.FlowDesignId == task.FlowId && c.StepId == currentTask.StepId).Select(m => new { m.StepType, m.BackType, m.SpecifiedBackStep }).SingleOrDefault(); if (currentStep.StepType == 0) { return new OperationResult(OperationResultType.ValidError, "流程的第一个步骤不能退回!"); } if (currentStep.BackType == 0) { return new OperationResult(OperationResultType.ValidError, "当前步骤为不可退回步骤!"); } #region 退回处理 List<WorkFlowTask> backTasks = new List<WorkFlowTask>(); if (currentStep.BackType == 1) //退回到上一步 { backTasks.AddRange(FlowTaskRepository.Entities.Where(c => c.Id == currentTask.PrevId).ToList()); } else if (currentStep.BackType == 2) //退回到第一步 { var firstTack = FlowTaskRepository.Entities.Where(c => c.PrevStepId == -1 && c.FlowItemId == currentTask.FlowItemId).OrderByDescending(c => c.CreatedTime).ToList()[0]; firstTack.PrevId = task.TaskId; //上一个任务Id backTasks.Add(firstTack); } else //退回到指定步 { var backStep = FlowStepRepository.Entities.Where(c => c.FlowDesignId == task.FlowId && c.StepName == currentStep.SpecifiedBackStep).Select(c => new { c.StepId }).Single(); if (backStep == null) { return new OperationResult(OperationResultType.ValidError, "当前流程步骤配置有误,不能退回!"); } var backtask = GetSiblingTask(currentTask.FlowItemId, backStep.StepId).OrderByDescending(c=>c.SenderId).ThenByDescending(c=>c.CreatedTime).ToList(); string senderId = ""; foreach (var item in backtask) //移除同一步骤中相同的发送人的以前的任务 { if (senderId == item.SenderId) backtask.Remove(item); senderId = item.SenderId; } backTasks.AddRange(backtask); } FlowTaskRepository.UnitOfWork.TransactionEnabled = true; //事务处理 foreach (var item in backTasks) { WorkFlowTask newTask = new WorkFlowTask(); newTask.Id = CombHelper.NewComb(); newTask.PrevId = item.PrevId; newTask.FlowItemId = item.FlowItemId; newTask.PrevStepId = item.PrevStepId; newTask.StepId = item.StepId; newTask.StepName = item.StepName; newTask.SenderId = task.SenderId; newTask.SenderName = task.SenderName; newTask.ReceiverId = item.ReceiverId; newTask.ReceiverName = item.ReceiverName; newTask.OpenedTime = null; newTask.CompletedTime = null; newTask.IsComment = item.IsComment; newTask.IsSeal = item.IsSeal; newTask.IsArchive = item.IsArchive; newTask.TaskNote = "退回的任务"; newTask.StepDay = item.StepDay; newTask.DelayDay = 0; newTask.Status = 1; FlowTaskRepository.Insert(newTask); } CompletedTask(currentTask, 20, task.Comment); CompletedOtherSiblingTask(currentTask, 40, "", "他人已退回"); FlowTaskRepository.UnitOfWork.SaveChanges(); re = new OperationResult(OperationResultType.Success, "退回成功!"); #endregion } else { re = new OperationResult(OperationResultType.ValidError, "您要退回的任务不存在!"); } return re; }
/// <summary> /// 得到Grid的html /// </summary> /// <param name="dataFormat"></param> /// <param name="dataSource"></param> /// <param name="dataSource1"></param> /// <returns></returns> public string GetFormGridHtml(string connID, string dataFormat, string dataSource, string dataSource1) { if (!dataFormat.IsInt() || !dataSource.IsInt() || dataSource1.IsNullOrEmpty()) { return(""); } switch (dataSource) { case "0": DBConnection dbConn = new DBConnection(); var dbconn = dbConn.Get(connID.ToGuid()); if (dbconn == null) { return(""); } DataTable dt = dbConn.GetDataTable(dbconn, dataSource1.ReplaceSelectSql()); switch (dataFormat) { case "0": return(dataTableToHtml(dt)); case "1": return(dt.Rows.Count > 0 ? dt.Rows[0][0].ToString() : ""); case "2": return(dt.Rows.Count > 0 ? jsonToHtml(dt.Rows[0][0].ToString()) : ""); default: return(""); } case "1": string str = string.Empty; try { str = FoWoSoft.Utility.HttpHelper.SendGet(dataSource1); switch (dataFormat) { case "0": case "1": return(str); case "2": return(jsonToHtml(str)); default: return(""); } } catch { return(""); } case "2": FoWoSoft.Data.Model.WorkFlowCustomEventParams eventParams = new FoWoSoft.Data.Model.WorkFlowCustomEventParams(); eventParams.FlowID = (System.Web.HttpContext.Current.Request.QueryString["FlowID"] ?? "").ToGuid(); eventParams.GroupID = (System.Web.HttpContext.Current.Request.QueryString["GroupID"] ?? "").ToGuid(); eventParams.StepID = (System.Web.HttpContext.Current.Request.QueryString["StepID"] ?? "").ToGuid(); eventParams.TaskID = (System.Web.HttpContext.Current.Request.QueryString["TaskID"] ?? "").ToGuid(); eventParams.InstanceID = System.Web.HttpContext.Current.Request.QueryString["InstanceID"] ?? ""; object obj = null; try { obj = new WorkFlowTask().ExecuteFlowCustomEvent(dataSource1, eventParams); switch (dataFormat) { case "0": return(dataTableToHtml((DataTable)obj)); case "1": return(obj.ToString()); case "2": return(jsonToHtml(obj.ToString())); default: return(""); } } catch { return(""); } } return(""); }
public static void Hasten(string types, string users, string contents, RoadFlow.Data.Model.WorkFlowTask task, string othersParams = "") { if (users.IsNullOrEmpty() || types.IsNullOrEmpty() || task == null) { return; } string[] strArray = users.Split(','); Guid guid = Guid.NewGuid(); List <RoadFlow.Data.Model.WorkFlowTask> all = new WorkFlowTask().GetNextTaskList(task.ID).FindAll((Predicate <RoadFlow.Data.Model.WorkFlowTask>)(p => p.Status.In(0, 1))); string str1 = !(HttpContext.Current.Request.Url != (Uri)null) || !HttpContext.Current.Request.Url.AbsolutePath.EndsWith(".aspx", StringComparison.CurrentCultureIgnoreCase) ? "/WorkFlowRun/Index" : "/Platform/WorkFlowRun/Default.aspx"; string str2 = types; char[] chArray = new char[1] { ',' }; foreach (string str3 in str2.Split(chArray)) { int test; if (str3.IsInt(out test)) { foreach (string id in strArray) { Guid userGuid; if (Users.RemovePrefix(id).IsGuid(out userGuid)) { RoadFlow.Data.Model.WorkFlowTask workFlowTask = all.Find((Predicate <RoadFlow.Data.Model.WorkFlowTask>)(p => p.ReceiveID == userGuid)); string str4; if (workFlowTask != null) { str4 = "javascript:openApp('" + str1 + "?flowid=" + (object)workFlowTask.FlowID + "&stepid=" + (object)workFlowTask.StepID + "&instanceid=" + workFlowTask.InstanceID + "&taskid=" + (object)workFlowTask.ID + "&groupid=" + (object)workFlowTask.GroupID + "',0,'" + workFlowTask.Title.Replace1(",", "") + "','tab_" + (object)workFlowTask.ID + "');closeMessage('" + (object)guid + "');"; } else { str4 = ""; } string linkUrl = str4; switch (test) { case 1: SMSLog.SendSMS(new Users().GetMobileNumber(userGuid), contents); continue; case 2: Email.Send(userGuid, "任务催办", contents, ""); continue; case 3: RoadFlow.Data.Model.Users users1 = new Users().Get(userGuid); if (users1 != null) { ShortMessage.Send(users1.ID, users1.Name, "任务催办", contents, 0, linkUrl, task.ID.ToString(), guid.ToString()); continue; } continue; case 4: RoadFlow.Data.Model.Users users2 = new Users().Get(userGuid); if (users2 != null) { new Message().SendText(contents, users2.Account, "", "", 0, new Agents().GetAgentIDByCode("weixinagents_waittasks"), true); continue; } continue; default: continue; } } } } } new HastenLog().Add(new RoadFlow.Data.Model.HastenLog() { Contents = contents, ID = Guid.NewGuid(), SendTime = DateTimeNew.Now, SendUser = Users.CurrentUserID, SendUserName = Users.CurrentUserName, OthersParams = othersParams.IsNullOrEmpty() ? task.ID.ToString() : othersParams, Types = types, Users = users }); }