public static void InitSecondaryPersistProvider() { try { secondaryPersistProviderEnabled = ConfigurationBag.Configuration.SecondaryPersistProviderEnabled; secondaryPersistProviderByteSize = ConfigurationBag.Configuration.SecondaryPersistProviderByteSize; // Load the abrstracte persistent provider var devicePersistentProviderComponent = Path.Combine( ConfigurationBag.Configuration.DirectoryOperativeRootExeName, ConfigurationBag.Configuration.PersistentProviderComponent); // Create the reflection method cached var assemblyPersist = Assembly.LoadFrom(devicePersistentProviderComponent); // Main class logging var assemblyClassDpp = (from t in assemblyPersist.GetTypes() let attributes = t.GetCustomAttributes(typeof(DevicePersistentProviderContract), true) where t.IsClass && attributes != null && attributes.Length > 0 select t).First(); DevicePersistentProvider = Activator.CreateInstance(assemblyClassDpp) as IDevicePersistentProvider; } catch (Exception ex) { LogEngine.WriteLog( ConfigurationBag.EngineName, $"Error in {MethodBase.GetCurrentMethod().Name}", Constant.LogLevelError, Constant.TaskCategoriesEventHubs, ex, Constant.LogLevelError); } }
/// <summary> /// Initialize the onramp engine the OffRampPatternComponent variable is for the next version /// </summary> /// <param name="offRampPatternComponent"> /// The Off Ramp Pattern Component. /// </param> /// <returns> /// The <see cref="bool" />. /// </returns> public static bool Init(string offRampPatternComponent) { try { LogEngine.WriteLog(ConfigurationBag.EngineName, $"Start engine initialization.", Constant.LogLevelError, Constant.TaskCategoriesError, null, Constant.LogLevelWarning); Debug.WriteLine("Initialize Abstract Event Up Stream Engine."); // Load event up stream external component var eventsUpStreamComponent = Path.Combine( ConfigurationBag.Configuration.DirectoryOperativeRootExeName, ConfigurationBag.Configuration.EventsStreamComponent); // Create the reflection method cached var assembly = Assembly.LoadFrom(eventsUpStreamComponent); // Main class logging var assemblyClass = (from t in assembly.GetTypes() let attributes = t.GetCustomAttributes(typeof(EventsOffRampContract), true) where t.IsClass && attributes != null && attributes.Length > 0 select t).First(); OffRampStream = Activator.CreateInstance(assemblyClass) as IOffRampStream; OffRampEngineQueue = new OffRampEngineQueue( ConfigurationBag.Configuration.ThrottlingOffRampIncomingRateNumber, ConfigurationBag.Configuration.ThrottlingOffRampIncomingRateSeconds); OffRampEngineQueue.OnPublish += OffRampEngineQueueOnPublish; LogEngine.WriteLog( ConfigurationBag.EngineName, "Start Off Ramp Engine.", Constant.LogLevelError, Constant.TaskCategoriesError, null, Constant.LogLevelInformation); // Inizialize the Dpp Debug.WriteLine("Initialize Abstract Storage Provider Engine."); //todo optimization utilizzare linterfaccia OffRampStream.CreateOffRampStream(); secondaryPersistProviderEnabled = ConfigurationBag.Configuration.SecondaryPersistProviderEnabled; secondaryPersistProviderByteSize = ConfigurationBag.Configuration.SecondaryPersistProviderByteSize; // Load the abrstracte persistent provider var devicePersistentProviderComponent = Path.Combine( ConfigurationBag.Configuration.DirectoryOperativeRootExeName, ConfigurationBag.Configuration.PersistentProviderComponent); // Create the reflection method cached var assemblyPersist = Assembly.LoadFrom(devicePersistentProviderComponent); // Main class logging var assemblyClassDpp = (from t in assemblyPersist.GetTypes() let attributes = t.GetCustomAttributes(typeof(DevicePersistentProviderContract), true) where t.IsClass && attributes != null && attributes.Length > 0 select t).First(); DevicePersistentProvider = Activator.CreateInstance(assemblyClassDpp) as IDevicePersistentProvider; return(true); } catch (Exception ex) { LogEngine.WriteLog( ConfigurationBag.EngineName, $"Error in {MethodBase.GetCurrentMethod().Name}", Constant.LogLevelError, Constant.TaskCategoriesError, ex, Constant.LogLevelError); return(false); } }