Exemple #1
0
        /// <summary>
        /// Create a new instance of a NotificationQueue class, initializes with specified parameters.
        /// </summary>
        /// <param name="template"></param>
        /// <param name="to"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        public NotificationQueue(NotificationTemplate template, string to, string subject, string body)
        {
            if (String.IsNullOrWhiteSpace(to))
            {
                throw new ArgumentException("Argument is required and cannot be null, empty or whitespace.", nameof(to));
            }
            if (String.IsNullOrWhiteSpace(subject))
            {
                throw new ArgumentException("Argument is required and cannot be null, empty or whitespace.", nameof(subject));
            }
            if (String.IsNullOrWhiteSpace(body))
            {
                throw new ArgumentException("Argument is required and cannot be null, empty or whitespace.", nameof(body));
            }

            this.Key        = Guid.NewGuid();
            this.TemplateId = template?.Id ?? throw new ArgumentNullException(nameof(template));
            this.Template   = template;
            this.To         = to;
            this.Subject    = subject;
            this.Body       = body;
            this.BodyType   = template.BodyType;
            this.Encoding   = template.Encoding;
            this.Priority   = template.Priority;
            this.SendOn     = DateTime.UtcNow;
            this.Tag        = template.Tag;
        }
Exemple #2
0
 /// <summary>
 /// Create a new instance of a NotificationQueue.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="template"></param>
 /// <param name="project"></param>
 /// <returns></returns>
 public static Entity.NotificationQueue CreateNotificationQueue(int id, Entity.NotificationTemplate template, Entity.Project project, Entity.Agency agency = null)
 {
     return(new Entity.NotificationQueue(template, project, agency ?? project.Agency, "test", "test")
     {
         Id = id,
         CreatedById = Guid.NewGuid(),
         CreatedOn = DateTime.UtcNow,
         RowVersion = new byte[] { 12, 13, 14 }
     });
 }
Exemple #3
0
 /// <summary>
 /// Create a new instance of a NotificationQueue.
 /// </summary>
 /// <param name="id"></param>
 /// <param name="template"></param>
 /// <param name="to"></param>
 /// <param name="subject"></param>
 /// <param name="body"></param>
 /// <returns></returns>
 public static Entity.NotificationQueue CreateNotificationQueue(int id, Entity.NotificationTemplate template, string to = "*****@*****.**", string subject = "test", string body = "test")
 {
     return(new Entity.NotificationQueue(template, to, subject, body)
     {
         Id = id,
         CreatedById = Guid.NewGuid(),
         CreatedOn = new DateTime(2019, 1, 1, 18, 23, 22, DateTimeKind.Utc),
         RowVersion = new byte[] { 12, 13, 14 }
     });
 }
Exemple #4
0
 /// <summary>
 /// Create a new instance of a ProjectStatusNotification class.
 /// </summary>
 /// <param name="template"></param>
 /// <param name="fromStatus"></param>
 /// <param name="toStatus"></param>
 /// <param name="delay"></param>
 /// <param name="delayDays"></param>
 public ProjectStatusNotification(NotificationTemplate template, ProjectStatus fromStatus, ProjectStatus toStatus, NotificationDelays delay, int delayDays = 0)
 {
     this.TemplateId   = template?.Id ?? throw new ArgumentNullException(nameof(template));
     this.Template     = template;
     this.FromStatusId = fromStatus?.Id;
     this.FromStatus   = fromStatus;
     this.ToStatusId   = toStatus?.Id;
     this.ToStatus     = toStatus;
     this.Priority     = template.Priority;
     this.Delay        = delay;
     this.DelayDays    = delayDays;
 }
Exemple #5
0
        /// <summary>
        /// Create a new List with new instances of NotificationQueues.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="startId"></param>
        /// <param name="count"></param>
        /// <param name="template"></param>
        /// <returns></returns>
        public static List <Entity.NotificationQueue> CreateNotificationQueues(this PimsContext context, int startId, int count, Entity.NotificationTemplate template)
        {
            var templates = new List <Entity.NotificationQueue>(count);

            for (var i = startId; i < (startId + count); i++)
            {
                templates.Add(context.CreateNotificationQueue(i, template));
            }
            return(templates);
        }
Exemple #6
0
        /// <summary>
        /// Create a new instance of a NotificationQueue.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="id"></param>
        /// <param name="template"></param>
        /// <param name="to"></param>
        /// <param name="subject"></param>
        /// <param name="body"></param>
        /// <returns></returns>
        public static Entity.NotificationQueue CreateNotificationQueue(this PimsContext context, int id, Entity.NotificationTemplate template, string to = "*****@*****.**", string subject = "test", string body = "test")
        {
            var notification = CreateNotificationQueue(id, template, to, subject, body);

            context.NotificationQueue.Add(notification);
            return(notification);
        }
Exemple #7
0
        /// <summary>
        /// Create a new List with new instances of NotificationQueues.
        /// </summary>
        /// <param name="startId"></param>
        /// <param name="count"></param>
        /// <param name="template"></param>
        /// <returns></returns>
        public static List <Entity.NotificationQueue> CreateNotificationQueues(int startId, int count, Entity.NotificationTemplate template)
        {
            var notifications = new List <Entity.NotificationQueue>(count);

            for (var i = startId; i < (startId + count); i++)
            {
                notifications.Add(CreateNotificationQueue(i, template));
            }
            return(notifications);
        }
Exemple #8
0
        /// <summary>
        /// Create a new instance of a NotificationQueue.
        /// </summary>
        /// <param name="context"></param>
        /// <param name="id"></param>
        /// <param name="template"></param>
        /// <param name="project"></param>
        /// <returns></returns>
        public static Entity.NotificationQueue CreateNotificationQueue(this PimsContext context, int id, Entity.NotificationTemplate template, Entity.Project project, Entity.Agency agency = null)
        {
            var notification = CreateNotificationQueue(id, template, project, agency);

            context.NotificationQueue.Add(notification);
            return(notification);
        }
Exemple #9
0
        /// <summary>
        /// Create a new List with new instances of NotificationQueues.
        /// </summary>
        /// <param name="startId"></param>
        /// <param name="count"></param>
        /// <param name="template"></param>
        /// <param name="project"></param>
        /// <returns></returns>
        public static List <Entity.NotificationQueue> CreateNotificationQueues(int startId, int count, Entity.NotificationTemplate template, Entity.Project project, Entity.Agency agency = null)
        {
            var notifications = new List <Entity.NotificationQueue>(count);

            for (var i = startId; i < (startId + count); i++)
            {
                notifications.Add(CreateNotificationQueue(i, template, project, agency));
            }
            return(notifications);
        }
Exemple #10
0
 /// <summary>
 /// Create a new instance of a NotificationQueue class, initializes with specified parameters.
 /// </summary>
 /// <param name="template"></param>
 /// <param name="to"></param>
 /// <param name="subject"></param>
 /// <param name="body"></param>
 public NotificationQueue(NotificationTemplate template, string to, string subject, string body) : this(template, to, null, null, subject, body)
 {
 }