Esempio n. 1
0
        private void ApplySuccessOne(string workId, string desc, IRepositoryBase db, WorkEntity workEntity, FlowNodeEntity currentNode, ref bool IsEnd)
        {
            FlowNodeEntity nextNode   = GetPassNextNodeId(workId, workEntity.CurrentNodeId, workEntity.FlowVersionId);
            string         nextNodeId = nextNode.Id;
            string         currUsers  = workEntity.CurrentUsers;
            bool           isEndNode  = nextNode.IsEndNode;

            AddApproProcess(workId, desc, ApprovalStatus.Pass, currentNode, db);
            if (!isEndNode)
            {
                bool   isNeedSkip = false;
                string userIds    = GetCurrentUserIds(nextNode, currUsers, out isNeedSkip);
                nextNodeId = nextNode.Id;
                if (isNeedSkip && !nextNode.IsEndNode)
                {
                    nextNodeId = SkipNode(workId, workEntity.CurrentNodeId, nextNode, workEntity.FlowVersionId, db, out userIds, out isEndNode);
                }
                if (!string.IsNullOrEmpty(userIds))
                {
                    workEntity.CurrentUsers = userIds;
                }
                if (!string.IsNullOrEmpty(nextNodeId))
                {
                    workEntity.CurrentNodeId = nextNodeId;
                }
                workEntity.FlowStatus = (int)WorkStatus.Applying;
            }
            if (isEndNode)
            {
                IsEnd = true;
                workEntity.FlowStatus = (int)WorkStatus.Success;
                AddEndApproProcess(workId, nextNode, db);
            }
            AddCcSuccess(workId, nextNodeId, currUsers, db);
        }
Esempio n. 2
0
 private FlowNodeEntity GetNextNodeId(string workId, ApprovalStatus approvalStatus, RejectType rejectType = RejectType.Last)
 {
     try
     {
         FlowNodeEntity nextNode = new FlowNodeEntity();
         using (var db = new RepositoryBase())
         {
             WorkEntity workEntity = db.FindEntity <WorkEntity>(m => m.Id == workId);
             if (workEntity != null && !string.IsNullOrEmpty(workEntity.Id))
             {
                 if (approvalStatus == ApprovalStatus.Pass)
                 {
                     if (string.IsNullOrEmpty(workEntity.CurrentNodeId))
                     {
                         FlowNodeEntity flowNodeEntity = db.FindEntity <FlowNodeEntity>(m => m.IsStartNode == true && m.FlowVersionId == workEntity.FlowVersionId);
                         if (flowNodeEntity != null && !string.IsNullOrEmpty(flowNodeEntity.Id))
                         {
                             workEntity.CurrentNodeId = flowNodeEntity.Id;
                         }
                     }
                     nextNode = GetNextNodeIdPass(workId, workEntity.CurrentNodeId, workEntity.FlowVersionId);
                 }
             }
         }
         return(nextNode);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 3
0
        private void AddCcFail(string workId, string nodeId, string currUserId, IRepositoryBase db)
        {
            FlowNodeEntity node = db.FindEntity <FlowNodeEntity>(m => m.Id == nodeId);

            if (node != null && !string.IsNullOrWhiteSpace(node.Id))
            {
                string ccUserIds = GetCurrentCcUserIds(node, currUserId);
                if (ccUserIds != null && !string.IsNullOrWhiteSpace(ccUserIds))
                {
                    List <string> ccUserIdslst = ccUserIds.Split(',').ToList();
                    ccUserIdslst.ForEach(delegate(string ccUserId)
                    {
                        ApprovalCcsEntity appproccEntity = new ApprovalCcsEntity();
                        appproccEntity.Create();
                        appproccEntity.WorkId         = workId;
                        appproccEntity.CcUserId       = ccUserId;
                        appproccEntity.NodeId         = nodeId;
                        appproccEntity.ApprovalUserId = currUserId;
                        appproccEntity.ApprovalStatus = (int)ApprovalStatus.Pass;
                        appproccEntity.IsViewed       = false;
                        var LoginInfo = OperatorProvider.Provider.GetCurrent();
                        if (LoginInfo != null)
                        {
                            appproccEntity.CreatorUserId = LoginInfo.UserId;
                        }
                        db.Insert(appproccEntity);
                    });
                }
            }
        }
Esempio n. 4
0
        private string SkipNode(string workId, string curentUser, FlowNodeEntity selNextNode,
                                string flowVersionId, IRepositoryBase db, out string userIds, out bool isEnd)
        {
            isEnd   = false;
            userIds = string.Empty;
            string nextNodeId = string.Empty;

            AddSkipProcess(workId, selNextNode, db);
            FlowNodeEntity nextNode = GetPassNextNodeId(workId, selNextNode.Id, flowVersionId);

            if (nextNode == null || string.IsNullOrEmpty(nextNode.Id))
            {
                throw new Exception("当前审批下一流程节点不存在,请联系管理员!");
            }
            isEnd = nextNode.IsEndNode;
            if (!isEnd)
            {
                bool isNeedSkip = false;
                userIds    = GetCurrentUserIds(nextNode, curentUser, out isNeedSkip);
                nextNodeId = nextNode.Id;
                if (isNeedSkip && !nextNode.IsEndNode)
                {
                    nextNodeId = SkipNode(workId, curentUser, nextNode, flowVersionId, db, out userIds, out isEnd);
                }
            }
            return(nextNodeId);
        }
Esempio n. 5
0
 private FlowNodeEntity GetCurrentNode(string workId)
 {
     try
     {
         FlowNodeEntity currentNode = new FlowNodeEntity();
         using (var db = new RepositoryBase())
         {
             WorkEntity workEntity = db.FindEntity <WorkEntity>(m => m.Id == workId);
             if (workEntity != null && !string.IsNullOrEmpty(workEntity.Id))
             {
                 if (string.IsNullOrEmpty(workEntity.CurrentNodeId))
                 {
                     currentNode = db.FindEntity <FlowNodeEntity>(m => m.FlowVersionId == workEntity.FlowVersionId && m.IsStartNode == true);
                 }
                 else
                 {
                     currentNode = db.FindEntity <FlowNodeEntity>(m => m.Id == workEntity.CurrentNodeId);
                 }
             }
         }
         return(currentNode);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 6
0
 private void AddSkipProcess(string workId, FlowNodeEntity node, IRepositoryBase db)
 {
     if (node != null && !string.IsNullOrEmpty(node.Id))
     {
         ApprovalProcessEntity appproEntity = new ApprovalProcessEntity();
         appproEntity.Create();
         appproEntity.WorkId         = workId;
         appproEntity.ApprovalStatus = (int)ApprovalStatus.Pass;
         appproEntity.NodeId         = node.Id;
         appproEntity.NodeName       = node.Name;
         appproEntity.Description    = string.Empty;
         appproEntity.IsStart        = false;
         appproEntity.IsEnd          = false;
         appproEntity.IsSkip         = true;
         var LoginInfo = OperatorProvider.Provider.GetCurrent();
         if (LoginInfo != null)
         {
             appproEntity.ApprovalUserId   = LoginInfo.UserId;
             appproEntity.ApprovalUserName = LoginInfo.UserName;
         }
         db.Insert(appproEntity);
     }
     else
     {
         throw new Exception("当前节点异常!");
     }
 }
Esempio n. 7
0
 public void Start(string workId, ref bool IsEnd)
 {
     try
     {
         string userId    = string.Empty;
         var    LoginInfo = OperatorProvider.Provider.GetCurrent();
         if (LoginInfo != null)
         {
             userId = LoginInfo.UserId;
         }
         using (var db = new RepositoryBase().BeginTrans())
         {
             WorkEntity workEntity = db.FindEntity <WorkEntity>(m => m.Id == workId);
             if (workEntity != null && !string.IsNullOrEmpty(workEntity.Id))
             {
                 if (workEntity.FlowStatus != (int)WorkStatus.Save)
                 {
                     throw new Exception("当前流程已进行申请,无法重复提交申请!");
                 }
                 AddStartApproProcess(workId, db);
                 workEntity.Modify(workEntity.Id);
                 workEntity.FlowStatus = (int)WorkStatus.Applying;
                 FlowNodeEntity nextNode = GetPassNextNodeId(workId, workEntity.CurrentNodeId, workEntity.FlowVersionId);
                 if (nextNode == null || string.IsNullOrEmpty(nextNode.Id))
                 {
                     throw new Exception("当前审批下一流程节点不存在,请联系管理员!");
                 }
                 bool isEndNode = nextNode.IsEndNode;
                 if (!isEndNode)
                 {
                     bool   isNeedSkip = false;
                     string userIds    = GetCurrentUserIds(nextNode, userId, out isNeedSkip);
                     string nextNodeId = nextNode.Id;
                     if (isNeedSkip && !nextNode.IsEndNode)
                     {
                         nextNodeId = SkipNode(workId, workEntity.CurrentNodeId, nextNode, workEntity.FlowVersionId, db, out userIds, out isEndNode);
                     }
                     workEntity.CurrentNodeId = nextNodeId;
                     if (!string.IsNullOrEmpty(userIds))
                     {
                         workEntity.CurrentUsers = userIds;
                     }
                 }
                 if (isEndNode)
                 {
                     IsEnd = true;
                     workEntity.FlowStatus = (int)WorkStatus.Success;
                     AddEndApproProcess(workId, nextNode, db);
                 }
                 AddCcSuccess(workId, nextNode.Id, userId, db);
                 db.Update(workEntity);
                 db.Commit();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 8
0
 private FlowNodeEntity GetNextNodeIdFail(string workId, string CurrentNodeId, string flowVersionId)
 {
     try
     {
         FlowNodeEntity nextNode = new FlowNodeEntity();
         using (var db = new RepositoryBase())
         {
             FlowNodeEntity flowNodeEntity = db.FindEntity <FlowNodeEntity>(m => m.Id == CurrentNodeId);
             if (flowNodeEntity != null && !string.IsNullOrEmpty(flowNodeEntity.Id))
             {
                 List <FlowLineEntity> flowLines = db.IQueryable <FlowLineEntity>(m => m.FlowVersionId == flowVersionId && m.FromNode == flowNodeEntity.MarkName).ToList();
                 if (flowLines != null && flowLines.Count > 0)
                 {
                     if (flowLines.Count == 1)
                     {
                         string         markName        = flowLines[0].FromNode;
                         FlowNodeEntity flowNodeEntityT = db.FindEntity <FlowNodeEntity>(m => m.FlowVersionId == flowVersionId && m.MarkName == markName);
                         if (flowNodeEntityT != null && !string.IsNullOrEmpty(flowNodeEntityT.Id))
                         {
                             nextNode = flowNodeEntityT;
                         }
                     }
                     else
                     {
                         foreach (FlowLineEntity flowline in flowLines)
                         {
                             bool bresult = JudgmentPlot(workId, flowline.PlotType, flowline.Plot);
                             if (bresult)
                             {
                                 string         markName        = flowline.FromNode;
                                 FlowNodeEntity flowNodeEntityT = db.FindEntity <FlowNodeEntity>(m => m.FlowVersionId == flowVersionId && m.MarkName == markName);
                                 if (flowNodeEntityT != null && !string.IsNullOrEmpty(flowNodeEntityT.Id))
                                 {
                                     nextNode = flowNodeEntityT;
                                 }
                                 break;
                             }
                         }
                     }
                 }
             }
         }
         bool bIsSkip = IsSkipLastNode(workId, nextNode.Id);
         if (bIsSkip)
         {
             nextNode = GetNextNodeIdFail(workId, nextNode.Id, flowVersionId);
         }
         return(nextNode);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 9
0
        public FlowNodeEntity GetNode(string flowId, string markName)
        {
            FlowNodeEntity    flowNodeModel    = new FlowNodeEntity();
            FlowVersionEntity flowVersionModel = GetNewFlowVersion(flowId);

            if (flowVersionModel != null && !string.IsNullOrEmpty(flowVersionModel.Id))
            {
                using (var db = new RepositoryBase())
                {
                    flowNodeModel = db.IQueryable <FlowNodeEntity>(m => m.FlowVersionId == flowVersionModel.Id && m.MarkName == markName).FirstOrDefault();
                }
            }
            return(flowNodeModel);
        }
Esempio n. 10
0
        private FlowNodeEntity GetFailNextNodeId(string workId, out bool isFail)
        {
            try
            {
                isFail = false;
                FlowNodeEntity nextNode = new FlowNodeEntity();
                using (var db = new RepositoryBase())
                {
                    WorkEntity workEntity = db.FindEntity <WorkEntity>(m => m.Id == workId);
                    if (workEntity != null && !string.IsNullOrEmpty(workEntity.Id))
                    {
                        if (!string.IsNullOrEmpty(workEntity.CurrentNodeId))
                        {
                            FlowNodeEntity flowNodeEntity = db.FindEntity <FlowNodeEntity>(m => m.Id == workEntity.CurrentNodeId);
                            if (flowNodeEntity != null && !string.IsNullOrEmpty(flowNodeEntity.Id))
                            {
                                switch (flowNodeEntity.RejectType)
                                {
                                case (int)RejectType.End:
                                    isFail = true;
                                    break;

                                case (int)RejectType.Last:
                                    nextNode = GetNextNodeIdFail(workId, workEntity.CurrentNodeId, workEntity.FlowVersionId);
                                    break;

                                case (int)RejectType.Specified:
                                    nextNode = db.IQueryable <FlowNodeEntity>(m => m.FlowVersionId == workEntity.FlowVersionId && m.MarkName == flowNodeEntity.RejectNode).FirstOrDefault();
                                    break;

                                default:
                                    throw new Exception("当前节点驳回配置异常!");
                                }
                            }
                        }
                        else
                        {
                            throw new Exception("当前节点异常!");
                        }
                    }
                }
                return(nextNode);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 11
0
        private async Task <FlowNodeEntity> CreateFlowNodeAsync(string flowNodeId, string flowNodeName, ProcessItemType processType, string ProcessId, int?parentFlowId = null)
        {
            FlowNodeEntity flowNode = new FlowNodeEntity()
            {
                FlowNodeId = flowNodeId,
                Name       = flowNodeName,
                ItemType   = processType,
                ParentId   = parentFlowId,
                Processid  = ProcessId
            };

            flowNodeStore.Create(flowNode);
            await SaveChangesAsync();

            return(flowNode);
        }
Esempio n. 12
0
        private string GetApplyUserByNode(FlowNodeEntity node, string workId)
        {
            string userId = string.Empty;

            if (node != null && !string.IsNullOrWhiteSpace(node.Id))
            {
                using (var db = new RepositoryBase())
                {
                    ApprovalProcessEntity approvalProcessEntity = db.IQueryable <ApprovalProcessEntity>(m => m.WorkId == workId &&
                                                                                                        m.DeleteMark != true &&
                                                                                                        m.EnabledMark == true &&
                                                                                                        m.NodeId == node.Id).OrderByDescending(m => m.CreatorTime).FirstOrDefault();
                    userId = approvalProcessEntity?.ApprovalUserId;
                }
            }
            return(userId);
        }
Esempio n. 13
0
        private async Task SaveAllFlowNodeAsync(int deploymentId, int processNodeId, tProcess process, Dictionary <string, int> itemKeys, string tenantId)
        {
            // Get all tFlowNode
            foreach (var flowNode in process.Items.OfType <tFlowNode>())
            {
                // Get All Process Flow Node
                FlowNodeEntity node = await CreateFlowNodeAsync(flowNode.id, flowNode.name, ProcessItem.GetProcessType(flowNode), process.id, processNodeId);

                itemKeys.Add(flowNode.id, node.Id);

                // Get Sub Process
                if (ProcessItem.IsSubProcess(flowNode))
                {
                    await SaveSubProcess(deploymentId, flowNode as tSubProcess, process, node, tenantId);
                }
            }
        }
Esempio n. 14
0
 public void ApplyFail(string workId, string desc)
 {
     try
     {
         using (var db = new RepositoryBase().BeginTrans())
         {
             WorkEntity workEntity = db.FindEntity <WorkEntity>(m => m.Id == workId);
             if (workEntity != null && !string.IsNullOrEmpty(workEntity.Id))
             {
                 workEntity.Modify(workEntity.Id);
                 FlowLineEntity flowLineEntity = new FlowLineEntity();
                 FlowNodeEntity currentNode    = db.FindEntity <FlowNodeEntity>(m => m.Id == workEntity.CurrentNodeId);
                 FlowNodeEntity nextNode       = GetNextNodeId(workId, ApprovalStatus.Pass, ref flowLineEntity);
                 if (nextNode != null && !string.IsNullOrEmpty(nextNode.Id))
                 {
                     workEntity.CurrentNodeId = nextNode.Id;
                 }
                 else
                 {
                     workEntity.CurrentNodeId = string.Empty;
                 }
                 string userIds = GetCurrentUserIds(nextNode);
                 if (!string.IsNullOrEmpty(userIds))
                 {
                     workEntity.CurrentUsers = userIds;
                 }
                 if (currentNode.RejectType == (int)RejectType.End)
                 {
                     workEntity.FlowStatus = (int)WorkStatus.Fail;
                     AddEndApproProcess(workId, nextNode, db);
                 }
                 else
                 {
                     workEntity.FlowStatus = (int)WorkStatus.Applying;
                 }
                 AddApproProcess(workId, desc, ApprovalStatus.Fail, currentNode, db);
                 db.Update(workEntity);
                 db.Commit();
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 15
0
        private string GetCurrentUserIds(FlowNodeEntity nextNode)
        {
            string userIds = string.Empty;

            if (nextNode.ReviewerType == (int)ReviewerType.Specified)
            {
                userIds = nextNode.ReviewerUser;
            }
            else
            if (nextNode.ReviewerType == (int)ReviewerType.Post)
            {
                if (!string.IsNullOrEmpty(nextNode.ReviewerOrg))
                {
                    List <string> orgIds = nextNode.ReviewerOrg.Split(',').ToList();
                    if (orgIds != null && orgIds.Count > 0)
                    {
                        List <UserEntity> userModels = new List <UserEntity>();
                        using (var db = new RepositoryBase())
                        {
                            List <string> useridsTemp = new List <string>();
                            foreach (var orgId in orgIds)
                            {
                                userModels = db.IQueryable <UserEntity>(m => m.OrganizeId == orgId && m.DeleteMark != true && m.EnabledMark == true).ToList();
                                if (userModels != null && userModels.Count > 0)
                                {
                                    string[] userids  = userModels.Select(m => m.Id).ToArray();
                                    string   strusers = string.Join(",", userids);
                                    useridsTemp.Add(strusers);
                                }
                            }
                            if (useridsTemp != null && useridsTemp.Count > 0)
                            {
                                userIds = string.Join(",", useridsTemp.ToArray());
                            }
                        }
                    }
                }
            }
            else
            if (nextNode.ReviewerType == (int)ReviewerType.Last)
            {
            }
            return(userIds);
        }
Esempio n. 16
0
        private void AddEndApproProcess(string workId, FlowNodeEntity node, IRepositoryBase db)
        {
            ApprovalProcessEntity appproEntity = new ApprovalProcessEntity();

            appproEntity.Create();
            appproEntity.WorkId         = workId;
            appproEntity.ApprovalStatus = (int)ApprovalStatus.Pass;
            appproEntity.NodeId         = node.Id;
            appproEntity.NodeName       = node.Name;
            appproEntity.IsStart        = false;
            appproEntity.IsEnd          = true;
            var LoginInfo = OperatorProvider.Provider.GetCurrent();

            if (LoginInfo != null)
            {
                appproEntity.ApprovalUserId   = LoginInfo.UserId;
                appproEntity.ApprovalUserName = LoginInfo.UserName;
            }
            db.Insert(appproEntity);
        }
Esempio n. 17
0
        private async Task SaveSubProcess(int deploymentId, tSubProcess subProcess, tProcess process, FlowNodeEntity node, string tenantId)
        {
            Dictionary <string, int> itemKeys = new Dictionary <string, int>();

            //SaveProcessDefinition
            await SaveProcessDefinitionAsync(deploymentId, node.Id, subProcess.id, subProcess.name, process.isClosed, process.isExecutable, tenantId);

            // Get Sub Process Flow Node
            foreach (var subProcessItem in subProcess.Items1.OfType <tFlowNode>())
            {
                FlowNodeEntity subNode = await CreateFlowNodeAsync(subProcessItem.id, subProcessItem.name, ProcessItem.GetProcessType(subProcessItem), subProcess.id, node.Id);

                itemKeys.Add(subProcessItem.id, subNode.Id);
            }

            // Get Sub Process Sequence Flow
            foreach (var sequenceFlow in subProcess.Items1.OfType <tSequenceFlow>())
            {
                // Save Sub Process Sequence Flow
                await CreateSequenceFlowAsync(sequenceFlow, itemKeys);
            }
        }
Esempio n. 18
0
 private FlowNodeEntity GetPassNextNodeId(string workId, string currentNodeId, string flowVersionId)
 {
     try
     {
         FlowNodeEntity nextNode = new FlowNodeEntity();
         using (var db = new RepositoryBase())
         {
             if (string.IsNullOrEmpty(currentNodeId))
             {
                 FlowNodeEntity flowNodeEntity = db.FindEntity <FlowNodeEntity>(m => m.IsStartNode == true && m.FlowVersionId == flowVersionId);
                 if (flowNodeEntity != null && !string.IsNullOrEmpty(flowNodeEntity.Id))
                 {
                     currentNodeId = flowNodeEntity.Id;
                 }
             }
             nextNode = GetNextNodeIdPass(workId, currentNodeId, flowVersionId);
         }
         return(nextNode);
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 19
0
        private async Task SaveProcessAsync(int deploymentId, IEnumerable <tProcess> processes, string tenantId)
        {
            Dictionary <string, int> itemKeys = new Dictionary <string, int>();

            foreach (var process in processes)
            {
                FlowNodeEntity ProcessNode = await CreateFlowNodeAsync(process.id, process.name, ProcessItemType.Process, process.id);

                itemKeys.Add(process.id, ProcessNode.Id);

                //SaveProcessDefinition
                await SaveProcessDefinitionAsync(deploymentId, ProcessNode.Id, process.id, process.name, process.isClosed, process.isExecutable, tenantId);

                // SaveAllFlowNodeAsync
                await SaveAllFlowNodeAsync(deploymentId, ProcessNode.Id, process, itemKeys, tenantId);

                // Get Process Sequence Flow
                foreach (var sequenceFlow in process.Items.OfType <tSequenceFlow>())
                {
                    // Save Sub Process Sequence Flow
                    await CreateSequenceFlowAsync(sequenceFlow, itemKeys);
                }
            }
        }
Esempio n. 20
0
        private static void GenFlowNodes(FlowVersionEntity flowVersionEntity, KeyValuePair <string, JToken> item)
        {
            if (flowVersionEntity.Nodes == null)
            {
                flowVersionEntity.Nodes = new List <FlowNodeEntity>();
            }
            JObject objnode = JObject.Parse(item.Value.ToString());

            if (objnode != null)
            {
                foreach (KeyValuePair <string, JToken> itemnode in objnode)
                {
                    FlowNodeEntity flowNode = new FlowNodeEntity();
                    flowNode.Id          = Guid.NewGuid().ToString();
                    flowNode.MarkName    = itemnode.Key.ToString();
                    flowNode.Marked      = false;
                    flowNode.IsStartNode = false;
                    flowNode.IsEndNode   = false;
                    JObject objnodeitem = JObject.Parse(itemnode.Value.ToString());
                    if (objnodeitem != null)
                    {
                        foreach (KeyValuePair <string, JToken> itemnodeitem in objnodeitem)
                        {
                            if (itemnodeitem.Key == "name")
                            {
                                flowNode.Name = itemnodeitem.Value.ToString();
                            }
                            if (itemnodeitem.Key == "left")
                            {
                                flowNode.Left = (int)itemnodeitem.Value;
                            }
                            if (itemnodeitem.Key == "top")
                            {
                                flowNode.Top = (int)itemnodeitem.Value;
                            }
                            if (itemnodeitem.Key == "width")
                            {
                                flowNode.Width = (int)itemnodeitem.Value;
                            }
                            if (itemnodeitem.Key == "height")
                            {
                                flowNode.Height = (int)itemnodeitem.Value;
                            }
                            if (itemnodeitem.Key == "type")
                            {
                                flowNode.TypeName = itemnodeitem.Value.ToString();
                            }
                            if (itemnodeitem.Key == "steptype")
                            {
                                flowNode.StepType = (int)itemnodeitem.Value;
                            }
                            if (itemnodeitem.Key == "rejecttype")
                            {
                                flowNode.RejectType = (int)itemnodeitem.Value;
                            }
                            if (itemnodeitem.Key == "rejectnode")
                            {
                                flowNode.RejectNode = itemnodeitem.Value.ToString();
                            }
                            if (itemnodeitem.Key == "reviewertype")
                            {
                                flowNode.ReviewerType = (int)itemnodeitem.Value;
                            }
                            if (itemnodeitem.Key == "reviewerusers")
                            {
                                flowNode.ReviewerUser = itemnodeitem.Value.ToString();
                            }
                            if (itemnodeitem.Key == "reviewerorgs")
                            {
                                flowNode.ReviewerOrg = itemnodeitem.Value.ToString();
                            }
                            if (itemnodeitem.Key == "cctype")
                            {
                                flowNode.CcType = (int)itemnodeitem.Value;
                            }
                            if (itemnodeitem.Key == "ccusers")
                            {
                                flowNode.CcUser = itemnodeitem.Value.ToString();
                            }
                            if (itemnodeitem.Key == "ccorgs")
                            {
                                flowNode.CcOrg = itemnodeitem.Value.ToString();
                            }
                            if (itemnodeitem.Key == "messagetype")
                            {
                                flowNode.MessageType = (int)itemnodeitem.Value;
                            }
                            if (itemnodeitem.Key == "isstart")
                            {
                                flowNode.IsStartNode = (bool)itemnodeitem.Value;
                            }
                            if (itemnodeitem.Key == "isend")
                            {
                                flowNode.IsEndNode = (bool)itemnodeitem.Value;
                            }
                        }
                    }
                    flowVersionEntity.Nodes.Add(flowNode);
                }
            }
        }
Esempio n. 21
0
        private FlowNodeEntity GetNextNodeId(string workId, ApprovalStatus approvalStatus, ref FlowLineEntity flowLineEntity, RejectType rejectType = RejectType.Last)
        {
            try
            {
                FlowNodeEntity nextNode = new FlowNodeEntity();
                using (var db = new RepositoryBase())
                {
                    WorkEntity workEntity = db.FindEntity <WorkEntity>(m => m.Id == workId);
                    if (workEntity != null && !string.IsNullOrEmpty(workEntity.Id))
                    {
                        if (approvalStatus == ApprovalStatus.Pass)
                        {
                            if (string.IsNullOrEmpty(workEntity.CurrentNodeId))
                            {
                                FlowNodeEntity flowNodeEntity = db.FindEntity <FlowNodeEntity>(m => m.IsStartNode == true && m.FlowVersionId == workEntity.FlowVersionId);
                                if (flowNodeEntity != null && !string.IsNullOrEmpty(flowNodeEntity.Id))
                                {
                                    workEntity.CurrentNodeId = flowNodeEntity.Id;
                                }
                            }
                            nextNode = GetNextNodeIdPass(workId, workEntity.CurrentNodeId, workEntity.FlowVersionId, ref flowLineEntity);
                        }
                        else
                        if (approvalStatus == ApprovalStatus.Fail)
                        {
                            if (!string.IsNullOrEmpty(workEntity.CurrentNodeId))
                            {
                                FlowNodeEntity flowNodeEntity = db.FindEntity <FlowNodeEntity>(m => m.Id == workEntity.CurrentNodeId);
                                if (flowNodeEntity != null && !string.IsNullOrEmpty(flowNodeEntity.Id))
                                {
                                    switch (flowNodeEntity.RejectType)
                                    {
                                    case (int)RejectType.Reviewer:
                                        FlowNodeEntity startflowNodeEntity = db.FindEntity <FlowNodeEntity>(m => m.IsStartNode == true && m.FlowVersionId == workEntity.FlowVersionId);
                                        if (flowNodeEntity != null && !string.IsNullOrEmpty(flowNodeEntity.Id))
                                        {
                                            workEntity.CurrentNodeId = flowNodeEntity.Id;
                                        }
                                        nextNode = GetNextNodeIdPass(workId, workEntity.CurrentNodeId, workEntity.FlowVersionId, ref flowLineEntity);
                                        break;

                                    case (int)RejectType.Last:
                                        nextNode = GetNextNodeIdFail(workId, workEntity.CurrentNodeId, workEntity.FlowVersionId, ref flowLineEntity);
                                        break;

                                    case (int)RejectType.Specified:
                                        break;

                                    default:
                                        throw new Exception("当前节点驳回配置异常!");
                                    }
                                }
                            }
                            else
                            {
                                throw new Exception("当前节点异常!");
                            }
                        }
                    }
                }
                return(nextNode);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 22
0
 private void ApplyFail(string workId, string desc)
 {
     try
     {
         string applyUserId = string.Empty;
         var    loguser     = OperatorProvider.Provider.GetCurrent();
         if (loguser != null)
         {
             applyUserId = loguser.UserId;
         }
         else
         {
             throw new Exception("当前用户信息异常!");
         }
         using (var db = new RepositoryBase().BeginTrans())
         {
             WorkEntity workEntity = db.FindEntity <WorkEntity>(m => m.Id == workId);
             if (workEntity != null && !string.IsNullOrEmpty(workEntity.Id))
             {
                 if (!workEntity.CurrentUsers.Contains(applyUserId))
                 {
                     throw new Exception("当前用户无权限审核此流程!");
                 }
                 if (workEntity.FlowStatus != (int)WorkStatus.Applying)
                 {
                     throw new Exception("当前审批状态不能进行审核!");
                 }
                 workEntity.Modify(workEntity.Id);
                 FlowNodeEntity currentNode = db.FindEntity <FlowNodeEntity>(m => m.Id == workEntity.CurrentNodeId);
                 bool           isFail      = false;
                 FlowNodeEntity lastNode    = GetFailNextNodeId(workId, out isFail);
                 if (isFail)
                 {
                     AddApproProcess(workId, desc, ApprovalStatus.Fail, currentNode, db);
                     workEntity.FlowStatus = (int)WorkStatus.Fail;
                     AddEndApproProcess(workId, lastNode, db);
                 }
                 else
                 {
                     if (lastNode != null && !string.IsNullOrEmpty(lastNode.Id))
                     {
                         workEntity.CurrentNodeId = lastNode.Id;
                         string lastUserId = GetApplyUserByNode(lastNode, workId);
                         bool   isNeedSkip = false;
                         string userIds    = GetCurrentUserIds(lastNode, lastUserId, out isNeedSkip);
                         if (!string.IsNullOrEmpty(userIds))
                         {
                             workEntity.CurrentUsers = userIds;
                         }
                         workEntity.FlowStatus = (int)WorkStatus.Applying;
                         AddApproProcess(workId, desc, ApprovalStatus.Fail, currentNode, db);
                     }
                     else
                     {
                         throw new Exception("当前节点驳回配置异常,请联系管理员!");
                     }
                 }
                 AddCcFail(workId, lastNode.Id, applyUserId, db);
                 db.Update(workEntity);
                 db.Commit();
             }
             else
             {
                 throw new Exception("获取当前流程信息异常!");
             }
         }
     }
     catch (Exception ex)
     {
         throw ex;
     }
 }
Esempio n. 23
0
        private string GetCurrentCcUserIds(FlowNodeEntity nextNode, string currUser)
        {
            string userIds = string.Empty;

            if (nextNode.CcType == (int)CcType.Specified)
            {
                userIds = nextNode.CcUser;
            }
            else
            if (nextNode.CcType == (int)CcType.Post)
            {
                if (!string.IsNullOrEmpty(nextNode.CcOrg))
                {
                    List <string> orgIds = nextNode.CcOrg.Split(',').ToList();
                    if (orgIds != null && orgIds.Count > 0)
                    {
                        List <UserEntity> userModels = new List <UserEntity>();
                        using (var db = new RepositoryBase())
                        {
                            List <string> useridsTemp = new List <string>();
                            foreach (var orgId in orgIds)
                            {
                                userModels = db.IQueryable <UserEntity>(m => m.OrganizeId == orgId && m.DeleteMark != true && m.EnabledMark == true).ToList();
                                if (userModels != null && userModels.Count > 0)
                                {
                                    string[] userids  = userModels.Select(m => m.Id).ToArray();
                                    string   strusers = string.Join(",", userids);
                                    useridsTemp.Add(strusers);
                                }
                            }
                            if (useridsTemp != null && useridsTemp.Count > 0)
                            {
                                userIds = string.Join(",", useridsTemp.ToArray());
                            }
                        }
                    }
                }
            }
            else if (nextNode.CcType == (int)CcType.Last)
            {
                using (var db = new RepositoryBase())
                {
                    UserEntity userEntity = db.IQueryable <UserEntity>(m => m.Id == currUser && m.DeleteMark != true && m.EnabledMark == true).FirstOrDefault();
                    if (userEntity != null && !string.IsNullOrWhiteSpace(userEntity.Id))
                    {
                        OrganizeEntity organizeEntity = db.IQueryable <OrganizeEntity>(m => m.Id == userEntity.DepartmentId && m.DeleteMark != true && m.EnabledMark == true).FirstOrDefault();
                        if (organizeEntity == null ||
                            string.IsNullOrWhiteSpace(organizeEntity.Id) ||
                            string.IsNullOrWhiteSpace(organizeEntity.ManagerId))
                        {
                            throw new Exception("上一级审批人未配置,请联系管理员!");
                        }
                        if (organizeEntity?.ManagerId == currUser)
                        {
                            organizeEntity = db.IQueryable <OrganizeEntity>(m => m.Id == organizeEntity.ParentId && m.DeleteMark != true && m.EnabledMark == true).FirstOrDefault();
                        }
                        userIds = organizeEntity?.ManagerId;
                    }
                }
            }
            return(userIds);
        }
Esempio n. 24
0
        private void ApplySuccess(string workId, string desc, ref bool IsEnd)
        {
            try
            {
                string applyUserId = string.Empty;
                var    loguser     = OperatorProvider.Provider.GetCurrent();
                if (loguser != null)
                {
                    applyUserId = loguser.UserId;
                }
                else
                {
                    throw new Exception("当前用户信息异常!");
                }
                using (var db = new RepositoryBase().BeginTrans())
                {
                    WorkEntity workEntity = db.FindEntity <WorkEntity>(m => m.Id == workId);
                    if (workEntity != null && !string.IsNullOrEmpty(workEntity.Id))
                    {
                        if (!workEntity.CurrentUsers.Contains(applyUserId))
                        {
                            throw new Exception("当前用户无权限审核此流程!");
                        }
                        if (workEntity.FlowStatus != (int)WorkStatus.Applying)
                        {
                            throw new Exception("当前审批状态不能进行审核!");
                        }
                        workEntity.Modify(workEntity.Id);
                        FlowNodeEntity currentNode = db.FindEntity <FlowNodeEntity>(m => m.Id == workEntity.CurrentNodeId);
                        if (currentNode != null && !string.IsNullOrEmpty(currentNode.Id))
                        {
                            if (currentNode.StepType == (int)StepType.One)
                            {
                                ApplySuccessOne(workId, desc, db, workEntity, currentNode, ref IsEnd);
                            }
                            else
                            {
                                string[] strUsers = workEntity.CurrentUsers.Split(',');
                                if (strUsers != null && strUsers.Length == 1)
                                {
                                    ApplySuccessOne(workId, desc, db, workEntity, currentNode, ref IsEnd);
                                }
                                else
                                {
                                    string[] strUsersNew = strUsers?.Where(m => m != applyUserId)?.ToArray();
                                    if (strUsersNew != null && strUsersNew.Length > 0)
                                    {
                                        workEntity.CurrentUsers = string.Join(",", strUsersNew.ToArray());
                                        AddApproProcess(workId, desc, ApprovalStatus.Pass, currentNode, db);

                                        AddCcSuccess(workId, workEntity.CurrentNodeId, applyUserId, db);
                                    }
                                }
                            }
                        }
                        else
                        {
                            throw new Exception("获取当前流程节点异常!");
                        }
                        db.Update(workEntity);
                        db.Commit();
                    }
                    else
                    {
                        throw new Exception("获取当前流程信息异常!");
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }