本文整理汇总了C#中umbraco.cms.businesslogic.web.Document.XmlGenerate方法的典型用法代码示例。如果您正苦于以下问题:C# Document.XmlGenerate方法的具体用法?C# Document.XmlGenerate怎么用?C# Document.XmlGenerate使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类umbraco.cms.businesslogic.web.Document
的用法示例。
在下文中一共展示了Document.XmlGenerate方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: PublishWithResult
/// <summary>
/// Publishing a document
/// A xmlrepresentation of the document and its data are exposed to the runtime data
/// (an xmlrepresentation is added -or updated if the document previously are published) ,
/// this will lead to a new version of the document being created, for continuing editing of
/// the data.
/// </summary>
/// <param name="u">The usercontext under which the action are performed</param>
/// <returns>True if the publishing succeed. Possible causes for not publishing is if an event aborts the publishing</returns>
public bool PublishWithResult(User u)
{
PublishEventArgs e = new PublishEventArgs();
FireBeforePublish(e);
if (!e.Cancel)
{
// make a lookup to see if template is 0 as the template is not initialized in the optimized
// Document.Children method which is used in PublishWithChildrenWithResult methhod
if (_template == 0)
{
_template = new DocumentType(this.ContentType.Id).DefaultTemplate;
}
_published = true;
string tempVersion = Version.ToString();
Guid newVersion = createNewVersion();
Log.Add(LogTypes.Publish, u, Id, "");
//PPH make sure that there is only 1 newest node, this is important in regard to schedueled publishing...
SqlHelper.ExecuteNonQuery("update cmsDocument set newest = 0 where nodeId = " + Id);
SqlHelper.ExecuteNonQuery("insert into cmsDocument (newest, nodeId, published, documentUser, versionId, Text, TemplateId) values (1,@id, 0, @userId, @versionId, @text, @template)",
SqlHelper.CreateParameter("@id", Id),
SqlHelper.CreateParameter("@template", _template > 0 ? (object)_template : (object)DBNull.Value), //pass null in if the template doesn't have a valid id
SqlHelper.CreateParameter("@userId", u.Id),
SqlHelper.CreateParameter("@versionId", newVersion),
SqlHelper.CreateParameter("@text", Text));
SqlHelper.ExecuteNonQuery("update cmsDocument set published = 0 where nodeId = " + Id);
SqlHelper.ExecuteNonQuery("update cmsDocument set published = 1, newest = 0 where versionId = @versionId",
SqlHelper.CreateParameter("@versionId", tempVersion));
// update release and expire dates
Document newDoc = new Document(Id, newVersion);
if (ReleaseDate != new DateTime())
newDoc.ReleaseDate = ReleaseDate;
if (ExpireDate != new DateTime())
newDoc.ExpireDate = ExpireDate;
// Update xml in db using the new document (has correct version date)
newDoc.XmlGenerate(new XmlDocument());
FireAfterPublish(e);
return true;
}
else
{
return false;
}
}