private static bool isNode(KBObject obj) { if (obj != null) { return((Functions.isRunable(obj) && ObjectsHelper.isGenerated(obj)) || (obj is Table) || (obj is ExternalObject)); } else { return(false); } }
private static void GenerateMDGGraph(string name, string fileName) { IKBService kbserv = UIServices.KB; KBModel model = kbserv.CurrentModel; StreamWriter scriptFile = new StreamWriter(fileName); IOutputService output = CommonServices.Output; StringCollection aristas = new StringCollection(); output.AddLine("Generating MDG " + name); string objName = ""; StringCollection nodos = new StringCollection(); foreach (KBObject obj in model.Objects.GetAll()) { bool includedInGraph = (Functions.isRunable(obj) && ObjectsHelper.isGenerated(obj)) || (obj is Table); if (includedInGraph) { objName = NombreNodo(obj); string modulename = ModulesHelper.ObjectModuleName(obj); if (!nodos.Contains(objName)) { scriptFile.WriteLine(" <node id='" + objName + "' label='" + objName + "' >"); scriptFile.WriteLine(" <attvalues> <attvalue for='0' value = '" + modulename + "' /> </attvalues>"); scriptFile.WriteLine(" </node>"); nodos.Add(objName); } foreach (EntityReference r in obj.GetReferencesTo()) { KBObject objRef = KBObject.Get(obj.Model, r.From); if ((objRef != null) && (Functions.isRunable(objRef) || objRef is Table)) { string objRefName = NombreNodo(objRef); if (objName != objRefName) { String edge = " source='" + objRefName + "' target='" + objName + "' weight= '1.0' "; if (!aristas.Contains(edge)) { aristas.Add(edge); } } } } } } ; scriptFile.WriteLine(" </nodes>"); //Grabo las aristas scriptFile.WriteLine(" <edges>"); int i = 0; foreach (String s in aristas) { scriptFile.WriteLine(" <edge id=" + i.ToString() + s + " /> "); i += 1; } ; scriptFile.WriteLine(" </edges>"); scriptFile.WriteLine(" </graph>"); scriptFile.WriteLine("</gexf>"); scriptFile.Close(); }
private static void GenerateKBObjectGraph(string name, string fileName) { IKBService kbserv = UIServices.KB; KBModel model = kbserv.CurrentModel; StreamWriter scriptFile = new StreamWriter(fileName); IOutputService output = CommonServices.Output; StringCollection aristas = new StringCollection(); output.AddLine("Generating " + name); scriptFile.WriteLine("<?xml version = '1.0' encoding = 'UTF-8'?>"); scriptFile.WriteLine("<gexf xmlns='http://www.gexf.net/1.2draft' xmlns:viz='http://www.gexf.net/1.2draft/viz' "); scriptFile.WriteLine(" xmlns:xsi='http://www.w3.org/2001/XMLSchema-instance' xsi:schemaLocation='http://www.gexf.net/1.2draft http://www.gexf.net/1.2draft/gexf.xsd' version = '1.2' > "); scriptFile.WriteLine(" <graph mode = 'static' defaultedgetype = 'directed' > "); scriptFile.WriteLine("<attributes class='node'> <attribute id='0' title = 'module' type = 'string' /> </attributes >"); scriptFile.WriteLine(" <nodes>"); string objName = ""; StringCollection nodos = new StringCollection(); foreach (KBObject obj in model.Objects.GetAll()) { if ((Functions.isRunable(obj) && ObjectsHelper.isGenerated(obj)) || (obj is Table)) { objName = NombreNodo(obj); string modulename = ModulesHelper.ObjectModuleName(obj); if (!nodos.Contains(objName)) { scriptFile.WriteLine(" <node id='" + objName + "' label='" + objName + "' >"); scriptFile.WriteLine(" <attvalues> <attvalue for='0' value = '" + modulename + "' /> </attvalues>"); scriptFile.WriteLine(" </node>"); nodos.Add(objName); } foreach (EntityReference r in obj.GetReferencesTo()) { KBObject objRef = KBObject.Get(obj.Model, r.From); if ((objRef != null) && (Functions.isRunable(objRef) || objRef is Table)) { string objRefName = NombreNodo(objRef); if (objName != objRefName) { String edge = " source='" + objRefName + "' target='" + objName + "' weight= '1.0' "; if (!aristas.Contains(edge)) { aristas.Add(edge); } } } } } } ; scriptFile.WriteLine(" </nodes>"); //Grabo las aristas scriptFile.WriteLine(" <edges>"); int i = 0; foreach (String s in aristas) { scriptFile.WriteLine(" <edge id=" + i.ToString() + s + " /> "); i += 1; } ; scriptFile.WriteLine(" </edges>"); scriptFile.WriteLine(" </graph>"); scriptFile.WriteLine("</gexf>"); scriptFile.Close(); }
public static bool IncludedInGraph(KBObject objRef) { return((Functions.isRunable(objRef) && ObjectsHelper.isGenerated(objRef)) || (objRef is Table) || (objRef is SDT) || (objRef is ExternalObject) || (objRef is Transaction)); }