public dynamic GetTaskDetail(string instanceId, string tokenId) { string pageDesc = ""; string pageValue = ""; var proxy = new WorkflowProxy(); List <Transition> transitions = proxy.GetTransitions(instanceId, tokenId); VariableInstance page = proxy.GetCurrentTaskSetPage(instanceId, tokenId); if (page != null) { //获取当前流程实例的所有变量,查找和当前节点的pageName相同的变量,取出变量值,该值就是表单的数据 VariableInstance vars = proxy.GetVariable(instanceId, page.Value.ToString()); pageValue = vars == null ? pageValue : vars.Value.ToString(); //var shortName = Path.GetFileName(page.Value.ToString()); var pageName = page.Value.ToString(); //获取page desc var firstOrDefault = stAnswerRepo.Entities.FirstOrDefault(m => m.TemplateName == pageName); if (firstOrDefault != null) { pageDesc = firstOrDefault.TemplateDesc; } } return(new { Transitions = transitions, Page = page.Value, PageDesc = pageDesc, PageData = pageValue }); }
public dynamic GetTaskDetail(string instanceId, string tokenId) { string pageDesc = ""; string pageValue = ""; var proxy = new WorkflowProxy(); List<Transition> transitions = proxy.GetTransitions(instanceId, tokenId); VariableInstance page = proxy.GetCurrentTaskSetPage(instanceId, tokenId); if (page != null) { //获取当前流程实例的所有变量,查找和当前节点的pageName相同的变量,取出变量值,该值就是表单的数据 VariableInstance vars = proxy.GetVariable(instanceId, page.Value.ToString()); pageValue = vars == null ? pageValue : vars.Value.ToString(); //var shortName = Path.GetFileName(page.Value.ToString()); var pageName = page.Value.ToString(); //获取page desc var firstOrDefault = stAnswerRepo.Entities.FirstOrDefault(m => m.TemplateName == pageName); if (firstOrDefault != null) { pageDesc = firstOrDefault.TemplateDesc; } } return new { Transitions = transitions, Page = page.Value, PageDesc = pageDesc, PageData = pageValue }; }
/// <summary> /// </summary> /// <param name="instanceid">流程ID</param> /// <param name="tokenid">节点ID</param> /// <param name="transitionName">按钮名称(离开当前节点的TransitionName)</param> public void Process(ProcessModel data) { var proxy = new WorkflowProxy(); var processInstance = new ProcessInstance(); processInstance.InstanceID = data.InstanceId; processInstance.TokenID = data.TokenId; processInstance.RouterName = data.TransitionName; var item = new VariableInstance(); if (processInstance.RouterName == "到是否参加社会保险") { int flag = 0; if (!string.IsNullOrWhiteSpace(data.TemplateData)) { dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject <object>(data.TemplateData); string idCardNumber = jsonObj.ShenFenZhengHaoMa; if (socialSpRepo.Entities.Any(m => m.IDCardNumber == idCardNumber)) { flag = 1; } else { flag = 0; socialSpRepo.Insert(new SocialSecurityPersonnel() { IDCardNumber = idCardNumber }); } } item.VariableName = "flag"; item.Value = flag; processInstance.Variables.Add(item); } //将表单数据保存至流程的变量中,以便在审核环节能够读出表单的数据(变量值不能超过2000) if (!string.IsNullOrWhiteSpace(data.TemplateData)) { VariableInstance pageUrl = proxy.GetCurrentTaskSetPage(processInstance.InstanceID, processInstance.TokenID); item = new VariableInstance(); item.Value = data.TemplateData; item.VariableName = pageUrl.Value.ToString(); processInstance.Variables.Add(item); } //获取下一个节点名并启动流程 string userId = ""; var list = proxy.GetTransitionNextNodeRoles(data.DefineName, data.TokenName, data.TransitionName); if (list != null && list.Count > 0) { string nodeName = list[0]; User choosenUser = teamRepo.GetNextUserByNodeName(data.DefineName, nodeName); //var choosenUser = GetRandomUserId(users); if (choosenUser == null) { throw new BusinessException("找不到下一步处理人"); } assignedUserRepo.Insert(new AssignedUser { InDate = DateTime.Now, InstanceID = data.InstanceId, UserID = choosenUser.UserID, Nodename = nodeName, ProcessName = data.DefineName, InUser = data.User.UserID }); var user = new TaskUser { UserId = choosenUser.UserID, UserName = choosenUser.UserName }; userId = choosenUser.UserID; processInstance.IncludeActors.Add(user); } proxy.ProcessExecuter(processInstance); LogHelper.Instanse.WriteInfo( string.Format("InstanceID:-{0},TokenID:-{1},推给了-{2}", processInstance.InstanceID, processInstance.TokenID, userId)); if (!string.IsNullOrEmpty(data.TemplateData)) { userAnswerRepo.Insert(new UserAnwser() { TemplateData = data.TemplateData, TemplateName = data.TemplateName, InDate = DateTime.Now, ProcessName = data.DefineName, NodeName = data.TokenName, UserID = data.User.UserID, InstanceID = data.InstanceId, TokenID = data.TokenId }); } }
/// <summary> /// </summary> /// <param name="instanceid">流程ID</param> /// <param name="tokenid">节点ID</param> /// <param name="transitionName">按钮名称(离开当前节点的TransitionName)</param> public void Process(ProcessModel data) { var proxy = new WorkflowProxy(); var processInstance = new ProcessInstance(); processInstance.InstanceID = data.InstanceId; processInstance.TokenID = data.TokenId; processInstance.RouterName = data.TransitionName; var item = new VariableInstance(); if (processInstance.RouterName == "到是否参加社会保险") { int flag = 0; if (!string.IsNullOrWhiteSpace(data.TemplateData)) { dynamic jsonObj = Newtonsoft.Json.JsonConvert.DeserializeObject<object>(data.TemplateData); string idCardNumber = jsonObj.ShenFenZhengHaoMa; if (socialSpRepo.Entities.Any(m => m.IDCardNumber == idCardNumber)) { flag = 1; } else { flag = 0; socialSpRepo.Insert(new SocialSecurityPersonnel() { IDCardNumber = idCardNumber }); } } item.VariableName = "flag"; item.Value = flag; processInstance.Variables.Add(item); } //将表单数据保存至流程的变量中,以便在审核环节能够读出表单的数据(变量值不能超过2000) if (!string.IsNullOrWhiteSpace(data.TemplateData)) { VariableInstance pageUrl = proxy.GetCurrentTaskSetPage(processInstance.InstanceID, processInstance.TokenID); item = new VariableInstance(); item.Value = data.TemplateData; item.VariableName = pageUrl.Value.ToString(); processInstance.Variables.Add(item); } //获取下一个节点名并启动流程 string userId = ""; var list = proxy.GetTransitionNextNodeRoles(data.DefineName, data.TokenName, data.TransitionName); if (list != null && list.Count > 0) { string nodeName = list[0]; User choosenUser = teamRepo.GetNextUserByNodeName(data.DefineName, nodeName); //var choosenUser = GetRandomUserId(users); if (choosenUser == null) { throw new BusinessException("找不到下一步处理人"); } assignedUserRepo.Insert(new AssignedUser { InDate = DateTime.Now, InstanceID = data.InstanceId, UserID = choosenUser.UserID, Nodename = nodeName, ProcessName = data.DefineName, InUser = data.User.UserID }); var user = new TaskUser { UserId = choosenUser.UserID, UserName = choosenUser.UserName }; userId = choosenUser.UserID; processInstance.IncludeActors.Add(user); } proxy.ProcessExecuter(processInstance); LogHelper.Instanse.WriteInfo( string.Format("InstanceID:-{0},TokenID:-{1},推给了-{2}", processInstance.InstanceID, processInstance.TokenID, userId)); if (!string.IsNullOrEmpty(data.TemplateData)) { userAnswerRepo.Insert(new UserAnwser() { TemplateData = data.TemplateData, TemplateName = data.TemplateName, InDate = DateTime.Now, ProcessName = data.DefineName, NodeName = data.TokenName, UserID = data.User.UserID, InstanceID = data.InstanceId, TokenID = data.TokenId }); } }