Hello,
still doing my Reporting-Addin.
This Addin uses the built-in RTF-Reporting of EA, internally.
I use specific RTF-Templates for the Addin. But I dont want that every user has to import these templates for each of their EA-Files manually.
The RTF-templates are located in the "t_document"-table of an EA-File (when you open it with access).
Well, if EA-files are databases, why not using the Repository.Execute("SQL-Statement") of the EA-API, to update the t_documents-table ?
And this is what i have at the moment:
I fill the content of my RTF-documents into byte-arrays and try to deploy these arrays to the bincontent-column of the t_document-table.
Here is the code.
DirectoryInfo d = new DirectoryInfo(AddInDirectory + @"\RTF-Templates");
foreach (FileInfo f in d.GetFiles())
{
FileStream fs = new FileStream(f.FullName, FileMode.Open);
try
{
byte[] MyData = new byte[fs.Length];
fs.Read(MyData, 0, System.Convert.ToInt32(fs.Length));
string guid = System.Guid.NewGuid().ToString();
DateTime dt = new DateTime();
dt = DateTime.Now;
string sqlstring = "INSERT INTO t_document(DocID,DocName, Notes, Style, ElementID, ElementType, StrContent, BinContent, DocType, Author, Version, isActive, Sequence,
DocDate) VALUES('" + guid + "','" + f.Name + "'," + "'teststring'," + "'Zip=1;'," + "'SSDOCSTYLE'," + "'SSDOCSTYLE'," + " 'teststring'," + MyData+ "," + "'SSDOCSTYLE'," + "'teststring', 'teststring', 2, 2,'" + dt.ToString("dd.MM.yyyy hh:mm:ss") + "'";
Repository.Execute(sqlstring);
}
finally
{
fs.Close();
}
}
My problem is, that the SQL-statement doesent work.
The RTF-templates seem to be blobs or OLE-objects in the accessdatabase. I dont understand whats the diference between these both and how to place them in an access-database. Or to be more precisely, i dont know how to convert an byte-array into something, that can be placed in an string-object (the SQL-statement of Repository.Execute()).
I hope you did understnad me. Sorry for my bad english.
Thx