internal static IEnhancedOrgService GetConnection(string connectionString, bool noCache = false) { Status.Update("Creating connection to CRM ... ", false); poolCache.TryGetValue(connectionString, out var pool); factoryCache.TryGetValue(connectionString, out var factory); if (pool == null || factory == null) { var template = EnhancedServiceBuilder.NewBuilder .Initialise(connectionString) .AddCaching() .Finalise() .GetBuild(); factoryCache[connectionString] = factory = new EnhancedServiceFactory <EnhancedOrgService>(template); poolCache[connectionString] = pool = new EnhancedServicePool <EnhancedOrgService>(factory); } if (noCache) { factory.ClearCache(); } var service = pool.GetService(); Status.Update("done!"); return(service); }
public static IEnhancedServicePool <IEnhancedOrgService> GetPool(ConnectionParams connectionParams, PoolParams poolParams) { var parameters = BuildBaseParams(string.Empty, 2, poolParams, connectionParams); var factory = new EnhancedServiceFactory <IEnhancedOrgService, Services.Enhanced.EnhancedOrgService>(parameters); return(new EnhancedServicePool <IEnhancedOrgService, Services.Enhanced.EnhancedOrgService>(factory, poolParams)); }
public static IEnhancedServicePool <IEnhancedOrgService> GetPool(string connectionString, int poolSize = 2) { var parameters = BuildBaseParams(connectionString, poolSize); var factory = new EnhancedServiceFactory <IEnhancedOrgService, Services.Enhanced.EnhancedOrgService>(parameters); return(new EnhancedServicePool <IEnhancedOrgService, Services.Enhanced.EnhancedOrgService>(factory, poolSize)); }
public static EnhancedServicePool <AsyncOrgService> GetAsyncPool(string connectionString, int poolSize = 10, EnhancedServiceParams serviceParams = null, bool isHoldAppForAsync = true) { var builder = EnhancedServiceBuilder.NewBuilder.Initialise(connectionString); if (serviceParams?.IsCachingEnabled == true) { builder.AddCaching(serviceParams.CachingParams); } if (serviceParams?.IsConcurrencyEnabled != false) { builder.AddConcurrency(serviceParams?.ConcurrencyParams); if (isHoldAppForAsync) { builder.HoldAppForAsync(); } } if (serviceParams?.IsTransactionsEnabled == true) { builder.AddTransactions(serviceParams.TransactionParams); } var build = builder.Finalise().GetBuild(); var factory = new EnhancedServiceFactory <AsyncOrgService>(build); return(new EnhancedServicePool <AsyncOrgService>(factory, poolSize)); }
public static IOrganizationService GetConnection(Settings settings, ref int connectionsCreated, int total = 1) { Status.Update($"Creating connection {connectionsCreated + 1} / {total} to CRM ... "); var connectionString = settings.GetOrganizationCrmConnectionString(); poolCache.TryGetValue(connectionString, out var pool); factoryCache.TryGetValue(connectionString, out var factory); if (pool == null || factory == null) { var template = EnhancedServiceBuilder.NewBuilder .Initialise(connectionString) .Finalise() .GetBuild(); factoryCache[connectionString] = factory = new EnhancedServiceFactory <EnhancedOrgService>(template); poolCache[connectionString] = pool = new EnhancedServicePool <EnhancedOrgService>(factory); } var service = pool.GetService(); Status.Update($"Created connection {++connectionsCreated} / {total}."); return(service); }
public EnhancedServicePool(EnhancedServiceFactory <TServiceInterface, TEnhancedOrgService> factory, int poolSize) { this.factory = factory; poolParams = new PoolParams { PoolSize = poolSize }; }
public static EnhancedServicePool <Services.EnhancedOrgService> GetPool(string connectionString, EnhancedServiceParams serviceParams = null) { var builder = EnhancedServiceBuilder.NewBuilder.Initialise(connectionString); if (serviceParams?.IsCachingEnabled == true) { serviceParams.CachingParams = serviceParams.CachingParams ?? new CachingParams { CacheMode = CacheMode.PrivatePerInstance }; builder.AddCaching(serviceParams.CachingParams); } if (serviceParams?.IsConcurrencyEnabled == true) { builder.AddConcurrency(serviceParams.ConcurrencyParams); } if (serviceParams?.IsTransactionsEnabled == true) { builder.AddTransactions(serviceParams.TransactionParams); } var build = builder.Finalise().GetBuild(); var factory = new EnhancedServiceFactory <Services.EnhancedOrgService>(build); return(new EnhancedServicePool <Services.EnhancedOrgService>(factory)); }
public static IEnhancedServicePool <ICachingOrgService> GetPoolCaching(ConnectionParams connectionParams, PoolParams poolParams, CachingParams cachingParams = null) { var parameters = BuildBaseParams(string.Empty, 2, null, connectionParams, cachingParams ?? new CachingParams()); var factory = new EnhancedServiceFactory <ICachingOrgService, CachingOrgService>(parameters); return(new EnhancedServicePool <ICachingOrgService, CachingOrgService>(factory, poolParams)); }
public static IEnhancedServicePool <ICachingOrgService> GetPoolCaching(string connectionString, int poolSize = 2, CachingParams cachingParams = null) { var parameters = BuildBaseParams(connectionString, poolSize, null, cachingParams: cachingParams ?? new CachingParams()); var factory = new EnhancedServiceFactory <ICachingOrgService, CachingOrgService>(parameters); return(new EnhancedServicePool <ICachingOrgService, CachingOrgService>(factory, poolSize)); }
public EnhancedServicePool(EnhancedServiceFactory <TServiceInterface, TEnhancedOrgService> factory, PoolParams poolParams = null) { this.factory = factory; if (poolParams != null) { poolParams.IsLocked = true; } this.poolParams = poolParams ?? factory.Parameters?.PoolParams ?? new PoolParams(); }
public static IEnhancedServicePool <ICachingOrgService> GetCachingPool(ServiceParams serviceParams) { serviceParams.Require(nameof(serviceParams)); if (AutoSetMaxPerformanceParams) { serviceParams.AutoSetMaxPerformanceParams(); } var factory = new EnhancedServiceFactory <ICachingOrgService, CachingOrgService>(serviceParams); return(new EnhancedServicePool <ICachingOrgService, CachingOrgService>(factory, serviceParams.PoolParams)); }
public static ICachingOrgService GetCachingPoolingService(ServiceParams serviceParams) { serviceParams.Require(nameof(serviceParams)); if (AutoSetMaxPerformanceParams) { serviceParams.AutoSetMaxPerformanceParams(); } var pool = new DefaultServicePool(serviceParams); var factory = new EnhancedServiceFactory <ICachingOrgService, CachingOrgService>(serviceParams); return(factory.CreateService(pool)); }
public static IEnhancedServicePool <ICachingOrgService> GetPoolCaching(EnhancedServiceParams serviceParams) { var factory = new EnhancedServiceFactory <ICachingOrgService, CachingOrgService>(serviceParams); return(new EnhancedServicePool <ICachingOrgService, CachingOrgService>(factory)); }
public static IEnhancedServicePool <IEnhancedOrgService> GetPool(EnhancedServiceParams serviceParams) { var factory = new EnhancedServiceFactory <IEnhancedOrgService, Services.Enhanced.EnhancedOrgService>(serviceParams); return(new EnhancedServicePool <IEnhancedOrgService, Services.Enhanced.EnhancedOrgService>(factory)); }
public EnhancedServicePool(EnhancedServiceFactory <TService> factory, int poolSize = 10) { this.factory = factory; this.poolSize = poolSize; }
public EnhancedServicePool(EnhancedServiceFactory <TService> factory) { this.factory = factory; }