Пример #1
0
        DataTable IEntityResourceManager.GetResultDetailsFromVersion(Guid tenantId, string entityName, Guid id, LayoutType type, string subType, LayoutContext context, Guid versionId)
        {
            var entityDetails = _iMetadataManager.GetEntitityByName(entityName);

            if (entityDetails != null && entityDetails.VersionControl != null)
            {
                var versionEntitiy = _iMetadataManager.GetEntitityByName(entityDetails.VersionControl.Name);
                if (versionEntitiy == null || versionEntitiy.Fields == null || !versionEntitiy.Fields.Any())
                {
                    return(null);
                }
                var filterField = versionEntitiy.Fields.FirstOrDefault(t => t.TypeOf.ToLower().Equals(entityName.ToLower()));

                var versionFilterString = filterField.Name + "=" + id;
                versionFilterString += ",DraftVersion=" + versionId.ToString();

                QueryContext   query          = MetadataHelper.GetVersionQuery(entityDetails.VersionControl.Name, 0, 0, versionFilterString);
                ILayoutManager iLayoutManager = new LayoutManager();
                var            fields         = iLayoutManager.GetDesignFieldsFromDefaultLayoutForEntity(tenantId, entityName, type, subType, (int)context);
                if (fields == null || !fields.Any())
                {
                    throw new FieldAccessException("Layout not found.");
                }
                query.Fields = string.Join(",", fields);
                var result = GetResultById(tenantId, entityDetails.VersionControl.Name, id, query);
                return(result);
            }

            return(null);
        }
Пример #2
0
        LayoutModel GetDefaultLayoutForEntity(Guid tenantId, string entityName, int layoutType, string subType, int context)
        {
            var entityContext = _iMetadataManager.GetEntityContextByEntityName(entityName, false);

            if (string.IsNullOrEmpty(entityContext))
            {
                return(null);
            }
            //return _review.GetLayoutsDetail(tenantId, entityContext, layoutType, _iMetadataManager.GetSubTypeId(subType), context);
            var layout = _review.GetLayoutsDetail(tenantId, entityContext, layoutType, _iMetadataManager.GetSubTypeId(entityName, subType), context);

            if (layout != null)
            {
                MapLayoutDetails(tenantId, layout);

                if (layoutType.Equals((int)LayoutType.List) && layout.ListLayoutDetails != null && layout.ListLayoutDetails.Fields != null && layout.ListLayoutDetails.Fields.Any())
                {
                    foreach (var field in layout.ListLayoutDetails.Fields)
                    {
                        if (field.DataType.ToLower().Equals("picklist") && !string.IsNullOrEmpty(field.DefaultView))
                        {
                            var splitPicklist = field.Name.Split('.');
                            var picklistName  = splitPicklist[splitPicklist.Count() - 1];
                            var view          = GetDefaultPicklistLayout(tenantId, picklistName, LayoutType.View, 0);
                            //it should be view layout...
                            if (view != null && view.ViewLayoutDetails != null && view.ViewLayoutDetails.Fields != null && view.ViewLayoutDetails.Fields.Any())
                            {
                                foreach (var item in view.ViewLayoutDetails.Fields)
                                {
                                    layout.ListLayoutDetails.Fields.Add(item);
                                }
                            }
                        }
                    }
                }

                //append plural name
                var result = _iMetadataManager.GetEntitityByName(entityName);
                if (result != null && result.PluralName != null)
                {
                    layout.PluralName = result.PluralName;
                }

                //append singular name
                if (result != null && result.DisplayName != null)
                {
                    layout.SingularName = result.DisplayName;
                }

                //append version name
                if (result != null && result.VersionControl != null && !string.IsNullOrEmpty(result.VersionControl.Name))
                {
                    layout.VersionName = Char.ToLowerInvariant(result.VersionControl.Name[0]) + result.VersionControl.Name.Substring(1);;
                }
            }

            return(layout);
        }
        public IActionResult GetentityByName(string name)
        {
            try
            {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called MetadataController GetentityByName");
                var result = _iMetadataManager.GetEntitityByName(name);
                if (result.Fields != null)
                {
                    result.Fields = result.Fields.OrderBy(x => x.Name).ToList();
                }

                if (result.Operations != null)
                {
                    result.Operations = result.Operations.OrderBy(x => x.Name).ToList();
                }

                stopwatch.StopAndLog("GetentityByName of MetadataController");
                return(_iJsonMessage.IgnoreNullableObject(result));
            }
            catch (Exception ex)
            {
                //_log.Error("Error calling MetadataController.GetentityByName method.");
                //throw new Exception(ex.Message);
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
        bool IManagerWorkFlowSecurity.InitializeRootTenantWorkFlow(Guid tenantId)
        {
            var allEntities = iMetadataManager.GetEntities(false);
            // Filtwer all  Workflow supported entity
            var workFlowEntities = (from allEntity in allEntities where allEntity.SupportWorkflow 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);
        }