void ensureDB(object stateInfo) { try { threadDescription = "Combining definitions..."; ContentDefinition contDef = ContentDefinition.CombineDefinitions(WAFContext.GetXmlDefinitions()); threadDescription = "Connecting to database..."; DataAccessObject dao = new DataAccessObject(WAFContext.AppSettings, contDef); if (dao.IsDataBaseEmpty()) dao.TryUpdateNamesNativeTable(ContentDefinition.LoadNativeDefinitions()); threadDescription = "Updating fields..."; List<DbAction> actions = contDef.GetDatabaseEnsureActions(); int n = 0; foreach (var a in actions) { if (isThreadCancelled()) return; threadDescription = "Updating field " + n + " of " + actions.Count + " fields. <br/><br/>" + a.TableName + "." + a.FieldName; n++; dao.DbProvider.UpdateDatabase(new List<DbAction>(new DbAction[] { a })); } if (_continueWithInstallationFormatting) { threadDescription = "DONE. Click: Ensure basic data "; _continueWithInstallationFormatting = false; } else { completeThread("DONE. Database is updated."); } } catch (Exception error) { completeThread("ERROR: " + error.Message); } }