本文整理汇总了C#中umbraco.NodeFactory.Node.GetDomainRootNode方法的典型用法代码示例。如果您正苦于以下问题:C# Node.GetDomainRootNode方法的具体用法?C# Node.GetDomainRootNode怎么用?C# Node.GetDomainRootNode使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类umbraco.NodeFactory.Node
的用法示例。
在下文中一共展示了Node.GetDomainRootNode方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: MigrateData
public static int MigrateData()
{
if (!GetUrlTrackerTableExists())
throw new Exception("Url Tracker table not found.");
if (!GetUrlTrackeOldTableExists())
throw new Exception("Old Url Tracker table not found.");
int newUrlTrackerEntriesCount = 0;
List<OldUrlTrackerModel> oldUrlTrackerEntries = new List<OldUrlTrackerModel>();
string query = string.Format("SELECT * FROM {0}", UrlTrackerSettings.OldTableName);
IRecordsReader recordsReader = _sqlHelper.ExecuteReader(query);
while(recordsReader.Read())
{
oldUrlTrackerEntries.Add(new OldUrlTrackerModel()
{
NodeId = recordsReader.GetInt("NodeID"),
OldUrl = recordsReader.GetString("OldUrl"),
IsCustom = recordsReader.GetBoolean("IsCustom"),
Message = recordsReader.GetString("Message"),
Inserted = recordsReader.GetDateTime("Inserted"),
IsRegex = recordsReader.GetBoolean("IsRegex")
});
}
foreach (OldUrlTrackerModel oldUrlTrackerEntry in oldUrlTrackerEntries)
{
Node node = new Node(oldUrlTrackerEntry.NodeId);
if ((node.Id > 0 || true) && !string.IsNullOrEmpty(oldUrlTrackerEntry.OldUrl) && oldUrlTrackerEntry.OldUrl != "#")
{
string oldUrl = oldUrlTrackerEntry.OldUrl;
Uri oldUri = null;
if (!oldUrlTrackerEntry.IsRegex)
{
if (!oldUrl.StartsWith(Uri.UriSchemeHttp))
oldUri = new Uri(_baseUri, oldUrl);
else
oldUri = new Uri(oldUrl);
oldUrl = UrlTrackerHelper.ResolveShortestUrl(oldUri.AbsolutePath);
}
else
{
if (oldUrl.StartsWith("^/"))
oldUrl = string.Concat("^", oldUrl.Substring(2));
if (oldUrl.StartsWith("/"))
oldUrl = oldUrl.Substring(1);
if (oldUrl.EndsWith("/$"))
oldUrl = string.Concat(oldUrl.Substring(0, oldUrl.Length - 2), "$");
if (oldUrl.EndsWith("/"))
oldUrl = oldUrl.Substring(0, oldUrl.Length - 1);
}
UrlTrackerModel newUrlTrackerEntry = new UrlTrackerModel(
!oldUrlTrackerEntry.IsRegex ? oldUrl : string.Empty,
oldUri != null ? !string.IsNullOrEmpty(oldUri.Query) && oldUri.Query.StartsWith("?") ? oldUri.Query.Substring(1) : oldUri.Query : string.Empty,
oldUrlTrackerEntry.IsRegex ? oldUrl : string.Empty,
node.GetDomainRootNode().Id,
oldUrlTrackerEntry.NodeId,
string.Empty,
301,
true,
false,
oldUrlTrackerEntry.Message);
newUrlTrackerEntry.Inserted = oldUrlTrackerEntry.Inserted;
AddUrlTrackerEntry(newUrlTrackerEntry);
newUrlTrackerEntriesCount++;
}
}
return newUrlTrackerEntriesCount;
}
示例2: ContentService_Publishing
void ContentService_Publishing(IPublishingStrategy sender, PublishEventArgs<IContent> e)
{
// When content is renamed or 'umbracoUrlName' property value is added/updated
foreach (IContent content in e.PublishedEntities)
{
#if !DEBUG
try
#endif
{
Node node = new Node(content.Id);
if (node.Name != content.Name && !string.IsNullOrEmpty(node.Name)) // If name is null, it's a new document
{
// Rename occurred
UrlTrackerRepository.AddUrlMapping(content, node.GetDomainRootNode().Id, node.NiceUrl, AutoTrackingTypes.Renamed);
if (ClientTools != null)
ClientTools.ChangeContentFrameUrl(string.Concat("/umbraco/editContent.aspx?id=", content.Id));
}
if (content.HasProperty("umbracoUrlName"))
{
string contentUmbracoUrlNameValue = content.GetValue("umbracoUrlName") != null ? content.GetValue("umbracoUrlName").ToString() : string.Empty;
string nodeUmbracoUrlNameValue = node.GetProperty("umbracoUrlName") != null ? node.GetProperty("umbracoUrlName").Value : string.Empty;
if (contentUmbracoUrlNameValue != nodeUmbracoUrlNameValue)
{
// 'umbracoUrlName' property value added/changed
UrlTrackerRepository.AddUrlMapping(content, node.GetDomainRootNode().Id, node.NiceUrl, AutoTrackingTypes.UrlOverwritten);
if (ClientTools != null)
ClientTools.ChangeContentFrameUrl(string.Concat("/umbraco/editContent.aspx?id=", content.Id));
}
}
}
#if !DEBUG
catch (Exception ex)
{
ex.LogException();
}
#endif
}
}
示例3: Document_BeforeMove
void Document_BeforeMove(object sender, MoveEventArgs e)
{
#if !DEBUG
try
#endif
{
Document doc = sender as Document;
#if !DEBUG
try
#endif
{
if (doc != null)
{
Node node = new Node(doc.Id);
if (node != null && !string.IsNullOrEmpty(node.NiceUrl) && !doc.Path.StartsWith("-1,-20")) // -1,-20 == Recycle bin | Not moved to recycle bin
UrlTrackerRepository.AddUrlMapping(doc, node.GetDomainRootNode().Id, node.NiceUrl, AutoTrackingTypes.Moved);
}
}
#if !DEBUG
catch (Exception ex)
{
ex.LogException(doc.Id);
}
#endif
}
#if !DEBUG
catch (Exception ex)
{
ex.LogException();
}
#endif
}
示例4: ContentService_Moving
void ContentService_Moving(IContentService sender, MoveEventArgs<IContent> e)
{
IContent content = e.Entity;
#if !DEBUG
try
#endif
{
if (content != null)
{
Node node = new Node(content.Id);
if (node != null && !string.IsNullOrEmpty(node.NiceUrl) && !content.Path.StartsWith("-1,-20")) // -1,-20 == Recycle bin | Not moved to recycle bin
UrlTrackerRepository.AddUrlMapping(content, node.GetDomainRootNode().Id, node.NiceUrl, AutoTrackingTypes.Moved);
}
}
#if !DEBUG
catch (Exception ex)
{
ex.LogException();
}
#endif
}
示例5: Document_BeforePublish
void Document_BeforePublish(Document doc, PublishEventArgs e)
{
// When document is renamed or 'umbracoUrlName' property value is added/updated
#if !DEBUG
try
#endif
{
Node node = new Node(doc.Id);
if (node.Name != doc.Text && !string.IsNullOrEmpty(node.Name)) // If name is null, it's a new document
{
// Rename occurred
UrlTrackerRepository.AddUrlMapping(doc, node.GetDomainRootNode().Id, node.NiceUrl, AutoTrackingTypes.Renamed);
if (BasePage.Current != null)
BasePage.Current.ClientTools.ChangeContentFrameUrl(string.Concat("/umbraco/editContent.aspx?id=", doc.Id));
}
if (doc.getProperty("umbracoUrlName") != null && node.GetProperty("umbracoUrlName") != null && node.GetProperty("umbracoUrlName").Value != doc.getProperty("umbracoUrlName").Value.ToString())
{
// 'umbracoUrlName' property value added/changed
UrlTrackerRepository.AddUrlMapping(doc, node.GetDomainRootNode().Id, node.NiceUrl, AutoTrackingTypes.UrlOverwritten);
if (BasePage.Current != null)
BasePage.Current.ClientTools.ChangeContentFrameUrl(string.Concat("/umbraco/editContent.aspx?id=", doc.Id));
}
}
#if !DEBUG
catch (Exception ex)
{
ex.LogException(doc.Id);
}
#endif
}