public IActionResult GetMenuById(Guid id)
        {
            var entityName = "";

            try
            {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called MenuController GetMenuById");

                var menu = _iMenuManager.GetMenuById(TenantCode, id);

                if (menu != null && menu.ReferenceEntityId != null && menu.ReferenceEntityId != "")
                {
                    if (menu.MenuTypeId == 1)
                    {
                        entityName = _iMetadataManager.GetEntityNameByEntityContext(menu.ReferenceEntityId, false);
                    }
                    else if (menu.MenuTypeId == 2)
                    {
                        entityName = _iMetadataManager.GetEntityNameByEntityContext(menu.ReferenceEntityId, true);
                    }
                    menu.ReferenceEntityId = entityName;
                }

                stopwatch.StopAndLog("GetMenuById of MenuController");

                if (menu != null)
                {
                    var settings = new JsonSerializerSettings();
                    settings.NullValueHandling = NullValueHandling.Ignore;
                    settings.ContractResolver  = new CamelCasePropertyNamesContractResolver();
                    return(Json(menu, settings));
                }

                return(NotFound("Menu not found"));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
        private DataTable SetEntityNamebyCode(string entityname, DataTable resultdt)
        {
            var targetentity = new List <string> (new string[] { "emailtemplate", "smstemplate" });

            if (targetentity.Contains(entityname.ToLower()))
            {
                if (resultdt.Columns.Contains("Context"))
                {
                    int x = 0;
                    foreach (DataRow myRow in resultdt.Rows)
                    {
                        myRow["Context"] = _iMetadataManager.GetEntityNameByEntityContext(Convert.ToString(myRow["Context"]), false);   //changes the ContextType;;
                        x++;
                    }
                }
            }
            return(resultdt);
        }
示例#3
0
 public IActionResult Get(Guid batchTypeId, [FromQuery] BatchItemTypeEnum itemType)
 {
     try
     {
         var stopwatch = StopwatchLogger.Start(_log);
         _log.Info("Called BatchItemController Get {0}=", JsonConvert.SerializeObject(batchTypeId));
         var items = _managerBatchItem.GetBatchItemListByStatus(TenantCode, batchTypeId, itemType);
         foreach (var item in items)
         {
             item.EntityId   = _iMetadataManager.GetEntityNameByEntityContext(item.EntityId);
             item.RetryCount = item.RetryCount > 0 ? (item.RetryCount - 1) : item.RetryCount;
         }
         stopwatch.StopAndLog("End BatchItemController Get");
         return(Ok(items));
     }
     catch (Exception ex)
     {
         _log.Error(ExceptionFormatter.SerializeToString(ex));
         return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
     }
 }
示例#4
0
        public IActionResult Get(Guid subscriptionId)
        {
            try
            {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called SubscriptionEntityController Get All");
                var retVal = _managerSubscriptionEntity.TenantSubscriptionEntities(TenantCode, subscriptionId);
                foreach (var ret in retVal)
                {
                    ret.EntityId = _iMetadataManager.GetEntityNameByEntityContext(ret.EntityId, false);
                }

                stopwatch.StopAndLog("End SubscriptionEntityController Get all");
                return(Ok(retVal));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
示例#5
0
        LayoutModel ILayoutManager.GetLayoutsDetailsById(Guid tenantId, Guid id)
        {
            //return _review.GetLayoutsDetailsById(tenantId, id);

            var layout = _review.GetLayoutsDetailsById(tenantId, id);

            if (layout != null && layout.EntityId != null && layout.Subtype != null)
            {
                var entityName = _iMetadataManager.GetEntityNameByEntityContext(layout.EntityId);
                var subTypes   = _iMetadataManager.GetSubTypesDetails(entityName);

                foreach (KeyValuePair <string, string> item in subTypes)
                {
                    if (item.Key == layout.Subtype)
                    {
                        layout.SubtypeeName = item.Value;
                    }
                }
            }

            MapLayoutDetails(tenantId, layout);

            return(layout);
        }
        List <WorkFlowInfo> IManagerWorkFlowSecurity.GetWorkFlowsByUserCode(Guid tenantId, Guid userId, bool isSuperAdmin)
        {
            var workFlowSteps      = _managerWorkFlowStep.GetWorkFlowStepsByUserId(tenantId, userId, isSuperAdmin);
            var workFlows          = _managerWorkFlow.GetWorkFlowsByIds(tenantId, workFlowSteps.Select(p => p.WorkFlowId).Distinct().ToList());
            var workFlowOperations = _managerOperation.GetWorkFlowOperationsByWorkFlowIds(tenantId, workFlows.Select(p => p.WorkFlowId).ToList());

            var workFlowInnerSteps        = _managerInnerStep.GetWorkFlowInnerStep_ByStepIds(tenantId, workFlowSteps.Select(p => p.WorkFlowStepId).ToList());
            var operationOrTransactionIds = new List <Guid>();

            operationOrTransactionIds.AddRange(workFlowOperations.Select(p => p.WorkFlowOperationId).ToList());
            operationOrTransactionIds.AddRange(workFlowInnerSteps.Select(p => p.InnerStepId).ToList());
            var workFlowProcess = _managerWorkFlowProcess.GetWorkFlowProcessByOperationOrTransitionIds(tenantId, operationOrTransactionIds);
            var processTasks    = _managerWorkFlowProcessTask.GetWorkFlowProcessTask_ByProcessIds(tenantId, workFlowProcess.Select(proc => proc.WorkFlowProcessId).ToList());
            var workFlowRoles   = _managerWorkFlowRole.GetWorkFlowRolesByStepIds(tenantId, workFlowSteps.Select(p => p.WorkFlowStepId).ToList());

            foreach (var workFlow in workFlows)
            {
                //get its operations
                workFlow.Operations = (from workFlowOperation in workFlowOperations where workFlowOperation.WorkFlowId == workFlow.WorkFlowId select workFlowOperation).ToList();
                //set process to operation
                foreach (var operation in workFlow.Operations)
                {
                    operation.WorkFlowProcess = (from workFlowPro in workFlowProcess where workFlowPro.OperationOrTransactionId == operation.WorkFlowOperationId &&
                                                 workFlowPro.WorkFlowId == workFlow.WorkFlowId select workFlowPro).ToList();
                    foreach (var process in operation.WorkFlowProcess)
                    {
                        process.WorkFlowProcessTasks = new List <WorkFlowProcessTaskInfo>();
                        if (process.ProcessType == (int)WorkFlowProcessType.PreProcess)
                        {
                            process.WorkFlowProcessTasks.AddRange((from allProcessTask in processTasks
                                                                   where process.WorkFlowProcessId == allProcessTask.WorkFlowProcessId && process.WorkFlowId == workFlow.WorkFlowId
                                                                   orderby allProcessTask.SequenceCode
                                                                   select allProcessTask).ToList());
                        }

                        if (process.ProcessType == (int)WorkFlowProcessType.Process)
                        {
                            process.WorkFlowProcessTasks.AddRange((from allProcessTask in processTasks
                                                                   where process.WorkFlowProcessId == allProcessTask.WorkFlowProcessId && process.WorkFlowId == workFlow.WorkFlowId
                                                                   orderby allProcessTask.SequenceCode
                                                                   select allProcessTask).ToList());
                        }

                        if (process.ProcessType == (int)WorkFlowProcessType.PostProcess)
                        {
                            process.WorkFlowProcessTasks.AddRange((from allProcessTask in processTasks
                                                                   where process.WorkFlowProcessId == allProcessTask.WorkFlowProcessId && process.WorkFlowId == workFlow.WorkFlowId
                                                                   orderby allProcessTask.SequenceCode
                                                                   select allProcessTask).ToList());
                        }
                    }
                }

                //get its steps
                workFlow.Steps = new List <WorkFlowStepInfo>();
                var allSteps         = WorkFlowHelper.GetAllSteps(workFlow.EntityId);
                var itsWorkFlowSteps = (from workFlowStep in workFlowSteps where workFlowStep.WorkFlowId == workFlow.WorkFlowId select workFlowStep).ToList();

                foreach (var itsWorkFlowStep in itsWorkFlowSteps)
                {
                    //filter its role
                    itsWorkFlowStep.Roles = (from workFlowRole in workFlowRoles where workFlowRole.WorkFlowStepId == itsWorkFlowStep.WorkFlowStepId &&
                                             workFlowRole.WorkFlowId == workFlow.WorkFlowId select workFlowRole).ToList();
                    var filteredStep = (from allStep in allSteps where itsWorkFlowStep.TransitionType.Id == allStep.Id select allStep).FirstOrDefault();
                    itsWorkFlowStep.TransitionType.Name = filteredStep.Value;
                    //filter its inner steps
                    var itsInnerSteps = (from workFlowInnerStep in workFlowInnerSteps where workFlowInnerStep.WorkFlowStepId == itsWorkFlowStep.WorkFlowStepId &&
                                         workFlowInnerStep.WorkFlowId == workFlow.WorkFlowId select workFlowInnerStep).ToList();
                    if (itsInnerSteps.Count > 0)
                    {
                        //filter Inner step process
                        foreach (var itsInnerStep in itsInnerSteps)
                        {
                            itsInnerStep.WorkFlowProcess = (from workFlowPro in workFlowProcess where workFlowPro.OperationOrTransactionId == itsInnerStep.InnerStepId &&
                                                            workFlowPro.WorkFlowId == workFlow.WorkFlowId select workFlowPro).ToList();

                            foreach (var process in itsInnerStep.WorkFlowProcess)
                            {
                                process.WorkFlowProcessTasks = new List <WorkFlowProcessTaskInfo>();
                                if (process.ProcessType == (int)WorkFlowProcessType.PreProcess)
                                {
                                    process.WorkFlowProcessTasks.AddRange((from allProcessTask in processTasks
                                                                           where process.WorkFlowProcessId == allProcessTask.WorkFlowProcessId && process.WorkFlowId == workFlow.WorkFlowId
                                                                           orderby allProcessTask.SequenceCode
                                                                           select allProcessTask).ToList());
                                }

                                if (process.ProcessType == (int)WorkFlowProcessType.Process)
                                {
                                    process.WorkFlowProcessTasks.AddRange((from allProcessTask in processTasks
                                                                           where process.WorkFlowProcessId == allProcessTask.WorkFlowProcessId && process.WorkFlowId == workFlow.WorkFlowId
                                                                           orderby allProcessTask.SequenceCode
                                                                           select allProcessTask).ToList());
                                }

                                if (process.ProcessType == (int)WorkFlowProcessType.PostProcess)
                                {
                                    process.WorkFlowProcessTasks.AddRange((from allProcessTask in processTasks
                                                                           where process.WorkFlowProcessId == allProcessTask.WorkFlowProcessId && process.WorkFlowId == workFlow.WorkFlowId
                                                                           orderby allProcessTask.SequenceCode
                                                                           select allProcessTask).ToList());
                                }
                            }
                        }
                        itsWorkFlowStep.InnerSteps = new List <WorkFlowInnerStepInfo>(itsInnerSteps);
                    }
                    workFlow.Steps.Add(itsWorkFlowStep);
                }
            }
            foreach (var workFlow in workFlows)
            {
                workFlow.EntityId = iMetadataManager.GetEntityNameByEntityContext(workFlow.EntityId);
                var subTypes = iMetadataManager.GetSubTypesDetails(workFlow.EntityId);
                foreach (var subType in subTypes)
                {
                    if (subType.Key == workFlow.SubTypeCode)
                    {
                        workFlow.SubTypeCode = subType.Value;
                    }
                }
            }
            return(workFlows);
        }