Esempio n. 1
0
 public void UpdateLine(FlowLineEntity flowLine)
 {
     using (var db = new RepositoryBase().BeginTrans())
     {
         db.Update(flowLine);
         db.Commit();
     }
 }
Esempio n. 2
0
        private static void GenFlowLines(FlowVersionEntity flowVersionEntity, KeyValuePair <string, JToken> item)
        {
            if (flowVersionEntity.Lines == null)
            {
                flowVersionEntity.Lines = new List <FlowLineEntity>();
            }
            JObject objnode = JObject.Parse(item.Value.ToString());

            if (objnode != null)
            {
                foreach (KeyValuePair <string, JToken> itemnode in objnode)
                {
                    FlowLineEntity flowLine = new FlowLineEntity();
                    flowLine.Id       = Guid.NewGuid().ToString();
                    flowLine.MarkName = itemnode.Key.ToString();
                    flowLine.Marked   = false;
                    JObject objnodeitem = JObject.Parse(itemnode.Value.ToString());
                    if (objnodeitem != null)
                    {
                        foreach (KeyValuePair <string, JToken> itemnodeitem in objnodeitem)
                        {
                            if (itemnodeitem.Key == "name")
                            {
                                flowLine.Name = itemnodeitem.Value.ToString();
                            }
                            if (itemnodeitem.Key == "from")
                            {
                                flowLine.FromNode = itemnodeitem.Value.ToString();
                            }
                            if (itemnodeitem.Key == "to")
                            {
                                flowLine.ToNode = itemnodeitem.Value.ToString();
                            }
                            if (itemnodeitem.Key == "type")
                            {
                                flowLine.TypeName = itemnodeitem.Value.ToString();
                            }
                            if (itemnodeitem.Key == "strategiestype")
                            {
                                flowLine.PlotType = (int)itemnodeitem.Value;
                            }
                            if (itemnodeitem.Key == "plot")
                            {
                                flowLine.Plot = itemnodeitem.Value.ToString();
                            }
                            if (itemnodeitem.Key == "sqlplot")
                            {
                                flowLine.SqlPlot = itemnodeitem.Value.ToString();
                            }
                        }
                    }
                    flowVersionEntity.Lines.Add(flowLine);
                }
            }
        }
Esempio n. 3
0
        public FlowLineEntity GetLine(string flowId, string markName)
        {
            FlowLineEntity    flowLineModel    = new FlowLineEntity();
            FlowVersionEntity flowVersionModel = GetNewFlowVersion(flowId);

            if (flowVersionModel != null && !string.IsNullOrEmpty(flowVersionModel.Id))
            {
                using (var db = new RepositoryBase())
                {
                    flowLineModel = db.IQueryable <FlowLineEntity>(m => m.FlowVersionId == flowVersionModel.Id && m.MarkName == markName).FirstOrDefault();
                }
            }
            return(flowLineModel);
        }
Esempio n. 4
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. 5
0
        public void SaveStrategies(string flowId, string markName, int flotType, string plots)
        {
            FlowLineEntity flowLineEntity = GetLine(flowId, markName);

            if (flowLineEntity != null && !string.IsNullOrEmpty(flowLineEntity.Id))
            {
                flowLineEntity.PlotType = flotType;
                if (flotType == (int)StrategiesType.Form)
                {
                    flowLineEntity.Plot = plots;
                }
                else
                if (flotType == (int)StrategiesType.Sql)
                {
                    flowLineEntity.SqlPlot = plots;
                }

                flowVersionService.UpdateLine(flowLineEntity);
            }
            else
            {
                throw new Exception("获取数据异常!");
            }
        }
Esempio n. 6
0
        private FlowNodeEntity GetNextNodeIdFail(string workId, string CurrentNodeId, string flowVersionId, ref FlowLineEntity flowLineEntity)
        {
            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.ToNode == flowNodeEntity.MarkName).ToList();
                        if (flowLines != null && flowLines.Count > 0)
                        {
                            if (flowLines.Count == 1)
                            {
                                flowLineEntity = flowLines[0];
                                string         markName        = flowLines[0].ToNode;
                                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)
                                    {
                                        flowLineEntity = flowline;
                                        string         markName        = flowline.ToNode;
                                        FlowNodeEntity flowNodeEntityT = db.FindEntity <FlowNodeEntity>(m => m.FlowVersionId == flowVersionId && m.MarkName == markName);
                                        if (flowNodeEntityT != null && !string.IsNullOrEmpty(flowNodeEntityT.Id))
                                        {
                                            nextNode = flowNodeEntityT;
                                        }
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }

                return(nextNode);
            }
            catch (Exception ex)
            {
                throw ex;
            }
        }
Esempio n. 7
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;
            }
        }