/// <summary> /// Components the list. /// </summary> /// <returns></returns> public BaseResponse <List <ComponentModel> > ComponentList() { try { logManagementRepository = new LogManagementRepository(); DataResponse <List <Component> > dataResponse = logManagementRepository.ComponentList(); List <ComponentModel> componentList = new List <ComponentModel>(); if (dataResponse != null && dataResponse.Data != null) { foreach (Component item in dataResponse.Data) { componentList.Add(new ComponentModel() { ComponentId = item.ComponentId, Name = item.Name }); } } return(new BaseResponse <List <ComponentModel> >() { Data = componentList, Message = new ResponseMessage() { Status = (ResponseStatus)dataResponse.Status }, }); } catch (Exception) { throw; } }
/// <summary> /// Components the list test. /// </summary> /// <returns></returns> public List <ComponentModel> ComponentListTest() { try { logManagementRepository = new LogManagementRepository(); DataResponse <List <Component> > dataResponse = logManagementRepository.ComponentList(); List <ComponentModel> componentList = new List <ComponentModel>(); if (dataResponse != null && dataResponse.Data != null) { foreach (Component item in dataResponse.Data) { componentList.Add(new ComponentModel() { ComponentId = item.ComponentId, Name = item.Name }); } } return(componentList); } catch (Exception) { throw; } }
public ComponentConfiguration GetConfiguration(string applicationCode, string logger) { lock (_lockConfig) { if (applicationCode == null) { applicationCode = string.Empty; } if (componentConfigurationList.FirstOrDefault(x => string.Equals(x.ApplicationCode, applicationCode, StringComparison.CurrentCulture)) == null) { LogManagementRepository logManagementRepository = new LogManagementRepository(); DataResponse <List <ComponentConfiguration> > dataResponse = logManagementRepository.LogComponentList(applicationCode); lock (_lockConfigObject) { if (dataResponse != null && dataResponse.Data != null && dataResponse.Data.Count > 0) { componentConfigurationList.AddRange(dataResponse.Data); return(componentConfigurationList.FirstOrDefault(x => x.Component.Name.Equals(logger, StringComparison.CurrentCultureIgnoreCase) && string.Equals(x.ApplicationCode, applicationCode, StringComparison.CurrentCulture))); } else if ((componentConfigurationList == null && componentConfigurationList.Count == 0) || !componentConfigurationList.Exists(x => x.ApplicationCode == string.Empty)) { DataResponse <List <ComponentConfiguration> > dataResponseEmptyApp = logManagementRepository.LogComponentList(string.Empty); if (dataResponseEmptyApp != null && dataResponseEmptyApp.Data != null) { componentConfigurationList.AddRange(dataResponseEmptyApp.Data); } } } } } return(componentConfigurationList.FirstOrDefault(x => x.Component.Name.Equals(logger, StringComparison.CurrentCultureIgnoreCase) && x.ApplicationCode == applicationCode)); }
/// <summary> /// Adds the application configuration. /// </summary> /// <param name="applicationCode">The application code.</param> /// <param name="enableOmsConfig">if set to <c>true</c> [enable oms configuration].</param> /// <returns></returns> public BaseResponse <string> AddApplicationConfiguration(string applicationCode, bool enableOmsConfig) { try { if (string.IsNullOrEmpty(applicationCode)) { FireValidation(component.logger.platform.common.MessageCode.InvalidApplication, ResponseStatus.Business_InvalidData); } logManagementRepository = new LogManagementRepository(); DataResponse <string> dataResponse = logManagementRepository.AddApplicationConfiguration(applicationCode, enableOmsConfig); ValidateResponse(dataResponse); return(new BaseResponse <string>() { Data = dataResponse.Data, Message = new ResponseMessage() { Status = (ResponseStatus)dataResponse.Status } }); } catch (Exception) { throw; } }
public ComponentConfiguration AddComponentConfiguration(string applicationCode, string logger) { lock (_lockConfig) { LogManagementRepository logManagementRepository = new LogManagementRepository(); bool isSucess = logManagementRepository.AddComponentConfiguration(applicationCode, logger); return(GetConfiguration(applicationCode, logger)); } }
public LogConfiguration GetLogSeverity(LogSeverity logSeverity) { lock (_lockLogConfig) { if (listLogConfiguration == null || listLogConfiguration.Count == 0) { LogManagementRepository logManagementRepository = new LogManagementRepository(); DataResponse <List <LogConfiguration> > dataResponse = logManagementRepository.GetSeverityList(); listLogConfiguration = dataResponse.Data; } } return(listLogConfiguration.FirstOrDefault(x => x.Type.Equals(Convert.ToString(logSeverity), StringComparison.CurrentCultureIgnoreCase))); }
public Component GetLogComponents(string logComponent) { lock (_lockLogComponent) { if (listLogComponent == null || listLogComponent.Count == 0) { LogManagementRepository logManagementRepository = new LogManagementRepository(); DataResponse <List <Component> > dataResponse = logManagementRepository.ComponentList(); listLogComponent = dataResponse.Data; } } return(listLogComponent.FirstOrDefault(x => x.Name.Equals(Convert.ToString(logComponent), StringComparison.CurrentCultureIgnoreCase))); }
/// <summary> /// Gets the application key. /// </summary> /// <param name="Key">The key.</param> /// <returns></returns> public string GetApplicationKey(string Key) { lock (_lockConfig) { if (appSettings == null || appSettings.Count == 0) { LogManagementRepository logManagementRepository = new LogManagementRepository(); appSettings = logManagementRepository.GetAppSetting(); } } AppSetting data = appSettings.FirstOrDefault(x => x.Key.Equals(Convert.ToString(Key), StringComparison.CurrentCultureIgnoreCase)); if (data != null) { return(data.Value); } else { return(string.Empty); } }
/// <summary> /// Jobs the clean application log. /// </summary> private async void JobCleanApplicationLog() { string days = ServiceAppSetting.Instance.GetAppSettingByKey("ApplicationLogKeepDays"); LogManagementRepository logManagementRepository = new LogManagementRepository(); bool dataResponse = logManagementRepository.CleanApplicationLog(string.IsNullOrWhiteSpace(days) ? 7 : Convert.ToInt32(days)); }