Exemple #1
0
 public void DatabaseUpgradeBefore(int ixVersionFrom, int ixVersionTo, CDatabaseUpgradeApi apiUpgrade)
 {
     if (ixVersionFrom <= DB_CHANGE_VERSION_EVENTUTC)
     {
         apiUpgrade.ChangeColumnDefinition(ExtendedEventEntity.GetPluginTableName(this.api.Database), "dtEventUtc");
     }
 }
Exemple #2
0
        public void DatabaseUpgradeAfter(int ixVersionFrom, int ixVersionTo, CDatabaseUpgradeApi apiUpgrade)
        {
            if (ixVersionFrom <= DB_CHANGE_VERSION_MESSAGES_HTML_SANITIZE)
            {
                var sanitizer = HtmlSanitizer.SimpleHtml5Sanitizer();

                var selectQuery = this.api.Database.NewSelectQuery(ExtendedEventEntity.GetPluginTableName(this.api.Database));
                selectQuery.AddSelect("ixExtendedEvent, sMessage");
                selectQuery.AddWhere("sEventType <> @sEventType");
                selectQuery.SetParamString("@sEventType", "commit");

                var ds = selectQuery.GetDataSet();
                if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
                {
                    foreach (DataRow row in ds.Tables[0].Rows)
                    {
                        var sMessage = row["sMessage"] as string;

                        if (!String.IsNullOrEmpty(sMessage))
                        {
                            sMessage = sanitizer.Sanitize(sMessage);

                            var ixExtendedEvent = Convert.ToInt32(row["ixExtendedEvent"]);

                            var updateQuery = this.api.Database.NewUpdateQuery(ExtendedEventEntity.GetPluginTableName(this.api.Database));
                            updateQuery.UpdateString("sMessage", sMessage);
                            updateQuery.AddWhere("ixExtendedEvent = @ixExtendedEvent");
                            updateQuery.SetParamInt("@ixExtendedEvent", ixExtendedEvent);

                            updateQuery.Execute();
                        }
                    }
                }
            }
        }
Exemple #3
0
        public static IEnumerable <ExtendedEventEntity> QueryEvents(CDatabaseApi db, int ixBug)
        {
            var selectQuery = db.NewSelectQuery(ExtendedEventEntity.GetPluginTableName(db));

            selectQuery.AddSelect("*");
            selectQuery.AddWhere("ixBug = @ixBug");
            selectQuery.SetParamInt("@ixBug", ixBug);

            var ds = selectQuery.GetDataSet();

            if (ds.Tables[0] != null && ds.Tables[0].Rows.Count > 0)
            {
                foreach (DataRow row in ds.Tables[0].Rows)
                {
                    var entity = new ExtendedEventEntity();
                    entity.Load(row);

                    yield return(entity);
                }
            }
        }