Exemple #1
0
        private void CreateNewTables()
        {
            try
            {
                //DatabaseContext ctx = ApplicationContext.Current.DatabaseContext;

                using (var db = LogViewerInternalHelper.GetLogDb())
                {
                    db.OpenSharedConnection();
                    //DatabaseSchemaHelper dbSchema = new DatabaseSchemaHelper(db,
                    //    ApplicationContext.Current.ProfilingLogger.Logger, ctx.SqlSyntax);

                    //if (dbSchema.TableExist("LogViewerLog")) dbSchema.DropTable<LogItem>();
                    //if (dbSchema.TableExist("LogViewerTagRules")) dbSchema.DropTable<TagRule>();

                    var msgDb = $"LogViewer CreateNewTables() running for database '{db.Connection.Database}'.";
                    LogHelper.Debug <LogViewerStartup>(msgDb);

                    CreateTable(db, LogItem.TableName, LogItem.CreateSql);

                    CreateTable(db, TagRule.TableName, TagRule.CreateSql);
                }
            }
            catch (Exception e)
            {
                var msg = $"Error occurred during LogViewer tables creation for Database. (You specified Use Umbraco DB: {LogViewerInternalHelper.UseUmbracoDb()})";
                LogHelper.Error <LogViewerStartup>(msg, e);
            }
        }
Exemple #2
0
 protected override void ApplicationStarted(UmbracoApplicationBase umbracoApplication, ApplicationContext applicationContext)
 {
     if (LogViewerInternalHelper.AllConfigsPresent())
     {
         //Umbraco DB
         if (LogViewerInternalHelper.UseUmbracoDb())
         {
             CreateNewTables();
         }
         else
         {
             //External DB
             var logDbIsValid = LogViewerInternalHelper.DbConnectionIsValid("LogDbDSN");
             if (logDbIsValid)
             {
                 CreateNewTables();
             }
             else
             {
                 var msgDb =
                     $"Dragonfly.UmbracoLogViewer is unable to connect to the 'LogDbDSN' Database. Please check your web.config and your network connectivity.";
                 LogHelper.Error <LogViewerStartup>(msgDb, null);
             }
         }
     }
 }