Ejemplo n.º 1
0
        private static WorkFlowProcessTaskInfo ReadWorkFlowProcessTask(SqlDataReader reader)
        {
            var objWorkFowStep = new WorkFlowProcessTaskInfo
            {
                WorkFlowProcessTaskId = reader.IsDBNull(0) ? Guid.Empty : reader.GetGuid(0),
                WorkFlowId            = reader.IsDBNull(1) ? Guid.Empty : reader.GetGuid(1),
                WorkFlowProcessId     = reader.IsDBNull(2) ? Guid.Empty : reader.GetGuid(2),
                ProcessCode           = reader.IsDBNull(3) ? Guid.Empty : reader.GetGuid(3),
                SequenceCode          = reader.IsDBNull(4) ? 0 : reader.GetByte(4),
                ProcessType           = reader.IsDBNull(5) ? 0 : reader.GetByte(5)
            };

            return(objWorkFowStep);
        }
Ejemplo n.º 2
0
 public IActionResult Post([FromBody] WorkFlowProcessTaskInfo processTask)
 {
     try
     {
         var stopwatch = StopwatchLogger.Start(_log);
         _log.Info("Called WorkFlowProcessTaskController Post {0}=", JsonConvert.SerializeObject(processTask));
         var retVal = _managerWorkFlowProcessTask.CreateWorkFlowProcessTask(TenantCode, processTask);
         stopwatch.StopAndLog("End WorkFlowProcessTaskController Post");
         return(Ok(retVal));
     }
     catch (Exception ex)
     {
         _log.Error(ExceptionFormatter.SerializeToString(ex));
         return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
     }
 }
Ejemplo n.º 3
0
 internal bool CreateWorkFlowProcessTask(Guid tenantId, WorkFlowProcessTaskInfo workFlowProcessTask)
 {
     try
     {
         var cmd = CreateProcedureCommand("dbo.WorkFlowProcessTask_Create");
         cmd.AppendGuid("@guidTenantId", tenantId);
         cmd.AppendGuid("@guidWorkFlowProcessTaskId", workFlowProcessTask.WorkFlowProcessTaskId);
         cmd.AppendGuid("@guidWorkFlowId", workFlowProcessTask.WorkFlowId);
         cmd.AppendGuid("@guidWorkFlowProcessId", workFlowProcessTask.WorkFlowProcessId);
         cmd.AppendGuid("@guidProcessCode", workFlowProcessTask.ProcessCode);
         ExecuteCommand(cmd);
         return(true);
     }
     catch (SqlException e)
     {
         throw ReportAndTranslateException(e, "DataWorkFlowProcessTask::dbo.WorkFlowProcessTask_Create");
     }
 }
 bool IAdminWorkFlowProcessTask.CreateWorkFlowProcessTask(Guid tenantId, WorkFlowProcessTaskInfo workFlowProcessTask)
 {
     return(_dataWorkFlowProcessTask.CreateWorkFlowProcessTask(tenantId, workFlowProcessTask));
 }
 WorkFlowProcessTaskInfo IManagerWorkFlowProcessTask.CreateWorkFlowProcessTask(Guid tenantId, WorkFlowProcessTaskInfo workFlowProcessTask)
 {
     //  _adminWorkFlowProcessTask.DeleteWorkFlowProcessTask(tenantId,innerStep);
     workFlowProcessTask.WorkFlowProcessTaskId = Guid.NewGuid();
     _adminWorkFlowProcessTask.CreateWorkFlowProcessTask(tenantId, workFlowProcessTask);
     return(workFlowProcessTask);
 }
        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);
        }