public static async Task Run( [EventGridTrigger] EventGridEvent eventGridEvent, [CosmosDB(databaseName: "TelemetryDb", collectionName: "alerts", ConnectionStringSetting = "CosmosDBConnection")] DocumentClient client, ILogger log) { var data = eventGridEvent.Data.ToString(); log.LogInformation(data); var jObject = JObject.Parse(data); var newAlerts = JsonConvert.DeserializeObject <IList <Alert> >(jObject["body"].ToString()); var databaseName = Environment.GetEnvironmentVariable("COSMOS_DB_DATABASE_NAME"); var collectionName = Environment.GetEnvironmentVariable("COSMOS_DB_COLLECTION_NAME"); var twilioConfig = new TwilioConfiguration { ToPhoneNumber = Environment.GetEnvironmentVariable("ALERT_TO_PHONE_NUMBER"), FromPhoneNumber = Environment.GetEnvironmentVariable("ALERT_FROM_PHONE_NUMBER"), AccountSid = Environment.GetEnvironmentVariable("TWILIO_ACCOUNT_SID"), AuthToken = Environment.GetEnvironmentVariable("TWILIO_AUTH_TOKEN") }; var alertsRepository = new AlertsRepository(client, databaseName, collectionName); var handler = new AlertHandler(alertsRepository, new TwilioNotificationService(twilioConfig, log), log); await handler.HandleAsync(newAlerts); }
public void addAlertMetting(List <AlertJson> listalert, MettingJson _MettingJson) { foreach (AlertJson _AlertJson in listalert) { _AlertJson.MeetingId = _MettingJson.ID; _AlertJson.ID = Guid.NewGuid().ToString(); _AlertJson.IsSent = "false"; _AlertJson.AlertOrCansel = "1"; _AlertJson.AlarmDate = Utilities.GetMiladiDate(_AlertJson.AlarmTarikh).ToString(); _AlertJson.SendStatus = "ثبت شده"; if (_AlertJson.AlarmType == "SMS") { _AlertJson.AlarmType = "1"; } else { _AlertJson.AlarmType = "2"; } if (_AlertJson.DatabaseOrErsalOrHoshdar != "1") { AlertTranslator _AlertTranslator = new AlertTranslator(); AlertsRepository _AlertsRepository = new AlertsRepository(); _AlertsRepository.Add(_AlertTranslator.ToEntity(_AlertJson)); } } }
public MainWindowViewModel(AlertsRepository alertsRepository, AuthenticationServices authenticationServices, SmartDetectorRunner smartDetectorRunner) { this.NumberOfAlertssFound = 0; alertsRepository.Alerts.CollectionChanged += (sender, args) => { this.NumberOfAlertssFound = args.NewItems.Count; }; this.UserName = authenticationServices.AuthenticationResult.UserInfo.GivenName; this.SmartDetectorRunner = smartDetectorRunner; }
public AlertsRepositoryTests() { fixture = new Fixture(); fixture.Customize(new AutoConfiguredMoqCustomization()); _configurationProviderMock = new Mock <IConfigurationProvider>(); _blobStorageClientMock = new Mock <IBlobStorageClient>(); var blobStorageFactory = new BlobStorageClientFactory(_blobStorageClientMock.Object); _configurationProviderMock.Setup(x => x.GetConfigurationSettingValue(It.IsNotNull <string>())) .ReturnsUsingFixture(fixture); alertsRepository = new AlertsRepository(_configurationProviderMock.Object, blobStorageFactory); }
public List <AlertJson> GetAllAlerByMettingId(string MettingId) { var result = new List <AlertJson>(); AlertsRepository _AlertsRepository = new AlertsRepository(); AlertTranslator _AlertTranslator = new AlertTranslator(); result = _AlertTranslator.ToDomainObjects(_AlertsRepository.GetAllByMettingById(Guid.Parse(MettingId))); int shomare = 1; foreach (AlertJson alert in result) { alert.ID = shomare.ToString(); if (alert.AlarmType == "1") { alert.AlarmType = "SMS"; } else { alert.AlarmType = "Email"; } shomare++; } return(result); }
private void IncludeSubscriberCount() { ViewBag.SubscriberCount = AlertsRepository.GetNewsletterSubscriberCount(); }