示例#1
0
 internal bool UpdateWorkFlowSteps(Guid tenantId, WorkFlowStepInfo workFlowStepInfo)
 {
     try
     {
         var cmd = CreateProcedureCommand("dbo.WorkFlowStep_Update");
         cmd.AppendGuid("@guidTenantId", tenantId);
         cmd.AppendGuid("@guidWorkFlowStepId", workFlowStepInfo.WorkFlowStepId);
         cmd.AppendGuid("@guidWorkFlowId", workFlowStepInfo.WorkFlowId);
         cmd.AppendBit("@bIsAssigmentMandatory", workFlowStepInfo.IsAssigmentMandatory);
         if (workFlowStepInfo.AllotedTime.HasValue && workFlowStepInfo.AllotedTime.Value > 0)
         {
             cmd.AppendInt("@intAllotedTime", workFlowStepInfo.AllotedTime.Value);
         }
         if (workFlowStepInfo.CriticalTime.HasValue && workFlowStepInfo.CriticalTime.Value > 0)
         {
             cmd.AppendInt("@intCriticalTime", workFlowStepInfo.CriticalTime.Value);
         }
         ExecuteCommand(cmd);
         return(true);
     }
     catch (SqlException e)
     {
         throw ReportAndTranslateException(e, "WorkFlow::dbo.WorkFlowStep_Update");
     }
 }
示例#2
0
 public IActionResult Put([FromBody] WorkFlowStepInfo workFlowStep)
 {
     try
     {
         var stopwatch = StopwatchLogger.Start(_log);
         _log.Info("Called WorkFlowStepController Put {0}=", JsonConvert.SerializeObject(workFlowStep));
         var retVal = _managerWorkFlowSteps.UpdateWorkFlowSteps(TenantCode, workFlowStep);
         stopwatch.StopAndLog("End WorkFlowStepController Put");
         return(Ok(retVal));
     }
     catch (Exception ex)
     {
         _log.Error(ExceptionFormatter.SerializeToString(ex));
         return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
     }
 }
示例#3
0
        private static WorkFlowStepInfo ReadWorkFlowStep(SqlDataReader reader)
        {
            var objWorkFowStep = new WorkFlowStepInfo
            {
                WorkFlowStepId = reader.IsDBNull(0) ? Guid.Empty : reader.GetGuid(0),
                WorkFlowId     = reader.IsDBNull(1) ? Guid.Empty : reader.GetGuid(1),
                TransitionType = new ItemName {
                    Id = reader.IsDBNull(2) ? Guid.Empty : reader.GetGuid(2),
                },
                SequenceNumber       = reader.IsDBNull(3) ? 0 : reader.GetByte(3),
                IsAssigmentMandatory = reader.IsDBNull(4) ? false : reader.GetBoolean(4),
                AllotedTime          = reader.IsDBNull(5) ? (int?)null : reader.GetInt32(5),
                CriticalTime         = reader.IsDBNull(6) ? (int?)null : reader.GetInt32(6),
            };

            return(objWorkFowStep);
        }
示例#4
0
 internal bool CreateWorkFlowStep(Guid tenantId, WorkFlowStepInfo workFlowStepInfo)
 {
     try
     {
         var cmd = CreateProcedureCommand("dbo.WorkFlowStep_Create");
         cmd.AppendGuid("@guidTenantId", tenantId);
         cmd.AppendGuid("@guidWorkFlowStepId", workFlowStepInfo.WorkFlowStepId);
         cmd.AppendGuid("@guidWorkFlowId", workFlowStepInfo.WorkFlowId);
         cmd.AppendGuid("@guidTransitionType", workFlowStepInfo.TransitionType.Id);
         ExecuteCommand(cmd);
         return(true);
     }
     catch (SqlException e)
     {
         throw ReportAndTranslateException(e, "WorkFlow::dbo.WorkFlowStep_Create");
     }
 }
 bool IManagerWorkFlowStep.UpdateWorkFlowSteps(Guid tenantId, WorkFlowStepInfo workFlowStep)
 {
     return(_adminWorkFlowStep.UpdateWorkFlowSteps(tenantId, workFlowStep));
 }
 Guid IManagerWorkFlowStep.CreateWorkFlowStep(Guid tenantId, WorkFlowStepInfo workFlowStep)
 {
     workFlowStep.WorkFlowStepId = Guid.NewGuid();
     _adminWorkFlowStep.CreateWorkFlowStep(tenantId, workFlowStep);
     return(workFlowStep.WorkFlowStepId);
 }
示例#7
0
 bool IAdminWorkFlowStep.UpdateWorkFlowSteps(Guid tenantId, WorkFlowStepInfo workFlowStep)
 {
     return(_dataWorkFlowSteps.UpdateWorkFlowSteps(tenantId, workFlowStep));
 }
        bool IManagerWorkFlowSecurity.InitializeRootTenantWorkFlow(Guid tenantId, string entityId)
        {
            var allEntities = iMetadataManager.GetEntities(false);
            // Filtwer all  Workflow supported entity
            var workFlowEntities = (from allEntity in allEntities where allEntity.SupportWorkflow && allEntity.Name == entityId select allEntity).ToList();

            foreach (var workFlowEntity in workFlowEntities)
            {
                var entityContextAll = iMetadataManager.GetEntitityByName(workFlowEntity.Name);
                var entityContext    = iMetadataManager.GetEntityContextByEntityName(workFlowEntity.Name);
                foreach (var subtype in workFlowEntity.Subtypes)
                {
                    var workflowInfo = new WorkFlowInfo
                    {
                        WorkFlowId  = Guid.NewGuid(),
                        EntityId    = entityContext,
                        Status      = true,
                        SubTypeCode = iMetadataManager.GetSubTypeId(workFlowEntity.Name, subtype)
                    };
                    _managerWorkFlow.CreateWorkFlow(tenantId, workflowInfo);

                    //all steps from static classes (Transition)
                    List <WorkFlowResource> allSteps = WorkFlowHelper.GetAllSteps(entityContext);
                    var count = 0;
                    foreach (var allStep in allSteps)
                    {
                        var workFlowStep = new WorkFlowStepInfo
                        {
                            WorkFlowId     = workflowInfo.WorkFlowId,
                            TransitionType = new ItemName {
                                Id = allStep.Id
                            },
                            SequenceNumber = count++
                        };
                        workFlowStep.WorkFlowStepId = _managerWorkFlowStep.CreateWorkFlowStep(tenantId, workFlowStep);
                    }

                    // (Operations)
                    List <WorkFlowOperationInfo> workFlowOperations = new List <WorkFlowOperationInfo>();
                    foreach (var entityCon in entityContextAll.Operations)
                    {
                        if (entityCon.Name == "Create")
                        {
                            workFlowOperations.Add(new WorkFlowOperationInfo
                            {
                                WorkFlowOperationId = Guid.NewGuid(),
                                OperationType       = WorkFlowOperationType.Create,
                                WorkFlowId          = workflowInfo.WorkFlowId
                            });
                        }
                        else if (entityCon.Name == "Update")
                        {
                            workFlowOperations.Add(new WorkFlowOperationInfo
                            {
                                WorkFlowOperationId = Guid.NewGuid(),
                                OperationType       = WorkFlowOperationType.Update,
                                WorkFlowId          = workflowInfo.WorkFlowId
                            });
                        }
                        else if (entityCon.Name == "Delete")
                        {
                            workFlowOperations.Add(new WorkFlowOperationInfo
                            {
                                WorkFlowOperationId = Guid.NewGuid(),
                                OperationType       = WorkFlowOperationType.Delete,
                                WorkFlowId          = workflowInfo.WorkFlowId
                            });
                        }
                        else if (entityCon.Name == "UpdateStatus")
                        {
                            workFlowOperations.Add(new WorkFlowOperationInfo
                            {
                                WorkFlowOperationId = Guid.NewGuid(),
                                OperationType       = WorkFlowOperationType.UpdateStatus,
                                WorkFlowId          = workflowInfo.WorkFlowId
                            });
                        }
                    }
                    _managerOperation.CreateWorkFlowOperations(tenantId, workFlowOperations);
                    count = 0;
                    List <WorkFlowProcessInfo> workFlowProcesses = new List <WorkFlowProcessInfo>();
                    foreach (var workFlowOperation in workFlowOperations)
                    {
                        workFlowProcesses.Add(new WorkFlowProcessInfo
                        {
                            WorkFlowProcessId          = Guid.NewGuid(),
                            WorkFlowId                 = workflowInfo.WorkFlowId,
                            OperationOrTransactionId   = workFlowOperation.WorkFlowOperationId,
                            OperationOrTransactionType = (int)OperationOrTransactionType.Operation,
                            ProcessType                = (int)WorkFlowProcessType.PreProcess
                        });

                        workFlowProcesses.Add(new WorkFlowProcessInfo
                        {
                            WorkFlowProcessId          = Guid.NewGuid(),
                            WorkFlowId                 = workflowInfo.WorkFlowId,
                            OperationOrTransactionId   = workFlowOperation.WorkFlowOperationId,
                            OperationOrTransactionType = (int)OperationOrTransactionType.Operation,
                            ProcessType                = (int)WorkFlowProcessType.Process
                        });
                        workFlowProcesses.Add(new WorkFlowProcessInfo
                        {
                            WorkFlowProcessId          = Guid.NewGuid(),
                            WorkFlowId                 = workflowInfo.WorkFlowId,
                            OperationOrTransactionId   = workFlowOperation.WorkFlowOperationId,
                            OperationOrTransactionType = (int)OperationOrTransactionType.Operation,
                            ProcessType                = (int)WorkFlowProcessType.PostProcess
                        });
                    }
                    _managerWorkFlowProcess.CreateWorkFlowProcess(tenantId, workFlowProcesses);
                }
            }

            return(true);
        }
        bool IManagerWorkFlowSecurity.InitializeTenantWorkFlow(Guid rootTenantId, Guid newTenantId, List <string> entityIds)
        {
            List <RoleInfo> newRoles = new List <RoleInfo>();
            var             allRoles = _managerRole.Roles(rootTenantId);

            foreach (var allRole in allRoles)
            {
                var itsRole = new RoleInfo();
                DataUtility.CopyPropertiesTo(allRole, itsRole);
                itsRole.RoleId = Guid.NewGuid();
                newRoles.Add(itsRole);
            }
            //Init roles
            _managerRole.CreateRoles(newTenantId, newRoles);

            var workFlows = _managerWorkFlow.GetWorkFlowsByEntityIds(rootTenantId, entityIds);

            if (workFlows.Count > 0)
            {
                //Get root tenant
                var workFlowIds          = workFlows.Select(p => p.WorkFlowId).ToList();
                var workFlowSteps        = _managerWorkFlowStep.GetWorkFlowStepsByWorkFlowIds(rootTenantId, workFlowIds);
                var workFlowInnerSteps   = _managerInnerStep.GetWorkFlowInnerStepByWorkFlowIds(rootTenantId, workFlowIds);
                var workFlowOperations   = _managerOperation.GetWorkFlowOperationsByWorkFlowIds(rootTenantId, workFlowIds);
                var workFlowProcess      = _managerWorkFlowProcess.GetWorkFlowProcessByWorkFlowIds(rootTenantId, workFlowIds);
                var workFlowProcessTasks = _managerWorkFlowProcessTask.GetWorkFlowProcessTaskByWorkFlowIds(rootTenantId, workFlowIds);
                var workFlowRoles        = _managerWorkFlowRole.GetWorkFlowRolesByWorkFlowIds(rootTenantId, workFlowIds);

                List <WorkFlowInfo>            newWorkFlows     = new List <WorkFlowInfo>();
                List <WorkFlowStepInfo>        newWorkFlowSteps = new List <WorkFlowStepInfo>();
                List <WorkFlowInnerStepInfo>   newInnerSteps    = new List <WorkFlowInnerStepInfo>();
                List <WorkFlowOperationInfo>   newOperations    = new List <WorkFlowOperationInfo>();
                List <WorkFlowProcessInfo>     newProcess       = new List <WorkFlowProcessInfo>();
                List <WorkFlowProcessTaskInfo> newProcessTasks  = new List <WorkFlowProcessTaskInfo>();
                List <WorkFlowRoleInfo>        newWorkFlowRoles = new List <WorkFlowRoleInfo>();

                foreach (var workFlow in workFlows)
                {
                    var itsWorkFlow = new WorkFlowInfo();
                    DataUtility.CopyPropertiesTo(workFlow, itsWorkFlow);
                    itsWorkFlow.WorkFlowId = Guid.NewGuid();

                    //Filter steps
                    var filterWorkFlowSteps = (from workFlowStep in workFlowSteps where workFlowStep.WorkFlowId == workFlow.WorkFlowId select workFlowStep).ToList();
                    foreach (var filterWorkFlowStep in filterWorkFlowSteps)
                    {
                        var itsStep = new WorkFlowStepInfo();
                        DataUtility.CopyPropertiesTo(filterWorkFlowStep, itsStep);
                        itsStep.WorkFlowId     = itsWorkFlow.WorkFlowId;
                        itsStep.WorkFlowStepId = Guid.NewGuid();

                        //Filter Inner steps
                        var filterInnerSteps = (from innerStep in workFlowInnerSteps where innerStep.WorkFlowStepId == filterWorkFlowStep.WorkFlowStepId &&
                                                innerStep.WorkFlowId == workFlow.WorkFlowId select innerStep).ToList();

                        foreach (var filterInnerStep in filterInnerSteps)
                        {
                            var itsInnerStep = new WorkFlowInnerStepInfo();;
                            DataUtility.CopyPropertiesTo(filterInnerStep, itsInnerStep);
                            itsInnerStep.InnerStepId    = Guid.NewGuid();
                            itsInnerStep.WorkFlowId     = itsWorkFlow.WorkFlowId;
                            itsInnerStep.WorkFlowStepId = itsStep.WorkFlowStepId;
                            //Filter Process
                            var filterProcess = (from workFlowProcs in workFlowProcess where workFlowProcs.OperationOrTransactionId == filterInnerStep.InnerStepId &&
                                                 workFlowProcs.WorkFlowId == workFlow.WorkFlowId select workFlowProcs).ToList();

                            foreach (var filterProces in filterProcess)
                            {
                                var itsProcess = new WorkFlowProcessInfo();
                                DataUtility.CopyPropertiesTo(filterProces, itsProcess);

                                itsProcess.WorkFlowProcessId        = Guid.NewGuid();
                                itsProcess.WorkFlowId               = itsWorkFlow.WorkFlowId;
                                itsProcess.OperationOrTransactionId = itsInnerStep.InnerStepId;

                                //Filter process tasks
                                var filterProcessTasks = (from processTask in workFlowProcessTasks where processTask.WorkFlowProcessId == filterProces.WorkFlowProcessId &&
                                                          processTask.WorkFlowId == workFlow.WorkFlowId select processTask).ToList();

                                foreach (var filterProcessTask in filterProcessTasks)
                                {
                                    var itsTasks = new WorkFlowProcessTaskInfo();
                                    DataUtility.CopyPropertiesTo(filterProcessTask, itsTasks);
                                    itsTasks.WorkFlowProcessTaskId = Guid.NewGuid();
                                    itsTasks.WorkFlowId            = itsWorkFlow.WorkFlowId;
                                    itsTasks.WorkFlowProcessId     = itsProcess.WorkFlowProcessId;
                                    newProcessTasks.Add(itsTasks);
                                }

                                newProcess.Add(itsProcess);
                            }

                            newInnerSteps.Add(itsInnerStep);
                        }

                        //Filter roles

                        var filterRoles = (from workFlowRole in workFlowRoles where workFlowRole.WorkFlowStepId == filterWorkFlowStep.WorkFlowStepId &&
                                           workFlowRole.WorkFlowId == workFlow.WorkFlowId select workFlowRole).ToList();

                        foreach (var filterRole in filterRoles)
                        {
                            var roleId = Guid.Empty;
                            var rootTenantRoleFilter = (from allRole in allRoles where allRole.RoleId == filterRole.RoleId select allRole).ToList();
                            if (rootTenantRoleFilter.Count > 0)
                            {
                                roleId = (from newRole in newRoles where newRole.Name == rootTenantRoleFilter[0].Name select newRole.RoleId).FirstOrDefault();
                            }
                            var itsRole = new WorkFlowRoleInfo();
                            DataUtility.CopyPropertiesTo(filterRole, itsRole);
                            itsRole.RoleAssignmetId = Guid.NewGuid();
                            itsRole.WorkFlowId      = itsWorkFlow.WorkFlowId;
                            itsRole.WorkFlowStepId  = itsStep.WorkFlowStepId;
                            itsRole.RoleId          = roleId;

                            newWorkFlowRoles.Add(itsRole);
                        }

                        newWorkFlowSteps.Add(itsStep);
                    }

                    //Filter Operation*****************************************
                    var filterOperations = (from workFlowOperation in workFlowOperations where workFlowOperation.WorkFlowId == workFlow.WorkFlowId select workFlowOperation).ToList();
                    foreach (var filterOperation in filterOperations)
                    {
                        var itsOperation = new WorkFlowOperationInfo();
                        DataUtility.CopyPropertiesTo(filterOperation, itsOperation);
                        itsOperation.WorkFlowOperationId = Guid.NewGuid();
                        itsOperation.WorkFlowId          = itsWorkFlow.WorkFlowId;

                        //filter process
                        var filterProcess = (from workFlowProcs in workFlowProcess where workFlowProcs.OperationOrTransactionId == filterOperation.WorkFlowOperationId &&
                                             workFlowProcs.WorkFlowId == workFlow.WorkFlowId select workFlowProcs).ToList();

                        foreach (var filterProces in filterProcess)
                        {
                            var itsProcess = new WorkFlowProcessInfo();
                            DataUtility.CopyPropertiesTo(filterProces, itsProcess);

                            itsProcess.WorkFlowProcessId        = Guid.NewGuid();
                            itsProcess.WorkFlowId               = itsWorkFlow.WorkFlowId;
                            itsProcess.OperationOrTransactionId = itsOperation.WorkFlowOperationId;

                            //Filter process tasks
                            var filterProcessTasks = (from processTask in workFlowProcessTasks where processTask.WorkFlowProcessId == filterProces.WorkFlowProcessId &&
                                                      processTask.WorkFlowId == workFlow.WorkFlowId select processTask).ToList();

                            foreach (var filterProcessTask in filterProcessTasks)
                            {
                                var itsTasks = new WorkFlowProcessTaskInfo();
                                DataUtility.CopyPropertiesTo(filterProcessTask, itsTasks);
                                itsTasks.WorkFlowProcessTaskId = Guid.NewGuid();
                                itsTasks.WorkFlowId            = itsWorkFlow.WorkFlowId;
                                itsTasks.WorkFlowProcessId     = itsProcess.WorkFlowProcessId;
                                newProcessTasks.Add(itsTasks);
                            }

                            newProcess.Add(itsProcess);
                        }


                        newOperations.Add(itsOperation);
                    }


                    newWorkFlows.Add(itsWorkFlow);
                }

                //Init workflow
                if (newWorkFlows.Count > 0)
                {
                    _managerWorkFlow.CreateWorkFlows(newTenantId, newWorkFlows);
                }
                if (newOperations.Count > 0)
                {
                    _managerOperation.CreateWorkFlowOperations(newTenantId, newOperations);
                }
                if (newWorkFlowSteps.Count > 0)
                {
                    _managerWorkFlowStep.CreateWorkFlowSteps(newTenantId, newWorkFlowSteps);
                }
                if (newInnerSteps.Count > 0)
                {
                    _managerInnerStep.CreateWorkFlowInnerSteps(newTenantId, newInnerSteps);
                }
                if (newProcess.Count > 0)
                {
                    _managerWorkFlowProcess.CreateWorkFlowProcess(newTenantId, newProcess);
                }
                if (newProcessTasks.Count > 0)
                {
                    _managerWorkFlowProcessTask.CreateWorkFlowProcessTasks(newTenantId, newProcessTasks);
                }
                if (newWorkFlowRoles.Count > 0)
                {
                    _managerWorkFlowRole.CreateWorkFlowRoles(newTenantId, newWorkFlowRoles);
                }
            }

            return(true);
        }