Esempio n. 1
0
 public IActionResult Get(Guid workFlowId)
 {
     try
     {
         var stopwatch = StopwatchLogger.Start(_log);
         _log.Info("Called WorkFlowOperationsController Get by workFlowId{0}=", JsonConvert.SerializeObject(workFlowId));
         var workFlowOperationProcess = _managerWorkFlowProcess.GetWorkFlowProcess(TenantCode, workFlowId);
         stopwatch.StopAndLog("End WorkFlowOperationsController Get by workFlowId");
         return(Ok(workFlowOperationProcess));
     }
     catch (Exception ex)
     {
         _log.Error(ExceptionFormatter.SerializeToString(ex));
         return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
     }
 }
        private List <WorkFlowProcessInfo> WorkFlowCommon(Guid tenantId, string entityName, string subTypeName, Guid innerStepId)
        {
            var entityId    = iMetadataManager.GetEntityContextByEntityName(entityName);
            var subTypeCode = iMetadataManager.GetSubTypeId(entityName, subTypeName);
            var workFlow    = _managerWorkFlow.GetWorkFlow(tenantId, entityId, subTypeCode);

            if (workFlow == null)
            {
                return(new List <WorkFlowProcessInfo>());
            }
            //get its all pre/post/process
            var allProcess          = _managerWorkFlowProcess.GetWorkFlowProcess(tenantId, workFlow.WorkFlowId);
            var itsOperationProcess = (from workFlowPro in allProcess where workFlowPro.OperationOrTransactionId == innerStepId select workFlowPro).ToList();

            return(itsOperationProcess);
        }
        private List <WorkFlowProcessInfo> WorkFlowCommon(Guid tenantId, string entityName, string subTypeCode, WorkFlowOperationType operationType)
        {
            var entityId = iMetadataManager.GetEntityContextByEntityName(entityName);
            var workFlow = _managerWorkFlow.GetWorkFlow(tenantId, entityId, subTypeCode);

            if (workFlow == null)
            {
                return(new List <WorkFlowProcessInfo>());
            }

            var workflowOperations = _managerWorkFlowOperation.GetWorkFlowOperations(tenantId, workFlow.WorkFlowId);
            var itsOperation       = (from workflowOperation in workflowOperations where workflowOperation.OperationType == operationType select workflowOperation).FirstOrDefault();

            if (itsOperation == null)
            {
                return(new List <WorkFlowProcessInfo>());
            }

            //get its all pre/post/process
            var allProcess          = _managerWorkFlowProcess.GetWorkFlowProcess(tenantId, workFlow.WorkFlowId);
            var itsOperationProcess = (from workFlowPro in allProcess where workFlowPro.OperationOrTransactionId == itsOperation.WorkFlowOperationId select workFlowPro).ToList();

            return(itsOperationProcess);
        }
        WorkFlowInfo IManagerWorkFlow.GetWorkFlowDetail(Guid tenantId, string entityname, string subTypeName)
        {
            var entityId    = iMetadataManager.GetEntityContextByEntityName(entityname);
            var subTypeCode = iMetadataManager.GetSubTypeId(entityname, subTypeName);
            var workFlow    = _reviewWorkFlow.GetWorkFlow(tenantId, entityId, subTypeCode);

            if (workFlow != null)
            {
                var workflowOperations = _managerWorkFlowOperation.GetWorkFlowOperations(tenantId, workFlow.WorkFlowId);
                workFlow.Operations = workflowOperations;
                //Get all steps from statci class
                var allSteps = WorkFlowHelper.GetAllSteps(entityId);

                var workFlowSteps      = _managerWorkFlowStep.GetWorkFlowSteps(tenantId, workFlow.WorkFlowId);
                var workFlowInnerSteps = _managerWorkFlowInnerStep.GetWorkFlowInnerStep(tenantId, workFlow.WorkFlowId);
                var workFlowProcess    = _managerWorkFlowProcess.GetWorkFlowProcess(tenantId, workFlow.WorkFlowId);

                // var workFlowProcessTasks=_managerWorkFlowProcessTask.GetWorkFlowProcessTask(tenantId,workFlow.WorkFlowId);
                var allWorkFlowSteps  = new List <WorkFlowStepInfo>();
                var allStepSavedCount = (from workFlowStep in workFlowSteps orderby workFlowStep.SequenceNumber descending select workFlowStep.SequenceNumber).FirstOrDefault();
                foreach (var step in allSteps)
                {
                    //return saved step
                    var checkStepsSaved = (from workFlowStep in workFlowSteps where workFlowStep.TransitionType.Id == step.Id select workFlowStep).FirstOrDefault();
                    if (checkStepsSaved != null)
                    {
                        checkStepsSaved.TransitionType.Name = step.Key;
                        checkStepsSaved.WorkFlowId          = workFlow.WorkFlowId;
                        allWorkFlowSteps.Add(checkStepsSaved);
                    }
                    else
                    {
                        //return not saved step
                        allWorkFlowSteps.Add(new WorkFlowStepInfo
                        {
                            WorkFlowStepId = Guid.Empty,
                            WorkFlowId     = workFlow.WorkFlowId,
                            SequenceNumber = ++allStepSavedCount,
                            TransitionType = new ItemName {
                                Id = step.Id, Name = step.Key
                            }
                        });
                    }
                }

                foreach (var workFlowStep in allWorkFlowSteps)
                {
                    var itsInnerSteps = (from workFlowInnerStep in workFlowInnerSteps where
                                         workFlowInnerStep.WorkFlowStepId == workFlowStep.WorkFlowStepId
                                         select workFlowInnerStep).ToList();

                    foreach (var workFlowInnerStep in itsInnerSteps)
                    {
                        workFlowInnerStep.TransitionType.Name = (from allStep in allSteps where allStep.Id == workFlowInnerStep.TransitionType.Id select allStep.Key).FirstOrDefault();

                        workFlowInnerStep.WorkFlowProcess = (from workFlowPro in workFlowProcess
                                                             where workFlowPro.OperationOrTransactionId == workFlowInnerStep.InnerStepId
                                                             select workFlowPro).ToList();
                    }

                    workFlowStep.InnerSteps = itsInnerSteps.OrderBy(p => p.SequenceNumber).ToList();
                }

                workFlow.Steps = allWorkFlowSteps.OrderBy(p => p.SequenceNumber).ToList();

                //Chnage sab typesId To name
                workFlow.SubTypeCode = subTypeName;
                workFlow.EntityId    = entityname;
            }


            return(workFlow);
        }