private async Task <WfApplyBase> GetModel(TableSource src, long id, JsonModel result) { WfApplyBase model = null; switch (src) { case TableSource.LeaveInfo: model = new LeaveInfoModel() { Days = 1, StartTime = DateTime.Now.AddDays(1), EndTime = DateTime.Now.AddDays(2) }; break; case TableSource.SealInfo: model = new SealInfoModel() { ApplyUserName = User.UserInfo.RealName, ApplyTime = DateTime.Now }; break; case TableSource.MeetingRoomInfo: model = new MeetingRoomInfoModel() { UsedTime = DateTime.Now, ApplyTime = DateTime.Now, ApplyName = User.UserInfo.RealName }; break; default: break; } if (id != 0) { var sourceData = await WorkflowSvc.GetSourceAsync(src, id); if (sourceData == null) { result.message = $"找不到Id为{model.Id}的{src}!"; return(null); } Mapper.Map(sourceData, model); } return(model); }
public async Task <ActionResult> ApplyInfo(TableSource src, long srcId) { var jsonModel = new JsonModel(); jsonModel.statusCode = 300; var source = await WorkflowSvc.GetSourceAsync(src, srcId); if (source == null) { jsonModel.message = $"找不到id为{src}的数据源{srcId}!"; return(Json(jsonModel, JsonRequestBehavior.AllowGet)); } var model = new DealActivityViewModel() { TableSource = src, SourceData = source }; return(View(model)); }
/// <summary> /// 处理节点 /// </summary> /// <param name="proInsId"></param> /// <param name="actInsId"></param> /// <returns></returns> public async Task <ActionResult> DealActivity(long proInsId, long actInsId) { var jsonModel = new JsonModel(); jsonModel.statusCode = 300; #region //获取流程实例 var processInstance = await WorkflowSvc.GetProcessInstanceAsync(proInsId); if (processInstance == null) { jsonModel.message = $"找不到id为{proInsId}的流程实例!"; return(Json(jsonModel, JsonRequestBehavior.AllowGet)); } #endregion #region //判断显示哪些按钮:1:回退;2:发送;3:完成。 var process = await WorkflowSvc.GetProcessById(processInstance.WfProcessId); if (process == null) { jsonModel.message = $"找不到id为{processInstance.WfProcessId}的流程!"; return(Json(jsonModel, JsonRequestBehavior.AllowGet)); } var currActIns = await WorkflowSvc.GetActivityAsync(proInsId, actInsId); if (currActIns == null) { jsonModel.message = $"流程{processInstance.ProcessName}({proInsId})中找不到id为{actInsId}的节点实例!"; return(Json(jsonModel, JsonRequestBehavior.AllowGet)); } if (currActIns.ActivityState != WfActivityState.Running) { jsonModel.message = $"该节点实例[{currActIns.ActivityName}(id:{currActIns.Id})]已经处理,状态为[{currActIns.ActivityState.GetDescriotion()}]!"; return(Json(jsonModel, JsonRequestBehavior.AllowGet)); } //如果是第一个节点,这跳转到对应的申请页面 var firstAct = process.GetFirstActivity(); if (firstAct.key == currActIns.ActivityGuid) { return(RedirectToAction("Index", "WorkflowApply", new { proInsId = processInstance.Id, id = processInstance.SourceId, currActInsId = currActIns.Id, src = processInstance.TableSource })); } WfActivityButton buttons = WfActivityButton.None; //是否有回退按钮 if (currActIns.PreActInstanceId != 0) { buttons = buttons | WfActivityButton.FallBack; } var conditions = GetCondition(processInstance.Conditions); var nextList = process.GetNextActivityList(currActIns.ActivityGuid, conditions); if (nextList == null || nextList.Count == 0) { jsonModel.message = "可选节点为空!请重新编辑流程!"; return(Json(jsonModel, JsonRequestBehavior.AllowGet)); } if (nextList.Any(m => m.activityType == WfActivityType.End)) { buttons = buttons | WfActivityButton.Complete; } if (nextList.Any(m => m.activityType == WfActivityType.Task)) { buttons = buttons | WfActivityButton.Send; } #endregion #region 获取历史处理信息 var dealActivityList = await WorkflowSvc.GetDealActivityListAsync(processInstance.Id); #endregion #region //获取展示信息 var src = await WorkflowSvc.GetSourceAsync(processInstance.TableSource, processInstance.SourceId); if (src == null) { jsonModel.message = $"找不到id为{processInstance.SourceId}的数据源{processInstance.TableSource}!"; return(Json(jsonModel, JsonRequestBehavior.AllowGet)); } #endregion var model = new DealActivityViewModel() { ActivityInstance = currActIns, Buttons = buttons, SourceData = src, TableSource = processInstance.TableSource, DealActivityList = dealActivityList, ProcessInstance = processInstance }; return(View(model)); }