Пример #1
0
 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;
 }
Пример #2
0
 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;
 }
Пример #3
0
        /// <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);
        }
Пример #4
0
        /// <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);
        }
Пример #5
0
        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();
            }
        }
Пример #6
0
 /// <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);
Пример #7
0
 /// <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);
Пример #8
0
        /// <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);
Пример #9
0
        /// <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;
        }
Пример #10
0
        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);
        }