is it possible to read the used datasources from template?
thanks
Last edited 30 March 2015
is it possible to read the used datasources from template?
thanks
Last edited 30 March 2015
Hi,
Yes, but it depends on what you would like to achieve. Could you please describe what information you would need to read? If you only need to get the list of the data sources (names) then you can do so by using APIs from the Docentric.Documents.Reporting.TemplateManagement namespace.
Best regards, Jure Leskovec
Hi,
thanks for your reply. Yes, I need just the list of the used datasources names. I tried to use the APIs from the Docentric.Documents.Reporting.TemplateManagement namespace, but i got a System.NotImplementedException.
Testcode:
using Docentric.Documents.Reporting;
using Docentric.Documents.ObjectModel;
using Docentric.Documents.Reporting.TemplateManagement;
using (FileStream templateStream = new FileStream(Server.MapPath(StorePath + mandant + template), FileMode.Open, FileAccess.Read))
{
MemoryStream outputDocumentStream = new MemoryStream();
templateStream.Position = 0;
templateStream.CopyTo(outputDocumentStream);
// Here I get the error
var test = TemplateDocument.Open(outputDocumentStream).Metadata.DataSources;
//outputDocumentStream = new MemoryStream();<br>
//DocumentGenerationResult result = dg.GenerateDocument(templateStream, outputDocumentStream);<br>
//if (result.HasErrors)
//{
// foreach (Error error in result.Errors) Console.Out.WriteLine(error.Message);
//}
}
We use Docentric Version 2.0.0.864 . Maybe we have to update?
You are properly using the APIs but the problem is that TemplateMetadata can only be retrieved for templates that only have XML data sources. We intentd to add the support for other data source kinds as well but there is no fixed date for when this might happen.
What can be done now is to fix the APIs to not throw an exception if a template defines a data source other than XML. This can be done by tomorrow (or even later today). I will let you know when the fix will be ready.
Kind regards, Jure Leskovec
ok. Very sade, we don't plan to use XML as datasource. But - it would be really! very helpful if the sources could also be read from a template if a dll were used as datasource. it would facilitate the work enormously! But thanks for your prompt reply!
Hi,
We prepared the new release for you that will allow you to read template metadata regardless of the kind of data source used on a template. Not that the schamas for non-XML data sources will not be read in this release and if you will save the template back (using these APIs), the data sources will loose their schemas.
Since this is a non-public release, you will get the download link on your email. Let me know if this fix works for you as expected.
Best regards, Jure