Exemplo n.º 1
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);
        }
Exemplo n.º 2
0
        private static void WriteToDatabase(ImageServer.Common.Alert alert)
        {
            XmlDocument doc = CreateXmlContent(alert);

            AlertUpdateColumns columns = new AlertUpdateColumns();

            columns.AlertCategoryEnum = AlertCategoryEnum.GetEnum(alert.Category.ToString());
            columns.AlertLevelEnum    = AlertLevelEnum.GetEnum(alert.Level.ToString());
            columns.Component         = alert.Source.Name;
            columns.Content           = doc;
            columns.InsertTime        = Platform.Time;
            columns.Source            = alert.Source.Host;
            columns.TypeCode          = alert.Code;

            IPersistentStore store = PersistentStoreRegistry.GetDefaultStore();

            using (IUpdateContext ctx = store.OpenUpdateContext(UpdateContextSyncMode.Flush))
            {
                IAlertEntityBroker alertBroker = ctx.GetBroker <IAlertEntityBroker>();
                alertBroker.Insert(columns);
                ctx.Commit();
            }
        }