Example #1
0
        bool IEntityResourceManager.UpdateResult(Guid tenantId, Guid userId, Guid resultId, string entityName, JObject resource, string subType)
        {
            IOperationFlowEngine operationEngine = new OperationFlowEngine();
            var subTypeCode = _iMetadataManager.GetSubTypeId(entityName, subType);

            var mainObj   = resource.Children().FirstOrDefault(t => t.Path.ToLower().Equals(entityName.ToLower()));
            var targetObj = mainObj.First().ToObject <JObject> ();

            var properties = new WorkFlowProcessProperties {
                EntityName = entityName, SubTypeCode = subTypeCode, UserId = userId, IsSuperAdmin = false, resultId = resultId
            };

            operationEngine.PreProcess(tenantId, new OperationWapper {
                OperationType = WorkFlowOperationType.Update, Data = targetObj
            }, properties);
            var returnVal = _queryManager.UpdateResult(tenantId, userId, entityName, resultId, resource, subType);

            operationEngine.Process(tenantId, new OperationWapper {
                OperationType = WorkFlowOperationType.Update, Data = targetObj
            }, properties);
            operationEngine.PostProcess(tenantId, new OperationWapper {
                OperationType = WorkFlowOperationType.Update, Data = targetObj
            }, properties);
            return(returnVal);
        }
        void IOperationFlowEngine.FirstOperation(Guid tenantId, WorkFlowProcessProperties properties)
        {
            var entityId = iMetadataManager.GetEntityContextByEntityName(properties.EntityName);
            var workFlow = _managerWorkFlow.GetWorkFlow(tenantId, entityId, properties.SubTypeCode);

            if (workFlow != null)
            {
                var steps = _managerWorkFlowStep.GetWorkFlowSteps(tenantId, workFlow.WorkFlowId).ToList();
                if (steps.Count > 0)
                {
                    transactionHistory.CreateTransitionHistory(tenantId, new WorkFlowTransition
                    {
                        TransitionHistoryId = Guid.NewGuid(),
                        RefId          = properties.resultId,
                        EntityId       = entityId,
                        WorkFlowStepId = steps[0].WorkFlowStepId,
                        StartTime      = DateTime.UtcNow,
                        EndTime        = DateTime.UtcNow,
                        AssignedUserId = Guid.Empty,
                        AuditInfo      = new Entities.Common.AuditDetail {
                            CreatedBy = properties.UserId
                        }
                    });

                    dynamic jsonObject = new JObject();
                    jsonObject.CurrentWorkFlowStep = steps[0].TransitionType.Id;

                    IEntityResourceManager _iEntityResourceManager = new VPC.Framework.Business.EntityResourceManager.Contracts.EntityResourceManager();
                    _iEntityResourceManager.UpdateSpecificField(tenantId, properties.EntityName, properties.resultId, "CurrentWorkFlowStep", steps[0].TransitionType.Id.ToString());
                    // var resultId = _iEntityResourceManager.UpdateResult (tenantId, properties.UserId,properties.resultId,properties.EntityName, jsonObject, properties.SubTypeCode);
                }
            }
        }
        WorkFlowResultMessage <WorkFlowTransition> IManagerWorkFlow.ManageTransition(Guid tenantId, TransitionWapper operationWapper, bool isSuperAdmin)
        {
            var resM = new WorkFlowResultMessage <WorkFlowTransition>();
            ITransitionFlowEngine transitionEngine = new TransitionFlowEngine();
            var subTypeCode = iMetadataManager.GetSubTypeId(operationWapper.EntityName, operationWapper.SubTypeName);

            if (!isSuperAdmin)
            {
                var isValid = CheckRoleWorkFlowSecurity(tenantId, operationWapper, subTypeCode);
                if (!isValid)
                {
                    throw new CustomWorkflowException <WorkFlowMessage>(WorkFlowMessage.InValidTransition);
                }
            }


            var properties = new WorkFlowProcessProperties {
                EntityName = operationWapper.EntityName, SubTypeCode = subTypeCode, UserId = operationWapper.UserId, IsSuperAdmin = isSuperAdmin
            };

            transitionEngine.PreProcess(tenantId, operationWapper);
            resM = Transition(tenantId, operationWapper);
            transitionEngine.Process(tenantId, operationWapper);
            transitionEngine.PostProcess(tenantId, operationWapper);
            return(resM);
        }
Example #4
0
        WorkFlowProcessMessage IOperation.Execute(dynamic obj)
        {
            IMetadataManager    iMetadataManager = new MetadataManager.Contracts.MetadataManager();
            IEntityQueryManager _queryManager    = new EntityQueryManager();
            // IEntityResourceManager _iEntityResourceManager = new VPC.Framework.Business.EntityResourceManager.Contracts.EntityResourceManager();
            var objWorkFlowProcessMessage = new WorkFlowProcessMessage();

            try
            {
                objWorkFlowProcessMessage = new WorkFlowProcessMessage {
                    Success = true
                };
                var workFlowProcessProperties = (WorkFlowProcessProperties)obj[0];
                var jObject  = (JObject)obj[1];
                var tenantId = (Guid)obj[2];

                var queryFilter1 = new List <QueryFilter> ();
                queryFilter1.Add(new QueryFilter {
                    FieldName = "TenantId", Operator = "Equal", Value = tenantId.ToString()
                });
                queryFilter1.Add(new QueryFilter {
                    FieldName = "ProductId", Operator = "Equal", Value = workFlowProcessProperties.resultId.ToString()
                });
                var queryContext1 = new QueryContext {
                    Fields = "VersionNo", Filters = queryFilter1, PageSize = 100, PageIndex = 1
                };
                DataTable productVersionDataTable = _queryManager.GetResult(tenantId, "productversion", queryContext1);



                var productVersionInfo = EntityMapper <ProductVersion> .Mapper(productVersionDataTable);

                var updateStatus = _queryManager.UpdateSpecificField(tenantId, "Product", workFlowProcessProperties.resultId, "ActiveVersion", productVersionInfo.InternalId.Value.ToString());

                //Update WorkFlowFirst step
                IOperationFlowEngine operationEngine = new OperationFlowEngine();
                var subTypeCode = iMetadataManager.GetSubTypeId("productversion", "standard");
                var properties  = new WorkFlowProcessProperties {
                    resultId = Guid.Parse(productVersionInfo.InternalId.Value), EntityName = "productversion", SubTypeCode = subTypeCode, UserId = workFlowProcessProperties.UserId, IsSuperAdmin = false
                };
                operationEngine.FirstOperation(tenantId, properties);
                return(objWorkFlowProcessMessage);
            }
            catch (System.Exception ex)
            {
                _log.Error("TenantEmailPostProcess  having exception message" + ex.Message);

                objWorkFlowProcessMessage.Success      = false;
                objWorkFlowProcessMessage.ErrorMessage = new ErrorMessage
                {
                    Code        = WorkFlowMessage.ApplicationError,
                    Description = ex.Message
                };
                return(objWorkFlowProcessMessage);
            }
        }
Example #5
0
        bool IEntityResourceManager.DeleteResult(Guid tenantId, Guid userId, Guid resultId, string entityName, string subType)
        {
            IOperationFlowEngine operationEngine = new OperationFlowEngine();
            var subTypeCode = _iMetadataManager.GetSubTypeId(entityName, subType);
            var properties  = new WorkFlowProcessProperties {
                EntityName = entityName, SubTypeCode = subTypeCode, UserId = userId, IsSuperAdmin = false, resultId = resultId
            };

            operationEngine.PreProcess(tenantId, new OperationWapper {
                OperationType = WorkFlowOperationType.Create, Data = null
            }, properties);
            var returnVal = _queryManager.DeleteResult(tenantId, userId, resultId, entityName);

            operationEngine.Process(tenantId, new OperationWapper {
                OperationType = WorkFlowOperationType.Create, Data = null
            }, properties);
            operationEngine.PostProcess(tenantId, new OperationWapper {
                OperationType = WorkFlowOperationType.Create, Data = null
            }, properties);
            return(returnVal);
        }
        WorkFlowResultMessage <WorkFlowTransition> IManagerWorkFlow.ManageTransitionFirstStep(Guid tenantId, TransitionWapper operationWapper)
        {
            var resM = new WorkFlowResultMessage <WorkFlowTransition>();
            IOperationFlowEngine operationEngine = new OperationFlowEngine();
            var subTypeCode = iMetadataManager.GetSubTypeId(operationWapper.EntityName, operationWapper.SubTypeName);
            var properties  = new WorkFlowProcessProperties {
                EntityName = operationWapper.EntityName, SubTypeCode = subTypeCode, UserId = operationWapper.UserId, IsSuperAdmin = false
            };

            operationEngine.PreProcess(tenantId, new OperationWapper {
                OperationType = WorkFlowOperationType.Create, Data = operationWapper.ObjectData
            }, properties);
            resM = Transition(tenantId, operationWapper);
            operationEngine.Process(tenantId, new OperationWapper {
                OperationType = WorkFlowOperationType.Create, Data = operationWapper.ObjectData
            }, properties);
            operationEngine.FirstOperation(tenantId, properties);
            operationEngine.PostProcess(tenantId, new OperationWapper {
                OperationType = WorkFlowOperationType.Create, Data = operationWapper.ObjectData
            }, properties);
            return(resM);
        }
        WorkFlowResultMessage <WorkFlowProcessMessage> IOperationFlowEngine.PostProcess(Guid tenantId, OperationWapper operation, WorkFlowProcessProperties properties)
        {
            var arrayList = new ArrayList {
                properties, operation.Data, tenantId
            };
            var resM = new WorkFlowResultMessage <WorkFlowProcessMessage>();


            var itsOperationProcess = WorkFlowCommon(tenantId, properties.EntityName, properties.SubTypeCode, operation.OperationType);

            if (itsOperationProcess.Count > 0)
            {
                //get its all process task
                var allTasks            = _managerWorkFlowProcessTask.GetWorkFlowProcessTask(tenantId, itsOperationProcess[0].WorkFlowId);
                var itsPostProcessTasks = new List <WorkFlowProcessTaskInfo>();
                foreach (var itsOperationProc in itsOperationProcess)
                {
                    if (itsOperationProc.ProcessType == (int)WorkFlowProcessType.PostProcess)
                    {
                        itsPostProcessTasks = (from allProcessTask in allTasks
                                               where itsOperationProc.WorkFlowProcessId == allProcessTask.WorkFlowProcessId
                                               orderby allProcessTask.SequenceCode
                                               select allProcessTask).ToList();
                    }
                }

                foreach (var itsPostProcessTask in itsPostProcessTasks)
                {
                    WorkFlowProcessMessage processResult = _processWorkFlow.OperationProcess(itsPostProcessTask.ProcessCode, arrayList);
                    if (!processResult.Success)
                    {
                        throw new CustomWorkflowException <WorkFlowMessage>(processResult.ErrorMessage.Code);
                    }
                    resM.Result = processResult;
                }
            }


            var resultArrayList = new ArrayList {
                properties
            };

            if (resM.Result != null && resM.Result.Data != null)
            {
                resultArrayList.Add(resM.Result.Data);
            }

            return(resM);
        }