internal static fwk_ServiceDispatcher Dispatcher_Get(string pInstanseName) { using (Fwk.ConfigData.FwkDatacontext dc = new Fwk.ConfigData.FwkDatacontext()) { return dc.fwk_ServiceDispatchers.Where(p => p.InstanseName.Equals(pInstanseName)).FirstOrDefault(); } }
/// <summary> /// Retorna un param por id y cultura /// </summary> /// <param name="paramId"></param> /// <param name="culture"></param> /// <param name="cnnStringName"></param> /// <returns></returns> public static ParamBE Get(int? paramId, string culture, string cnnStringName) { ParamBE wParamBE =null; try { using (Fwk.ConfigData.FwkDatacontext dc = new Fwk.ConfigData.FwkDatacontext(System.Configuration.ConfigurationManager.ConnectionStrings[cnnStringName].ConnectionString)) { var param_db = dc.fwk_Params.Where(s => (!paramId.HasValue || s.ParamId.Equals(paramId)) && (string.IsNullOrEmpty(culture) || s.Culture.Equals(culture)) ).FirstOrDefault(); if (param_db != null) { wParamBE = new ParamBE(); wParamBE.ParamId = param_db.ParamId; wParamBE.ParentId = param_db.ParentId; wParamBE.Name = param_db.Name; wParamBE.Description = param_db.Description; wParamBE.Enabled = param_db.Enabled; wParamBE.Culture = param_db.Culture; wParamBE.Id = param_db.Id; } return wParamBE; } } catch (Exception ex) { throw ex; } }
/// <summary> /// Retorna un param por id y cultura /// </summary> /// <param name="paramId"></param> /// <param name="culture"></param> /// <param name="cnnStringName"></param> /// <returns></returns> public static ParamBE Get(int?paramId, string culture, string cnnStringName) { ParamBE wParamBE = null; try { using (Fwk.ConfigData.FwkDatacontext dc = new Fwk.ConfigData.FwkDatacontext(System.Configuration.ConfigurationManager.ConnectionStrings[cnnStringName].ConnectionString)) { var param_db = dc.fwk_Params.Where(s => (!paramId.HasValue || s.ParamId.Equals(paramId)) && (string.IsNullOrEmpty(culture) || s.Culture.Equals(culture)) ).FirstOrDefault(); if (param_db != null) { wParamBE = new ParamBE(); wParamBE.ParamId = param_db.ParamId; wParamBE.ParentId = param_db.ParentId; wParamBE.Name = param_db.Name; wParamBE.Description = param_db.Description; wParamBE.Enabled = param_db.Enabled; wParamBE.Culture = param_db.Culture; wParamBE.Id = param_db.Id; } return(wParamBE); } } catch (Exception ex) { throw ex; } }
/// <summary> /// /// </summary> /// <param name="paramId"></param> /// <param name="parentId"></param> /// <param name="culture"></param> /// <param name="cnnStringName"></param> /// <returns></returns> public static Boolean Exist(int? paramId, int? parentId, string culture, string cnnStringName) { try { using (Fwk.ConfigData.FwkDatacontext dc = new Fwk.ConfigData.FwkDatacontext(System.Configuration.ConfigurationManager.ConnectionStrings[cnnStringName].ConnectionString)) { bool exist = dc.fwk_Params.Any(s=> (!parentId.HasValue || s.ParentId.Equals(parentId)) && (!paramId.HasValue || s.ParamId.Equals(paramId)) && (string.IsNullOrEmpty(culture) || s.Culture.Equals(culture)) ); return exist; } } catch (Exception ex) { throw ex; } }
/// <summary> /// /// </summary> /// <returns></returns> internal static List<fwk_ServiceDispatcher> Dispatcher_List() { using (Fwk.ConfigData.FwkDatacontext dc = new Fwk.ConfigData.FwkDatacontext()) { return dc.fwk_ServiceDispatchers.ToList < fwk_ServiceDispatcher>(); } }
internal static void Dispatcher_Create(fwk_ServiceDispatcher disp) { using(Fwk.ConfigData.FwkDatacontext dc = new Fwk.ConfigData.FwkDatacontext ()) { dc.fwk_ServiceDispatchers.InsertOnSubmit(disp); dc.SubmitChanges(); } }
internal static bool Dispatcher_Exist(string dispName, string url) { using (Fwk.ConfigData.FwkDatacontext dc = new Fwk.ConfigData.FwkDatacontext()) { if (!string.IsNullOrEmpty(dispName)) return dc.fwk_ServiceDispatchers.Any( p=>p.InstanseName.Equals(dispName)); if (!string.IsNullOrEmpty(url)) return dc.fwk_ServiceDispatchers.Any( p => p.InstanseName.Equals(url)); } return true; }
/// <summary> /// Retorna parametros por id, id padre, y filtra x vigentes o no vigentes La cultura puede se String.Empty /// en cuyo caso no la tendra en cuenta para el filtro /// </summary> /// <param name="parentId">Relacion con otro param</param> /// <param name="enabled">Vigentes o no</param> /// <param name="culture">Cultura que se desea consultar: th-TH, en-US, es-AR etc etc</param> /// <param name="cnnStringName">Cadena de coneccion</param> /// <returns></returns> public static ParamList RetriveByParams(int? parentId, bool? enabled,string culture, string cnnStringName) { ParamList wParamList = new ParamList(); ParamBE wParamBE = null; try { using (Fwk.ConfigData.FwkDatacontext dc = new Fwk.ConfigData.FwkDatacontext(System.Configuration.ConfigurationManager.ConnectionStrings[cnnStringName].ConnectionString)) { var rulesinCat = from s in dc.fwk_Params where (!parentId.HasValue || s.ParentId.Equals(parentId)) && (!enabled.HasValue || s.Enabled.Equals(enabled) && (string.IsNullOrEmpty(culture) || s.Culture.Equals(culture))) select s; foreach (Fwk.ConfigData.fwk_Param param_db in rulesinCat.ToList<Fwk.ConfigData.fwk_Param>()) { wParamBE = new ParamBE(); wParamBE.ParamId = param_db.ParamId; wParamBE.ParentId = param_db.ParentId; wParamBE.Name = param_db.Name; wParamBE.Description = param_db.Description; wParamBE.Enabled = param_db.Enabled; wParamBE.Culture = param_db.Culture; wParamBE.Id = param_db.Id; wParamList.Add(wParamBE); } } return wParamList; } catch (Exception ex) { throw ex; } }
/// <summary> /// /// </summary> /// <param name="paramBE"></param> /// <param name="userId"></param> /// <param name="cnnStringName"></param> public static void Create(ParamBE paramBE, Guid?userId, string cnnStringName) { using (Fwk.ConfigData.FwkDatacontext dc = new Fwk.ConfigData.FwkDatacontext(System.Configuration.ConfigurationManager.ConnectionStrings[cnnStringName].ConnectionString)) { Fwk.ConfigData.fwk_Param param = new ConfigData.fwk_Param(); param.Culture = paramBE.Culture; param.Description = paramBE.Description; param.Enabled = true; param.Name = paramBE.Name; param.ParamId = paramBE.ParamId; param.ParentId = paramBE.ParentId; dc.fwk_Params.InsertOnSubmit(param); dc.SubmitChanges(); paramBE.Id = param.Id; } }
/// <summary> /// Actualiza fwk_Param /// </summary> /// <param name="paramBE"></param> /// <param name="userUpdateId"></param> /// <param name="cnnStringName"></param> public static void Update(ParamBE paramBE, Guid?userUpdateId, string cnnStringName) { using (Fwk.ConfigData.FwkDatacontext dc = new Fwk.ConfigData.FwkDatacontext(System.Configuration.ConfigurationManager.ConnectionStrings[cnnStringName].ConnectionString)) { Fwk.ConfigData.fwk_Param param = dc.fwk_Params.Where(p => p.Id.Equals(paramBE.Id)).FirstOrDefault(); if (param != null) { param.Enabled = true; param.Name = paramBE.Name; param.Culture = paramBE.Culture; param.Description = paramBE.Description; //param.ParamId = paramBE.ParamId; //param.ParentId = paramBE.ParentId; dc.SubmitChanges(); } } }
/// <summary> /// Permite eliminar por /// solo parentId /// solo paramId /// por ambos /// no permite que ambos sean Null /// </summary> /// <param name="paramId"></param> /// <param name="parentId"></param> /// <param name="cnnStringName"></param> public static void Delete(int?paramId, int?parentId, string cnnStringName) { //no permite que ambos sean Null if (paramId.HasValue == false || parentId.HasValue == false) { throw new Fwk.Exceptions.TechnicalException("Debe proporcinar almeno uno de los dos parametros"); } using (Fwk.ConfigData.FwkDatacontext dc = new Fwk.ConfigData.FwkDatacontext(System.Configuration.ConfigurationManager.ConnectionStrings[cnnStringName].ConnectionString)) { var paramsList = dc.fwk_Params.Where(p => (paramId.HasValue == false || p.ParamId.Equals(paramId.Value)) && (parentId.HasValue == false || p.ParentId.Equals(parentId.Value))); foreach (fwk_Param p in paramsList) { dc.fwk_Params.DeleteOnSubmit(p); } dc.SubmitChanges(); } }
/// <summary> /// Retorna parametros por id, id padre, y filtra x vigentes o no vigentes La cultura puede se String.Empty /// en cuyo caso no la tendra en cuenta para el filtro /// </summary> /// <param name="parentId">Relacion con otro param</param> /// <param name="enabled">Vigentes o no</param> /// <param name="culture">Cultura que se desea consultar: th-TH, en-US, es-AR etc etc</param> /// <param name="cnnStringName">Cadena de coneccion</param> /// <returns></returns> public static ParamList RetriveByParams(int?parentId, bool?enabled, string culture, string cnnStringName) { ParamList wParamList = new ParamList(); ParamBE wParamBE = null; try { using (Fwk.ConfigData.FwkDatacontext dc = new Fwk.ConfigData.FwkDatacontext(System.Configuration.ConfigurationManager.ConnectionStrings[cnnStringName].ConnectionString)) { var rulesinCat = from s in dc.fwk_Params where (!parentId.HasValue || s.ParentId.Equals(parentId)) && (!enabled.HasValue || s.Enabled.Equals(enabled) && (string.IsNullOrEmpty(culture) || s.Culture.Equals(culture))) select s; foreach (Fwk.ConfigData.fwk_Param param_db in rulesinCat.ToList <Fwk.ConfigData.fwk_Param>()) { wParamBE = new ParamBE(); wParamBE.ParamId = param_db.ParamId; wParamBE.ParentId = param_db.ParentId; wParamBE.Name = param_db.Name; wParamBE.Description = param_db.Description; wParamBE.Enabled = param_db.Enabled; wParamBE.Culture = param_db.Culture; wParamBE.Id = param_db.Id; wParamList.Add(wParamBE); } } return(wParamList); } catch (Exception ex) { throw ex; } }
internal static void Dispatcher_Update(fwk_ServiceDispatcher disp) { using (Fwk.ConfigData.FwkDatacontext dc = new Fwk.ConfigData.FwkDatacontext()) { var disp_db = dc.fwk_ServiceDispatchers.Where(p => p.InstanseName.Equals(disp.InstanseId)).FirstOrDefault(); disp_db.AuditMode = disp.AuditMode; disp_db.CompanyName = disp.CompanyName; disp_db.HostIp = disp.HostIp; disp_db.HostName = disp.HostName; disp_db.InstanseName = disp.InstanseName; disp_db.Logo = disp.Logo; disp_db.Port = disp.Port; disp_db.Url_URI = disp.Url_URI; dc.SubmitChanges(); } }
/// <summary> /// /// </summary> /// <param name="paramId"></param> /// <param name="parentId"></param> /// <param name="culture"></param> /// <param name="cnnStringName"></param> /// <returns></returns> public static Boolean Exist(int?paramId, int?parentId, string culture, string cnnStringName) { try { using (Fwk.ConfigData.FwkDatacontext dc = new Fwk.ConfigData.FwkDatacontext(System.Configuration.ConfigurationManager.ConnectionStrings[cnnStringName].ConnectionString)) { bool exist = dc.fwk_Params.Any(s => (!parentId.HasValue || s.ParentId.Equals(parentId)) && (!paramId.HasValue || s.ParamId.Equals(paramId)) && (string.IsNullOrEmpty(culture) || s.Culture.Equals(culture)) ); return(exist); } } catch (Exception ex) { throw ex; } }
/// <summary> /// Realiza cambios a una propiedad.- /// </summary> /// <param name="provider">Proveedor de configuracion</param> /// <param name="groupName">Nombre del grupo donde se encuentra la propiedad</param> /// <param name="property">Propiedad actualizada. Este objeto puede contener todos sus valores modifcados</param> /// <param name="propertyName">Nombre de la propiedad que se mofdifico.- Este valor es el original sin modificacion</param> internal static void ChangeProperty(ConfigProviderElement provider, string groupName, Key property, string propertyName) { try { using (FwkDatacontext dc = new FwkDatacontext(GetCnnString(provider))) { var prop = dc.fwk_ConfigManagers.Where(config => config.ConfigurationFileName.ToLower().Equals(provider.BaseConfigFile.ToLower()) && config.group.ToLower().Equals(groupName.ToLower()) && config.key.ToLower().Equals(propertyName.ToLower()) ).FirstOrDefault<fwk_ConfigManager>(); prop.value = property.Value.Text; prop.encrypted = property.Encrypted; prop.key = property.Name; dc.SubmitChanges(); } } catch (Exception ex) { TechnicalException te = new TechnicalException("Problemas con Fwk.Configuration al realizar operaciones con la base de datos \r\n", ex); ExceptionHelper.SetTechnicalException<DatabaseConfigManager>(te); te.ErrorId = "8200"; throw te; } }
/// <summary> /// Cambia el nombre de un grupo.- /// </summary> /// <param name="provider">Proveedor de configuracion</param> /// <param name="groupName">Nombre del grupo</param> /// <param name="newGroupName">Nuevo nombre del grupo</param> internal static void ChangeGroupName(ConfigProviderElement provider, string groupName, string newGroupName) { //ConfigurationFile wConfigurationFile = GetConfig(provider); try { using (FwkDatacontext dc = new FwkDatacontext(GetCnnString(provider))) { var configs = dc.fwk_ConfigManagers.Where(p => p.group.Equals(groupName) && p.ConfigurationFileName.Equals(provider.BaseConfigFile)); foreach (fwk_ConfigManager confg in configs) { confg.group = newGroupName; } dc.SubmitChanges(); } } catch (Exception ex) { TechnicalException te = new TechnicalException("Problemas con Fwk.Configuration al realizar operaciones con la base de datos \r\n", ex); ExceptionHelper.SetTechnicalException<DatabaseConfigManager>(te); te.ErrorId = "8200"; throw te; } }
/// <summary> /// /// </summary> /// <param name="provider">Proveedor de configuracion</param> /// <param name="group">Grupo</param> internal static void AddGroup(ConfigProviderElement provider, Group group) { ConfigurationFile wConfigurationFile = GetConfig(provider); wConfigurationFile.Groups.Add(group); fwk_ConfigManager confg; try { using (FwkDatacontext dc = new FwkDatacontext(GetCnnString(provider))) { foreach (Key k in group.Keys) { confg = new fwk_ConfigManager(); confg.ConfigurationFileName = provider.BaseConfigFile; confg.key = k.Name; confg.encrypted = k.Encrypted; confg.value = k.Value.Text; confg.group = group.Name; dc.fwk_ConfigManagers.InsertOnSubmit(confg); } dc.SubmitChanges(); } } catch (Exception ex) { TechnicalException te = new TechnicalException("Problemas con Fwk.Configuration al realizar operaciones con la base de datos \r\n", ex); ExceptionHelper.SetTechnicalException<DatabaseConfigManager>(te); te.ErrorId = "8200"; throw te; } }
/// <summary> ///Si grupo no existe en un provider p/bd es por que seguramente se agrego el grupo por la aplicacion del fwk y ahun este grupo se encuentra vasio. ///y no es posible agregar grupos vasios ya que los grupos tienen que tener al menos una propiedad para ser agregados a la tabla /// </summary> /// <param name="provider">Proveedor de configuracion</param> /// <param name="key"></param> /// <param name="groupName">Nombre del gruop que contiene las propiedades</param> internal static void AddProperty(ConfigProviderElement provider, Key key, string groupName) { System.Text.StringBuilder sqlCommand = new StringBuilder(); ConfigurationFile wConfigurationFile = GetConfig(provider); Group wGroup = wConfigurationFile.Groups.GetFirstByName(groupName); //Si grupo no existe en un provider p/bd es por que seguramente se agrego el grupo por la aplicacion del fwk y ahun este grupo se encuentra vasio. //y no es posible agregar grupos vasios ya que los grupos tienen que tener al menos una propiedad para ser agregados a la tabla if (wGroup == null) { wGroup = new Group(); wGroup.Keys = new Keys(); wGroup.Name=groupName; AddGroup(provider, wGroup); } wGroup.Keys.Add(key); fwk_ConfigManager confg; try { using (FwkDatacontext dc = new FwkDatacontext(GetCnnString(provider))) { confg = new fwk_ConfigManager(); confg.ConfigurationFileName = provider.BaseConfigFile; confg.key = key.Name; confg.encrypted = key.Encrypted; confg.value = key.Value.Text; confg.group = groupName; dc.fwk_ConfigManagers.InsertOnSubmit(confg); dc.SubmitChanges(); } } catch (Exception ex) { TechnicalException te = new TechnicalException("Problemas con Fwk.Configuration al realizar operaciones con la base de datos \r\n", ex); ExceptionHelper.SetTechnicalException<DatabaseConfigManager>(te); te.ErrorId = "8200"; throw te; } }
/// <summary> /// Busca en la base de datos el archivo de configuracion /// </summary> /// <param name="groupName"></param> /// <param name="keyName"></param> /// <param name="destinationProvider">Provedor destino</param> /// <Author>Marcelo Oviedo</Author> static bool ExistProperty(string groupName,string keyName, ConfigProviderElement destinationProvider) { try { using (FwkDatacontext dc = new FwkDatacontext(GetCnnString(destinationProvider))) { var properties = dc.fwk_ConfigManagers.Where(config => config.ConfigurationFileName.ToLower().Equals(destinationProvider.BaseConfigFile.ToLower()) && config.group.ToLower().Equals(groupName.ToLower()) && config.key.ToLower().Equals(keyName.ToLower()) ); return properties.Any(); } } catch (Exception ex) { TechnicalException te = new TechnicalException("Problemas con Fwk.Configuration al realizar operaciones con la base de datos \r\n", ex); ExceptionHelper.SetTechnicalException<DatabaseConfigManager>(te); te.ErrorId = "8200"; throw te; } }
/// <summary> /// Busca en la base de datos el archivo de configuracion /// </summary> /// <param name="pFileName">Nombre de archivo.</param> /// <param name="provider">provider</param> /// <Author>Marcelo Oviedo</Author> static ConfigurationFile GetFromDatabase(string pFileName, ConfigProviderElement provider) { ConfigurationFile wConfigurationFile = new ConfigurationFile(); wConfigurationFile.Groups = new Groups(); string groupAuxiliar = string.Empty; Group g = null; Key k = null; wConfigurationFile.FileName = pFileName; try { using (FwkDatacontext dc = new FwkDatacontext(GetCnnString(provider))) { IEnumerable<fwk_ConfigManager> fwk_ConfigManagerList = from s in dc.fwk_ConfigManagers where s.ConfigurationFileName.Equals(pFileName) select s; foreach (fwk_ConfigManager fwk_Config in fwk_ConfigManagerList.OrderBy(p => p.group)) { if (!groupAuxiliar.Equals(fwk_Config.group)) { groupAuxiliar = Convert.ToString(fwk_Config.group); g = new Group(); g.Name = groupAuxiliar; wConfigurationFile.Groups.Add(g); } k = new Key(); k.Encrypted = fwk_Config.encrypted; k.Name = fwk_Config.key; k.Value.Text = fwk_Config.value; g.Keys.Add(k); } } } catch (Exception ex) { TechnicalException te = new TechnicalException("Problemas con Fwk.Configuration al realizar operaciones con la base de datos \r\n", ex); ExceptionHelper.SetTechnicalException<DatabaseConfigManager>(te); te.ErrorId = "8200"; throw te; } return wConfigurationFile; }
/// <summary> /// Obtiene un grupo determinado en el archivo de configuracion /// </summary> /// <param name="configProvider">Proveedor de configuuracion</param> /// <param name="groupName">Nombre del grupo</param> /// <returns>Hashtable con los grupos contenidos en el archivo de configuracion</returns> /// <Author>Marcelo Oviedo</Author> internal static Group GetGroup(string configProvider, string groupName) { ConfigProviderElement provider = ConfigurationManager.GetProvider(configProvider); Group wGroup = null; try { using (FwkDatacontext dc = new FwkDatacontext(DatabaseConfigManager.GetCnnString(provider))) { var properties_group = dc.fwk_ConfigManagers.Where(config => config.ConfigurationFileName.ToLower().Equals(provider.BaseConfigFile.ToLower()) && config.group.ToLower().Equals(groupName.ToLower()) ); if (properties_group == null) { TechnicalException te = new TechnicalException(string.Concat(new String[] { "No se encuentra el grupo ", groupName, " en el archivo de configuración: ", provider.BaseConfigFile })); te.ErrorId = "8006"; Fwk.Exceptions.ExceptionHelper.SetTechnicalException(te, typeof(ConfigurationManager)); throw te; } wGroup = new Group(); wGroup.Keys = new Keys(); Key wKey = new Key(); foreach (var item in properties_group) { wKey = new Key(); wKey.Name = item.key; wKey.Value.Text = item.value; wKey.Encrypted = item.encrypted; wGroup.Keys.Add(wKey); } } } catch (Exception ex) { TechnicalException te = new TechnicalException("Problemas con Fwk.Configuration al realizar operaciones con la base de datos \r\n", ex); ExceptionHelper.SetTechnicalException<DatabaseConfigManager>(te); te.ErrorId = "8200"; throw te; } return wGroup; }
/// <summary> /// Permite eliminar por /// solo parentId /// solo paramId /// por ambos /// no permite que ambos sean Null /// </summary> /// <param name="paramId"></param> /// <param name="parentId"></param> /// <param name="cnnStringName"></param> public static void Delete(int? paramId, int? parentId, string cnnStringName) { //no permite que ambos sean Null if (paramId.HasValue == false || parentId.HasValue == false) throw new Fwk.Exceptions.TechnicalException("Debe proporcinar almeno uno de los dos parametros"); using (Fwk.ConfigData.FwkDatacontext dc = new Fwk.ConfigData.FwkDatacontext(System.Configuration.ConfigurationManager.ConnectionStrings[cnnStringName].ConnectionString)) { var paramsList = dc.fwk_Params.Where(p => (paramId.HasValue == false || p.ParamId.Equals(paramId.Value)) && (parentId.HasValue == false || p.ParentId.Equals(parentId.Value))); foreach (fwk_Param p in paramsList) { dc.fwk_Params.DeleteOnSubmit(p); } dc.SubmitChanges(); } }
/// <summary> /// Actualiza fwk_Param /// </summary> /// <param name="paramBE"></param> /// <param name="userUpdateId"></param> /// <param name="cnnStringName"></param> public static void Update(ParamBE paramBE, Guid? userUpdateId, string cnnStringName) { using (Fwk.ConfigData.FwkDatacontext dc = new Fwk.ConfigData.FwkDatacontext(System.Configuration.ConfigurationManager.ConnectionStrings[cnnStringName].ConnectionString)) { Fwk.ConfigData.fwk_Param param = dc.fwk_Params.Where(p => p.Id.Equals(paramBE.Id)).FirstOrDefault(); if (param != null) { param.Enabled = true; param.Name = paramBE.Name; param.Culture = paramBE.Culture; param.Description = paramBE.Description; //param.ParamId = paramBE.ParamId; //param.ParentId = paramBE.ParentId; dc.SubmitChanges(); } } }
/// <summary> /// /// </summary> /// <param name="configProvider"></param> /// <param name="groupName"></param> /// <param name="propertyName"></param> /// <returns></returns> static string GetProperty_FromDB(string configProvider, string groupName, string propertyName) { ConfigProviderElement provider = ConfigurationManager.GetProvider(configProvider); if (System.Configuration.ConfigurationManager.ConnectionStrings[provider.SourceInfo] == null) { TechnicalException te = new TechnicalException(string.Concat("Problemas con Fwk.Configuration, no se puede encontrar la cadena de conexión: ", provider.SourceInfo)); ExceptionHelper.SetTechnicalException<DatabaseConfigManager>(te); te.ErrorId = "8200"; throw te; } try { using (FwkDatacontext dc = new FwkDatacontext(System.Configuration.ConfigurationManager.ConnectionStrings[provider.SourceInfo].ConnectionString)) { var val = dc.fwk_ConfigManagers.Where(config => config.ConfigurationFileName.ToLower().Equals(provider.BaseConfigFile.ToLower()) && config.group.ToLower().Equals(groupName.ToLower()) && config.key.ToLower().Equals(propertyName.ToLower())).FirstOrDefault(); if (val == null) { TechnicalException te = new TechnicalException(string.Concat(new String[] { "No se encuentra la propiedad ", propertyName, " en el grupo de propiedades: ", groupName, " del archivo de configuración: ", provider.BaseConfigFile })); te.ErrorId = "8007"; Fwk.Exceptions.ExceptionHelper.SetTechnicalException(te, typeof(ConfigurationManager)); throw te; } return val.value; } } catch (Exception ex) { TechnicalException te = new TechnicalException("Problemas con Fwk.Configuration al realizar operaciones con la base de datos \r\n", ex); ExceptionHelper.SetTechnicalException<DatabaseConfigManager>(te); te.ErrorId = "8200"; throw te; } }
/// <summary> /// Almacena informacion de auditoria.- /// Llama a StaticLogger y carga el log auditando los datos del Request de entrada /// </summary> /// <param name="pRequest">Request</param> /// <param name="wResult">Response</param> internal static void LogSuccessfulExecution(IServiceContract pRequest, IServiceContract wResult) { fwk_ServiceAudit audit = new fwk_ServiceAudit(); audit.LogTime = System.DateTime.Now; audit.ServiceName = pRequest.ServiceName; audit.Send_Time = pRequest.ContextInformation.HostTime; if(Fwk.HelperFunctions.DateFunctions.IsSqlDateTimeOutOverflow(wResult.ContextInformation.HostTime)==false) audit.Resived_Time = wResult.ContextInformation.HostTime; else { audit.Resived_Time = wResult.ContextInformation.HostTime = DateTime.Now; } audit.Send_UserId = pRequest.ContextInformation.UserId; audit.Send_Machine = pRequest.ContextInformation.HostName; audit.Dispatcher_Instance_Name = FacadeHelper.ServiceDispatcherConfig.InstanseName; audit.ApplicationId = pRequest.ContextInformation.AppId; audit.Requets = TypeFunctions.ConvertStringToByteArray(pRequest.GetXml()); audit.Response = TypeFunctions.ConvertStringToByteArray(wResult.GetXml()); try { using (FwkDatacontext context = new FwkDatacontext(System.Configuration.ConfigurationManager.ConnectionStrings[ConfigurationsHelper.ServiceDispatcherConnection].ConnectionString)) { context.fwk_ServiceAudits.InsertOnSubmit(audit); context.SubmitChanges(); } } catch(Exception) { LogSuccessfulExecution_Old(pRequest, wResult); } }
/// <summary> /// Permite volver a cargar la configuracion si es que en el inicio estatico no lo hiso correctamente /// </summary> internal static void ReloadConfig(out String stringMessage) { stringMessage = string.Empty; //ConnectionString donde proviene la configuracion del Service Dispatcher ConfigurationsHelper.ServiceDispatcherConnection = System.Configuration.ConfigurationManager.AppSettings["ServiceDispatcherConnection"]; string serviceDispatcherName = System.Configuration.ConfigurationManager.AppSettings["ServiceDispatcherName"]; if (!String.IsNullOrEmpty(ConfigurationsHelper.ServiceDispatcherConnection) || !String.IsNullOrEmpty(serviceDispatcherName)) { #region Check cnn string if exist if (System.Configuration.ConfigurationManager.ConnectionStrings[ConfigurationsHelper.ServiceDispatcherConnection] == null) { TechnicalException te = new TechnicalException(string.Concat("No se puede encontrar la cadena de conexión : ", ConfigurationsHelper.ServiceDispatcherConnection)); ExceptionHelper.SetTechnicalException<DatabaseConfigManager>(te); te.ErrorId = "8200"; stringMessage = Audit.LogDispatcherErrorConfig(te).Message; DefaultSettings = true; } #endregion if (DefaultSettings == false) { #region Try coinnect tod serivice dispatcher database try { using (FwkDatacontext context = new FwkDatacontext(System.Configuration.ConfigurationManager.ConnectionStrings[ConfigurationsHelper.ServiceDispatcherConnection].ConnectionString)) { ServiceDispatcherConfig = context.fwk_ServiceDispatchers.Where(s => s.InstanseName.Equals(serviceDispatcherName.Trim())).FirstOrDefault(); if (ServiceDispatcherConfig == null) { TechnicalException te = new TechnicalException(string.Concat("No se puede encontrar la configuracion del despachador de servicio en la base de datos\r\nCadena de conexión : ", ConfigurationsHelper.ServiceDispatcherConnection)); ExceptionHelper.SetTechnicalException<DatabaseConfigManager>(te); te.ErrorId = "7009"; stringMessage = Audit.LogDispatcherErrorConfig(te).Message; } } ConfigurationsHelper.HostApplicationName = ServiceDispatcherConfig.InstanseName; } catch (Exception ex) { DefaultSettings = true; stringMessage = Audit.LogDispatcherErrorConfig(ex).Message; } #endregion } } else { DefaultSettings = true; } if (DefaultSettings) { ServiceDispatcherConfig = new fwk_ServiceDispatcher(); ServiceDispatcherConfig.AuditMode = (int)AuditMode.None; ServiceDispatcherConfig.HostIp = "127.0.0.1"; ServiceDispatcherConfig.InstanseName = "Fwk Dispatcher (default name)"; stringMessage = Audit.LogDispatcherErrorConfig(null).Message; } }
/// <summary> /// /// </summary> /// <param name="paramBE"></param> /// <param name="userId"></param> /// <param name="cnnStringName"></param> public static void Create(ParamBE paramBE, Guid? userId, string cnnStringName) { using (Fwk.ConfigData.FwkDatacontext dc = new Fwk.ConfigData.FwkDatacontext(System.Configuration.ConfigurationManager.ConnectionStrings[cnnStringName].ConnectionString)) { Fwk.ConfigData.fwk_Param param = new ConfigData.fwk_Param(); param.Culture = paramBE.Culture; param.Description = paramBE.Description; param.Enabled = true; param.Name = paramBE.Name; param.ParamId = paramBE.ParamId; param.ParentId = paramBE.ParentId; dc.fwk_Params.InsertOnSubmit(param); dc.SubmitChanges(); paramBE.Id = param.Id; } }