public NotificationTypeDto(Int32 notificationTypeId, String notificationTypeName, String notificationTypeDisplayName, Byte[] notificationTypeIcon, SendingApplicationDto sendingApplication) { this.NotificationTypeId = notificationTypeId; this.NotificationTypeName = notificationTypeName; this.NotificationTypeDisplayName = notificationTypeDisplayName; this.NotificationTypeIcon = notificationTypeIcon; this.SendingApplication = sendingApplication; }
public SubscriberDto(Guid subscriberId, String subscriberName, Nullable <Int32> port, String hostName, String password, List <NotificationDto> notificationsSent, SendingApplicationDto sendingApplication) { this.SubscriberId = subscriberId; this.SubscriberName = subscriberName; this.Port = port; this.HostName = hostName; this.Password = password; this.NotificationsSent = notificationsSent; this.SendingApplication = sendingApplication; }
public void TestRegisterSendingApplication_LoadNotificationTypesFromExcel_AllLoaded() { var foghornClient = new ChannelFactory<IFoghornService>(new BasicHttpBinding(), new EndpointAddress(ServiceUrl)).CreateChannel(); var notificationTypeDtos = new List<NotificationTypeDto>(); LoadNotificationTypes(notificationTypeDtos); var sendingApplicationDto = new SendingApplicationDto {SendingApplicationName = ApplicationTestName}; LoadApplicationIcon(sendingApplicationDto); foghornClient.RegisterSendingApplication(sendingApplicationDto, notificationTypeDtos); //TODO: Add Assertions }
/// <summary> /// Converts this instance of <see cref="SendingApplicationDto"/> to an instance of <see cref="SendingApplication"/>. /// </summary> /// <param name="dto"><see cref="SendingApplicationDto"/> to convert.</param> public static SendingApplication ToEntity(this SendingApplicationDto dto) { if (dto == null) { return(null); } var entity = new SendingApplication(); entity.SendingApplicationId = dto.SendingApplicationId; entity.SendingApplicationName = dto.SendingApplicationName; entity.SendingApplicationIcon = dto.SendingApplicationIcon; dto.OnEntity(entity); return(entity); }
/// <summary> /// Converts this instance of <see cref="SendingApplication"/> to an instance of <see cref="SendingApplicationDto"/>. /// </summary> /// <param name="entity"><see cref="SendingApplication"/> to convert.</param> public static SendingApplicationDto ToDto(this SendingApplication entity) { if (entity == null) { return(null); } var dto = new SendingApplicationDto(); dto.SendingApplicationId = entity.SendingApplicationId; dto.SendingApplicationName = entity.SendingApplicationName; dto.SendingApplicationIcon = entity.SendingApplicationIcon; entity.OnDto(dto); return(dto); }
public int RegisterSendingApplication(SendingApplicationDto sendingApplicationDto, IEnumerable<NotificationTypeDto> notificationTypeDtos) { var notificationTypes = new List<NotificationType>(); foreach (var notificationTypeDto in notificationTypeDtos) { var notificationType = DataContext.NotificationTypes.FirstOrDefault( x => x.NotificationTypeName == notificationTypeDto.NotificationTypeName); if (notificationType == null) { notificationType = notificationTypeDto.ToEntity(); DataContext.NotificationTypes.Add(notificationType); Logger.Trace("Adding a new NotificationType: {0}, for application: {1}", notificationTypeDto.NotificationTypeName, sendingApplicationDto.SendingApplicationName); } notificationType.NotificationTypeIcon = notificationTypeDto.NotificationTypeIcon; notificationType.NotificationTypeDisplayName = notificationTypeDto.NotificationTypeDisplayName; notificationTypes.Add(notificationType); } var sendingApplication = DataContext.SendingApplications.FirstOrDefault( x => x.SendingApplicationName == sendingApplicationDto.SendingApplicationName); if (sendingApplication == null) { sendingApplication = sendingApplicationDto.ToEntity(); Logger.Trace("Adding a new SendingApplication: {0}", sendingApplicationDto.SendingApplicationName); DataContext.SendingApplications.Add(sendingApplication); } else { sendingApplication.SendingApplicationIcon = sendingApplicationDto.SendingApplicationIcon; } sendingApplication.NotificationTypes.Clear(); foreach (var notificationType in notificationTypes) { sendingApplication.NotificationTypes.Add(notificationType); } DataContext.SaveChanges(); return sendingApplication.SendingApplicationId; }
partial static void OnDto(this SendingApplication entity, SendingApplicationDto dto) { dto.NotificationTypes = (List<NotificationTypeDto>) entity.NotificationTypes.ToDtos(); dto.Subscribers = (List<SubscriberDto>) entity.Subscribers.ToDtos(); }
private static void LoadApplicationIcon(SendingApplicationDto sendingApplicationDto) { Stream iconStream = null; try { iconStream = File.OpenRead(Path.Combine(@"..\..\NotificationIcons", "Icon.png")); var buffer = new byte[iconStream.Length]; iconStream.Read(buffer, 0, (int) iconStream.Length); sendingApplicationDto.SendingApplicationIcon = buffer; } catch (Exception exception) { Logger.LogException(LogLevel.Error, "Exception Ignored", exception); throw; } finally { if (iconStream != null) iconStream.Close(); } }
/// <summary> /// Invoked when <see cref="ToEntity"/> operation is about to return. /// </summary> /// <param name="dto"><see cref="SendingApplicationDto"/> converted from <see cref="SendingApplication"/>.</param> /// <param name="entity"><see cref="SendingApplication"/> converted from <see cref="SendingApplicationDto"/>.</param> static partial void OnEntity(this SendingApplicationDto dto, SendingApplication entity);
/// <summary> /// Invoked when <see cref="ToDto"/> operation is about to return. /// </summary> /// <param name="dto"><see cref="SendingApplicationDto"/> converted from <see cref="SendingApplication"/>.</param> /// <param name="entity"><see cref="SendingApplication"/> converted from <see cref="SendingApplicationDto"/>.</param> static partial void OnDto(this SendingApplication entity, SendingApplicationDto dto);
public SubscriberDto(Guid subscriberId, String subscriberName, Nullable<Int32> port, String hostName, String password, List<NotificationDto> notificationsSent, SendingApplicationDto sendingApplication) { this.SubscriberId = subscriberId; this.SubscriberName = subscriberName; this.Port = port; this.HostName = hostName; this.Password = password; this.NotificationsSent = notificationsSent; this.SendingApplication = sendingApplication; }
/// <summary> /// Invoked when <see cref="ToDto"/> operation is about to return. /// </summary> /// <param name="dto"><see cref="SendingApplicationDto"/> converted from <see cref="SendingApplication"/>.</param> /// <param name="entity"><see cref="SendingApplication"/> converted from <see cref="SendingApplicationDto"/>.</param> partial static void OnDto(this SendingApplication entity, SendingApplicationDto dto);
/// <summary> /// Converts this instance of <see cref="SendingApplication"/> to an instance of <see cref="SendingApplicationDto"/>. /// </summary> /// <param name="entity"><see cref="SendingApplication"/> to convert.</param> public static SendingApplicationDto ToDto(this SendingApplication entity) { if (entity == null) return null; var dto = new SendingApplicationDto(); dto.SendingApplicationId = entity.SendingApplicationId; dto.SendingApplicationName = entity.SendingApplicationName; dto.SendingApplicationIcon = entity.SendingApplicationIcon; entity.OnDto(dto); return dto; }
static partial void OnDto(this SendingApplication entity, SendingApplicationDto dto) { dto.NotificationTypes = (List <NotificationTypeDto>)entity.NotificationTypes.ToDtos(); dto.Subscribers = (List <SubscriberDto>)entity.Subscribers.ToDtos(); }
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); }