private static void StartHost(string consumerGroupPrefix) { Trace.WriteLine("Starting Worker..."); #if DEBUG_LOG RoleEnvironment.TraceSource.TraceInformation("Starting Worker..."); #endif var config = new Configuration(); config.AlertEHConnectionString = ConfigurationManager.AppSettings.Get("Microsoft.ServiceBus.ConnectionStringAlerts"); config.AlertEHName = ConfigurationManager.AppSettings.Get("Microsoft.ServiceBus.EventHubAlerts"); config.DeviceEHConnectionString = ConfigurationManager.AppSettings.Get("Microsoft.ServiceBus.ConnectionStringDevices"); config.DeviceEHName = ConfigurationManager.AppSettings.Get("Microsoft.ServiceBus.EventHubDevices");; config.AnomalyDetectionApiUrl = ConfigurationManager.AppSettings.Get("AnomalyDetectionApiUrl"); config.AnomalyDetectionAuthKey = ConfigurationManager.AppSettings.Get("AnomalyDetectionAuthKey"); config.LiveId = ConfigurationManager.AppSettings.Get("LiveId"); config.TukeyThresh = ConfigurationManager.AppSettings.Get("TukeyThresh"); config.ZscoreThresh = ConfigurationManager.AppSettings.Get("ZscoreThresh"); bool.TryParse(ConfigurationManager.AppSettings.Get("UseMarketApi"), out config.UseMarketApi); int.TryParse(ConfigurationManager.AppSettings.Get("MessagesBufferSize"), out config.MessagesBufferSize); int.TryParse(ConfigurationManager.AppSettings.Get("AlertsIntervalSec"), out config.AlertsIntervalSec); _analyzer = new Analyzer(config.AnomalyDetectionApiUrl, config.AnomalyDetectionAuthKey, config.LiveId, config.UseMarketApi, config.TukeyThresh, config.ZscoreThresh); _eventHubReader = new EventHubReader(config.MessagesBufferSize, consumerGroupPrefix); Process(config); }
private static void StartHost(string consumerGroupSuffix) { Trace.WriteLine("Starting Worker..."); #if DEBUG_LOG RoleEnvironment.TraceSource.TraceInformation("Starting Worker..."); #endif _Config = ConfigurationLoader.GetConfig(); if (_Config == null) { return; } _Config.ConsumerGroupPrefix += consumerGroupSuffix; _NotificationService = (NotificationServiceType)Enum.Parse(typeof(NotificationServiceType), _Config.NotificationService); var credentials = new NetworkCredential(_Config.EmailServiceUserName, _Config.EmailServicePassword); PrepareMailAddressInstances(); switch (_NotificationService) { case NotificationServiceType.Smtp: { _SmtpClient = new SmtpClient { Port = _Config.SmtpEnableSSL ? 587 : 25, DeliveryMethod = SmtpDeliveryMethod.Network, UseDefaultCredentials = false, EnableSsl = false, Host = _Config.SmtpHost, Credentials = credentials }; } break; case NotificationServiceType.SendGridWeb: { _SendGridTransportWeb = new Web(credentials); } break; case NotificationServiceType.Twilio: case NotificationServiceType.TwilioCall: { string ACCOUNT_SID = _Config.EmailServiceUserName; string AUTH_TOKEN = _Config.EmailServicePassword; _TwilioRestClient = new TwilioRestClient(ACCOUNT_SID, AUTH_TOKEN); } break; } _EventHubReader = new EventHubReader(_Config.ConsumerGroupPrefix, OnMessage); Process(); }
private static void StartHost(string consumerGroupPrefix) { Trace.WriteLine("Starting Worker..."); #if DEBUG_LOG RoleEnvironment.TraceSource.TraceInformation("Starting Worker..."); #endif var config = new Configuration(); config.AlertEHConnectionString = ConfigurationManager.AppSettings.Get("Microsoft.ServiceBus.ConnectionStringAlerts"); config.AlertEHName = ConfigurationManager.AppSettings.Get("Microsoft.ServiceBus.EventHubAlerts"); config.DeviceEHConnectionString = ConfigurationManager.AppSettings.Get("Microsoft.ServiceBus.ConnectionStringDevices"); config.DeviceEHName = ConfigurationManager.AppSettings.Get("Microsoft.ServiceBus.EventHubDevices");; config.AnomalyDetectionApiUrl = ConfigurationManager.AppSettings.Get("AnomalyDetectionApiUrl"); config.AnomalyDetectionAuthKey = ConfigurationManager.AppSettings.Get("AnomalyDetectionAuthKey"); config.LiveId = ConfigurationManager.AppSettings.Get("LiveId"); config.MeasureNameFilter = ConfigurationManager.AppSettings.Get("MeasureNameFilter"); config.TukeyThresh = ConfigurationManager.AppSettings.Get("TukeyThresh"); config.ZscoreThresh = ConfigurationManager.AppSettings.Get("ZscoreThresh"); bool.TryParse(ConfigurationManager.AppSettings.Get("UseMarketApi"), out config.UseMarketApi); int.TryParse(ConfigurationManager.AppSettings.Get("MessagesBufferSize"), out config.MessagesBufferSize); int.TryParse(ConfigurationManager.AppSettings.Get("AlertsIntervalSec"), out config.AlertsIntervalSec); config.StorageConnectionString = ConfigurationManager.AppSettings.Get("Microsoft.Storage.ConnectionString"); config.BlobContainerName = ConfigurationManager.AppSettings.Get("blobContainerName"); config.BlobNamePrefix = ConfigurationManager.AppSettings.Get("blobNamePrefix"); config.SqlDatabaseConnectionString = ConfigurationManager.AppSettings.Get("sqlDatabaseConnectionString"); _analyzer = new Analyzer(config.AnomalyDetectionApiUrl, config.AnomalyDetectionAuthKey, config.LiveId, config.UseMarketApi, config.TukeyThresh, config.ZscoreThresh); _eventHubReader = new EventHubReader(config.MessagesBufferSize, consumerGroupPrefix); if (ConfigurationManager.AppSettings.Get("sendToBlob") == "true") { _blobWriter = new BlobWriter(); if (_blobWriter.Connect(config.BlobNamePrefix, config.BlobContainerName, config.StorageConnectionString)) { _blobWriter = null; } } if (ConfigurationManager.AppSettings.Get("sendToSQL") == "true") { _sqlOutputRepository = new SQLOutputRepository(config.SqlDatabaseConnectionString); } Process(config); }