private Guid AddNotificationBatch(GenericNotificationViewModel model)
        {
            //Add the  Notification Batch .....
            var notificationTemplate = _notificationTemplatesService.GetByKey(model.NotificationTemplateKey);

            if (notificationTemplate != null)
            {
                NotificationBatch notificationBatch = new NotificationBatch();
                Guid batchGuid = Guid.NewGuid();
                notificationBatch.StartDate = model.CurrentDate;
                if (!string.IsNullOrEmpty(model.NotificationTemplateKey))
                {
                    notificationBatch.ResourceType   = model.NotificationTemplateKey.Split('.')[0];
                    notificationBatch.ResourceAction = model.NotificationTemplateKey.Split('.')[1];
                }
                notificationBatch.AdditionalMessage        = "";
                notificationBatch.ResourceId               = model.ResourceId;
                notificationBatch.NotificationBatchGuid    = batchGuid;
                notificationBatch.NotificationTemplateGuid = notificationTemplate.NotificationTemplateGuid;
                notificationBatch.CreatedBy = model.CurrentUserGuid;
                notificationBatch.CreatedOn = model.CurrentDate;

                _notificationBatchService.Add(notificationBatch);
                return(batchGuid);
            }
            return(Guid.Empty);
        }
Exemplo n.º 2
0
        public Guid Add(NotificationBatch model)
        {
            var sql = @"INSERT INTO NotificationBatch
                                                    (NotificationBatchGuid
                                                    ,NotificationTemplateGuid
                                                    ,ResourceId
                                                    ,ResourceType
                                                    ,ResourceAction
                                                    ,StartDate
                                                    ,AdditionalMessage
                                                    ,CreatedOn
                                                    ,CreatedBy)
                                            VALUES
                                                    (@NotificationBatchGuid
                                                    ,@NotificationTemplateGuid
                                                    ,@ResourceId
                                                    ,@ResourceType
                                                    ,@ResourceAction
                                                    ,@StartDate
                                                    ,@AdditionalMessage
                                                    ,@CreatedOn
                                                    ,@CreatedBy)";

            _context.Connection.Execute(sql, model);
            return(model.NotificationBatchGuid);
        }
Exemplo n.º 3
0
        public void SendNotifications(Notification[] notifications)
        {
            NotificationBatch batch = new NotificationBatch(this, notifications);
            bool complete           = false;

            while (!complete)
            {
                complete = batch.SendMessages();
            }
            batch.Complete();
        }
Exemplo n.º 4
0
 public void SendNotifications(Notification[] notifications)
 {
     NotificationBatch batch = new NotificationBatch(this, notifications);
     bool complete = false;
     while(!complete)
         complete = batch.SendMessages();
     batch.Complete();
 }
Exemplo n.º 5
0
 public Guid Add(NotificationBatch model)
 {
     return(_notificationBatchRepository.Add(model));
 }