Beispiel #1
0
        public ModalResponse(ResponseType response, bool _Redirect = true, string _Url = "", bool _Loading = true, bool _Notify = false, AlertTypes AlertType = AlertTypes.info, string Title = "", string Message = "", string Footer = "", string Position = "", int?Timer = null)
        {
            switch (response)
            {
            case ResponseType.Success:
                success = true;
                break;

            case ResponseType.Error:
                success = false;
                break;

            default:
                break;
            }
            redirect = _Redirect;
            url      = _Url;
            loading  = _Loading;
            notify   = _Notify;
            if (notify)
            {
                alertType = AlertType;
                title     = Title;
                message   = Message;
                footer    = Footer;
                position  = Position;
                timer     = Timer;
            }
        }
 private int CreateUniqueAlert(int tenant, string user, int mailboxId, AlertTypes type, object data = null)
 {
     using (var db = GetDb())
     {
         return(CreateUniqueAlert(db, tenant, user, mailboxId, type, data));
     }
 }
Beispiel #3
0
    /// <summary>
    /// Add one to the index of the attack type
    ///
    /// Author: Ben Hoffman
    /// </summary>
    /// <param name="attackType"></param>
    public void AddAlert(AlertTypes attackType)
    {
        if (snortManager == null)
        {
            return;
        }

        // Cast the alert type and store it
        int alertInt = (int)attackType;

        // Add to the count of this alert type
        alertCount[alertInt]++;

        // Calculate the percentage of health on this node based on the
        riskNumbers[alertInt] =
            (float)alertCount[alertInt] / (float)(snortManager.maxAlertCounts[alertInt] + 1);

        // If we are showign the health report and this quad specifically,
        if (showHealthReport && quadObjs[alertInt].isActiveAndEnabled)
        {
            // Set the color of the quad object
            quadObjs[alertInt].color = Color.Lerp(healthyColor, hurtColor, riskNumbers[alertInt]);
        }

        // Tell our group this
        GetComponentInParent <IPGroup>().AddAlert(alertInt, alertCount[alertInt]);
    }
 private int CreateAlerts(int tenant, List <string> users, AlertTypes type, object data = null)
 {
     using (var db = GetDb())
     {
         return(CreateAlerts(db, tenant, users, type, data));
     }
 }
    /// <summary>
    /// Add an alert to this PC of this alert type
    ///
    /// Author: Ben Hoffman
    /// </summary>
    /// <param name="ipBeingAttacked"></param>
    public void Alert(int ipBeingAttacked, AlertTypes alertType)
    {
        // If we do NOT have this IP that is being attacked:
        if (!DeviceManager.Instance.CheckDictionary(ipBeingAttacked))
        {
            // Create a new source based on the source IP that we have
            Source newSource = new Source();

            // Set up the source data to properlly represent a computer that we don't yet have
            newSource.sourceIpInt = ipBeingAttacked;

            // Add them to the network, and wait for that to finish:
            DeviceManager.Instance.NewComputer(newSource);

            return;
        }

        // Set the alert to that PC
//        DeviceManager.ComputersDict[ipBeingAttacked].AddAlert(alertType);

        // Check if that is the most amount of alerts for this alert type
        //       if (DeviceManager.ComputersDict[ipBeingAttacked].AlertCount(alertType) > maxAlertCounts[(int)alertType])
        {
            // Keep track of the highest number alert count we have to calculate the health
            //          maxAlertCounts[(int)alertType] = DeviceManager.ComputersDict[ipBeingAttacked].AlertCount(alertType);

            // Tell all the computers to calculate their new health for this alert type
            DeviceManager.Instance.CalculateColors();
        }
    }
Beispiel #6
0
        /// <summary>
        /// Utility script to generate bootstrap alert via script dynamically
        /// </summary>
        /// <param name="Message"></param>
        /// <param name="Types"></param>
        /// <returns></returns>
        public static string Prepare(string Message, AlertTypes Types)
        {
            var    str      = new StringBuilder();
            string alertCss = "alert-danger";

            switch ((int)Types)
            {
            case 0:
                // error
                alertCss = "alert-danger";
                break;

            case 1:
                // success
                alertCss = "alert-success";
                break;

            case 2:
                // warning
                alertCss = "alert-warning";
                break;

            case 3:
                // info
                alertCss = "alert-info";
                break;
            }
            str.Append("<div class=\"alert " + alertCss + "\">\n");
            str.Append(Message);
            str.Append("</div>");

            return(str.ToString());
        }
        private void AddAlert(AlertTypes alertStyle, string message, bool dismissable, bool showFirstOnly = true)
        {
            List <string> messages = new List <string>();

            messages.Add(message);

            AddAlert(alertStyle, messages, dismissable, showFirstOnly);
        }
Beispiel #8
0
    /// <summary>
    /// Get the alert count of this alert type on this object
    /// </summary>
    /// <param name="attackType">The type of alert we are checking</param>
    /// <returns>How many of these alerts have occured on this object</returns>
    public int AlertCount(AlertTypes attackType)
    {
        if (snortManager == null)
        {
            return(-1);
        }

        return(alertCount[(int)attackType]);
    }
Beispiel #9
0
 public void Add(AlertTypes type, String message, Decimal fadeoutAfter)
 {
     Add(new Alert
     {
         Message      = message,
         FadeoutAfter = fadeoutAfter,
         Type         = type
     });
 }
        private static void OnAlertType(BindableObject bindable, object oldValue, object newValue)
        {
            var        currentView    = bindable as AlertView;
            AlertTypes type           = (AlertTypes)newValue;
            string     alertImageName = Constants.GetImage(type);

            if (currentView == null || string.IsNullOrEmpty(alertImageName))
            {
                return;
            }

            currentView.AlertImage = ImageSource.FromResource(alertImageName);
        }
Beispiel #11
0
        public void Show(string Header, string Message, AlertTypes Type)
        {
            AlertTypes AlertType = Type;
            //if (Header.Trim() != string.Empty)
            //    Header += " : ";
            string tmp = string.Format(
                @"<div id=""DivMessage"" runat=""server"" class=""alert alert-{0}"">
                    <!-- success alert -->
                    <strong>{1} ! </strong> {2}
                </div>", AlertType, Header, Message);

            lblAlert.Visible = true;
            lblAlert.Text    = tmp;
        }
Beispiel #12
0
        private void AddAlert(AlertTypes alertType, string message)
        {
            var ErrorsAlerts = TempData.ContainsKey("ErrorsAlerts") ? (Dictionary<string, string>) TempData["Errors"] : new Dictionary<string, string>();
            var SuccessAlerts = TempData.ContainsKey("SuccessAlerts") ? (Dictionary<string, string>) TempData["Errors"] : new Dictionary<string, string>();

            if (alertType == AlertTypes.Success)
            {
                SuccessAlerts.Add(Guid.NewGuid().ToString("N"), message);
            } else {
                ErrorsAlerts.Add(Guid.NewGuid().ToString("N"), message);
            }
            TempData["ErrorsAlert"] = ErrorsAlerts;
            TempData["SuccessAlerts"] = SuccessAlerts;
        }
        private void AddAlert(AlertTypes alertStyle, List <string> messages, bool dismissable, bool showFirstOnly = true)
        {
            TempData[Alert.TempDataCreateDate] = DateTime.Now;

            var alerts = TempData.ContainsKey(Alert.TempDataKey) ? (List <Alert>)TempData[Alert.TempDataKey] : new List <Alert>();

            alerts.Add(new Alert
            {
                AlertStyle  = alertStyle,
                Messages    = messages,
                Dismissable = dismissable
            });
            TempData[Alert.TempDataKey]     = alerts;
            TempData[Alert.TempDataDisplay] = showFirstOnly;
        }
        private int CreateAlert(int tenant, string id_user, int id_mailbox, AlertTypes type, object data = null)
        {
            using (var db = GetDb())
            {
                var json_data = GetJsonString(data);

                var insert_query = new SqlInsert(MAIL_ALERTS)
                                   .InColumnValue(MailAlerts.id_tenant, tenant)
                                   .InColumnValue(MailAlerts.id_user, id_user)
                                   .InColumnValue(MailAlerts.id_mailbox, id_mailbox)
                                   .InColumnValue(MailAlerts.type, (int)type)
                                   .InColumnValue(MailAlerts.data, json_data);

                return(db.ExecuteNonQuery(insert_query));
            }
        }
        private int CreateAlert(int tenant, string user, int mailboxId, AlertTypes type, object data = null)
        {
            using (var db = GetDb())
            {
                var jsonData = MailUtil.GetJsonString(data);

                var insertQuery = new SqlInsert(MailAlertsTable.name)
                                  .InColumnValue(MailAlertsTable.Columns.id_tenant, tenant)
                                  .InColumnValue(MailAlertsTable.Columns.id_user, user)
                                  .InColumnValue(MailAlertsTable.Columns.id_mailbox, mailboxId)
                                  .InColumnValue(MailAlertsTable.Columns.type, (int)type)
                                  .InColumnValue(MailAlertsTable.Columns.data, jsonData);

                return(db.ExecuteNonQuery(insertQuery));
            }
        }
        private int CreateAlerts(int tenant, IEnumerable <string> ids_user, AlertTypes type, object data = null)
        {
            var result = 0;

            var users = ids_user as string[] ?? ids_user.ToArray();

            if (users.Length == 0)
            {
                return(result);
            }

            using (var db = GetDb())
            {
                var json_data = GetJsonString(data);

                CreateInsertDelegate create_insert_query = ()
                                                           => new SqlInsert(MAIL_ALERTS)
                                                           .IgnoreExists(true)
                                                           .InColumns(MailAlerts.id_tenant,
                                                                      MailAlerts.id_user,
                                                                      MailAlerts.id_mailbox,
                                                                      MailAlerts.type,
                                                                      MailAlerts.data);

                var insert_query = create_insert_query();

                int i, users_len;
                for (i = 0, users_len = users.Length; i < users_len; i++)
                {
                    var user_id = users[i];

                    insert_query
                    .Values(tenant, user_id, -1, (int)type, json_data);

                    if ((i % 100 != 0 || i == 0) && i + 1 != users_len)
                    {
                        continue;
                    }

                    result      += db.ExecuteNonQuery(insert_query);
                    insert_query = create_insert_query();
                }
            }
            return(result);
        }
        private int CreateAlerts(IDbManager db, int tenant, List <string> users, AlertTypes type, object data = null)
        {
            var result = 0;

            if (!users.Any())
            {
                return(result);
            }


            var jsonData = MailUtil.GetJsonString(data);

            CreateInsertDelegate createInsertQuery = ()
                                                     => new SqlInsert(MailAlertsTable.name)
                                                     .IgnoreExists(true)
                                                     .InColumns(MailAlertsTable.Columns.id_tenant,
                                                                MailAlertsTable.Columns.id_user,
                                                                MailAlertsTable.Columns.id_mailbox,
                                                                MailAlertsTable.Columns.type,
                                                                MailAlertsTable.Columns.data);

            var insertQuery = createInsertQuery();

            int i, usersLen;

            for (i = 0, usersLen = users.Count; i < usersLen; i++)
            {
                var user = users[i];

                insertQuery
                .Values(tenant, user, -1, (int)type, jsonData);

                if ((i % 100 != 0 || i == 0) && i + 1 != usersLen)
                {
                    continue;
                }

                result     += db.ExecuteNonQuery(insertQuery);
                insertQuery = createInsertQuery();
            }

            return(result);
        }
Beispiel #18
0
        public ActionResult _AlertTypeDetail(int id)
        {
            try
            {
                ViewBag.Error        = "";
                ViewBag.SessionError = "";
                var userData = MvcApplication.GetUserData(User.Identity.Name) ?? new UserData();
                if (userData.UserId < 1)
                {
                    ViewBag.SessionError = "Your session has expired! Please re-login";
                    return(View(new AlertTypeObj()));
                }

                if (id < 1)
                {
                    ViewBag.Error = "Invalid selection";
                    return(View(new AlertTypeObj()));
                }

                if (!(Session["_AlertTypeList_"] is List <AlertTypeObj> AlertTypes) || AlertTypes.Count < 1)
                {
                    ViewBag.Error = "Error Occurred! Unable to process selected item";
                    return(View(new AlertTypeObj()));
                }

                var thisAlertType = AlertTypes.Find(m => m.AlertTypeId == id);
                if (thisAlertType == null || thisAlertType.AlertTypeId < 1)
                {
                    ViewBag.Error = "Error Occurred! Unable to process selected item";
                    return(View(new AlertTypeObj()));
                }

                return(View(thisAlertType));
            }
            catch (Exception ex)
            {
                ViewBag.Error = "Error Occurred! Please try again later";
                UtilTools.LogE(ex.StackTrace, ex.Source, ex.Message);
                return(View(new AlertTypeObj()));
            }
        }
 //[Route("tjenestevarsler/{parentregister}/{registerowner}/{registerName}/ny")]
 //[Route("tjenestevarsler/{registerName}/ny")]
 public ActionResult Create(Alert alert, string parentRegister, string registerName, string category = Constants.AlertCategoryService)
 {
     alert.register = _registerService.GetRegister(parentRegister, registerName);
     if (alert.register != null)
     {
         if (_accessControlService.Access(alert.register))
         {
             //if (!_registerItemService.ItemNameIsValid(alert))
             //{
             //    ModelState.AddModelError("ErrorMessage", HtmlHelperExtensions.ErrorMessageValidationName());
             //    return View(alert);
             //}
             if (ModelState.IsValid)
             {
                 var alertTranslation = new AlertTypes(_registerService, category).GetAlertType(alert.AlertType);
                 alert.GetMetadataByUuid();
                 alert.AlertCategory = category;
                 alert.submitter     = _registerService.GetOrganizationByUserName();
                 alert.InitializeNewAlert();
                 if (category == Constants.AlertCategoryOperation)
                 {
                     alert.Owner = alert.submitter.name;
                     alert.name  = alert.UuidExternal;
                 }
                 alert.AlertType = alertTranslation.Key.Value;
                 for (int t = 0; t < alert.Translations.Count; t++)
                 {
                     var translation = alertTranslation.Value;
                     alert.Translations[t].AlertType = translation.Where(c => c.Culture.Equals(alert.Translations[t].CultureName)).Select(s => s.AlertType).FirstOrDefault();
                 }
                 alert.versioningId      = _registerItemService.NewVersioningGroup(alert);
                 alert.register.modified = System.DateTime.Now;
                 _registerItemService.SaveNewRegisterItem(alert);
                 return(Redirect(alert.GetObjectUrl()));
             }
         }
     }
     ViewBags(alert, category);
     return(View(alert));
 }
        public static string GetImage(AlertTypes type)
        {
            string fileName = string.Empty;

            switch (type)
            {
            case AlertTypes.Success:
                fileName = SuccessImage;;
                break;

            case AlertTypes.Error:
                fileName = FailImage;
                break;

            case AlertTypes.Info:
                fileName = InfoImage;
                break;

            default:
                break;
            }
            return(string.Format("{0}.Images.{1}.png", typeof(Constants).Namespace, fileName));
        }
        public List<MailAlert> FindAlerts(IDbManager db, int tenant, string user, int mailboxId = -1, AlertTypes type = AlertTypes.Empty)
        {
            var searchQuery = new SqlQuery(MailAlertsTable.name)
                    .Select(MailAlertsTable.Columns.id, MailAlertsTable.Columns.type, MailAlertsTable.Columns.id_mailbox, MailAlertsTable.Columns.data)
                    .Where(GetUserWhere(user, tenant));

            if (mailboxId > 0)
                searchQuery.Where(MailAlertsTable.Columns.id_mailbox, mailboxId);

            if (type != AlertTypes.Empty)
                searchQuery.Where(MailAlertsTable.Columns.type, (int)type);

            var foundAlerts = db.ExecuteList(searchQuery)
                .ConvertAll(x => new MailAlert
                {
                    id = Convert.ToInt32(x[0]),
                    type = (AlertTypes)x[1],
                    id_mailbox = Convert.ToInt32(x[2]),
                    data = (string)x[3]
                });

            return foundAlerts;
        }
Beispiel #22
0
		public void PushAlert(AlertTypes type, string caption, string message, DateTime time)
		{
			_alerts.Enqueue(new Tuple<AlertTypes, string, string, DateTime>(type, caption, message, time));
		}
        public int CreateCrmOperationFailureAlert(int tenant, string user, int messageId, AlertTypes type)
        {
            var data = new CrmOperationFailure
                {
                    message_id = messageId
                };

            return CreateAlert(tenant, user, -1, type, data);
        }
        private List<MailAlert> FindAlerts(IDbManager db, int tenant, string id_user, int id_mailbox = -1, AlertTypes type = AlertTypes.Empty)
        {
            var search_query = new SqlQuery(MAIL_ALERTS)
                    .Select(MailAlerts.id, MailAlerts.type, MailAlerts.id_mailbox, MailAlerts.data)
                    .Where(GetUserWhere(id_user, tenant));

            if (id_mailbox > 0)
                search_query.Where(MailAlerts.id_mailbox, id_mailbox);

            if (type != AlertTypes.Empty)
                search_query.Where(MailAlerts.type, (int) type);

            var found_alerts = db.ExecuteList(search_query)
                .ConvertAll(x => new MailAlert
                {
                    id = Convert.ToInt32(x[0]),
                    type = Convert.ToInt32(x[1]),
                    id_mailbox = Convert.ToInt32(x[2]),
                    data = (string) x[3]
                });

            return found_alerts;
        }
 public AlertInfo(AlertTypes type, string message)
 {
     this.Type    = type;
     this.Message = message;
 }
        private int CreateAlerts(IDbManager db, int tenant, List<string> users, AlertTypes type, object data = null)
        {
            var result = 0;

            if (!users.Any()) return result;

            
                var jsonData = MailUtil.GetJsonString(data);

                CreateInsertDelegate createInsertQuery = ()
                => new SqlInsert(MailAlertsTable.name)
                        .IgnoreExists(true)
                        .InColumns(MailAlertsTable.Columns.id_tenant,
                                   MailAlertsTable.Columns.id_user,
                                   MailAlertsTable.Columns.id_mailbox,
                                   MailAlertsTable.Columns.type,
                                   MailAlertsTable.Columns.data);

                var insertQuery = createInsertQuery();

                int i, usersLen;
                for (i = 0, usersLen = users.Count; i < usersLen; i++)
                {
                    var user = users[i];

                    insertQuery
                        .Values(tenant, user, -1, (int) type, jsonData);

                    if ((i%100 != 0 || i == 0) && i + 1 != usersLen) continue;

                    result += db.ExecuteNonQuery(insertQuery);
                    insertQuery = createInsertQuery();
                }
            
            return result;
        }
        public List <MailAlert> FindAlerts(IDbManager db, int tenant, string user, int mailboxId = -1, AlertTypes type = AlertTypes.Empty)
        {
            var searchQuery = new SqlQuery(MailAlertsTable.name)
                              .Select(MailAlertsTable.Columns.id, MailAlertsTable.Columns.type, MailAlertsTable.Columns.id_mailbox, MailAlertsTable.Columns.data)
                              .Where(GetUserWhere(user, tenant));

            if (mailboxId > 0)
            {
                searchQuery.Where(MailAlertsTable.Columns.id_mailbox, mailboxId);
            }

            if (type != AlertTypes.Empty)
            {
                searchQuery.Where(MailAlertsTable.Columns.type, (int)type);
            }

            var foundAlerts = db.ExecuteList(searchQuery)
                              .ConvertAll(x => new MailAlert
            {
                id         = Convert.ToInt32(x[0]),
                type       = (AlertTypes)x[1],
                id_mailbox = Convert.ToInt32(x[2]),
                data       = (string)x[3]
            });

            return(foundAlerts);
        }
        private int CreateUniqueAlert(IDbManager db, int tenant, string user, int mailboxId, AlertTypes type, object data = null)
        {
            var alerts = FindAlerts(db, tenant, user, mailboxId, type);

            if (alerts.Any())
                return -1;

            var jsonData = MailUtil.GetJsonString(data);

            var insertQuery = new SqlInsert(MailAlertsTable.name)
                .InColumnValue(MailAlertsTable.Columns.id_tenant, tenant)
                .InColumnValue(MailAlertsTable.Columns.id_user, user)
                .InColumnValue(MailAlertsTable.Columns.id_mailbox, mailboxId)
                .InColumnValue(MailAlertsTable.Columns.type, (int)type)
                .InColumnValue(MailAlertsTable.Columns.data, jsonData);

            return db.ExecuteNonQuery(insertQuery);
        }
        private int CreateAlert(int tenant, string user, int mailboxId, AlertTypes type, object data = null)
        {
            using (var db = GetDb())
            {
                var jsonData = MailUtil.GetJsonString(data);

                var insertQuery = new SqlInsert(MailAlertsTable.name)
                    .InColumnValue(MailAlertsTable.Columns.id_tenant, tenant)
                    .InColumnValue(MailAlertsTable.Columns.id_user, user)
                    .InColumnValue(MailAlertsTable.Columns.id_mailbox, mailboxId)
                    .InColumnValue(MailAlertsTable.Columns.type, (int)type)
                    .InColumnValue(MailAlertsTable.Columns.data, jsonData);

                return db.ExecuteNonQuery(insertQuery);
            }
        }
Beispiel #30
0
 /// <summary>
 /// Add alert at the output.
 /// </summary>
 /// <param name="type">Alert type.</param>
 /// <param name="caption">Signal header.</param>
 /// <param name="message">Alert text.</param>
 /// <param name="time">Creation time.</param>
 public void PushAlert(AlertTypes type, string caption, string message, DateTimeOffset time)
 {
     _alerts.Enqueue(Tuple.Create(type, caption, message, time));
 }
        private int CreateAlerts(int tenant, IEnumerable<string> ids_user, AlertTypes type, object data = null)
        {
            var result = 0;

            var users = ids_user as string[] ?? ids_user.ToArray();
            if (users.Length == 0) return result;

            using (var db = GetDb())
            {
                var json_data = GetJsonString(data);

                CreateInsertDelegate create_insert_query = ()
                => new SqlInsert(MAIL_ALERTS)
                        .IgnoreExists(true)
                        .InColumns(MailAlerts.id_tenant,
                                   MailAlerts.id_user,
                                   MailAlerts.id_mailbox,
                                   MailAlerts.type,
                                   MailAlerts.data);

                var insert_query = create_insert_query();

                int i, users_len;
                for (i = 0, users_len = users.Length; i < users_len; i++)
                {
                    var user_id = users[i];

                    insert_query
                        .Values(tenant, user_id, -1, (int) type, json_data);

                    if ((i%100 != 0 || i == 0) && i + 1 != users_len) continue;

                    result += db.ExecuteNonQuery(insert_query);
                    insert_query = create_insert_query();
                }
            }
            return result;
        }
        public int CreateCrmOperationFailureAlert(int tenant, string id_user, int message_id, AlertTypes type)
        {
            var data = new CrmOperationFailure
                {
                    type = (int) type,
                    message_id = message_id
                };

            return CreateAlert(tenant, id_user, data);
        }
Beispiel #33
0
 /// <summary>
 /// Html Helper for Creating Alerts
 /// </summary>
 /// <typeparam name="TModel">The type of the model.</typeparam>
 /// <param name="helper">The helper.</param>
 /// <param name="alertText">The alert text.</param>
 /// <param name="alertType">Type of the alert.</param>
 /// <returns></returns>
 public static AlertBuilder <TModel> Alert <TModel>(this HtmlHelper <TModel> helper, string alertText, AlertTypes alertType = AlertTypes.Info)
 {
     return(new AlertBuilder <TModel>(helper, alertText, alertType));
 }
		private void PushAlert(AlertTypes type)
		{
			_alertService.PushAlert(type, _testCaption, LocalizedStrings.Str3035, TimeHelper.Now);
		}
 private int CreateUniqueAlert(int tenant, string user, int mailboxId, AlertTypes type, object data = null)
 {
     using (var db = GetDb())
     {
         return CreateUniqueAlert(db, tenant, user, mailboxId, type, data);
     }
 }
 private void PushAlert(AlertTypes type)
 {
     _alertService.PushAlert(type, _testCaption, LocalizedStrings.Str3035, TimeHelper.Now);
 }
 private int CreateAlerts(int tenant, List<string> users, AlertTypes type, object data = null)
 {
     using (var db = GetDb())
     {
         return CreateAlerts(db, tenant, users, type, data);
     }
 }
        private List <MailAlert> FindAlerts(IDbManager db, int tenant, string id_user, int id_mailbox = -1, AlertTypes type = AlertTypes.Empty)
        {
            var search_query = new SqlQuery(MAIL_ALERTS)
                               .Select(MailAlerts.id, MailAlerts.type, MailAlerts.id_mailbox, MailAlerts.data)
                               .Where(GetUserWhere(id_user, tenant));

            if (id_mailbox > 0)
            {
                search_query.Where(MailAlerts.id_mailbox, id_mailbox);
            }

            if (type != AlertTypes.Empty)
            {
                search_query.Where(MailAlerts.type, (int)type);
            }

            var found_alerts = db.ExecuteList(search_query)
                               .ConvertAll(x => new MailAlert
            {
                id         = Convert.ToInt32(x[0]),
                type       = Convert.ToInt32(x[1]),
                id_mailbox = Convert.ToInt32(x[2]),
                data       = (string)x[3]
            });

            return(found_alerts);
        }
        public int CreateCrmOperationFailureAlert(int tenant, string user, int messageId, AlertTypes type)
        {
            var data = new CrmOperationFailure
            {
                message_id = messageId
            };

            return(CreateAlert(tenant, user, -1, type, data));
        }
        private int CreateUniqueAlert(IDbManager db, int tenant, string id_user, int id_mailbox, AlertTypes type, object data = null)
        {
            var alerts = FindAlerts(db, tenant, id_user, id_mailbox, type);

            if (alerts.Any())
            {
                return(-1);
            }

            var json_data = GetJsonString(data);

            var insert_query = new SqlInsert(MAIL_ALERTS)
                               .InColumnValue(MailAlerts.id_tenant, tenant)
                               .InColumnValue(MailAlerts.id_user, id_user)
                               .InColumnValue(MailAlerts.id_mailbox, id_mailbox)
                               .InColumnValue(MailAlerts.type, (int)type)
                               .InColumnValue(MailAlerts.data, json_data);

            return(db.ExecuteNonQuery(insert_query));
        }
        private int CreateUniqueAlert(IDbManager db, int tenant, string user, int mailboxId, AlertTypes type, object data = null)
        {
            var alerts = FindAlerts(db, tenant, user, mailboxId, type);

            if (alerts.Any())
            {
                return(-1);
            }

            var jsonData = MailUtil.GetJsonString(data);

            var insertQuery = new SqlInsert(MailAlertsTable.name)
                              .InColumnValue(MailAlertsTable.Columns.id_tenant, tenant)
                              .InColumnValue(MailAlertsTable.Columns.id_user, user)
                              .InColumnValue(MailAlertsTable.Columns.id_mailbox, mailboxId)
                              .InColumnValue(MailAlertsTable.Columns.type, (int)type)
                              .InColumnValue(MailAlertsTable.Columns.data, jsonData);

            return(db.ExecuteNonQuery(insertQuery));
        }
        private int CreateAlert(int tenant, string id_user, int id_mailbox, AlertTypes type, object data = null)
        {
            using (var db = GetDb())
            {
                var json_data = GetJsonString(data);

                var insert_query = new SqlInsert(MAIL_ALERTS)
                    .InColumnValue(MailAlerts.id_tenant, tenant)
                    .InColumnValue(MailAlerts.id_user, id_user)
                    .InColumnValue(MailAlerts.id_mailbox, id_mailbox)
                    .InColumnValue(MailAlerts.type, (int) type)
                    .InColumnValue(MailAlerts.data, json_data);

                return db.ExecuteNonQuery(insert_query);
            }
        }
        private int CreateUniqueAlert(IDbManager db, int tenant, string id_user, int id_mailbox, AlertTypes type, object data = null)
        {
            var alerts = FindAlerts(db, tenant, id_user, id_mailbox, type);

            if (alerts.Any())
                return -1;

            var json_data = GetJsonString(data);

            var insert_query = new SqlInsert(MAIL_ALERTS)
                .InColumnValue(MailAlerts.id_tenant, tenant)
                .InColumnValue(MailAlerts.id_user, id_user)
                .InColumnValue(MailAlerts.id_mailbox, id_mailbox)
                .InColumnValue(MailAlerts.type, (int)type)
                .InColumnValue(MailAlerts.data, json_data);

            return db.ExecuteNonQuery(insert_query);
        }
Beispiel #44
0
        public int CreateCrmOperationFailureAlert(int tenant, string id_user, int message_id, AlertTypes type)
        {
            var data = new CrmOperationFailure
            {
                type       = (int)type,
                message_id = message_id
            };

            return(CreateAlert(tenant, id_user, data));
        }
Beispiel #45
0
		/// <summary>
		/// Add alert at the output.
		/// </summary>
		/// <param name="type">Alert type.</param>
		/// <param name="caption">Signal header.</param>
		/// <param name="message">Alert text.</param>
		/// <param name="time">Creation time.</param>
		public void PushAlert(AlertTypes type, string caption, string message, DateTime time)
		{
			_alerts.Enqueue(Tuple.Create(type, caption, message, time));
		}
Beispiel #46
0
 public void Add(AlertTypes type, String message)
 {
     Add(type, message, DefaultFadeout);
 }