Book a Demo

Author Topic: Automation and Document Artifact  (Read 3837 times)

patrice

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Automation and Document Artifact
« on: January 11, 2006, 01:34:29 pm »
Hello,
I would like to read the rtf stream from a document artifact (model document) by programmation in c# to include this content in a winword document.
How it's possible ?
???

patrice

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Automation and Document Artifact
« Reply #1 on: January 12, 2006, 03:11:02 am »
Please help me !!!!    ???  :-[  ???

I can read the content ( by xml) but the content is in format '.zip' .  And after,  I don't know the format (.dat in the .zip) (internal, ? ole? )

if (_elem.Type=="Artifact")
{
EA.Project proj=(EA.Project)rep.GetProjectInterface();
string test=proj.GetElement(proj.GUIDtoXML(_elem.ElementGUID));
//test=proj.GetElementProperties(_elem.ElementGUID);
XmlDocument  xmlDoc = new XmlDocument();
xmlDoc.LoadXml(test);
XmlNodeList oNodes;

XmlNamespaceManager nsmgr = new XmlNamespaceManager(xmlDoc.NameTable);
nsmgr.AddNamespace("UML","omg.org/UML1.3");
XmlElement root = xmlDoc.DocumentElement;
oNodes=root.GetElementsByTagName("UML:TaggedValue");
//oNodes=root.SelectNodes("//@tag='isSpecification'",nsmgr);

String val="";
foreach (XmlNode oNode in oNodes)
{
try
{
if (oNode.Attributes["tag"].Value=="modeldocument")
{
val=oNode.InnerText;
}
}
catch
{
}

}

System.Windows.Forms.MessageBox.Show(val);

byte[] valbase10= System.Convert.FromBase64String(val);


System.Text.ASCIIEncoding ascii = new System.Text.ASCIIEncoding();
 
// Write out the decoded data.
System.IO.FileStream outFile;
try
{
outFile = new System.IO.FileStream("d:\\test.zip",
System.IO.FileMode.Create,
System.IO.FileAccess.Write);
outFile.Write(valbase10, 0, valbase10.Length);
outFile.Close();
}
catch
{
}


}

Oliver Michalski

  • EA User
  • **
  • Posts: 116
  • Karma: +0/-0
    • View Profile
Re: Automation and Document Artifact
« Reply #2 on: January 12, 2006, 08:43:14 am »
Hi,

unfortunately I understand that not completely. Why do you create a ZIP file? A simple way is: Write the data in a XML-File. The data can be transmitted by a XML document to Word via a XSLT-Transformation

Oliver :)

patrice

  • EA Novice
  • *
  • Posts: 4
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Automation and Document Artifact
« Reply #3 on: January 12, 2006, 09:27:19 am »
Hello,
No, it's the content of a 'document artifact' (or linked document ) which is stored in an internal format compressed ( zip) and converted in base64 in the XML.

My code is not very clean but it was to try
:-/  :'(

Oliver Michalski

  • EA User
  • **
  • Posts: 116
  • Karma: +0/-0
    • View Profile
Re: Automation and Document Artifact
« Reply #4 on: January 12, 2006, 10:31:02 am »
Hi,

Let's take a review of your code
1. You create a new ZIP File called test.zip  (System.IO.FileMode.Create)  
2. You have (only) Write-Permissions to test.zip      (System.IO.FileAccess.Write)  
3. You want read the content of test.zip     (System.IO.FileMode.Open or System.IO.FileMode.OpenOrCreate)  
4. You must have Read-Permissions    (System.IO.FileAccess.Read or System.IO.FileAccess.ReadWrite)
So the code cannot function

Oliver  :)

Joel_Melan

  • EA Novice
  • *
  • Posts: 13
  • Karma: +0/-0
  • I love YaBB 1G - SP1!
    • View Profile
Re: Automation and Document Artifact
« Reply #5 on: January 26, 2006, 01:35:47 am »
hi patrice !

if you don't need programmation, you can use "linked documents" to include some RTF document in a EA generated RTF documentation

just look at my answer on the subject "Linked Files in RTF Documentation "

joel
Joel MELAN, Casino IT