ContentService.cs. Source Code. Error. Using Console application.
I using Umbraco from console application with ContentService.
When I try use method SaveAndPublish - get error.
I included source code Umbraco.Core.dll in my project.
And as result I detected that error is in file ContentService.cs in next line:
var xml = content.ToXml();
Method ToXml() return error because UmbracoSettings.UseLegacyXmlSchema is null .
When I commented all next code file ContentService.cs, everything works perfectly.
/*var xml = content.ToXml();
//Preview Xml
var previewPoco = new PreviewXmlDto
{
NodeId = content.Id,
Timestamp = DateTime.Now,
VersionId = content.Version,
Xml = xml.ToString(SaveOptions.None)
};
var previewExists =
uow.Database.ExecuteScalar<int>("SELECT COUNT(nodeId) FROM cmsPreviewXml WHERE nodeId = @Id AND versionId = @Version",
new { Id = content.Id, Version = content.Version }) != 0;
int previewResult = previewExists
? uow.Database.Update<PreviewXmlDto>(
"SET xml = @Xml, timestamp = @Timestamp WHERE nodeId = @Id AND versionId = @Version",
new
{
Xml = previewPoco.Xml,
Timestamp = previewPoco.Timestamp,
Id = previewPoco.NodeId,
Version = previewPoco.VersionId
})
: Convert.ToInt32(uow.Database.Insert(previewPoco));
if (published)
{
//Content Xml
var contentPoco = new ContentXmlDto { NodeId = content.Id, Xml = xml.ToString(SaveOptions.None) };
var contentExists = uow.Database.ExecuteScalar<int>("SELECT COUNT(nodeId) FROM cmsContentXml WHERE nodeId = @Id", new { Id = content.Id }) != 0;
int contentResult = contentExists
? uow.Database.Update(contentPoco)
: Convert.ToInt32(uow.Database.Insert(contentPoco));
}*/
If I could otherwise get rid of bugs in the method .ToXml() ?
Is my solution of this error right for the console application ? (comment out code)
Why is this code in file ContentService.cs, if all work perfect without it?
After all, as I understand this code used for display nodes tree on umbraco admin pages(content item). In my case, this code give error because in console application we haven't any tree nodes preview.
Maybe it will also come in handy for other beginner like me . Thanks everybody.
ContentService.cs. Source Code. Error. Using Console application.
I using Umbraco from console application with ContentService. When I try use method SaveAndPublish - get error. I included source code Umbraco.Core.dll in my project. And as result I detected that error is in file ContentService.cs in next line:
Method
ToXml()
return error becauseUmbracoSettings.UseLegacyXmlSchema
is null .When I commented all next code file ContentService.cs, everything works perfectly.
If I could otherwise get rid of bugs in the method
.ToXml()
?Is my solution of this error right for the console application ? (comment out code)
Why is this code in file ContentService.cs, if all work perfect without it?
Thanks.
After all, as I understand this code used for display nodes tree on umbraco admin pages(content item). In my case, this code give error because in console application we haven't any tree nodes preview.
Maybe it will also come in handy for other beginner like me . Thanks everybody.
is working on a reply...