Author Topic: Check if EA template is exist  (Read 3087 times)

Tehila1

  • EA User
  • **
  • Posts: 256
  • Karma: +0/-0
    • View Profile
Check if EA template is exist
« on: March 09, 2014, 07:34:49 pm »
Hello!

How can I check programmatically if an EA template is exist already in a model, by template name?

Thanks in advance!

Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: Check if EA template is exist
« Reply #1 on: March 10, 2014, 06:05:11 pm »
You can try queries.
If 'tis a document generation template, user defined templates are in t_document (select * from t_document) table.

or if 'tis a code gen / transformation template, user defined changes / new templates are in t_template(select * from t_template)

Tehila1

  • EA User
  • **
  • Posts: 256
  • Karma: +0/-0
    • View Profile
Re: Check if EA template is exist
« Reply #2 on: March 10, 2014, 08:38:01 pm »
Thanks a lot!

For other's sake- here is the complete way to check if a document template is exist in current model:  

Code: [Select]
string squery = @"SELECT t_document.DocID FROM t_document WHERE t_document.DocName LIKE 'YourTemplateName' ";
                  XmlDocument result = Repository.SelectStatement(squery);
                  XmlNodeList template = result.SelectNodes("//DocID");
                  if (template.Count <= 0) // The template is missing

David Rains (bioform)

  • EA User
  • **
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Re: Check if EA template is exist
« Reply #3 on: March 12, 2014, 08:28:00 am »
Where do I find help about parsing the XML results of SQL query (XML is really new to me...) so that bit of code when I checked the EA Help file came up empty?
« Last Edit: March 12, 2014, 08:30:40 am by DavidRains »

qwerty

  • EA Guru
  • *****
  • Posts: 12841
  • Karma: +367/-296
  • I'm no guru at all
    • View Profile
Re: Check if EA template is exist
« Reply #4 on: March 12, 2014, 09:32:53 am »
Which language do you use?

q.

David Rains (bioform)

  • EA User
  • **
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Re: Check if EA template is exist
« Reply #5 on: March 12, 2014, 10:34:52 am »
Right now vbscript but I am flexible :)

David Rains (bioform)

  • EA User
  • **
  • Posts: 83
  • Karma: +0/-0
    • View Profile
Re: Check if EA template is exist
« Reply #6 on: March 12, 2014, 10:36:22 am »
BTW I had Inside EA, now today I picked up your other three!  :)
Have to print them out and start reading!

david.rains@live.com

Nizam Mohamed

  • EA User
  • **
  • Posts: 193
  • Karma: +1/-0
    • View Profile
Re: Check if EA template is exist
« Reply #7 on: March 12, 2014, 03:40:48 pm »
Try this VB Sample code in
Code: [Select]
Dim XmlData As String
      Dim Notes, Script, ScriptLanguage, ScriptName As String
      Dim root, noteX As XElement
      XmlData = Repository.SQLQuery("SELECT Notes FROM t_script)
      root = XElement.Parse(XmlData)
      If root.Elements("Dataset_0").Any() Then
         Notes = root.<Dataset_0>.<Data>.<Row>.<Notes>.Value().ToString()
         noteX = XElement.Parse(Notes)
         ScriptName = noteX.FirstAttribute.Value
         ScriptLanguage = noteX.LastAttribute.Value
      End If

qwerty

  • EA Guru
  • *****
  • Posts: 12841
  • Karma: +367/-296
  • I'm no guru at all
    • View Profile
Re: Check if EA template is exist
« Reply #8 on: March 12, 2014, 11:22:47 pm »
Quote
BTW I had Inside EA, now today I picked up your other three!  :)
Have to print them out and start reading!

david.rains@live.com
Thanks :-) Hope you enjoy them. If you have any questions or remarks please contact me via mail.

q.