Exemplo n.º 1
0
 public void SendAlertNotification(AlertNotification notification)
 {
     if (_watchAllAlerts > 0)
     {
         Send(notification);
     }
 }
        public void ToString_AnyNotification_MatchesWithExpected()
        {
            var notification = new AlertNotification("tit", "subtit", "bbb", 4, "q.mp4");
            var actual       = notification.ToString();
            var expected     = GetExpectedToStringFrom(notification);

            Assert.AreEqual(expected, actual);
        }
Exemplo n.º 3
0
        protected override void ConcealCancelled(long entityId)
        {
            Notification notice = new AlertNotification()
            {
                Text = "Conceal cancelled for entity " + entityId
            };

            notice.Raise();
        }
 private string GetExpectedToStringFrom(AlertNotification notification)
 {
     return("{" +
            "\"aps\":" + "{" +
            "\"alert\":" + "{" +
            $"\"title\":\"{notification.Title}\"," +
            $"\"subtitle\":\"{notification.Subtitle}\"," +
            $"\"body\":\"{notification.Body}\"" +
            "}," +
            $"\"badge\":{notification.Badge}," +
            $"\"sound\":\"{notification.Sound}\"" +
            "}}");
 }
        private void CreateAlert(DefinedValueCache audience)
        {
            if (audience == null)
            {
                maPopup.Show("The audience is not defined.", ModalAlertType.Information);
                return;
            }

            RockContext rockContext = new RockContext();

            AlertNotificationService alertNotificationService = new AlertNotificationService(rockContext);
            AlertMessageService      alertMessageService      = new AlertMessageService(rockContext);

            int alertTypeId = 31480;

            var alertnotification = new AlertNotification
            {
                Title = lAlertTitle.Text,
                AlertNotificationTypeValueId = alertTypeId,
                AudienceValueId = audience.Id,
                IsActive        = true,
            };

            alertNotificationService.Add(alertnotification);

            rockContext.SaveChanges();

            var alertMessage = new AlertMessage
            {
                AlertNotificationId = alertnotification.Id,
                Message             = lMessage.Text,
            };

            alertMessageService.Add(alertMessage);


            rockContext.SaveChanges();



            alertMessage.SendCommunication(GetAttributeValue("From").AsGuid());

            mdCustomMessage.Hide();
            mdLockdownAlert.Hide();

            maPopup.Show("The LockDown message has been sent.", ModalAlertType.Information);
        }
Exemplo n.º 6
0
        private void Send(AlertNotification notification)
        {
            var value = new DynamicJsonValue
            {
                ["Type"]  = "AlertNotification",
                ["Value"] = new DynamicJsonValue
                {
                    [nameof(AlertNotification.Global)] = notification.Global,
                    [nameof(AlertNotification.Alert)]  = notification.Alert.ToJson()
                }
            };

            if (_disposeToken.IsCancellationRequested == false)
            {
                _sendQueue.Enqueue(new NotificationValue
                {
                    ValueToSend = value,
                    AllowSkip   = false
                });
            }
        }
Exemplo n.º 7
0
        /// <summary>
        ///  Create Notification
        /// </summary>
        public async Task CreateNotificationAlertAsync(string text, string email, DateTime date, int?requestId, int?alertTypeId)
        {
            _logger.LogInformation($"Create notificationAlert. (user='******'");

            var newAlertNotification = new AlertNotification
            {
                Id          = 0,
                Text        = text,
                Email       = email,
                Date        = date,
                IsRead      = false,
                RequestId   = requestId,
                AlertTypeId = alertTypeId
            };

            await _contextDb.AlertNotifications.AddAsync(newAlertNotification);

            await _contextDb.SaveChangesAsync();

            _logger.LogInformation($"Created notification. (id={newAlertNotification.Id})'");
        }
        public async Task <IActionResult> PostAsync(AlertNotification request)
        {
            var model = new AlertNotificationViewModel()
            {
                AffectedSystem     = request.AffectedSystem,
                ErrorDetail        = request.ErrorDetail,
                OccurrenceDateTime = request.OccurrenceDateTime,
                TicketLink         = request.TicketLink
            };
            var plainTextContent = base._plainTextContentRenderer.RenderModelToString(new
            {
                Sistema  = model.AffectedSystem,
                Data     = model.OccurrenceDateTime.Date,
                Hora     = $"{model.OccurrenceDateTime.Hour}:{model.OccurrenceDateTime.Minute}:{model.OccurrenceDateTime.Second}.",
                Detalhes = model.ErrorDetail,
                Ticket   = model.TicketLink,
            });

            foreach (var keeper in request.Keepers)
            {
                model.KeeperName = keeper.Name;
                var htmlContent = await base._viewRenderer.RenderViewToString("Views/Admin/Alert.cshtml", model);

                var emailDetail = new EmailDetail()
                {
                    ToEmail          = keeper.Email,
                    ToName           = keeper.Name,
                    Subject          = $"[Alert From System {request.AffectedSystem}]",
                    PlainTextContent = plainTextContent,
                    HtmlContent      = htmlContent,
                    FromEmail        = request.CompanyEmail,
                    FromName         = request.CompanyName,
                };

                await base._emailService.SendEmail(emailDetail);
            }
            return(Ok());
        }
Exemplo n.º 9
0
        protected void btnStaff_Click(object sender, EventArgs e)
        {
            GetStaff();

            RockContext rockContext = new RockContext();

            AlertNotificationService alertNotificationService = new AlertNotificationService(rockContext);
            AlertMessageService      alertMessageService      = new AlertMessageService(rockContext);

            int alertTypeId     = 31480;
            int alertAudienceId = 31476;

            var alertnotification = new AlertNotification
            {
                Title = lAlertTitle.Text,
                AlertNotificationTypeValueId = alertTypeId,
                AudienceValueId = alertAudienceId,
                IsActive        = true,
            };



            alertNotificationService.Add(alertnotification);

            rockContext.SaveChanges();



            alertMessageService.Add(new AlertMessage
            {
                AlertNotificationId = alertnotification.Id,
                Message             = lMessage.Text,
                CommunicationId     = 40558,
            });

            rockContext.SaveChanges();
        }
Exemplo n.º 10
0
 public AlertNotificationDetail CreateAlertNotification(AlertNotification alertNotification)
 {
     return(new AlertNotificationDetail(
                alertNotification.AlertId,
                new List <string>(alertNotification.Reasons)));
 }
Exemplo n.º 11
0
        public Alert(AlertNotification an)
        {
            resolver = ((PBApp)Application.Current).GetResolver();
            if (resolver != null)
            {
                pbData = resolver.GetInstanceOf <IPBData>();
            }

            string path = AppHelper.ImageFolderLocation + an.image_id + ".png";

            if (File.Exists(path))
            {
                alertImage  = c.GetImageForPath(path, loadDefaultIfNeeded: false);
                icon_width  = 60;
                icon_height = 40;
            }
            else
            {
                alertImage  = DefaultProperties.ReturnImage(DefaultProperties.SecurityAlertIcon);
                icon_width  = 21;
                icon_height = 18;
            }
            if (an.AlertType == AlertType.SecurityAlert)
            {
                siteName = an.site_name;
                if (an.has_duplicate)
                {
                    status = (string)Application.Current.Resources["DuplicatePassword"];
                }
                else if (an.is_weak)
                {
                    status = (string)Application.Current.Resources["WeakPassword"];
                }
                else if (an.last_password_change.HasValue)
                {
                    int days = (int)DateTime.Now.Subtract(an.last_password_change.Value).TotalDays;
                    if (days >= 365)
                    {
                        status = string.Format((string)Application.Current.Resources["OldPasswordDesktop"], days);
                    }
                }
            }
            else if (an.AlertType == AlertType.NewShare)
            {
                siteName = an.CustomMessage;
                if (pbData != null)
                {
                    email   = an.sender == pbData.ActiveUser ? an.receiver : an.sender;
                    visible = true;
                }
                status      = an.nickname;// an.message;
                shareStatus = an.status;
                uuid        = an.id;
                alertImage  = (ImageSource)Application.Current.FindResource("imgShare2Hover");
                icon_width  = 21;
                icon_height = 18;
            }
            if (uuid == null)
            {
                uuid = an.secure_item_id;
            }
            AlertNotification = an;
        }
Exemplo n.º 12
0
 public void NewAlertArrived(String name)
 {
     this.UnreadCount++;
     this.LastNotification = new AlertNotification(name);
 }