Пример #1
0
        public IActionResult GetDuration()
        {
            try
            {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called SubscriptionController Get All");

                var mainObj = new List <object>();
                Dictionary <int, string> routeRx = DataUtility.GetIntFieldNameFromEnum(typeof(SubscriptionDuration));
                foreach (var route in routeRx.OrderBy(u => u.Key))
                {
                    mainObj.Add(new
                    {
                        id   = route.Key.ToString(CultureInfo.InvariantCulture),
                        name = DataUtility.GetEnumDescription((SubscriptionDuration)route.Key)
                    });
                }
                stopwatch.StopAndLog("End SubscriptionController Get all");
                return(Ok(mainObj));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #2
0
        public IActionResult Get([FromRoute] string entityname, [FromQuery]  Guid transitionType, [FromQuery] Guid workFlowId)
        {
            try
            {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called WorkFlowStepController Get {0}=", JsonConvert.SerializeObject(entityname));
                var entityId           = _iMetadataManager.GetEntityContextByEntityName(entityname);
                var retVal             = WorkFlowHelper.GetAllSteps(entityId);
                var itsSavedInnerSteps = _managerWorkFlowInnerSteps.GetWorkFlowInnerStep_ByStepTransactionType(TenantCode, transitionType, workFlowId);
                if (retVal.Count > 0)
                {
                    retVal = (from retV in retVal where retV.Id != transitionType select retV).ToList();
                }
                List <WorkFlowResource> filteredInnerSteps = new List <WorkFlowResource>();
                foreach (var retV in retVal)
                {
                    var checkExistance = (from itsSavedInnerStep in itsSavedInnerSteps where itsSavedInnerStep.TransitionType.Id == retV.Id select itsSavedInnerStep).ToList();
                    if (checkExistance.Count == 0)
                    {
                        filteredInnerSteps.Add(retV);
                    }
                }

                stopwatch.StopAndLog("End WorkFlowStepController Get");
                return(Ok(filteredInnerSteps));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #3
0
        public IActionResult Get([FromRoute] Guid workFlowOperationId, [FromQuery] string entityName)
        {
            try
            {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called WorkFlowProcessTaskController Get by workFlowOperationId{0}=", JsonConvert.SerializeObject(workFlowOperationId));
                var tasks = _managerWorkFlowProcessTask.GetWorkFlowProcessTask_ByInnerStepId(TenantCode, workFlowOperationId);

                if (tasks.Count > 0)
                {
                    var entityId          = _iMetadataManager.GetEntityContextByEntityName(entityName);
                    var itsProcessorTasks = WorkFlowHelper.GetProcessorTitleByOperationModule(entityId);
                    foreach (var workFlowProcessTask in tasks)
                    {
                        var task = (from itsProcessorTask in itsProcessorTasks
                                    where itsProcessorTask.Id == workFlowProcessTask.ProcessCode select itsProcessorTask).ToList();
                        if (task.Count > 0)
                        {
                            workFlowProcessTask.ProcessName = task[0].Key;
                        }
                    }
                }

                stopwatch.StopAndLog("End WorkFlowProcessTaskController Get by innerStepId");
                return(Ok(tasks));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
        public IActionResult Delete(string resourceKey)
        {
            try
            {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called ResourceController Delete {0}=", JsonConvert.SerializeObject(resourceKey));
                bool retVal = false;
                Guid resourceId;
                if (Guid.TryParse(resourceKey, out resourceId))
                {
                    if (resourceId != null)
                    {
                        retVal = _resourceManager.Delete(TenantCode, resourceId);
                        stopwatch.StopAndLog("End ResourceController Delete");
                    }
                }
                else
                {
                    retVal = _resourceManager.DeleteByKey(TenantCode, resourceKey);
                    stopwatch.StopAndLog("End ResourceController Delete");
                }

                return(Ok(retVal));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #5
0
        public IActionResult UpdateSetting([FromBody] List <SettingModel> Item)
        {
            if (Item == null)
            {
                return(BadRequest("Invalid parameter"));
            }
            var isinserted = new List <bool>();

            try
            {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called SettingsController UpdateSettings");

                foreach (var item in Item)
                {
                    isinserted.Add(_iSettingManager.UpdateSetting(TenantCode, Mapfield(item)));
                }
                //if (string.IsNullOrEmpty(Item.Content))
                //    return BadRequest("Invalid parameter.");
                //if (Item.Context == 0)
                //    return BadRequest("Invalid parameter");
                //if (Item.Id == "")
                //    return BadRequest("Invalid parameter");

                stopwatch.StopAndLog("UpdateSettings method of SettingsController");
                return(Ok(isinserted.Contains(false) ? HttpStatusCode.ExpectationFailed : HttpStatusCode.OK));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #6
0
        public IActionResult GetDefaultLayout(string name, int type, int context)
        {
            try {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called PicklistController GetDefaultLayout with type {0}=", type);
                _log.Info("Called PicklistController GetDefaultLayout with name {0}=", name);
                _log.Info("Called PicklistController GetDefaultLayout with context {0}=", context);

                if (string.IsNullOrEmpty(name))
                {
                    return(BadRequest("Entity name required !"));
                }

                if (type == 0)
                {
                    return(BadRequest("Layout type required !"));
                }

                var layout = _iLayoutManager.GetDefaultPicklistLayout(TenantCode, name, (LayoutType)type, context);

                stopwatch.StopAndLog("GetDefaultLayout of PicklistController");
                if (layout != null)
                {
                    return(_iJsonMessage.IgnoreNullableObject(layout));
                }

                return(NotFound("No default layout found."));
            } catch (Exception ex) {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
        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));
            }
        }
        public IActionResult GetQuery()
        {
            try {
                //      var result = new Dictionary<string, dynamic>();

                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called ComparisonController GetQuery");

                var  result     = new List <dynamic>();
                Type enumType   = typeof(Comparison);
                var  enumValues = enumType.GetEnumValues();
                foreach (Comparison value in enumValues)
                {
                    MemberInfo memberInfo           = enumType.GetMember(value.ToString()).First();
                    var        descriptionAttribute = memberInfo.GetCustomAttribute <DescriptionAttribute>();
                    var        id          = value.ToString();
                    var        description = (descriptionAttribute != null)?descriptionAttribute.Description:value.ToString();
                    var        myObj       = new { id, description };
                    result.Add(myObj);
                }

                stopwatch.StopAndLog("GetQuery of ComparisonController");

                return(Ok(new { result }));
            } catch (FieldAccessException fx) {
                //return BadRequest (fx.Message);
                _log.Error(ExceptionFormatter.SerializeToString(fx));
                return(StatusCode((int)HttpStatusCode.BadRequest, ApiConstant.CustomErrorMessage));
            } catch (Exception ex) {
                //return StatusCode ((int) HttpStatusCode.InternalServerError, ex.Message);
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #9
0
 public IActionResult GetInfo(string fieldName = "DefaultLanguage")
 {
     try
     {
         var stopwatch = StopwatchLogger.Start(_log);
         _log.Info("Called TenantController Get Info");
         if (fieldName == null || fieldName == String.Empty)
         {
             fieldName = "DefaultLanguage";
         }
         if (fieldName != "DefaultLanguage")
         {
             return(StatusCode((int)HttpStatusCode.BadRequest, ApiConstant.CustomErrorMessage));
         }
         var retVal = _manageTenant.GetTenantLanguageInfo(TenantCode);
         //dynamic totalRow = 1; // retVal.Count;
         stopwatch.StopAndLog("End RuleController Get all");
         return(Ok(retVal)); //(new { retVal, totalRow });
     }
     catch (FieldAccessException fx)
     {
         _log.Error(ExceptionFormatter.SerializeToString(fx));
         return(StatusCode((int)HttpStatusCode.BadRequest, ApiConstant.CustomErrorMessage));
     }
     catch (Exception ex)
     {
         _log.Error(ExceptionFormatter.SerializeToString(ex));
         return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
     }
 }
Пример #10
0
        public IActionResult GetCurrentUserWorkFlow([FromRoute] string entityname)
        {
            try
            {
                // var details = iMetadataManager.GetEntitityByName(entityname);
                // if(details!=null && details.VersionControl !=null )
                // entityname=details.VersionControl.Name;

                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called WorkFlowController Get all by entity name {0}=", JsonConvert.SerializeObject(entityname));
                var workFlows            = SecurityCache.WorkFlow;
                List <WorkFlowInfo> list = new List <WorkFlowInfo>();
                if (workFlows.Count > 0)
                {
                    list = (from workFlow in workFlows where workFlow.EntityId.ToLower() == entityname.ToLower() select workFlow).ToList();
                }

                stopwatch.StopAndLog("End WorkFlowController Get all by entity name");
                return(Ok(list));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
        public IActionResult Get(Guid subscriptionEntityId, Guid subscriptionEntityDetailId)
        {
            try
            {
                if (subscriptionEntityId == Guid.Empty)
                {
                    return(BadRequest("Invalid parameter"));
                }

                if (subscriptionEntityDetailId == Guid.Empty)
                {
                    return(BadRequest("Invalid parameter"));
                }

                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called SubscriptionEntityDetailController Get");
                var retVal = _managerEntityDetail.TenantSubscriptionEntityDetail(TenantCode, subscriptionEntityDetailId);
                stopwatch.StopAndLog("End SubscriptionEntityDetailController Get");
                return(Ok(retVal));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #12
0
        public IActionResult Get()
        {
            try
            {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called BatchTypeController Get All");
                var allBatchTypes = DataUtility.GetAllBatchTypes();
                var savesBatches  = _managerBatchType.GetBatchTypes(TenantCode);
                foreach (var allBatchType in allBatchTypes)
                {
                    var checkBatchExists = (from savesBatche in savesBatches where savesBatche.Context == allBatchType.Context select savesBatche).FirstOrDefault();
                    if (checkBatchExists != null)
                    {
                        allBatchType.BatchTypeId = checkBatchExists.BatchTypeId;
                        allBatchType.Status      = checkBatchExists.Status;
                        allBatchType.IdleTime    = checkBatchExists.IdleTime;
                        allBatchType.Priority    = checkBatchExists.Priority;
                    }
                }

                stopwatch.StopAndLog("End BatchTypeController Get all");
                return(Ok(allBatchTypes));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #13
0
        public IActionResult GetAllMenu()
        {
            try
            {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called MenuController GetMenu");

                List <MenuItem> Objmenu = new List <MenuItem>();

                try
                {
                    Objmenu = _iMenuManager.GetMenuBytenant(TenantCode);
                }
                catch (Exception ex)
                {
                    _log.Error(ExceptionFormatter.SerializeToString(ex));
                    return(BadRequest("Incorrect Type."));
                }

                stopwatch.StopAndLog("GetMenu of MenuController");

                var settings = new JsonSerializerSettings();
                settings.NullValueHandling = NullValueHandling.Ignore;
                settings.ContractResolver  = new CamelCasePropertyNamesContractResolver();
                return(Json(Objmenu, settings));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #14
0
        public IActionResult GetMenu([FromQuery] int pageIndex, int pageSize, string groupName)
        {
            try
            {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called MenuController GetMenu");

                List <MenuItem> menus = new List <MenuItem>();

                try
                {
                    //var tenantId = new Guid("1C083115-7DB3-4B92-A449-D57FD1D2A52A");
                    menus = _iMenuManager.GetMenu(TenantCode, groupName, pageIndex, pageSize);
                    //menus = _iMenuManager.GetMenu(tenantId, groupName, pageIndex, pageSize);
                }
                catch (Exception ex)
                {
                    _log.Error(ExceptionFormatter.SerializeToString(ex));
                    return(BadRequest("Incorrect Type."));
                }

                stopwatch.StopAndLog("GetMenu of MenuController");

                var settings = new JsonSerializerSettings();
                settings.NullValueHandling = NullValueHandling.Ignore;
                settings.ContractResolver  = new CamelCasePropertyNamesContractResolver();
                return(Json(menus, settings));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #15
0
        public IActionResult SetPickListLayoutDefault([FromRoute] string name, [FromBody] LayoutModel layout)
        {
            try {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called PicklistController SetPickListLayoutDefault");
                _log.Info("Called PicklistController SetPickListLayoutDefault with LayoutModel {0}=", JsonConvert.SerializeObject(layout));
                _log.Info("Called PicklistController SetPickListLayoutDefault with name {0}=", name);

                if (string.IsNullOrEmpty(name))
                {
                    return(BadRequest("Picklist name required"));
                }
                if (layout == null)
                {
                    return(BadRequest("Layout required"));
                }

                _iLayoutManager.SetPicklistLayoutDefault(name, layout, UserId, TenantCode);
                stopwatch.StopAndLog("SetPickListLayoutDefault method of PicklistController.");
                return(Ok(true));
            } catch (Exception ex) {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #16
0
        // [ValidateJObjectdata]
        public IActionResult UpdateResult([FromRoute] string entityName, Guid id, [FromQuery] string subType, [FromBody] JObject value)
        {
            try {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called EntityController UpdateResult");
                if (value == null)
                {
                    return(BadRequest("Value required"));
                }
                if (string.IsNullOrEmpty(subType))
                {
                    return(BadRequest("sub type required"));
                }

                // var mainObj = value.Children ().FirstOrDefault (t => t.Path.ToLower ().Equals (entityName.ToLower()));
                // var targetObj = mainObj.First ().ToObject<JObject> ();
                // var result = _iEntityResourceManager.UpdateResult (TenantCode, UserId, id, entityName, targetObj, subType);

                var result = _iEntityResourceManager.UpdateResult(TenantCode, UserId, id, entityName, value, subType);
                stopwatch.StopAndLog("UpdateResult of EntityController");
                return(Ok(result));
            } catch (FieldAccessException ex) {
                //return BadRequest(ex.Message);
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.BadRequest, ApiConstant.CustomErrorMessage));
            } catch (Exception ex) {
                //return StatusCode((int)HttpStatusCode.InternalServerError, ex.Message);
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #17
0
        public IActionResult GetLayoutsDetailsById(Guid id)
        {
            try {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called PicklistController GetLayoutsDetailsById");

                if (id == Guid.Empty)
                {
                    return(BadRequest("Picklist id required !"));
                }

                var layout = _iLayoutManager.GetPicklistLayoutDetailsById(TenantCode, id);

                stopwatch.StopAndLog("GetLayoutsDetailsById of PicklistController");
                if (layout != null)
                {
                    return(_iJsonMessage.IgnoreNullableObject(layout));
                }

                return(NotFound("No default layout found."));
            } catch (Exception ex) {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #18
0
        public IActionResult DetailEntity_UpdateResult([FromRoute] string entityName, Guid id, string detailEntityName, Guid detailId, [FromQuery] string subType, [FromBody] JObject value)
        {
            try {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called EntityController DetailEntity_UpdateResult");

                if (value == null)
                {
                    return(BadRequest("Value required"));
                }
                if (string.IsNullOrEmpty(subType))
                {
                    return(BadRequest("sub type required"));
                }
                var result = _iEntityResourceManager.UpdateResult(TenantCode, UserId, detailId, detailEntityName, value, subType);
                stopwatch.StopAndLog("DetailEntity_UpdateResult of EntityController");
                return(Ok(result));
            } catch (FieldAccessException ex) {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.BadRequest, ApiConstant.CustomErrorMessage));
            } catch (Exception ex) {
                //return StatusCode((int)HttpStatusCode.InternalServerError, ex.Message);
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #19
0
        public IActionResult GetEntities([FromQuery] string entityType = "")
        {
            try
            {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called MetadataController GetEntities");

                var result = _iMetadataManager.GetEntities(false).OrderBy(t => t.Name);

                if (entityType.ToLower() == "primaryentity")
                {
                    result = result.Where(a => a.Type.ToLower() == "primaryentity" || a.Type.ToLower() == "detailentity" || a.Type.ToLower() == "intersectentity").OrderBy(t => t.Name);
                }

                stopwatch.StopAndLog("GetEntities of MetadataController");
                return(_iJsonMessage.IgnoreNullableObject(result));
            }
            catch (Exception ex)
            {
                //_log.Error("Error calling MetadataController.GetEntities method.");
                //throw new Exception(ex.Message);
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #20
0
        public IActionResult Put([FromBody] RuleInfo rule, string entityName)
        {
            try
            {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called RuleController Put {0}=", JsonConvert.SerializeObject(rule));

                if (!String.IsNullOrEmpty(rule.EntityName))
                {
                    rule.EntityId = _iMetadataManager.GetEntityContextByEntityName(entityName);
                }

                string strMsg = string.Empty;
                var    retVal = _manageRule.Update(TenantCode, rule, ref strMsg);

                if (!String.IsNullOrEmpty(strMsg) && retVal == false)
                {
                    return(StatusCode((int)HttpStatusCode.AlreadyReported, strMsg));
                }

                stopwatch.StopAndLog("End RuleController put");
                return(Ok(retVal));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #21
0
        public IActionResult Put(Guid resourceId, [FromBody] VPC.Entities.EntityCore.Model.Resource.Resource resource)
        {
            try
            {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called ResourceController Put {0}=", JsonConvert.SerializeObject(resource));

                string strMsg = string.Empty;

                var retVal = _resourceManager.Update(resourceId, TenantCode, resource, UserId, ref strMsg);

                if (!String.IsNullOrEmpty(strMsg) && retVal == false)
                {
                    return(StatusCode((int)HttpStatusCode.AlreadyReported, strMsg));
                }

                stopwatch.StopAndLog("End ResourceController Put");
                return(Ok(retVal));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #22
0
 public IActionResult GetPicklistValueById([FromRoute] string name, Guid id)
 {
     try {
         var stopwatch = StopwatchLogger.Start(_log);
         _log.Info("Called PicklistController GetPicklistValueById");
         _log.Info("Called PicklistController GetPicklistValueById with name {0}=", name);
         _log.Info("Called PicklistController GetPickListValueByPiGetPicklistValueByIdcklistName with id {0}=", id.ToString());
         if (string.IsNullOrEmpty(name))
         {
             return(BadRequest("Entity name required!"));
         }
         if (id == Guid.Empty)
         {
             return(BadRequest("Id required!"));
         }
         var result = _picklistManager.GetPicklistValueDetails(TenantCode, name, id, LayoutType.Form, LayoutContext.Edit);
         if (result != null && result.Rows.Count > 0)
         {
             ApiHelper.MapDynamicColumn(result.Columns);
             var json = new JObject(result.Columns.Cast <DataColumn> ().Select(c => new JProperty(c.ColumnName, JToken.FromObject(result.Rows[0][c]))));
             return(Ok(json));
         }
         stopwatch.StopAndLog("GetPicklistValueById method of PicklistController.");
         return(NotFound("Data not found"));
     } catch (Exception ex) {
         _log.Error(ExceptionFormatter.SerializeToString(ex));
         return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
     }
 }
Пример #23
0
        public IActionResult GetSettingById(Guid id)
        {
            if (id == Guid.Empty)
            {
                return(BadRequest("Setting Id required!"));
            }
            try
            {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called SettingController GetSettingById");

                var result = _iSettingManager.GetSettingsById(TenantCode, id);

                stopwatch.StopAndLog("GetSettingById of SettingController");


                //var settings = new JsonSerializerSettings();
                //settings.NullValueHandling = NullValueHandling.Ignore;
                //settings.ContractResolver = new CamelCasePropertyNamesContractResolver();
                //return Json(result, settings);
                return(Ok(result));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #24
0
        public IActionResult DeletePickListValue([FromRoute] string name, Guid id)
        {
            try {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called PicklistController DeletePickListValue");
                _log.Info("Called PicklistController DeletePickListValue with fields {0}=", id);
                _log.Info("Called PicklistController UpdatePicklistValue with name {0}=", name);

                if (string.IsNullOrEmpty(name))
                {
                    return(BadRequest("Entity name required!"));
                }
                if (id == Guid.Empty)
                {
                    return(BadRequest("Id required!"));
                }

                var result = _picklistManager.DeletePickListValueById(TenantCode, name, id);
                stopwatch.StopAndLog("DeletePickListValue method of PicklistController.");
                return(Ok(result));
            } catch (Exception ex) {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #25
0
        public IActionResult GetSettingByContext(string contexttype)
        {
            try
            {
                var tenantId = TenantCode;
                SettingContextTypeEnum contextenum;
                if (tenantId == Guid.Empty)
                {
                    return(BadRequest("Tenant is invalid!"));
                }

                if (!Enum.TryParse(contexttype, out contextenum))
                {
                    return(BadRequest("ContextType is invalid!"));
                }

                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called SettingController GetSettingByContext");

                SettingModel retobj = new SettingModel();
                // var dd = _iSettingManager.GetSenderNameByContext(tenantId, contextenum);

                var result = _iSettingManager.GetSettingsByContext(TenantCode, contextenum); //(ContextType)contexttype

                stopwatch.StopAndLog("GetSettingByContext of SettingController");


                return(Ok(result));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #26
0
        public IActionResult GetPickListLayoutByPicklistName([FromRoute] string name, [FromQuery] string type)
        {
            try {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called PicklistController GetPickListLayoutByPicklistName");
                _log.Info("Called PicklistController UpdatePicklistValue with name {0}=", name);

                if (string.IsNullOrEmpty(name))
                {
                    return(BadRequest("Entity name required!"));
                }

                if (string.IsNullOrEmpty(type))
                {
                    var result = _iLayoutManager.GetLayoutsByPicklistName(TenantCode, name);
                    stopwatch.StopAndLog("GetPickListLayoutByPicklistName method of PicklistController.");
                    return(Ok(result));
                }
                else
                {
                    var result = _iLayoutManager.GetLayoutsByEntityName(TenantCode, _iMetadataManager.GetEntityContextByEntityName(name, true), _iMetadataManager.GetTypeId(type), true);
                    stopwatch.StopAndLog("GetPickListLayoutByPicklistName method of PicklistController.");
                    return(Ok(result));
                }
            } catch (Exception ex) {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
        public IActionResult Initialize([FromRoute] Guid tenantCode)
        {
            try
            {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called InitilizationController Initialize with tenantCode {0}=", tenantCode);

                if (tenantCode != Guid.Empty)
                {
                    return(BadRequest("tenant code required!"));
                }

                //string tenantcode = "GCTT001";
                _initilizeManager.Initilize(tenantCode, new List <string> {
                    "EN10003"
                }, UserId, Guid.Empty);

                stopwatch.StopAndLog("Initialize method of InitilizationController.");
                return(Ok(true));
            }
            catch (FieldAccessException ex)
            {
                return(BadRequest(ex.Message));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #28
0
        public IActionResult SavePickListLayout([FromRoute] string name, [FromBody] LayoutModel layoutModel)
        {
            try {
                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called PicklistController SavePickListLayout");
                _log.Info("Called PicklistController GetPickListValueByPicklistName with LayoutModel {0}=", JsonConvert.SerializeObject(layoutModel));
                _log.Info("Called PicklistController UpdatePicklistValue with name {0}=", name);

                if (string.IsNullOrEmpty(name))
                {
                    return(BadRequest("Entity name required!"));
                }

                if (layoutModel == null)
                {
                    return(BadRequest("Layout detail required!"));
                }

                var retVal = _iLayoutManager.CreatePicklistLayout(name, layoutModel, UserId, TenantCode);
                stopwatch.StopAndLog("SavePickListLayout method of PicklistController.");
                return(Ok(retVal));
            } catch (Exception ex) {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #29
0
        public IActionResult Post([FromBody] RoleInfo role)
        {
            try
            {
                if (role == null)
                {
                    return(BadRequest("Invalid parameter"));
                }
                if (string.IsNullOrEmpty(role.Name))
                {
                    return(BadRequest("Invalid parameter."));
                }
                if (role.RoleType == 0)
                {
                    return(BadRequest("Invalid parameter"));
                }

                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called RoleController Post {0}=", JsonConvert.SerializeObject(role));
                role.AuditDetail = new AuditDetail {
                    ModifiedBy = UserId
                };
                var retVal = _managerRole.Create(TenantCode, role);
                stopwatch.StopAndLog("End RoleController Post");
                return(Ok(retVal));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }
Пример #30
0
        public IActionResult Put([FromBody] TenantSubscriptionInfo info)
        {
            try
            {
                if (info == null)
                {
                    return(BadRequest("Invalid parameter"));
                }
                if (string.IsNullOrEmpty(info.Name))
                {
                    return(BadRequest("Invalid parameter."));
                }
                if (info.Group == null)
                {
                    return(BadRequest("Invalid parameter"));
                }
                if (info.Group.Id == Guid.Empty)
                {
                    return(BadRequest("Invalid parameter"));
                }

                var stopwatch = StopwatchLogger.Start(_log);
                _log.Info("Called SubscriptionController Put {0}=", JsonConvert.SerializeObject(info));
                var retVal = _managerSubscription.Update(TenantCode, info);
                stopwatch.StopAndLog("End SubscriptionController Put");
                return(Ok(retVal));
            }
            catch (Exception ex)
            {
                _log.Error(ExceptionFormatter.SerializeToString(ex));
                return(StatusCode((int)HttpStatusCode.InternalServerError, ApiConstant.CustomErrorMessage));
            }
        }