private static void LoadNotificationTypes(ICollection <NotificationTypeDto> notificationTypeDtos) { Stream excelFile = null; try { excelFile = File.OpenRead(@"..\..\NotificationTypes.xlsx"); var excel = ExcelReaderFactory.CreateOpenXmlReader(excelFile); excel.IsFirstRowAsColumnNames = true; var excelData = excel.AsDataSet(); var sheet = excelData.Tables["NotificationTypes"]; foreach (DataRow row in sheet.Rows) { var notificationTypeDto = new NotificationTypeDto { NotificationTypeName = row["NotificationTypeName"].ToString(), NotificationTypeDisplayName = row["NotificationTypeDescription"].ToString(), }; Stream notificationIconStream = null; try { notificationIconStream = File.OpenRead(Path.Combine(@"..\..\NotificationIcons", row["IconFileName"].ToString())); var buffer = new byte[notificationIconStream.Length]; notificationIconStream.Read(buffer, 0, (int)notificationIconStream.Length); notificationTypeDto.NotificationTypeIcon = buffer; notificationTypeDtos.Add(notificationTypeDto); } catch (Exception exception) { Logger.LogException(LogLevel.Error, "Exception Ignored", exception); throw; } finally { if (notificationIconStream != null) { notificationIconStream.Close(); } } } } catch (Exception exception) { Logger.LogException(LogLevel.Error, "Exception Ignored", exception); } finally { if (excelFile != null) { excelFile.Close(); } } }
private void RegisterTestApplication(IFoghornService service) { var notificationTypeDtos = new List <NotificationTypeDto>(); for (var i = 0; i < NumNotificationTypes; i++) { var notificationTypeDto = new NotificationTypeDto { NotificationTypeName = NotificationName + i, NotificationTypeDisplayName = "Test Notfication " + i }; try { var iconFilePath = string.Format(@"..\..\NotificationIcons\{0}{1}.png", NotificationName, i); var iconFile = File.OpenRead(iconFilePath); var iconBuffer = new byte[iconFile.Length]; iconFile.Read(iconBuffer, 0, (int)iconFile.Length); notificationTypeDto.NotificationTypeIcon = iconBuffer; } catch (Exception exception) { Logger.LogException(LogLevel.Error, FailureMessage, exception); throw; } notificationTypeDtos.Add(notificationTypeDto); } var sendingApplicationDto = new SendingApplicationDto { SendingApplicationName = ApplicationTestName }; try { var iconFilePath = string.Format(@"..\..\NotificationIcons\Icon.png"); var iconFile = File.OpenRead(iconFilePath); var iconBuffer = new byte[iconFile.Length]; iconFile.Read(iconBuffer, 0, (int)iconFile.Length); sendingApplicationDto.SendingApplicationIcon = iconBuffer; } catch (Exception exception) { Logger.LogException(LogLevel.Error, FailureMessage, exception); throw; } _testApplicationId = service.RegisterSendingApplication(sendingApplicationDto, notificationTypeDtos); }
private NotificationTypeParameters MapNotificationType(NotificationTypeDto notification) { switch (notification) { case NotificationTypeDto.Daily: return NotificationTypeParameters.Daily; case NotificationTypeDto.Weekly: return NotificationTypeParameters.Weekly; case NotificationTypeDto.Monthly: return NotificationTypeParameters.Monthly; default: return NotificationTypeParameters.Daily; } }
private NotificationTypeViewModel MapNotificationType(NotificationTypeDto notification) { switch (notification) { case NotificationTypeDto.Daily: return NotificationTypeViewModel.Daily; case NotificationTypeDto.Weekly: return NotificationTypeViewModel.Weekly; case NotificationTypeDto.Monthly: return NotificationTypeViewModel.Monthly; default: return NotificationTypeViewModel.Daily; } }