private void ClearAlert(int alertNotificationId)
        {
            RockContext rockContext = new RockContext();

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

            var alert = alertNotificationService
                        .Get(alertNotificationId);

            alert.IsActive = false;

            rockContext.SaveChanges();
        }
        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);
        }
Esempio n. 3
0
        private void BindRepeater()
        {
            RockContext rockContext = new RockContext();

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


            var alerts = alertNotificationService
                         .Queryable()
                         .Where(a => a.IsActive)
                         .OrderBy(a => a.CreatedDateTime)
                         .ToList();


            rNotifications.DataSource = alerts;
            rNotifications.DataBind();
        }
Esempio n. 4
0
        protected void AllClear_Click(object sender, CommandEventArgs e)
        {
            if (e.CommandName == "AllClear_Click")
            {
                int  index;
                bool bIsConverted = int.TryParse(e.CommandArgument.ToString(), out index);

                RockContext rockContext = new RockContext();

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

                var alert = alertNotificationService
                            .Get(index);

                alert.IsActive = false;


                rockContext.SaveChanges();

                BindRepeater();
            }
        }
Esempio n. 5
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();
        }
        protected void mdSendUpdate_SendClick(object sender, EventArgs e)
        {
            int alertID = hfAlertID.Value.AsInteger();

            if (tbAlertMessage.Text.IsNotNullOrWhiteSpace())
            {
                RockContext              rockContext              = new RockContext();
                AlertMessageService      alertMessageService      = new AlertMessageService(rockContext);
                AlertNotificationService alertNotificationService = new AlertNotificationService(rockContext);


                var alert = alertNotificationService
                            .Get(alertID);

                var alertMessage = new AlertMessage
                {
                    AlertNotification = alert,
                    Message           = tbAlertMessage.Text,
                };

                alertMessageService.Add(alertMessage);

                rockContext.SaveChanges();

                alertMessage.SendCommunication(GlobalAttributesCache.Value("DefaultSMSFromNumber").AsGuid());
            }


            if (hfAllClear.Value.AsBoolean())
            {
                ClearAlert(alertID);
            }
            mdSendUpdate.Hide();

            BindRepeater();
        }