///<summary>Inserts one AlertCategory into the database. Provides option to use the existing priKey. Doesn't use the cache.</summary> public static long InsertNoCache(AlertCategory alertCategory, bool useExistingPK) { bool isRandomKeys = Prefs.GetBoolNoCache(PrefName.RandomPrimaryKeys); string command = "INSERT INTO alertcategory ("; if (!useExistingPK && isRandomKeys) { alertCategory.AlertCategoryNum = ReplicationServers.GetKeyNoCache("alertcategory", "AlertCategoryNum"); } if (isRandomKeys || useExistingPK) { command += "AlertCategoryNum,"; } command += "IsHQCategory,InternalName,Description) VALUES("; if (isRandomKeys || useExistingPK) { command += POut.Long(alertCategory.AlertCategoryNum) + ","; } command += POut.Bool(alertCategory.IsHQCategory) + "," + "'" + POut.String(alertCategory.InternalName) + "'," + "'" + POut.String(alertCategory.Description) + "')"; if (useExistingPK || isRandomKeys) { Db.NonQ(command); } else { alertCategory.AlertCategoryNum = Db.NonQ(command, true, "AlertCategoryNum", "alertCategory"); } return(alertCategory.AlertCategoryNum); }
private void butDuplicate_Click(object sender, EventArgs e) { if (gridCustom.GetSelectedIndex() == -1) { MsgBox.Show(this, "Please select an custom alert category from the list first."); return; } List <AlertCategory> listNewAlertCategories = _listInternalAlertCategory.Select(x => x.Copy()).ToList(); AlertCategory alertCat = _listCustomAlertCategory[gridCustom.GetSelectedIndex()].Copy(); alertCat.Description += Lan.g(this, "(Copy)"); listNewAlertCategories.Add(alertCat); //alertCat.AlertCategoryNum reflects the original pre-copied PK. After sync this will be a new PK for the new row. List <AlertCategoryLink> listAlertCategoryType = AlertCategoryLinks.GetForCategory(alertCat.AlertCategoryNum); if (AlertCategories.Sync(listNewAlertCategories, _listInternalAlertCategory)) { //At this point alertCat has a new PK, so we need to update and insert our new copied alertCategoryLinks listAlertCategoryType.ForEach(x => { x.AlertCategoryNum = alertCat.AlertCategoryNum; AlertCategoryLinks.Insert(x); }); DataValid.SetInvalid(InvalidType.AlertCategories, InvalidType.AlertCategoryLinks); FillGrids(selectedCustomKey: alertCat.AlertCategoryNum); } }
/// <summary> /// Generates an alert message with an expiration time. /// </summary> /// <param name="category">An alert category</param> /// <param name="level">Alert level</param> /// <param name="source">Name of the source where the alert is raised</param> /// <param name="alertCode">Alert type code</param> /// <param name="contextData">The user-defined application context data</param> /// <param name="expirationTime">Expiration time for the alert</param> /// <param name="message">The alert message or formatted message.</param> /// <param name="args">Paramaters used in the alert message, when specified.</param> public static void Alert(AlertCategory category, AlertLevel level, String source, int alertCode, object contextData, TimeSpan expirationTime, String message, params object[] args) { Platform.CheckForNullReference(source, "source"); Platform.CheckForNullReference(message, "message"); IAlertService service = Platform.GetService <IAlertService>(); if (service != null) { AlertSource src = new AlertSource(source, ServerInstanceId) { Host = ServerInstanceId }; Alert alert = new Alert { Category = category, Level = level, Code = alertCode, ExpirationTime = Platform.Time.Add(expirationTime), Source = src, Message = String.Format(message, args), ContextData = contextData }; service.GenerateAlert(alert); } }
///<summary>Inserts one AlertCategory into the database. Provides option to use the existing priKey.</summary> public static long Insert(AlertCategory alertCategory, bool useExistingPK) { if (!useExistingPK && PrefC.RandomKeys) { alertCategory.AlertCategoryNum = ReplicationServers.GetKey("alertcategory", "AlertCategoryNum"); } string command = "INSERT INTO alertcategory ("; if (useExistingPK || PrefC.RandomKeys) { command += "AlertCategoryNum,"; } command += "IsHQCategory,InternalName,Description) VALUES("; if (useExistingPK || PrefC.RandomKeys) { command += POut.Long(alertCategory.AlertCategoryNum) + ","; } command += POut.Bool(alertCategory.IsHQCategory) + "," + "'" + POut.String(alertCategory.InternalName) + "'," + "'" + POut.String(alertCategory.Description) + "')"; if (useExistingPK || PrefC.RandomKeys) { Db.NonQ(command); } else { alertCategory.AlertCategoryNum = Db.NonQ(command, true, "AlertCategoryNum", "alertCategory"); } return(alertCategory.AlertCategoryNum); }
///<summary>Inserts one AlertCategory into the database. Returns the new priKey.</summary> public static long Insert(AlertCategory alertCategory) { if (DataConnection.DBtype == DatabaseType.Oracle) { alertCategory.AlertCategoryNum = DbHelper.GetNextOracleKey("alertcategory", "AlertCategoryNum"); int loopcount = 0; while (loopcount < 100) { try { return(Insert(alertCategory, true)); } catch (Oracle.ManagedDataAccess.Client.OracleException ex) { if (ex.Number == 1 && ex.Message.ToLower().Contains("unique constraint") && ex.Message.ToLower().Contains("violated")) { alertCategory.AlertCategoryNum++; loopcount++; } else { throw ex; } } } throw new ApplicationException("Insert failed. Could not generate primary key."); } else { return(Insert(alertCategory, false)); } }
public Alert(AlertType type, AlertCategory category, string message, string field1, string field2) : this() { _type = type; _category = category; _message = message; _field1 = field1; _field2 = field2; }
///<summary>Updates one AlertCategory in the database.</summary> public static void Update(AlertCategory alertCategory) { string command = "UPDATE alertcategory SET " + "IsHQCategory = " + POut.Bool(alertCategory.IsHQCategory) + ", " + "InternalName = '" + POut.String(alertCategory.InternalName) + "', " + "Description = '" + POut.String(alertCategory.Description) + "' " + "WHERE AlertCategoryNum = " + POut.Long(alertCategory.AlertCategoryNum); Db.NonQ(command); }
/// <summary> /// Creates an instance of <see cref="Alert"/> of specified category and level for the specified source. /// </summary> /// <param name="source"></param> /// <param name="category"></param> /// <param name="level"></param> public Alert(AlertSource source, AlertCategory category, AlertLevel level) { _source = source; _timeStamp = Platform.Time; _expirationTime = Platform.Time; _category = category; _level = level; _code = 0; _data = null; _message = null; }
/// <summary> /// Copy constructor /// </summary> /// <param name="other"></param> public Alert(Alert other) { _alertID = other._alertID; _type = other._type; _category = other._category; _message = other._message; _field1 = other._field1; _field2 = other._field2; _status = other._status; _alertedOnDate = other._alertedOnDate; }
public Alert() { _alertID = 0; _type = AlertType.support; _category = AlertCategory.expired; _message = ""; _field1 = ""; _field2 = ""; _status = AlertStatus.active; _alertedOnDate = DateTime.Today; }
///<summary>Inserts one AlertCategory into the database. Returns the new priKey. Doesn't use the cache.</summary> public static long InsertNoCache(AlertCategory alertCategory) { if (DataConnection.DBtype == DatabaseType.MySql) { return(InsertNoCache(alertCategory, false)); } else { if (DataConnection.DBtype == DatabaseType.Oracle) { alertCategory.AlertCategoryNum = DbHelper.GetNextOracleKey("alertcategory", "AlertCategoryNum"); //Cacheless method } return(InsertNoCache(alertCategory, true)); } }
///<summary>Returns true if Update(AlertCategory,AlertCategory) would make changes to the database. ///Does not make any changes to the database and can be called before remoting role is checked.</summary> public static bool UpdateComparison(AlertCategory alertCategory, AlertCategory oldAlertCategory) { if (alertCategory.IsHQCategory != oldAlertCategory.IsHQCategory) { return(true); } if (alertCategory.InternalName != oldAlertCategory.InternalName) { return(true); } if (alertCategory.Description != oldAlertCategory.Description) { return(true); } return(false); }
private void InsertCopyAlertCategory(AlertCategory alertCat) { alertCat.IsHQCategory = false; alertCat.Description += Lan.g(this, "(Copy)"); //alertCat.AlertCategoryNum reflects the original pre-copied PK. After Insert this will be a new PK for the new row. List <AlertCategoryLink> listAlertCategoryType = AlertCategoryLinks.GetForCategory(alertCat.AlertCategoryNum); alertCat.AlertCategoryNum = AlertCategories.Insert(alertCat); //At this point alertCat has a new PK, so we need to update and insert our new copied alertCategoryLinks listAlertCategoryType.ForEach(x => { x.AlertCategoryNum = alertCat.AlertCategoryNum; AlertCategoryLinks.Insert(x); }); DataValid.SetInvalid(InvalidType.AlertCategories, InvalidType.AlertCategoryLinks); FillGrids(); }
///<summary>Converts a DataTable to a list of objects.</summary> public static List <AlertCategory> TableToList(DataTable table) { List <AlertCategory> retVal = new List <AlertCategory>(); AlertCategory alertCategory; foreach (DataRow row in table.Rows) { alertCategory = new AlertCategory(); alertCategory.AlertCategoryNum = PIn.Long(row["AlertCategoryNum"].ToString()); alertCategory.IsHQCategory = PIn.Bool(row["IsHQCategory"].ToString()); alertCategory.InternalName = PIn.String(row["InternalName"].ToString()); alertCategory.Description = PIn.String(row["Description"].ToString()); retVal.Add(alertCategory); } return(retVal); }
public Alert(DataRow dataRow) : this() { try { _alertID = (int)dataRow["_ALERTID"]; _type = (AlertType)(int)dataRow["_TYPE"]; _category = (AlertCategory)(int)dataRow["_CATEGORY"]; _message = (string)dataRow["_MESSAGE"]; _field1 = (string)dataRow["_FIELD1"]; _field2 = (string)dataRow["_FIELD2"]; _status = (AlertStatus)(int)dataRow["_STATUS"]; _alertedOnDate = (DateTime)dataRow["_ALERTDATE"]; _assetName = (string)dataRow["_ASSETNAME"]; _alertName = (string)dataRow["_ALERTNAME"]; } catch (Exception ex) { MessageBox.Show("Exception occured creating an ALERT Object, please check database schema. The message was " + ex.Message); } }
public static MvcHtmlString Alert(this HtmlHelper htmlHelper, string strongMessage, string message = "", AlertCategory alertCategory = AlertCategory.Default) { var tagBuilder = new TagBuilder("div"); switch (alertCategory) { case AlertCategory.Error: tagBuilder.MergeAttribute("class", "alert alert-danger"); break; case AlertCategory.Success: tagBuilder.MergeAttribute("class", "alert alert-success"); break; case AlertCategory.Info: tagBuilder.MergeAttribute("class", "alert alert-info"); break; default: tagBuilder.MergeAttribute("class", "alert"); break; } var a = new TagBuilder("a"); a.MergeAttribute("class", "close"); a.MergeAttribute("data-dismiss", "alert"); a.SetInnerText("×"); var strong = new TagBuilder("strong"); strong.SetInnerText(strongMessage); tagBuilder.InnerHtml = string.Format("{0}{1}{2}", a.ToString(TagRenderMode.Normal), strong.ToString(TagRenderMode.Normal), message); return(MvcHtmlString.Create(tagBuilder.ToString(TagRenderMode.Normal))); }
///<summary>Updates one AlertCategory in the database. Uses an old object to compare to, and only alters changed fields. This prevents collisions and concurrency problems in heavily used tables. Returns true if an update occurred.</summary> public static bool Update(AlertCategory alertCategory, AlertCategory oldAlertCategory) { string command = ""; if (alertCategory.IsHQCategory != oldAlertCategory.IsHQCategory) { if (command != "") { command += ","; } command += "IsHQCategory = " + POut.Bool(alertCategory.IsHQCategory) + ""; } if (alertCategory.InternalName != oldAlertCategory.InternalName) { if (command != "") { command += ","; } command += "InternalName = '" + POut.String(alertCategory.InternalName) + "'"; } if (alertCategory.Description != oldAlertCategory.Description) { if (command != "") { command += ","; } command += "Description = '" + POut.String(alertCategory.Description) + "'"; } if (command == "") { return(false); } command = "UPDATE alertcategory SET " + command + " WHERE AlertCategoryNum = " + POut.Long(alertCategory.AlertCategoryNum); Db.NonQ(command); return(true); }
/// <summary> /// Generates an alert message with an expiration time. /// </summary> /// <param name="category">An alert category</param> /// <param name="level">Alert level</param> /// <param name="source">Name of the source where the alert is raised</param> /// <param name="alertCode">Alert type code</param> /// <param name="contextData">The user-defined application context data</param> /// <param name="expirationTime">Expiration time for the alert</param> /// <param name="message">The alert message or formatted message.</param> /// <param name="args">Paramaters used in the alert message, when specified.</param> public static void Alert(AlertCategory category, AlertLevel level, String source, int alertCode, object contextData, TimeSpan expirationTime, String message, params object[] args) { Platform.CheckForNullReference(source, "source"); Platform.CheckForNullReference(message, "message"); IAlertService service = Platform.GetService<IAlertService>(); if (service != null) { AlertSource src = new AlertSource(source, ServerInstanceId) { Host = ServerInstanceId }; Alert alert = new Alert { Category = category, Level = level, Code = alertCode, ExpirationTime = Platform.Time.Add(expirationTime), Source = src, Message = String.Format(message, args), ContextData = contextData }; service.GenerateAlert(alert); } }
/// <summary> /// Converts the <see cref="sourceValue" /> parameter to the <see cref="destinationType" /> parameter using <see cref="formatProvider" /// /> and <see cref="ignoreCase" /> /// </summary> /// <param name="sourceValue">the <see cref="System.Object"/> to convert from</param> /// <param name="destinationType">the <see cref="System.Type" /> to convert to</param> /// <param name="formatProvider">not used by this TypeConverter.</param> /// <param name="ignoreCase">when set to <c>true</c>, will ignore the case when converting.</param> /// <returns> /// an instance of <see cref="AlertCategory" />, or <c>null</c> if there is no suitable conversion. /// </returns> public override object ConvertFrom(object sourceValue, global::System.Type destinationType, global::System.IFormatProvider formatProvider, bool ignoreCase) => AlertCategory.CreateFrom(sourceValue);
public FormAlertCategoryEdit(AlertCategory category) { InitializeComponent(); Lan.F(this); _categoryCur = category; }
public AlertMessage(AlertCategory category, string message) { this.Category = category; this.Message = message; }
/// <returns>true iff an alert of the indicated alert category is currently showing</returns> public bool IsShowingAlertCategory(AlertCategory alertCategory) { return(IsShowingAlert(AlertKey.ForCategory(alertCategory))); }
/// <param name="category">alert category, must not be null</param> /// <returns>An alert key for the provided alert category</returns> public static AlertKey ForCategory(AlertCategory category) { return(new AlertKey(null, category)); }
///<summary>Inserts one AlertCategory into the database. Returns the new priKey.</summary> public static long Insert(AlertCategory alertCategory) { return(Insert(alertCategory, false)); }
public static string Alert(string strongMessage, string message, AlertCategory alertCategory) { return(string.Format("$('#{0}').prepend('{1}')", FrameworkKeys.MainContent, GeboExtensions.Alert(null, strongMessage, message, alertCategory))); }