Exemplo n.º 1
0
        public void CheckAlert(AlertType alertType, string computerName = "")
        {
            // Talk to team to have delete alert with computer name and remove the hack

            var alertMessage = computerName != ""
                ? $"'Computer {computerName} has been {alertType.ToString()}'"
                : $"'Computer has been {alertType.ToString()}'";

            var alertCreated =
                By.XPath(
                    $"//div[@class='alert-message warning'][contains(.,{alertMessage})]");

            //verify creation
            _selenium.IsElementReady(alertCreated).ShouldBeTrue("Created alert should be visible");
        }
Exemplo n.º 2
0
 public IEnumerable <ConfigurationAlert> GetConfigurationAlerts(AlertType type)
 {
     using (LiteDatabase db = new LiteDatabase(connectionString))
     {
         LiteCollection <ConfigurationAlert> col = db.GetCollection <ConfigurationAlert>(configurationAlertsCollectionName);
         return(col.Find(Query.EQ("AlertType", type.ToString())));
     }
 }
Exemplo n.º 3
0
        public void RenderAlert(AlertType type, string text = null)
        {
            string _type = type.ToString().ToLower();

            ViewBag.HasAlert     = true;
            ViewBag.AlertType    = _type;
            ViewBag.AlertMessage = text;
        }
        public static MvcHtmlString Alert(this HtmlHelper html, AlertType type, List <string> errors)
        {
            if (errors.Count == 0)
            {
                return(MvcHtmlString.Create(""));
            }

            /*
             * <div class="alert alert-danger fade in">
             *                      <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
             *                      <i class="glyphicon glyphicon-ban-circle alert-icon "></i>
             *                      <strong>Oh snap!</strong> Change a few things up and try submitting again.
             *                  </div>
             *                  <div class="alert alert-success fade in">
             *                      <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
             *
             *                      <strong>Well done!</strong> You successfully read this important alert message.
             *                  </div>
             * <div class="alert alert-info fade in">
             *                      <button type="button" class="close" data-dismiss="alert" aria-hidden="true">&times;</button>
             *                      <i class="glyphicon glyphicon-info-sign alert-icon "></i>
             *                      <strong>Heads up!</strong> This alert needs your attention, but it's not super important.
             *                  </div>
             */
            var div = new TagBuilder("div");

            div.MergeAttribute("class", "alert alert-" + type.ToString().ToLower() + " fade in");
            div.InnerHtml = "<button type=\"button\" class=\"close\" data-dismiss=\"alert\" aria-hidden=\"true\">&times;</button>";

            switch (type)
            {
            case AlertType.Success:
                div.InnerHtml = div.InnerHtml + "<i class=\"fa fa-check alert-icon \"></i>";
                div.InnerHtml = div.InnerHtml + "<strong >Bien Hecho!</strong>";
                break;

            case AlertType.Danger:
                div.InnerHtml = div.InnerHtml + "<i class=\"glyphicon glyphicon-ban-circle alert-icon \"></i>";
                div.InnerHtml = div.InnerHtml + "<strong >Error!</strong>";
                break;

            case AlertType.Info:
                div.InnerHtml = div.InnerHtml + "<i class=\"glyphicon glyphicon-info-sign alert-icon \"></i>";
                div.InnerHtml = "<strong >Información</strong>";
                break;
            }

            foreach (var err in errors)
            {
                div.InnerHtml = div.InnerHtml + "<li><p class='note-txt'>" + err + "</p></li>";
            }

            string alertHtml = div.ToString(TagRenderMode.Normal);

            return(MvcHtmlString.Create(alertHtml));
        }
Exemplo n.º 5
0
        private void SendEmail()
        {
            Email.BreachEnd        = EndEventTime;
            Email.BreachStart      = StartEventTime;
            Email.Percentage       = NotificationSettings.PercentageLimit;
            Email.TimeThresholdSec = NotificationSettings.ThresholdTime;
            Email.BreachType       = AlertType.ToString();

            Sendy.SendEmail(Email);
        }
Exemplo n.º 6
0
        public CloseModalResult(bool success = true, string message = null, string title = null, AlertType alertType = AlertType.Success)
        {
            var serializer = new JavaScriptSerializer();

            JsonData = serializer.Serialize(new
            {
                Success   = success,
                Message   = message,
                Title     = title,
                AlertType = alertType.ToString()
            });
        }
Exemplo n.º 7
0
 /// <summary>
 /// This endpoint allows user to create alert for certain price of certain currency pair.
 /// </summary>
 /// <param name="ccyPair">Currency pair.</param>
 /// <param name="limitPrice">Limited Price.</param>
 /// <param name="type">Raising or falling.</param>
 /// <returns></returns>
 public async Task <AlertResponse> CreateAlertAsync(string ccyPair, decimal limitPrice, AlertType type)
 {
     return(await QueryPrivateAsync <AlertResponse>(
                "alert/create",
                new Dictionary <string, string>(3)
     {
         ["ccyPair"] = ccyPair,
         ["limitPrice"] = limitPrice.ToString(_culture),
         ["type"] = type.ToString(),
     }
                ));
 }
Exemplo n.º 8
0
        public void AddAlertToUser(string message, string user, AlertType type, PositionClass positionClass = PositionClass.TopRight, string Timeout = "5000")
        {
            var notificationHub = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>();

            if (NotificationHub.Connections.TryGetValue(user, out ConnectionHandler connId))
            {
                foreach (string s in connId.ConnectionId)
                {
                    notificationHub.Clients.Client(s).displayStatus(message, type.ToString(), Alert.GetStringValue(positionClass), Timeout);
                }
            }
        }
Exemplo n.º 9
0
    internal static void Adds_Alert(Action <ITempDataDictionary, string> add, AlertType type)
    {
        // Arrange
        var text     = Rnd.Str;
        var td       = Substitute.For <ITempDataDictionary>();
        var expected = $"[{{\"type\":\"{type.ToString().ToLower()}\",\"text\":\"{text}\"}}]";

        // Act
        add(td, text);

        // Assert
        td.Received().Add(TempDataDictionaryExtensions.AlertsKey, expected);
    }
Exemplo n.º 10
0
        public void AddAlert(string message, string CallerMethod, string CallerClass, AlertType type, Exception ex, PositionClass positionClass = PositionClass.TopRight, string Timeout = "5000")
        {
            var notificationHub = GlobalHost.ConnectionManager.GetHubContext <NotificationHub>();

            if (NotificationHub.Connections.TryGetValue(User.Identity.Name, out ConnectionHandler connId))
            {
                foreach (string s in connId.ConnectionId)
                {
                    notificationHub.Clients.Client(s).displayStatus(message, type.ToString(), Alert.GetStringValue(positionClass));
                }
            }

            log.Error($"[{CallerMethod}] {ex.Message}", ex);
        }
Exemplo n.º 11
0
        public static MvcHtmlString Alert(this HtmlHelper html, string shortTitle, string message, AlertType alertType)
        {
            var div = new TagBuilder("div");
            var alertTypeCSS = string.Format("alert-{0}", alertType.ToString().ToLower());
            div.AddCssClass("alert");
            div.AddCssClass(alertTypeCSS);

            var a = new TagBuilder("a");
            a.AddCssClass("close");
            a.Attributes.Add("data-dismiss", "alert");
            a.InnerHtml = "&times;";

            div.InnerHtml = string.Format("{0}<strong>{1} </strong>{2}", a.ToString(), shortTitle, message);
            return new MvcHtmlString(div.ToString());
        }
Exemplo n.º 12
0
        private string GetCssClass()
        {
            string result = "alert alert-" + AlertType.ToString().ToLower();

            if (Dismissable)
            {
                result += " alert-dismissable";
            }

            if (!string.IsNullOrEmpty(CssClass))
            {
                result += " " + CssClass;
            }

            return(result.Trim());
        }
Exemplo n.º 13
0
        public void TriggerAlert(AlertType alertType, String optionalText, bool isConditional)
        {
            var alertText = alertType.ToString();

            if (!string.IsNullOrEmpty(optionalText))
            {
                alertText = alertText + System.Environment.NewLine + optionalText;
            }

            DT1WatchdogData.SetAlert(alertText);

            if ((!isConditional) || (DT1WatchdogData.MuteAlertTimeout <= DateTimeOffset.UtcNow))
            {
                EnterAlertMode();

                switch (DT1WatchdogData.AlertNotificationType)
                {
                case DT1WatchdogData.AlertNotification.SMSAlert:
                {
                    if (!string.IsNullOrEmpty(DT1WatchdogData.SMSAlertContact))
                    {
                        SmsManager.Default.SendTextMessage(DT1WatchdogData.SMSAlertContact, null, alertText, null, null);

                        if (!isConditional)
                        {
                            // non conditional trigger audio also
                            dt1WatchdogAudioAlert.Start();
                        }
                    }
                    else
                    {
                        // fallback trigger audio alert
                        dt1WatchdogAudioAlert.Start();
                    }

                    break;
                }

                case DT1WatchdogData.AlertNotification.AudioAlert:
                {
                    dt1WatchdogAudioAlert.Start();
                    break;
                }
                }
            }
        }
Exemplo n.º 14
0
        private void buttonSaveAlert_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBoxAlertType.SelectedIndex >= 0)
                {
                    selAlert                      = (AlertType)comboBoxAlertType.SelectedIndex;
                    selAlertInfo                  = new alertInfo();
                    selAlertInfo.AlertName        = selAlert.ToString();
                    selAlertInfo.RecipientList    = textBoxMailToList.Text;
                    selAlertInfo.CCRecipientList  = textBoxCCList.Text;
                    selAlertInfo.BCCRecipientList = textBoxBCCList.Text;
                    selAlertInfo.MailSubject      = textBoxMailSubject.Text;
                    selAlertInfo.AlertMessage     = richTextBox.Text;
                    selAlertInfo.bActive          = checkBoxAlertActive.Checked;
                    if (selAlert == AlertType.AT_Remove_Tag_Max_Time)
                    {
                        if (checkedListBox.CheckedIndices.Count > 0)
                        {
                            selAlertInfo.alertData = textBoxAlert.Text;
                            for (int i = 0; i < checkedListBox.CheckedIndices.Count; i++)
                            {
                                selAlertInfo.alertData += ";" + DeviceArray[checkedListBox.CheckedIndices[i]].SerialRFID;
                            }
                        }
                    }
                    else
                    {
                        selAlertInfo.alertData = textBoxAlert.Text;
                    }

                    db.DeleteAlert(selAlertInfo);
                    db.AddAlertInfo(selAlertInfo);
                    MessageBox.Show(ResStrings.strAlertSaved, ResStrings.strAlertManagmentInfo, MessageBoxButtons.OK, MessageBoxIcon.Information);
                }
            }
            catch (Exception exp)
            {
                ErrorMessage.ExceptionMessageBox.Show(exp);
            }
        }
Exemplo n.º 15
0
        private void buttonTestAlert_Click(object sender, EventArgs e)
        {
            try
            {
                if (comboBoxAlertType.SelectedIndex >= 0)
                {
                    selAlert                      = (AlertType)comboBoxAlertType.SelectedIndex;
                    selAlertInfo                  = new alertInfo();
                    selAlertInfo.AlertName        = selAlert.ToString();
                    selAlertInfo.RecipientList    = textBoxMailToList.Text;
                    selAlertInfo.CCRecipientList  = textBoxCCList.Text;
                    selAlertInfo.BCCRecipientList = textBoxBCCList.Text;
                    selAlertInfo.MailSubject      = textBoxMailSubject.Text;
                    selAlertInfo.AlertMessage     = richTextBox.Text;
                    selAlertInfo.bActive          = checkBoxAlertActive.Checked;
                    if (selAlert == AlertType.AT_Remove_Tag_Max_Time)
                    {
                        if (checkedListBox.SelectedIndices.Count > 0)
                        {
                            selAlertInfo.alertData = textBoxAlert.Text;
                            for (int i = 0; i < checkedListBox.SelectedIndices.Count; i++)
                            {
                                selAlertInfo.alertData += ";" + DeviceArray[checkedListBox.SelectedIndices[i]].SerialRFID;
                            }
                        }
                    }
                    else
                    {
                        selAlertInfo.alertData = textBoxAlert.Text;
                    }


                    createAndSendMail(selAlertInfo, smtp);
                }
            }
            catch (Exception exp)
            {
                ErrorMessage.ExceptionMessageBox.Show(exp);
            }
        }
Exemplo n.º 16
0
 public void SetAlert(string message, AlertType type)
 {
     TempData["AlertType"] = type.ToString().ToLower();
     TempData["AlertMessage"] = message;
 }
Exemplo n.º 17
0
        private static void AddMessage(TempDataDictionary tempData, AlertType type, string message,
            AlertLocation location)
        {
            var alertData = tempData.InitializeAlertData();

            alertData[location][type].Add(message);

            tempData["AlertData"] = alertData;
            tempData[type.ToString()] = message;
        }
Exemplo n.º 18
0
 protected JsonResult JsonSuccess(string message = null, string title = null, AlertType alertType = AlertType.Success)
 {
     return(Json(new { Success = true, Message = message, Title = title, AlertType = alertType.ToString() }));
 }
Exemplo n.º 19
0
 public static string ToAlertCssClass(this AlertType alertType)
 {
     return($"alert-{alertType.ToString().ToLower()}");
 }
Exemplo n.º 20
0
 /// <summary>
 /// 顯示alert訊息
 /// </summary>
 protected void SetAlertMessage(string message, AlertType type)
 {
     TempData["AlertMessage"] = message;
     TempData["AlertType"]    = type.ToString();
 }
Exemplo n.º 21
0
 private void SetMessageTitle(AlertType alertType, string messageTitle)
 {
     lblTitle.Text = string.IsNullOrEmpty(messageTitle) ? alertType.ToString() : messageTitle;
 }
Exemplo n.º 22
0
 protected JsonResult JsonError(string message = null, string title = null, AlertType alertType = AlertType.Danger)
 {
     return(Json(new { Success = false, Message = message, Title = title, AlertType = alertType.ToString() }));
 }
Exemplo n.º 23
0
 public void ShowAlert(AlertType MsgType, string Message)
 {
     TempData["AlertType"] = MsgType.ToString();
     TempData["Message"]   = Message.ToString();
 }
Exemplo n.º 24
0
 public void Add(AlertType type, LocalizedHtmlString message)
 {
     _logger.LogInformation($"The alert of type '{type.ToString()}' was added for display. Message: '{message.ToHtmlString()}'.");
     _alerts.Add(new AlertInfo(type, message));
 }
Exemplo n.º 25
0
 public void SetAlert(string message, AlertType type)
 {
     TempData["AlertType"]    = type.ToString().ToLower();
     TempData["AlertMessage"] = message;
 }
Exemplo n.º 26
0
 public static IActionResult With(this IActionResult result, string title, string body, AlertType type)
 {
     _type = type;
     return(Alert(result, "alert alert-" + type.ToString(), title, body));
 }
Exemplo n.º 27
0
        public void ClickForJsAlert(AlertType alertType)
        {
            var clickForJsAlert = By.XPath($"//*[@id='content'] //button[text()='Click for JS {alertType.ToString()}']");

            _selenium.Click(clickForJsAlert);
        }
Exemplo n.º 28
0
 public void Alert(string message, AlertType type = AlertType.info, string boldMessage = null)
 {
     TempData["Alert.Message"]     = message;
     TempData["Alert.Type"]        = type.ToString();
     TempData["Alert.BoldMessage"] = boldMessage;
 }
Exemplo n.º 29
0
 public void Alert(string message, AlertType type = AlertType.info)
 {
     TempData["Alert.Message"] = message;
     TempData["Alert.Type"]    = type.ToString();
 }
Exemplo n.º 30
0
 protected void SetActionState(string message, AlertType alertType = AlertType.danger)
 {
     TempData["ValidationError"] = message;
     TempData["AlertType"]       = alertType.ToString();
 }