public NotificationDto(Int32 notificationId, String notificationTitle, String notificationMessage, DateTime sentDateTime, Int32 priority, Boolean sticky, List <SubscriberDto> sentToSubscribers, NotificationTypeDto notificationType) { this.NotificationId = notificationId; this.NotificationTitle = notificationTitle; this.NotificationMessage = notificationMessage; this.SentDateTime = sentDateTime; this.Priority = priority; this.Sticky = sticky; this.SentToSubscribers = sentToSubscribers; this.NotificationType = notificationType; }
public NotificationDto(Int32 notificationId, String notificationTitle, String notificationMessage, DateTime sentDateTime, Int32 priority, Boolean sticky, List<SubscriberDto> sentToSubscribers, NotificationTypeDto notificationType) { this.NotificationId = notificationId; this.NotificationTitle = notificationTitle; this.NotificationMessage = notificationMessage; this.SentDateTime = sentDateTime; this.Priority = priority; this.Sticky = sticky; this.SentToSubscribers = sentToSubscribers; this.NotificationType = notificationType; }
/// <summary> /// Converts this instance of <see cref="NotificationType"/> to an instance of <see cref="NotificationTypeDto"/>. /// </summary> /// <param name="entity"><see cref="NotificationType"/> to convert.</param> public static NotificationTypeDto ToDto(this NotificationType entity) { if (entity == null) { return(null); } var dto = new NotificationTypeDto(); dto.NotificationTypeId = entity.NotificationTypeId; dto.NotificationTypeName = entity.NotificationTypeName; dto.NotificationTypeDisplayName = entity.NotificationTypeDisplayName; dto.NotificationTypeIcon = entity.NotificationTypeIcon; entity.OnDto(dto); return(dto); }
/// <summary> /// Converts this instance of <see cref="NotificationTypeDto"/> to an instance of <see cref="NotificationType"/>. /// </summary> /// <param name="dto"><see cref="NotificationTypeDto"/> to convert.</param> public static NotificationType ToEntity(this NotificationTypeDto dto) { if (dto == null) { return(null); } var entity = new NotificationType(); entity.NotificationTypeId = dto.NotificationTypeId; entity.NotificationTypeName = dto.NotificationTypeName; entity.NotificationTypeDisplayName = dto.NotificationTypeDisplayName; entity.NotificationTypeIcon = dto.NotificationTypeIcon; dto.OnEntity(entity); return(entity); }
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(); } }
/// <summary> /// Invoked when <see cref="ToEntity"/> operation is about to return. /// </summary> /// <param name="dto"><see cref="NotificationTypeDto"/> converted from <see cref="NotificationType"/>.</param> /// <param name="entity"><see cref="NotificationType"/> converted from <see cref="NotificationTypeDto"/>.</param> static partial void OnEntity(this NotificationTypeDto dto, NotificationType entity);
/// <summary> /// Invoked when <see cref="ToDto"/> operation is about to return. /// </summary> /// <param name="dto"><see cref="NotificationTypeDto"/> converted from <see cref="NotificationType"/>.</param> /// <param name="entity"><see cref="NotificationType"/> converted from <see cref="NotificationTypeDto"/>.</param> static partial void OnDto(this NotificationType entity, NotificationTypeDto dto);
/// <summary> /// Invoked when <see cref="ToDto"/> operation is about to return. /// </summary> /// <param name="dto"><see cref="NotificationTypeDto"/> converted from <see cref="NotificationType"/>.</param> /// <param name="entity"><see cref="NotificationType"/> converted from <see cref="NotificationTypeDto"/>.</param> partial static void OnDto(this NotificationType entity, NotificationTypeDto dto);
/// <summary> /// Converts this instance of <see cref="NotificationType"/> to an instance of <see cref="NotificationTypeDto"/>. /// </summary> /// <param name="entity"><see cref="NotificationType"/> to convert.</param> public static NotificationTypeDto ToDto(this NotificationType entity) { if (entity == null) return null; var dto = new NotificationTypeDto(); dto.NotificationTypeId = entity.NotificationTypeId; dto.NotificationTypeName = entity.NotificationTypeName; dto.NotificationTypeDisplayName = entity.NotificationTypeDisplayName; dto.NotificationTypeIcon = entity.NotificationTypeIcon; entity.OnDto(dto); return dto; }
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); }