/// <summary> /// 创建流程 /// </summary> /// <param name="formInstanceID"></param> /// <param name="userID"></param> /// <param name="userName"></param> /// <returns></returns> public S_WF_InsFlow CreateFlow(string formInstanceID, string userID, string userName) { try { S_WF_InsFlow insFlow = new S_WF_InsFlow(); insFlow.S_WF_InsDefFlow = this; insFlow.ID = FormulaHelper.CreateGuid(); insFlow.CreateTime = DateTime.Now; insFlow.CreateUserID = userID; insFlow.CreateUserName = userName; insFlow.FormInstanceID = formInstanceID; insFlow.Status = FlowTaskStatus.Processing.ToString(); insFlow.FlowName = insFlow.GetInsName(this.FlowNameTemplete); insFlow.FlowCategory = insFlow.GetInsName(this.FlowCategorytemplete); insFlow.FlowSubCategory = insFlow.GetInsName(this.FlowSubCategoryTemplete); var entities = FormulaHelper.GetEntities <WorkflowEntities>(); entities.S_WF_InsFlow.Add(insFlow); //初始化流程变量 if (!string.IsNullOrEmpty(this.InitVariable)) { foreach (string str in this.InitVariable.Split(',')) { if (string.IsNullOrWhiteSpace(str)) { continue; } string strKey = str.Split('=')[0]; string strValue = str.Contains('=') ? str.Split('=')[1] : ""; strValue = strValue.Trim('\''); var variable = new S_WF_InsVariable(); variable.ID = FormulaHelper.CreateGuid(); variable.VariableName = strKey; variable.VariableValue = strValue; insFlow.S_WF_InsVariable.Add(variable); } } return(insFlow); } catch (Exception ex) { throw new FlowException(ex.Message); } }
/// <summary> /// /// </summary> /// <param name="variableSet"></param> /// <param name="nextExecUserIDs"></param> /// <param name="execComment"></param> /// <param name="proxyRoles">当前用户所代理的角色</param> /// <param name="reverse">是否反向操作(撤回需要反向操作</param> public void SetFlowVariable(S_WF_InsFlow flow) { if (string.IsNullOrEmpty(this.VariableSet)) { return; } foreach (string str in this.VariableSet.Split(',')) { if (string.IsNullOrWhiteSpace(str)) { continue; } string strKey = str.Split('=')[0]; string strValue = str.Contains('=') ? str.Split('=')[1] : ""; strValue = strValue.Trim('\'', ' '); S_WF_InsVariable variable = flow.S_WF_InsVariable.Where(c => c.VariableName == strKey).SingleOrDefault(); if (variable == null) { variable = new S_WF_InsVariable(); variable.ID = FormulaHelper.CreateGuid(); variable.VariableName = strKey; variable.VariableValue = strValue; flow.S_WF_InsVariable.Add(variable); } else { variable.VariableValue = strValue; } } }