本文整理汇总了C#中N2.Edit.Installation.DatabaseStatus类的典型用法代码示例。如果您正苦于以下问题:C# DatabaseStatus类的具体用法?C# DatabaseStatus怎么用?C# DatabaseStatus使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
DatabaseStatus类属于N2.Edit.Installation命名空间,在下文中一共展示了DatabaseStatus类的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: Migrate
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 };
}
示例2: Migrate
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"
};
}
示例3: Migrate
public override MigrationResult Migrate(DatabaseStatus preSchemaUpdateStatus)
{
if (IsApplicable(preSchemaUpdateStatus))
return new MigrationResult(this) { RedirectTo = "UpgradeVersions.aspx" };
else
return new MigrationResult(this);
}
示例4: IsApplicable
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();
}
示例5: UpdateSchema
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;
}
}
示例6: UpdateRecordedValues
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;
}
}
示例7: Migrate
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 };
}
示例8: UpdateConnection
protected void UpdateConnection(DatabaseStatus status)
{
//base.UpdateConnection(status);
if (GetConnectionException() == null)
{
status.IsConnected = true;
}
}
示例9: IsApplicable
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;
}
示例10: MigrateOnly
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;
}
示例11: Migrate
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 };
}
示例12: TryApplicable
public bool? TryApplicable(DatabaseStatus initialStatus)
{
try
{
return IsApplicable(initialStatus);
}
catch (System.Exception)
{
return null;
}
}
示例13: IsApplicable
public override bool IsApplicable(DatabaseStatus status)
{
try
{
return persister.Repository.Count(new Parameter("class", "News")) > 0;
}
catch (Exception)
{
return true;
}
}
示例14: IsApplicable
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;
}
}
示例15: CheckConnection
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;
}