public formatXPath ( string xpath ) : string | ||
xpath | string | the xpath to format |
return | string |
public static bool isItemUsedInASchema(UML.Classes.Kernel.Element element, TSF_EA.Model model) { var sqlGetCountSchemas = @"select count(*) as countresult from t_document d inner join t_object o on o.ea_guid = d.ElementID where d.DocType = 'SC_MessageProfile' " + $"and d.StrContent like '%{element.uniqueID}%'"; var resultXml = model.SQLQuery(sqlGetCountSchemas); var countNode = resultXml.SelectSingleNode(model.formatXPath("//countresult")); return(countNode.InnerText != "0"); }
/// <summary> /// gets all scripts defined in the model /// </summary> /// <param name="model"></param> /// <returns></returns> public static List <Script> getEAMaticScripts(EAWrappers.Model model) { if (model != null) { XmlDocument xmlScripts = model.SQLQuery(@"select s.ScriptID, s.Notes, s.Script,ps.Script as SCRIPTGROUP, ps.Notes as GROUPNOTES from t_script s inner join t_script ps on s.ScriptAuthor = ps.ScriptName where s.Script like '%EA-Matic%'" ); //check the hash before continuing int newHash = xmlScripts.InnerXml.GetHashCode(); //only create the scripts of the hash is different //otherwise we returned the cached scripts if (newHash != scriptHash) { //set the new hashcode scriptHash = newHash; //reset scripts allScripts = new List <Script>(); //set flag to reload scripts in includableScripts reloadModelIncludableScripts = true; modelIncludableScripts = new Dictionary <string, string>(); XmlNodeList scriptNodes = xmlScripts.SelectNodes("//Row"); foreach (XmlNode scriptNode in scriptNodes) { //get the <notes> node. If it countaints "Group Type=" then it is a group. Else we need to find "Language=" XmlNode notesNode = scriptNode.SelectSingleNode(model.formatXPath("Notes")); if (notesNode.InnerText.Contains(scriptLanguageIndicator)) { //we have an actual script. //the name of the script string scriptName = getValueByName(notesNode.InnerText, scriptNameIndicator); //now figure out the language string language = getValueByName(notesNode.InnerText, scriptLanguageIndicator); //get the ID XmlNode IDNode = scriptNode.SelectSingleNode(model.formatXPath("ScriptID")); string ScriptID = IDNode.InnerText; //get the group XmlNode groupNode = scriptNode.SelectSingleNode(model.formatXPath("SCRIPTGROUP")); string groupName = groupNode.InnerText; //then get teh code XmlNode codeNode = scriptNode.SelectSingleNode(model.formatXPath("Script")); if (codeNode != null && language != string.Empty) { //if the script is still empty EA returns NULL string scriptCode = codeNode.InnerText; if (scriptCode.Equals("NULL", StringComparison.InvariantCultureIgnoreCase)) { scriptCode = string.Empty; } Script script = new Script(ScriptID, scriptName, groupName, scriptCode, language, model); //and create the script if both code and language are found allScripts.Add(script); //also add the script to the include dictionary modelIncludableScripts.Add("!INC " + script.groupName + "." + script.name, script._code); } } } //Add the static EA-Matic scripts to allScripts foreach (Script staticScript in staticEAMaticScripts) { //add the model to the static script first staticScript.model = model; //then add the static scrip to all scripts allScripts.Add(staticScript); } //load the code of the scripts (because a script can include another script we can only load the code after all scripts have been created) foreach (Script script in allScripts) { script.reloadCode(); } } } return(allScripts); }