public override MigrationResult Migrate(DatabaseStatus preSchemaUpdateStatus) { int updatedItems = 0; using (var tx = repository.BeginTransaction()) { var itemsWithUntrackedLinks = repository.Find(Parameter.Like(null, "%/upload/%").Detail() & Parameter.IsNull("TrackedLinks").Detail()); foreach (var item in itemsWithUntrackedLinks) { tracker.UpdateLinks(item); repository.SaveOrUpdate(item); updatedItems++; } tx.Commit(); } var path = config.UploadFolders.AllElements.Where(uf => !string.IsNullOrEmpty(uf.UrlPrefix)).Select(uf => uf.Path).FirstOrDefault(); path = Url.ToAbsolute(path); return new MigrationResult(this) { UpdatedItems = updatedItems, RedirectTo = "{ManagementUrl}/Content/LinkTracker/UpdateReferences.aspx" + "?selectedUrl=" + path + "&previousUrl=" + path + "&location=upgrade" }; }
public override DatabaseStatus GetStatus() { logger.Debug("checking database status"); DatabaseStatus status = new DatabaseStatus(); if (IsSql(status)) { if (UpdateConnection(status)) { if (UpdateVersion(status)) { if (UpdateSchema(status)) { if (UpdateCount(status)) { if (UpdateItems(status)) { UpdateRecordedValues(status); } } } } } } return(status); }
public override bool IsApplicable(DatabaseStatus status) { return status.DatabaseVersion < DatabaseStatus.RequiredDatabaseVersion || !status.HasSchema || repository.Find("State", ContentState.None).Any() || repository.Find("State", ContentState.New).Any(); }
private void UpdateVersion(DatabaseStatus status) { try { using (sessionProvider) { status.DatabaseVersion = 0; sessionProvider.OpenSession.Session.CreateQuery("select ci.ID from ContentItem ci").SetMaxResults(1).List(); status.DatabaseVersion = 1; // checking for properties added between version 1 and 2 sessionProvider.OpenSession.Session.CreateQuery("select ci.AncestralTrail from ContentItem ci").SetMaxResults(1).List(); status.DatabaseVersion = 2; // checking for properties added between version 2 and 3 sessionProvider.OpenSession.Session.CreateQuery("select ci.AlteredPermissions from ContentItem ci").SetMaxResults(1).List(); status.DatabaseVersion = 3; // checking persistable properties added in application sessionProvider.OpenSession.Session.CreateQuery("select ci from ContentItem ci").SetMaxResults(1).List(); status.DatabaseVersion = 4; } } catch (Exception ex) { Trace.WriteLine(ex); } }
private void UpdateRecordedValues(DatabaseStatus status) { try { if (status.RootItem == null) { return; } status.AppPath = status.RootItem[InstallationAppPath] as string; status.NeedsRebase = !string.IsNullOrEmpty(status.AppPath) && !string.Equals(status.AppPath, N2.Web.Url.ToAbsolute("~/")); Version v; if (status.RootItem[installationAssemblyVersion] != null && Version.TryParse(status.RootItem[installationAssemblyVersion].ToString(), out v)) { status.RecordedAssemblyVersion = v; } if (status.RootItem[installationFileVersion] != null && Version.TryParse(status.RootItem[installationFileVersion].ToString(), out v)) { status.RecordedFileVersion = v; } status.RecordedFeatures = status.RootItem.GetInstalledFeatures(); status.RecordedImageSizes = status.RootItem.GetInstalledImageSizes().ToArray(); } catch (Exception ex) { status.ItemsError = ex.Message; } }
public override MigrationResult Migrate(DatabaseStatus preSchemaUpdateStatus) { if (IsApplicable(preSchemaUpdateStatus)) return new MigrationResult(this) { RedirectTo = "UpgradeVersions.aspx" }; else return new MigrationResult(this); }
private bool UpdateSchema(DatabaseStatus status) { try { ISession session = sessionProvider.OpenSession.Session; session.CreateQuery("from ContentItem").SetMaxResults(1).List(); session.CreateQuery("from ContentDetail").SetMaxResults(1).List(); session.CreateQuery("from AuthorizedRole").SetMaxResults(1).List(); session.CreateQuery("from DetailCollection").SetMaxResults(1).List(); //session.CreateQuery("from ContentVersion").SetMaxResults(1).List(); status.HasSchema = true; return(true); } catch (Exception ex) { logger.Error(ex); status.HasSchema = false; status.SchemaError = ex.Message; status.SchemaException = ex; return(false); } }
private void CheckInstallation() { string currentUrl = webContext.ToAppRelative(webContext.Url.LocalUrl); bool isEditing = currentUrl.StartsWith(webContext.ToAppRelative(managementUrl), StringComparison.InvariantCultureIgnoreCase); if (isEditing) { return; } DatabaseStatus status = installer.GetStatus(); Url redirectUrl = Url.ResolveTokens(welcomeUrl); if (status.NeedsUpgrade) { redirectUrl = redirectUrl.AppendQuery("action", "upgrade"); } else if (!status.IsInstalled) { redirectUrl = redirectUrl.AppendQuery("action", "install"); } else if (status.NeedsRebase) { redirectUrl = redirectUrl.AppendQuery("action", "rebase"); } else { return; } Trace.WriteLine("Redirecting to '" + redirectUrl + "' to handle status: " + status.ToStatusString()); webContext.Response.Redirect(redirectUrl); }
public static bool UpdateSchema(DatabaseStatus status) { try { ISession session = sessionProvider.OpenSession.Session; session.CreateQuery("from ContentItem").SetMaxResults(1).List(); session.CreateQuery("from ContentDetail").SetMaxResults(1).List(); session.CreateQuery("from AuthorizedRole").SetMaxResults(1).List(); session.CreateQuery("from DetailCollection").SetMaxResults(1).List(); //session.CreateQuery("from ContentVersion").SetMaxResults(1).List(); status.HasSchema = true; return true; } catch (Exception ex) { logger.Error(ex); status.HasSchema = false; status.SchemaError = ex.Message; status.SchemaException = ex; return false; } }
public static void UpdateRecordedValues(DatabaseStatus status) { try { if (status.RootItem == null) return; status.AppPath = status.RootItem[InstallationAppPath] as string; status.NeedsRebase = !string.IsNullOrEmpty(status.AppPath) && !string.Equals(status.AppPath, N2.Web.Url.ToAbsolute("~/")); Version v; if (status.RootItem[installationAssemblyVersion] != null && Version.TryParse(status.RootItem[installationAssemblyVersion].ToString(), out v)) status.RecordedAssemblyVersion = v; if (status.RootItem[installationFileVersion] != null && Version.TryParse(status.RootItem[installationFileVersion].ToString(), out v)) status.RecordedFileVersion = v; status.RecordedFeatures = status.RootItem.GetInstalledFeatures(); status.RecordedImageSizes = status.RootItem.GetInstalledImageSizes().ToArray(); } catch (Exception ex) { status.ItemsError = ex.Message; } }
public override MigrationResult Migrate(DatabaseStatus preSchemaUpdateStatus) { var alreadyUpdated = new HashSet<string>(); int updatedItems = 0; using (var transaction = repository.BeginTransaction()) { var detailsWithImages = repository.Find( Parameter.Equal("ValueTypeKey", "String"), Parameter.Like("StringValue", "%<img%") ); foreach (var detail in detailsWithImages) { if (alreadyUpdated.Contains(detail.EnclosingItem.Name)) continue; alreadyUpdated.Add(detail.EnclosingItem.Name); linkTracker.UpdateLinks(detail.EnclosingItem); itemRepository.SaveOrUpdate(detail.EnclosingItem); updatedItems++; } repository.Flush(); transaction.Commit(); } return new MigrationResult(this) { UpdatedItems = updatedItems }; }
private void CheckInstallation() { string currentUrl = Url.ToRelative(webContext.Url.LocalUrl); try { AuthenticationSection authentication = ConfigurationManager.GetSection("system.web/authentication") as AuthenticationSection; if (currentUrl.Trim('~', '/').StartsWith(Url.ToAbsolute(authentication.Forms.LoginUrl.Trim('~', '/')), StringComparison.InvariantCultureIgnoreCase)) // don't redirect from login page return; } catch (Exception ex) { logger.Warn(ex); } if (Status == null) { Status = installer.GetStatus(); } Url redirectUrl = Url.ResolveTokens(welcomeUrl); if (Status == null) { Engine.Logger.Warn("Null status"); installer.UpdateStatus(SystemStatusLevel.Unknown); return; } else if (Status.NeedsUpgrade) { redirectUrl = redirectUrl.AppendQuery("action", "upgrade"); } else if (!Status.IsInstalled) { redirectUrl = redirectUrl.AppendQuery("action", "install"); } else if (Status.NeedsRebase) { redirectUrl = redirectUrl.AppendQuery("action", "rebase"); } else { this.broker.BeginRequest -= BeginRequest; installer.UpdateStatus(Status.Level); this.Status = null; return; } installer.UpdateStatus(Status.Level); bool isEditing = currentUrl.StartsWith(N2.Web.Url.ToRelative(managementUrl), StringComparison.InvariantCultureIgnoreCase); if (isEditing) return; logger.Debug("Redirecting to '" + redirectUrl + "' to handle status: " + Status.ToStatusString()); this.Status = null; webContext.HttpContext.Response.Redirect(redirectUrl); }
public override MigrationResult Migrate(DatabaseStatus preSchemaUpdateStatus) { preSchemaUpdateStatus.RootItem[InstallationManager.InstallationAppPath] = N2.Web.Url.ToAbsolute("~/"); repository.Update(preSchemaUpdateStatus.RootItem); repository.Flush(); return new MigrationResult(this) { UpdatedItems = 1 }; }
private bool IsSql(DatabaseStatus status) { if (config.Flavour.IsFlagSet(DatabaseFlavour.NoSql)) { return(false); } return(true); }
public virtual IEnumerable <MigrationResult> UpgradeAndMigrate() { DatabaseStatus initialStatus = installer.GetStatus(); installer.Upgrade(); return(MigrateOnly(initialStatus)); }
protected void btnInstallAndMigrate_Click(object sender, EventArgs e) { ExecuteWithErrorHandling(() => { ShowResults(Migrator.UpgradeAndMigrate()); }); status = null; }
protected void UpdateConnection(DatabaseStatus status) { //base.UpdateConnection(status); if (GetConnectionException() == null) { status.IsConnected = true; } }
public override bool IsApplicable(DatabaseStatus status) { if (!status.IsInstalled) return false; var recordedSizeHash = string.Join(";", status.RecordedImageSizes.OrderBy(s => s.Name).Select(s => s.ToString())); var existingSizeHash = string.Join(";", configuredSizes.AllElements.OrderBy(s => s.Name).Select(s => s.ToString())); return recordedSizeHash != existingSizeHash; }
public virtual IEnumerable<MigrationResult> MigrateOnly(DatabaseStatus initialStatus) { List<MigrationResult> results = new List<MigrationResult>(); foreach (var service in GetMigrations(initialStatus)) { var result = service.Migrate(initialStatus); results.Add(result); } return results; }
public override MigrationResult Migrate(DatabaseStatus preSchemaUpdateStatus) { var root = persister.Get(preSchemaUpdateStatus.RootItemID); root[InstallationManager.installationAssemblyVersion] = typeof(Context).Assembly.GetName().Version.ToString(); root[InstallationManager.installationFileVersion] = InstallationUtility.GetFileVersion(typeof(Context).Assembly); root.RecordInstalledFeature("CMS"); persister.Save(root); return new MigrationResult(this) { UpdatedItems = 1 }; }
public override bool IsApplicable(DatabaseStatus status) { try { return status.RootItem != null && status.RootItem["RecordedAssemblyVersion"] == null; } catch (Exception) { return false; } }
public override string CheckConnection(out string stackTrace) { stackTrace = null; var status = new DatabaseStatus(); if (UpdateConnection(status)) return null; stackTrace = status.ConnectionException.StackTrace; return status.ConnectionError; }
public bool? TryApplicable(DatabaseStatus initialStatus) { try { return IsApplicable(initialStatus); } catch (System.Exception) { return null; } }
public override bool IsApplicable(DatabaseStatus status) { try { return GetNews().Any(); } catch (Exception) { return true; } }
public override bool IsApplicable(DatabaseStatus status) { try { return persister.Repository.Find(new Parameter("class", "Redirect")).Where(p => p.Parent is Models.Pages.LanguageRoot).Any(); } catch (Exception) { return true; } }
public bool?TryApplicable(DatabaseStatus initialStatus) { try { return(IsApplicable(initialStatus)); } catch (System.Exception) { return(null); } }
public override bool IsApplicable(DatabaseStatus status) { try { return persister.Repository.Find(new Parameter("class", "Top")).Where(p => p.State != ContentState.Deleted).Any(); } catch (Exception) { return true; } }
public virtual IEnumerable <MigrationResult> MigrateOnly(DatabaseStatus initialStatus) { List <MigrationResult> results = new List <MigrationResult>(); foreach (var service in GetMigrations(initialStatus)) { var result = service.Migrate(initialStatus); results.Add(result); } return(results); }
public override bool IsApplicable(DatabaseStatus status) { try { return persister.Repository.Count(new Parameter("class", "News")) > 0; } catch (Exception) { return true; } }
protected void btnMigrate_Click(object sender, EventArgs e) { ExecuteWithErrorHandling(() => { var results = Migrator.GetAllMigrations() .Where(m => cblMigrations.Items.FindByValue(m.GetType().Name).Selected) .Select(m => m.Migrate(Status)) .ToList(); ShowResults(results); }); status = null; }
public override DatabaseStatus GetStatus() { logger.Debug("checking database status"); var status = new DatabaseStatus(); if (UpdateConnection(status)) if (UpdateCount(status)) if (UpdateItems(status)) UpdateAppPath(status); return status; }
public virtual IEnumerable<MigrationResult> MigrateOnly(DatabaseStatus initialStatus) { List<MigrationResult> results = new List<MigrationResult>(); var migs = GetMigrations(initialStatus).ToList(); for (int i = 0; i < migs.Count; ++i) { var service = migs[i]; PostProgress(String.Format("Migrating service {0} of {1} ('{2}')", i, migs.Count, service.Title)); var result = service.Migrate(initialStatus); results.Add(result); } return results; }
public override MigrationResult Migrate(DatabaseStatus preSchemaUpdateStatus) { indexer.Clear(); int count = 0; foreach (var item in repository.Find("VersionOf.ID", null)) { indexer.Update(item); count++; } return new MigrationResult(this) { UpdatedItems = count }; }
public override MigrationResult Migrate(DatabaseStatus preSchemaUpdateStatus) { var path = config.UploadFolders.AllElements.Where(uf => !string.IsNullOrEmpty(uf.UrlPrefix)).Select(uf => uf.Path).FirstOrDefault(); path = Url.ToAbsolute(path); return new MigrationResult(this) { RedirectTo = "{ManagementUrl}/Content/LinkTracker/UpdateReferences.aspx" + "?selectedUrl=" + path + "&previousUrl=" + path + "&location=upgrade" }; }
public DatabaseStatus GetStatus() { Trace.WriteLine("InstallationManager: checking database status"); DatabaseStatus status = new DatabaseStatus(); UpdateConnection(status); UpdateVersion(status); UpdateSchema(status); UpdateCount(status); UpdateItems(status); UpdateAppPath(status); return(status); }
public override MigrationResult Migrate(DatabaseStatus preSchemaUpdateStatus) { using (var tx = persister.Repository.BeginTransaction()) { var result = new MigrationResult(this); ; foreach (var redirect in persister.Repository.Find(new Parameter("class", "Redirect")).Where(p => p.Parent is Models.Pages.LanguageRoot)) { persister.Delete(redirect); result.UpdatedItems++; } tx.Commit(); return result; } }
protected void UpdateCount(DatabaseStatus status) { try { status.Items = cp.Session.Query<ContentItem>().Count(); status.Details = cp.Session.Query<ContentDetail>().Count(); status.DetailCollections = cp.Session.Query<DetailCollection>().Count(); status.AuthorizedRoles = cp.Session.Query<AuthorizedRole>().Count(); } catch (Exception) { throw; } }
private bool UpdateVersion(DatabaseStatus status) { try { status.DatabaseVersion = 0; sessionProvider.OpenSession.Session.CreateQuery("select ci.ID from " + typeof(ContentItem).Name + " ci").SetMaxResults(1).List(); status.DatabaseVersion = 1; // checking for properties added between version 1 and 2 sessionProvider.OpenSession.Session.CreateQuery("select ci.AncestralTrail from " + typeof(ContentItem).Name + " ci").SetMaxResults(1).List(); status.DatabaseVersion = 2; // checking for properties added between version 2 and 3 sessionProvider.OpenSession.Session.CreateQuery("select ci.AlteredPermissions from " + typeof(ContentItem).Name + " ci").SetMaxResults(1).List(); status.DatabaseVersion = 3; // checking for properties added between version 3 and 4 sessionProvider.OpenSession.Session.CreateQuery("select ci.TemplateKey from " + typeof(ContentItem).Name + " ci").SetMaxResults(1).List(); status.DatabaseVersion = 4; // checking for properties added between 4 and 5 sessionProvider.OpenSession.Session.CreateQuery("select ci.ChildState from " + typeof(ContentItem).Name + " ci").SetMaxResults(1).List(); status.DatabaseVersion = 5; // checking for properties added between 5 and 6 sessionProvider.OpenSession.Session.CreateQuery("select cd.Meta from " + typeof(ContentDetail).Name + " cd").SetMaxResults(1).List(); status.DatabaseVersion = 6; // checking for properties added between 6 and 7 sessionProvider.OpenSession.Session.CreateQuery("select cv.FuturePublish from " + typeof(ContentVersion).Name + " cv").SetMaxResults(1).List(); status.DatabaseVersion = 7; if (isDatabaseFileSystemEnbled) { // checking file system table (if enabled) sessionProvider.OpenSession.Session.CreateQuery("select ci from " + typeof(N2.Edit.FileSystem.NH.FileSystemItem).Name + " ci").SetMaxResults(1).List(); status.DatabaseVersion = 8; } // checking persistable properties added in application sessionProvider.OpenSession.Session.CreateQuery("select ci from " + typeof(ContentItem).Name + " ci").SetMaxResults(1).List(); status.DatabaseVersion = DatabaseStatus.RequiredDatabaseVersion; return(true); } catch (Exception ex) { logger.Error(ex); return(false); } }
public virtual IEnumerable <MigrationResult> MigrateOnly(DatabaseStatus initialStatus) { List <MigrationResult> results = new List <MigrationResult>(); var migs = GetMigrations(initialStatus).ToList(); for (int i = 0; i < migs.Count; ++i) { var service = migs[i]; PostProgress(String.Format("Migrating service {0} of {1} ('{2}')", i, migs.Count, service.Title)); var result = service.Migrate(initialStatus); results.Add(result); } return(results); }
private void UpdateCount(DatabaseStatus status) { try { ISession session = sessionProvider.OpenSession.Session; status.Items = Convert.ToInt32(session.CreateQuery("select count(*) from ContentItem").UniqueResult()); status.Details = Convert.ToInt32(session.CreateQuery("select count(*) from ContentDetail").UniqueResult()); status.DetailCollections = Convert.ToInt32(session.CreateQuery("select count(*) from AuthorizedRole").UniqueResult()); status.AuthorizedRoles = Convert.ToInt32(session.CreateQuery("select count(*) from DetailCollection").UniqueResult()); } catch (Exception ex) { logger.Error(ex); } }
private void UpdateAppPath(DatabaseStatus status) { try { if (status.RootItem == null) return; status.AppPath = status.RootItem[InstallationAppPath] as string; status.NeedsRebase = !string.IsNullOrEmpty(status.AppPath) && !string.Equals(status.AppPath, N2.Web.Url.ToAbsolute("~/")); } catch (Exception ex) { logger.Warn(ex); status.ItemsError = ex.Message; } }
private void UpdateItems(DatabaseStatus status) { try { status.StartPageID = host.DefaultSite.StartPageID; status.RootItemID = host.DefaultSite.RootItemID; status.StartPage = persister.Get(status.StartPageID); status.RootItem = persister.Get(status.RootItemID); status.IsInstalled = status.RootItem != null && status.StartPage != null; } catch (Exception ex) { status.IsInstalled = false; status.ItemsError = ex.Message; } }
public override MigrationResult Migrate(DatabaseStatus preSchemaUpdateStatus) { var events = GetEvents().ToList(); var result = new MigrationResult(this); ; using (var tx = persister.Repository.BeginTransaction()) { foreach (var ev in events.OfType<Event>()) { ev.EventDate = ev.GetDetail<DateTime?>("EventDate", null); persister.Save(ev); result.UpdatedItems++; } tx.Commit(); return result; } }
public override MigrationResult Migrate(DatabaseStatus preSchemaUpdateStatus) { int updatedItems = 0; using (var transaction = repository.BeginTransaction()) { foreach (var item in installer.ExecuteQuery(NHInstallationManager.QueryItemsWithoutAncestralTrail)) { item.AncestralTrail = Utility.GetTrail(item.Parent); repository.SaveOrUpdate(item); updatedItems++; } transaction.Commit(); } return new MigrationResult(this) { UpdatedItems = updatedItems }; }
private void UpdateAppPath(DatabaseStatus status) { try { if (status.RootItem == null) { return; } status.AppPath = status.RootItem[installationAppPath] as string; status.NeedsRebase = !string.IsNullOrEmpty(status.AppPath) && !string.Equals(status.AppPath, N2.Web.Url.ToAbsolute("~/")); } catch (Exception ex) { status.ItemsError = ex.Message; } }
private void UpdateConnection(DatabaseStatus status) { try { using (IDbConnection conn = GetConnection()) { status.ConnectionType = conn.GetType().Name; conn.Open(); conn.Close(); } status.IsConnected = true; status.ConnectionError = null; } catch (Exception ex) { status.IsConnected = false; status.ConnectionError = ex.Message; status.ConnectionException = ex; } }
private bool UpdateItems(DatabaseStatus status) { try { status.StartPageID = host.DefaultSite.StartPageID; status.RootItemID = host.DefaultSite.RootItemID; status.StartPage = persister.Get(status.StartPageID); status.RootItem = persister.Get(status.RootItemID); status.IsInstalled = status.RootItem != null && status.StartPage != null && !IsTrashed(status.RootItem) && !IsTrashed(status.StartPage) /* fix #583 -- ~/N2 should detect if the RootNode is Trash */; return(true); } catch (Exception ex) { status.IsInstalled = false; status.ItemsError = ex.Message; return(false); } }
private void UpdateSchema(DatabaseStatus status) { try { ISession session = sessionProvider.OpenSession.Session; session.CreateQuery("from ContentItem").SetMaxResults(1).List(); session.CreateQuery("from ContentDetail").SetMaxResults(1).List(); session.CreateQuery("from AuthorizedRole").SetMaxResults(1).List(); session.CreateQuery("from DetailCollection").SetMaxResults(1).List(); status.HasSchema = true; } catch (Exception ex) { Trace.WriteLine(ex); status.HasSchema = false; status.SchemaError = ex.Message; status.SchemaException = ex; } }
public InstallationChecker(IWebContext webContext, EventBroker broker, ConfigurationManagerWrapper configuration, InstallationManager installer) { this.installer = installer; if (configuration.Sections.Management.Installer.CheckInstallationStatus) { welcomeUrl = configuration.Sections.Management.Installer.WelcomeUrl; managementUrl = configuration.Sections.Management.Paths.ManagementInterfaceUrl; this.webContext = webContext; this.broker = broker; this.Status = installer.GetStatus(); installer.UpdateStatus(Status.Level); if (Status.Level != SystemStatusLevel.UpAndRunning) { this.broker.BeginRequest += BeginRequest; } } else { installer.UpdateStatus(SystemStatusLevel.Unconfirmed); } }
private void UpdateVersion(DatabaseStatus status) { try { status.DatabaseVersion = 0; sessionProvider.OpenSession.Session.CreateQuery("select ci.ID from " + typeof(ContentItem).Name + " ci").SetMaxResults(1).List(); status.DatabaseVersion = 1; // checking for properties added between version 1 and 2 sessionProvider.OpenSession.Session.CreateQuery("select ci.AncestralTrail from " + typeof(ContentItem).Name + " ci").SetMaxResults(1).List(); status.DatabaseVersion = 2; // checking for properties added between version 2 and 3 sessionProvider.OpenSession.Session.CreateQuery("select ci.AlteredPermissions from " + typeof(ContentItem).Name + " ci").SetMaxResults(1).List(); status.DatabaseVersion = 3; // checking for properties added between version 3 and 4 sessionProvider.OpenSession.Session.CreateQuery("select ci.TemplateKey from " + typeof(ContentItem).Name + " ci").SetMaxResults(1).List(); status.DatabaseVersion = 4; if (isDatabaseFileSystemEnbled) { // checking file system table (if enabled) sessionProvider.OpenSession.Session.CreateQuery("select ci from " + typeof(N2.Edit.FileSystem.NH.FileSystemItem).Name + " ci").SetMaxResults(1).List(); status.DatabaseVersion = 5; } // checking persistable properties added in application sessionProvider.OpenSession.Session.CreateQuery("select ci from " + typeof(ContentItem).Name + " ci").SetMaxResults(1).List(); status.DatabaseVersion = DatabaseStatus.RequiredDatabaseVersion; } catch (Exception ex) { logger.Error(ex); } }
public DatabaseStatus GetStatus() { logger.Debug("InstallationManager: checking database status"); DatabaseStatus status = new DatabaseStatus(); if (UpdateConnection(status)) { if (UpdateVersion(status)) { if (UpdateSchema(status)) { if (UpdateCount(status)) { if (UpdateItems(status)) { UpdateAppPath(status); } } } } } return(status); }
private void CheckInstallation() { string currentUrl = Url.ToRelative(webContext.Url.LocalUrl); try { AuthenticationSection authentication = ConfigurationManager.GetSection("system.web/authentication") as AuthenticationSection; if (currentUrl.Trim('~', '/').StartsWith(Url.ToAbsolute(authentication.Forms.LoginUrl.Trim('~', '/')), StringComparison.InvariantCultureIgnoreCase)) { // don't redirect from login page return; } } catch (Exception ex) { Engine.Logger.Warn(ex); } if (Status == null) { Status = installer.GetStatus(); } Url redirectUrl = Url.ResolveTokens(welcomeUrl); if (Status == null) { Engine.Logger.Warn("Null status"); installer.UpdateStatus(SystemStatusLevel.Unknown); return; } else if (Status.NeedsUpgrade) { redirectUrl = redirectUrl.AppendQuery("action", "upgrade"); } else if (!Status.IsInstalled) { redirectUrl = redirectUrl.AppendQuery("action", "install"); } else if (Status.NeedsRebase) { redirectUrl = redirectUrl.AppendQuery("action", "rebase"); } else { this.broker.BeginRequest -= BeginRequest; installer.UpdateStatus(Status.Level); this.Status = null; return; } installer.UpdateStatus(Status.Level); bool isEditing = currentUrl.StartsWith(N2.Web.Url.ToRelative(managementUrl), StringComparison.InvariantCultureIgnoreCase); if (isEditing) { return; } logger.Debug("Redirecting to '" + redirectUrl + "' to handle status: " + Status.ToStatusString()); this.Status = null; webContext.HttpContext.Response.Redirect(redirectUrl); }
public virtual bool IsApplicable(DatabaseStatus status) { return(true); }
public abstract MigrationResult Migrate(DatabaseStatus preSchemaUpdateStatus);
public virtual IEnumerable <AbstractMigration> GetMigrations(DatabaseStatus initialStatus) { return(GetAllMigrations().Where(m => m.IsApplicable(initialStatus))); }