Exemple #1
0
        /// <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) {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);
            }
        }
 public bool DeleteAlert(Alert item)
 {
     return _adaptor.Delete(item.Key);
 }
Exemple #3
0
 static public Alert Insert(IUpdateContext update, Alert entity)
 {
     var broker = update.GetBroker<IAlertEntityBroker>();
     var updateColumns = new AlertUpdateColumns();
     updateColumns.InsertTime = entity.InsertTime;
     updateColumns.Component = entity.Component;
     updateColumns.TypeCode = entity.TypeCode;
     updateColumns.Source = entity.Source;
     updateColumns.AlertLevelEnum = entity.AlertLevelEnum;
     updateColumns.AlertCategoryEnum = entity.AlertCategoryEnum;
     updateColumns.Content = entity.Content;
     Alert newEntity = broker.Insert(updateColumns);
     return newEntity;
 }
Exemple #4
0
 static public Alert Insert(Alert entity)
 {
     using (var update = PersistentStoreRegistry.GetDefaultStore().OpenUpdateContext(UpdateContextSyncMode.Flush))
     {
         Alert newEntity = Insert(update, entity);
         update.Commit();
         return newEntity;
     }
 }
		private AlertSummary CreateAlertSummary(Alert item)
		{
			AlertSummary summary = new AlertSummary();
			summary.TheAlertItem = item;

			return summary;
		}