コード例 #1
0
ファイル: FlowDesignController.cs プロジェクト: zhudk2000/DKW
        public string SaveForm(string keyValue, string InfoEntity, string ContentEntity, string shcemeAuthorizeData)
        {
            WFSchemeInfo    entyity       = InfoEntity.ToObject <WFSchemeInfo>();
            WFSchemeContent contententity = ContentEntity.ToObject <WFSchemeContent>();

            wfFlowInfoBLL.SaveForm(keyValue, entyity, contententity);
            return(Result.ToJson());
        }
コード例 #2
0
        /// <summary>
        /// 保存流程
        /// </summary>
        /// <param name="entity">表单模板实体类</param>
        /// <param name="keyValue">主键</param>
        /// <returns></returns>
        public int SaveForm(string keyValue, WFSchemeInfo entity, WFSchemeContent modelentity)
        {
            try
            {
                if (string.IsNullOrEmpty(keyValue))
                {
                    entity.SchemeVersion = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                    _unitWork.Add(entity);

                    modelentity.SchemeInfoId  = entity.Id;
                    modelentity.SchemeVersion = entity.SchemeVersion;
                    _unitWork.Add(modelentity);
                }
                else
                {
                    Guid            schemeid       = Guid.Parse(keyValue);
                    WFSchemeContent modelentityold =
                        _unitWork.FindSingle <WFSchemeContent>(u => u.SchemeVersion == entity.SchemeVersion &&
                                                               u.SchemeInfoId == schemeid);

                    if (modelentityold.SchemeContent != modelentity.SchemeContent)
                    {
                        if (modelentity.SchemeVersion == "cg")
                        {
                            modelentityold.SchemeContent = modelentity.SchemeContent;
                            modelentityold.SchemeVersion = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                            modelentity.SchemeVersion    = modelentityold.SchemeVersion;
                            _unitWork.Update(modelentityold);
                        }
                        else
                        {
                            modelentity.SchemeInfoId  = schemeid;
                            modelentity.SchemeVersion = DateTime.Now.ToString("yyyyMMddHHmmssffff");
                            _unitWork.Add(modelentity);
                        }
                    }
                    else
                    {
                        modelentity.SchemeVersion = modelentityold.SchemeVersion;
                    }
                    entity.Id            = Guid.Parse(keyValue);
                    entity.SchemeVersion = modelentity.SchemeVersion;
                    _unitWork.Update(entity);
                }

                _unitWork.Save();
                return(1);
            }
            catch (Exception)
            {
                throw;
            }
        }
コード例 #3
0
        /// <summary>
        /// 创建一个实例
        /// </summary>
        /// <param name="processId">进程GUID</param>
        /// <param name="schemeInfoId">模板信息ID</param>
        /// <param name="wfLevel"></param>
        /// <param name="code">进程编号</param>
        /// <param name="customName">自定义名称</param>
        /// <param name="description">备注</param>
        /// <param name="frmData">表单数据信息</param>
        /// <returns></returns>
        public bool CreateInstance(Guid processId, Guid schemeInfoId, WFProcessInstance WFProcessInstance, string frmData = null)
        {
            try
            {
                WFSchemeInfo    WFSchemeInfo    = _unitWork.FindSingle <WFSchemeInfo>(u => u.Id == schemeInfoId);
                WFSchemeContent WFSchemeContent = _unitWork.FindSingle <WFSchemeContent>(u =>
                                                                                         u.SchemeInfoId == schemeInfoId && u.SchemeVersion == WFSchemeInfo.SchemeVersion);

                WF_RuntimeInitModel wfRuntimeInitModel = new WF_RuntimeInitModel()
                {
                    schemeContent = WFSchemeContent.SchemeContent,
                    currentNodeId = "",
                    frmData       = frmData,
                    processId     = processId
                };
                IWF_Runtime wfruntime = null;

                if (frmData == null)
                {
                    throw new Exception("自定义表单需要提交表单数据");
                }
                else
                {
                    wfruntime = new WF_Runtime(wfRuntimeInitModel);
                }


                var user = AuthUtil.GetCurrentUser();
                #region 实例信息
                WFProcessInstance.ActivityId     = wfruntime.runtimeModel.nextNodeId;
                WFProcessInstance.ActivityType   = wfruntime.GetStatus();//-1无法运行,0会签开始,1会签结束,2一般节点,4流程运行结束
                WFProcessInstance.ActivityName   = wfruntime.runtimeModel.nextNode.name;
                WFProcessInstance.PreviousId     = wfruntime.runtimeModel.currentNodeId;
                WFProcessInstance.SchemeType     = WFSchemeInfo.SchemeType;
                WFProcessInstance.FrmType        = WFSchemeInfo.FrmType;
                WFProcessInstance.EnabledMark    = 1;//正式运行
                WFProcessInstance.CreateUserId   = user.User.Id.ToString();
                WFProcessInstance.CreateUserName = user.User.Account;
                WFProcessInstance.MakerList      = (wfruntime.GetStatus() != 4 ? GetMakerList(wfruntime) : "");//当前节点可执行的人信息
                WFProcessInstance.IsFinish       = (wfruntime.GetStatus() == 4 ? 1 : 0);
                #endregion

                #region 实例模板
                var data = new
                {
                    SchemeContent = WFSchemeContent.SchemeContent,
                    frmData       = frmData
                };
                WFProcessScheme WFProcessScheme = new WFProcessScheme
                {
                    SchemeInfoId  = schemeInfoId,
                    SchemeVersion = WFSchemeInfo.SchemeVersion,
                    ProcessType   = 1,//1正式,0草稿
                    SchemeContent = data.ToJson().ToString()
                };
                #endregion

                #region 流程操作记录
                WFProcessOperationHistory processOperationHistoryEntity = new WFProcessOperationHistory();
                processOperationHistoryEntity.Content = "【创建】" + user.User.Name + "创建了一个流程进程【" + WFProcessInstance.Code + "/" + WFProcessInstance.CustomName + "】";
                #endregion

                #region 流转记录
                WFProcessTransitionHistory processTransitionHistoryEntity = new WFProcessTransitionHistory();
                processTransitionHistoryEntity.FromNodeId     = wfruntime.runtimeModel.currentNodeId;
                processTransitionHistoryEntity.FromNodeName   = wfruntime.runtimeModel.currentNode.name.Value;
                processTransitionHistoryEntity.FromNodeType   = wfruntime.runtimeModel.currentNodeType;
                processTransitionHistoryEntity.ToNodeId       = wfruntime.runtimeModel.nextNodeId;
                processTransitionHistoryEntity.ToNodeName     = wfruntime.runtimeModel.nextNode.name.Value;
                processTransitionHistoryEntity.ToNodeType     = wfruntime.runtimeModel.nextNodeType;
                processTransitionHistoryEntity.TransitionSate = 0;
                processTransitionHistoryEntity.IsFinish       = (processTransitionHistoryEntity.ToNodeType == 4 ? 1 : 0);
                #endregion

                #region 委托记录
                //List<WFDelegateRecord> delegateRecordEntitylist = GetDelegateRecordList(schemeInfoId, WFProcessInstance.Code, WFProcessInstance.CustomName, WFProcessInstance.MakerList);
                //WFProcessInstance.MakerList += delegateUserList;
                #endregion

                SaveProcess(wfruntime.runtimeModel, WFProcessInstance, WFProcessScheme, processOperationHistoryEntity, processTransitionHistoryEntity);

                return(true);
            }
            catch
            {
                throw;
            }
        }