/// <summary> /// Ejecuta un servicio de negocio. /// </summary> /// <param name="providerName">Nombre del proveedor de metadata de servicios.-</param> /// <param name="pRequest">Request con datos de entrada para la ejecución del servicio.</param> /// <returns>XML con el resultado de la ejecución del servicio.</returns> /// <date>2008-04-07T00:00:00</date> /// <author>moviedo</author> public IServiceContract ExecuteService(string providerName, IServiceContract pRequest) { IServiceContract wResult = null; if (string.IsNullOrEmpty(pRequest.ServiceName)) { throw get_TechnicalException_error_serviceName_null(); } Boolean wExecuteOndispatcher = true; IRequest req = (IRequest)pRequest; ServiceConfiguration wServiceConfiguration = FacadeHelper.GetServiceConfiguration(providerName, pRequest.ServiceName); //establezco el nombre del proveedor de seguridad al request req.SecurityProviderName = FacadeHelper.GetProviderInfo(providerName).SecurityProviderName; req.ContextInformation.SetProviderName(providerName); //if (String.IsNullOrEmpty(req.ContextInformation.DefaultCulture)) // req.ContextInformation.DefaultCulture = FacadeHelper.GetProviderInfo(providerName).DefaultCulture; // Validación de disponibilidad del servicio. FacadeHelper.ValidateAvailability(wServiceConfiguration, out wResult); if (wResult != null) { if (wResult.Error != null) { return(wResult); } } // Caching del servicio. if (req.CacheSettings != null && req.CacheSettings.CacheOnServerSide) //--------->>> Implement the cache factory { wResult = GetCaheDataById(req, wServiceConfiguration); if (wResult != null) { wExecuteOndispatcher = false; } } // Realiza la ejecucion del servicio if (wExecuteOndispatcher) { // ejecución del servicio. if (wServiceConfiguration.TransactionalBehaviour == Fwk.Transaction.TransactionalBehaviour.Suppres) { wResult = FacadeHelper.RunNonTransactionalProcess(pRequest, wServiceConfiguration); } else { wResult = FacadeHelper.RunTransactionalProcess(pRequest, wServiceConfiguration); } } return(wResult); }
/// <summary> /// Obtiene la data de la cache. si no lo encuentra ejecuta el servicio y lo almacena en la cache para proximo busqueda /// </summary> /// <param name="pRequest"></param> /// <param name="pServiceConfiguration"></param> /// <returns>IServiceContract con el response</returns> private static IServiceContract GetCaheDataById(IRequest pRequest, ServiceConfiguration pServiceConfiguration) { IServiceContract wResult; object wItemInCache = null; if (string.IsNullOrEmpty(pRequest.CacheSettings.ResponseCacheId)) { pRequest.CacheSettings.ResponseCacheId = pRequest.ServiceName; } //TODO: Agregar manejo de error para catching wItemInCache = CacheManager.GetData(pRequest.CacheSettings.ResponseCacheId); if (wItemInCache == null) { wResult = null; } else { wResult = (IServiceContract)wItemInCache; } //Si no hay resultados en la cahce se procede a ejecurar el servicio y de obtener resultados sin error //se almacena en la cache if (wResult == null) { if (pServiceConfiguration.TransactionalBehaviour == Fwk.Transaction.TransactionalBehaviour.Suppres) { wResult = FacadeHelper.RunNonTransactionalProcess(pRequest, pServiceConfiguration); } else { wResult = FacadeHelper.RunTransactionalProcess(pRequest, pServiceConfiguration); } //Almaceno el resultado en la cache solo si no hay errores en la ejecucion del servicio if (wResult.Error == null) { CacheManager.Add( pRequest.CacheSettings.ResponseCacheId, wResult, pRequest.CacheSettings.ExpirationTime, pRequest.CacheSettings.TimeMeasures); } } return(wResult); }
/// <summary> /// Ejecuta un servicio de negocio. /// </summary> /// <param name="providerName">Nombre del proveedor de metadata de servicios.-</param> /// <param name="pRequest">Request con datos de entrada para la ejecución del servicio.</param> /// <returns>XML con el resultado de la ejecución del servicio.</returns> /// <date>2008-04-07T00:00:00</date> /// <author>moviedo</author> public static IServiceContract ExecuteService(string providerName, IServiceContract pRequest) { IServiceContract wResult = null; if (string.IsNullOrEmpty(pRequest.ServiceName)) { TechnicalException te = new TechnicalException("El despachador de servicio no pudo continuar debido\r\n a que el nombre del servicio no fue establecido"); Fwk.Exceptions.ExceptionHelper.SetTechnicalException <SimpleFacade>(te); te.ErrorId = "7005"; throw te; } Boolean wExecuteOndispatcher = true; IRequest req = (IRequest)pRequest; ServiceConfiguration wServiceConfiguration = FacadeHelper.GetServiceConfiguration(providerName, pRequest.ServiceName); //establezco el nombre del proveedor de seguridad al request req.SecurityProviderName = FacadeHelper.GetProviderInfo(providerName).SecurityProviderName; req.ContextInformation.SetProviderName(providerName); // Validación de disponibilidad del servicio. FacadeHelper.ValidateAvailability(wServiceConfiguration, out wResult); if (wResult != null) { if (wResult.Error != null) { return(wResult); } } // Caching del servicio. if (req.CacheSettings != null && req.CacheSettings.CacheOnServerSide) //--------->>> Implement the cache factory { wResult = GetCaheDataById(req, wServiceConfiguration); if (wResult != null) { wExecuteOndispatcher = false; } } // Realiza la ejecucion del servicio if (wExecuteOndispatcher) { // ejecución del servicio. if (wServiceConfiguration.TransactionalBehaviour == Fwk.Transaction.TransactionalBehaviour.Suppres) { wResult = FacadeHelper.RunNonTransactionalProcess(pRequest, wServiceConfiguration); } else { wResult = FacadeHelper.RunTransactionalProcess(pRequest, wServiceConfiguration); } } return(wResult); }