private static KBObjectCollection CreateListObjectsModuleAndReferences(KBModel kbModel, Module mdl, KBDoctorXMLWriter writer) { KBObjectCollection objToBuild = new KBObjectCollection(); foreach (KBObject obj in mdl.GetAllMembers()) { if (KBObjectHelper.IsSpecifiable(obj) && KBDoctorCore.Sources.Utility.isGenerated(obj)) { if (!objToBuild.Contains(obj)) { objToBuild.Add(obj); writer.AddTableData(new string[] { obj.QualifiedName.ToString(), obj.Description, obj.QualifiedName.ToString() + " (" + obj.TypeDescriptor.Name + ")" }); } } AddObjectsReferenceTo(obj, objToBuild, writer); } foreach (Table tbl in Table.GetAll(kbModel)) { if (TablesHelper.TableModule(kbModel, tbl) == mdl) { AddObjectsReferenceTo(tbl, objToBuild, writer); } } return(objToBuild); }
public static void ListAttWithoutDescription() { IKBService kbserv = UIServices.KB; string title = "KBDoctor - Attributes with incomplete description"; string outputFile = Functions.CreateOutputFile(kbserv, title); IOutputService output = CommonServices.Output; output.StartSection(title); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); writer.AddHeader(title); writer.AddTableHeader(new string[] { "Table", "Attribute", "Description", "Data type", "Title", "Column Title" }); string description; string titlesuggested; string columnTitle; foreach (Artech.Genexus.Common.Objects.Attribute a in Artech.Genexus.Common.Objects.Attribute.GetAll(kbserv.CurrentModel)) { description = a.Description; titlesuggested = a.Title; columnTitle = a.ColumnTitle; string Picture = Functions.ReturnPicture(a); if ((a.Description.Replace(" ", "") == a.Name) || (a.Title == a.Description) || (a.ColumnTitle == a.Description)) { string attNameLink = Functions.linkObject(a); // "<a href=\"gx://?Command=fa2c542d-cd46-4df2-9317-bd5899a536eb;OpenObject&name=" + a.Guid.ToString() + "\">" + a.Name + "</a>"; if (a.Title == a.Description) { titlesuggested = "<a href=\"gx://?Command=fa2c542d-cd46-4df2-9317-bd5899a536eb;AssignTitleToAttribute&attName=" + a.Name + "\">" + a.Title + "</a>"; } if (a.Description.Replace(" ", "") == a.Name) { description = "<a href=\"gx://?Command=fa2c542d-cd46-4df2-9317-bd5899a536eb;AssignDescriptionToAttribute&attName=" + a.Name + "\">" + a.Description + "</a>"; Table t = TablesHelper.TableOfAttribute(a); writer.AddTableData(new string[] { Functions.linkObject(t), attNameLink, description, Picture, titlesuggested, columnTitle }); } if (a.ColumnTitle == a.Description) { columnTitle = "<a href=\"gx://?Command=fa2c542d-cd46-4df2-9317-bd5899a536eb;AssignColumnTitleToAttribute&attName=" + a.Name + "\">" + a.ColumnTitle + "</a>"; } // writer.AddTableData(new string[] { attNameLink, description, Picture, titlesuggested, columnTitle }); } } writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection(title, success); }
internal static KBObjectCollection ModuleObjects(Module module) { { KBObjectCollection objectsModule = new KBObjectCollection(); foreach (KBObject obj in module.GetAllMembers()) { if (KBObjectHelper.IsSpecifiable(obj)) { if (!objectsModule.Contains(obj)) { objectsModule.Add(obj); } } } foreach (Table tbl in Table.GetAll(module.Model)) { if (TablesHelper.TableModule(module.Model, tbl) == module) { objectsModule.Add(tbl); } } return(objectsModule); } }
public bool Insert(string tableName, List <string> data) { string values = string.Empty; for (int i = 0; i < data.Count; i++) { values += data[i] != null && data[i].Contains("STR_TO_DATE") ? $"{data[i]}" : $"'{data[i]}'"; if (i < data.Count - 1)//Not to put a ',' at the last value { values += ","; } } string query = $"INSERT INTO {tableName} {TablesHelper.GetTableColumnsToInsert(tableName)} VALUES({values})"; try { OpenConnection(); MySqlCommand cmd = new MySqlCommand(query, connection); var result = cmd.ExecuteNonQuery(); CloseConnection(); return(true); } catch (Exception e) { CloseConnection(); //TODO - log defect return(false); } }
internal static void ListObjectsWithTableInOtherModule() { IKBService kbserv = UIServices.KB; KBModel model = kbserv.CurrentModel.GetDesignModel(); string title = "KBDoctor - List Objects with table in other module"; IOutputService output = CommonServices.Output; output.StartSection(title); string outputFile = Functions.CreateOutputFile(kbserv, title); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); writer.AddHeader(title); writer.AddTableHeader(new string[] { "Name", "Description", "Object Module", "Table ", "Table Module" }); SelectObjectOptions selectObjectOption = new SelectObjectOptions(); selectObjectOption.MultipleSelection = true; foreach (KBObject obj in UIServices.SelectObjectDialog.SelectObjects(selectObjectOption)) { string modulename = ModulesHelper.ObjectModuleName(obj); foreach (EntityReference reference in obj.GetReferences()) { KBObject objref = KBObject.Get(obj.Model, reference.To); if (objref != null && objref is Table && !ObjectsHelper.isGeneratedbyPattern(obj)) { Table t = (Table)objref; string tablemodulename = TablesHelper.TableModule(t.Model, t).Name; if (tablemodulename != modulename) { string objNameLink = Functions.linkObject(obj); output.AddLine("Processing... " + obj.Name + " reference table " + t.Name + " Object module:" + modulename + " Table module:" + tablemodulename); writer.AddTableData(new string[] { objNameLink, obj.Description, modulename, t.Name, tablemodulename }); } } } } writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection(title, success); }
private static void GetStatsOnTablesWithChains() { for (int i = 0; i < definedConst.Length; i++) { for (int j = 0; j < 50; j++) { TablesHelper.ReadAndMeasureChains(j, definedConst[i]); } } }
public static string ObjectModuleName(KBObject obj) { string modulename = ""; if (obj is Table) { modulename = TablesHelper.TableModule(obj.Model, (Table)obj).Name; } else { modulename = obj.Module.Name; } return(modulename); }
private static List <Module> ListModulesOfReferencedTables(KBObject obj) { List <Module> moduleList = new List <Module>(); foreach (EntityReference refe in obj.GetReferences()) { KBObject objref = KBObject.Get(obj.Model, refe.To); if (objref != null && objref is Table) { Module objrefModule = TablesHelper.TableModule(objref.Model, (Table)objref); if (!moduleList.Contains(objrefModule)) { moduleList.Add(objrefModule); } } } return(moduleList); }
//Select statement public List <List <DBDataUnit> > Select(string tableName, string attributes = null, string filter = null) { string query = $"SELECT {attributes ?? WildCard} FROM {tableName} WHERE {filter};"; //Create a list to store the result List <List <DBDataUnit> > results = new List <List <DBDataUnit> >(); try { OpenConnection(); MySqlCommand cmd = new MySqlCommand(query, connection); //Create a data reader and Execute the command MySqlDataReader dataReader = cmd.ExecuteReader(); //Read the data and store them in the list while (dataReader.Read()) { var dataUnits = TablesHelper.GetTableDataUnitsTemplates(tableName); foreach (var dataUnit in dataUnits) { var value = dataReader[dataUnit.ColumnName]; dataUnit.Value = value; } results.Add(dataUnits); } //close Data Reader dataReader.Close(); CloseConnection(); return(results); } catch (Exception e) { CloseConnection(); //TODO - log defect return(null); } }
private void WriteMetaDataInCHM() { SetStatus("Writing Columns..."); ColumnsHelper.WriteColumns(); backgroundWorker2.ReportProgress(5, ObjectTypes.Columns); SetStatus("Writing ForeignKeys..."); ForeignKeysHelper.WriteForeignKeys(); backgroundWorker2.ReportProgress(10, ObjectTypes.ForeignKeys); SetStatus("Writing IndexColumns..."); IndexColumnsHelper.WriteIndexColumns(); backgroundWorker2.ReportProgress(15, ObjectTypes.IndexColumns); SetStatus("Writing Indexes..."); IndexesHelper.WriteIndexes(); backgroundWorker2.ReportProgress(20, ObjectTypes.Indexes); SetStatus("Writing Tables..."); TablesHelper.WriteTables(); backgroundWorker2.ReportProgress(25, ObjectTypes.Tables); SetStatus("Writing ViewColumns..."); ViewColumnsHelper.WriteViewColumns(); backgroundWorker2.ReportProgress(30, ObjectTypes.ViewColumns); SetStatus("Writing Views..."); ViewsHelper.WriteViews(); backgroundWorker2.ReportProgress(35, ObjectTypes.Views); SetStatus("Writing ProcedureParameters..."); ProcedureParametersHelper.WriteProcedureParameters(); backgroundWorker2.ReportProgress(40, ObjectTypes.ProcedureParameters); SetStatus("Writing Procedures..."); ProceduresHelper.WriteProcedures(); backgroundWorker2.ReportProgress(45, ObjectTypes.Procedures); SetStatus("Writing Triggers..."); SMOHelper.TriggersHelper.WriteTriggers(); backgroundWorker2.ReportProgress(50, ObjectTypes.Triggers); SetStatus("Writing UserDefinedDataTypes..."); SMOHelper.UserDefinedDataTypesHelper.WriteUserDefinedDataTypes(); backgroundWorker2.ReportProgress(55, ObjectTypes.UserDefinedDataTypes); SetStatus("Writing InstanceInformation..."); InstanceInformationHelper.WriteInstanceInformation(); backgroundWorker2.ReportProgress(60, ObjectTypes.InstanceInformation); SetStatus("Writing DataSourceInformation..."); DataSourceInformationHelper.WriteDataSourceInformation(); backgroundWorker2.ReportProgress(65, ObjectTypes.DataSourceInformation); SetStatus("Writing DataTypes..."); DataTypesHelper.WriteDataTypes(); backgroundWorker2.ReportProgress(70, ObjectTypes.DataTypes); SetStatus("Writing Restrictions..."); RestrictionsHelper.WriteRestrictions(); backgroundWorker2.ReportProgress(75, ObjectTypes.Restrictions); SetStatus("Writing ReservedWords..."); ReservedWordsHelper.WriteReservedWords(); backgroundWorker2.ReportProgress(80, ObjectTypes.ReservedWords); SetStatus("Writing Users..."); UsersHelper.WriteUsers(); backgroundWorker2.ReportProgress(85, ObjectTypes.Users); }
private void GetMetaData() { SetStatus("Fetching Columns..."); ColumnsHelper.GetColumns(); backgroundWorker1.ReportProgress(5, ObjectTypes.Columns); SetStatus("Fetching ForeignKeys..."); ForeignKeysHelper.GetForeignKeys(); backgroundWorker1.ReportProgress(10, ObjectTypes.ForeignKeys); SetStatus("Fetching IndexColumns..."); IndexColumnsHelper.GetIndexColumns(); backgroundWorker1.ReportProgress(15, ObjectTypes.IndexColumns); SetStatus("Fetching Indexes..."); IndexesHelper.GetIndexes(); backgroundWorker1.ReportProgress(20, ObjectTypes.Indexes); SetStatus("Fetching Tables..."); TablesHelper.GetTables(); backgroundWorker1.ReportProgress(25, ObjectTypes.Tables); SetStatus("Fetching ViewColumns..."); ViewColumnsHelper.GetViewColumns(); backgroundWorker1.ReportProgress(30, ObjectTypes.ViewColumns); SetStatus("Fetching Views..."); ViewsHelper.GetViews(); backgroundWorker1.ReportProgress(35, ObjectTypes.Views); SetStatus("Fetching ProcedureParameters..."); ProcedureParametersHelper.GetProcedureParameters(); backgroundWorker1.ReportProgress(40, ObjectTypes.ProcedureParameters); SetStatus("Fetching Procedures..."); ProceduresHelper.GetProcedures(); backgroundWorker1.ReportProgress(45, ObjectTypes.Procedures); SetStatus("Fetching Triggers..."); SMOHelper.TriggersHelper.GetTriggers(Utility.DatabaseName); backgroundWorker1.ReportProgress(50, ObjectTypes.Triggers); SetStatus("Fetching UserDefinedDataTypes..."); SMOHelper.UserDefinedDataTypesHelper.GetUserDefinedDataTypes(Utility.DatabaseName); backgroundWorker1.ReportProgress(55, ObjectTypes.UserDefinedDataTypes); SetStatus("Fetching InstanceInformation..."); InstanceInformationHelper.GetInstanceInformation(); backgroundWorker1.ReportProgress(60, ObjectTypes.InstanceInformation); SetStatus("Fetching DataSourceInformation..."); DataSourceInformationHelper.GetDataSourceInformation(); backgroundWorker1.ReportProgress(65, ObjectTypes.DataSourceInformation); SetStatus("Fetching DataTypes..."); DataTypesHelper.GetDataTypes(); backgroundWorker1.ReportProgress(70, ObjectTypes.DataTypes); SetStatus("Fetching Restrictions..."); RestrictionsHelper.GetRestrictions(); backgroundWorker1.ReportProgress(75, ObjectTypes.Restrictions); SetStatus("Fetching ReservedWords..."); ReservedWordsHelper.GetReservedWords(); backgroundWorker1.ReportProgress(80, ObjectTypes.ReservedWords); SetStatus("Fetching Users..."); UsersHelper.GetUsers(); backgroundWorker1.ReportProgress(85, ObjectTypes.Users); }
internal static void ObjectsToDivide() { IKBService kbserv = UIServices.KB; KBModel kbModel = UIServices.KB.CurrentModel; IOutputService output = CommonServices.Output; bool success = true; int objInRoot = 0; int objSinRoot = 0; string title = "KBDoctor - Objects to divide"; output.StartSection(title); string outputFile = Functions.CreateOutputFile(kbserv, title); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); writer.AddHeader(title); writer.AddTableHeader(new string[] { "Object", "Module", "Type", "Is referenced by" }); KBObjectCollection objRefCollection = new KBObjectCollection(); SelectObjectOptions selectObjectOption = new SelectObjectOptions(); selectObjectOption.MultipleSelection = false; selectObjectOption.ObjectTypes.Add(KBObjectDescriptor.Get <Module>()); Module module2 = new Module(kbModel); foreach (Module module in UIServices.SelectObjectDialog.SelectObjects(selectObjectOption)) { module2 = module; output.AddLine("Procesing " + module.Name + "...."); foreach (KBObject obj in ModuleObjects(module)) { foreach (EntityReference reference in obj.GetReferences()) { KBObject objref = KBObject.Get(obj.Model, reference.To); if (objref != null && objref.TypeDescriptor.Name != "Attribute" && objref.TypeDescriptor.Name != "MasterPage") { Module objrefModule = ((objref is Table) ? TablesHelper.TableModule(objref.Model, (Table)objref) : objref.Module); if (objrefModule != module) { if (!(objref is Domain) && !(objref is Image) && !(objref is Theme) && !(objref is ThemeClass) && !(objref is GeneratorCategory) && !(objref is KBCategory) && !(objref is SDT)) { bool contain = objRefCollection.Any(p => p.Guid == objref.Guid); if (!contain) { objRefCollection.Add(objref); } } } } } } } string listObj = ""; //Listo todos los objetos externos referenciados desde el modulo foreach (KBObject o in objRefCollection) { listObj = ""; //Armo lista de objetos de mi modulo que referencian al objeto externo foreach (EntityReference refe in o.GetReferencesTo()) { KBObject objref = KBObject.Get(o.Model, refe.From); if (objref != null) { Module objrefModule = ((objref is Table) ? TablesHelper.TableModule(objref.Model, (Table)objref) : objref.Module); if (objrefModule == module2) { listObj += " " + Functions.linkObject(objref); } } } Module oModule = ((o is Table) ? TablesHelper.TableModule(o.Model, (Table)o) : o.Module); writer.AddTableData(new string[] { Functions.linkObject(o), oModule.Name, o.TypeDescriptor.Name, listObj }); } output.AddLine(""); output.EndSection(title, success); writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); }
public bool ExecGenerateTrnFromTables2(CommandData cmdData) { TablesHelper.GenerateTrnFromTables2(); return(true); }
internal static void ListTableInModules() { IKBService kbserv = UIServices.KB; KBModel model = kbserv.CurrentModel.GetDesignModel(); string title = "KBDoctor - List tables in modules"; IOutputService output = CommonServices.Output; output.StartSection(title); string outputFile = Functions.CreateOutputFile(kbserv, title); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); writer.AddHeader(title); writer.AddTableHeader(new string[] { "Name", "Description", "Visibility", "Best", "Best Module", "Modules", "Transaction", "Trn(NoGenerate)", "Referenced Modules", "Referenced" }); SelectObjectOptions selectObjectOption = new SelectObjectOptions(); selectObjectOption.MultipleSelection = true; selectObjectOption.ObjectTypes.Add(KBObjectDescriptor.Get <Module>()); foreach (KBObject module in UIServices.SelectObjectDialog.SelectObjects(selectObjectOption)) { foreach (Table t in Table.GetAll(module.Model)) { if (TablesHelper.TableModule(module.Model, t) == module) { string objNameLink = Functions.linkObject(t); output.AddLine("Processing... " + t.Name); int countAttr = 0; int countKeyAttr = 0; int widthKey = 0; int width = 0; int widthVariable = 0; int widthFixed = 0; ObjectVisibility objVisibility = TableVisibility(t); KBObject trnBest = GenexusBLServices.Tables.GetBestAssociatedTransaction(model, t.Key); Module mdlTrnBest = trnBest.Module; string trnGen = ""; string trnNoGen = ""; List <string> mdlList = new List <string>(); foreach (Transaction trn in t.AssociatedTransactions) { string trnstr = Functions.linkObject(trn) + "(" + ((trn.IsPublic) ? "Public" : "Private") + ") <br/> "; if (trn.GetPropertyValue <bool>(Properties.TRN.GenerateObject)) { trnGen += trnstr; } else { trnNoGen += trnstr; } if (!mdlList.Contains(trn.Module.Name)) { mdlList.Add(trn.Module.Name); } } IList <KBObject> objList = (from r in model.GetReferencesTo(t.Key, LinkType.UsedObject) where r.ReferenceType == ReferenceType.WeakExternal // las referencias a tablas que agrega el especificador son de este tipo //where ReferenceTypeInfo.HasUpdateAccess(r.LinkTypeInfo) select model.Objects.Get(r.From)).ToList(); IList <KBObject> objList2 = objList.Where(r => r.Module != mdlTrnBest).ToList(); string objListQNames = null; objList2.ToList().ForEach(v => objListQNames += " " + Functions.linkObject(v)); List <string> mdlReferencedList = new List <string>(); foreach (KBObject o in objList) { if (!mdlReferencedList.Contains(o.Module.Name)) { mdlReferencedList.Add(o.Module.Name); } } string mdlListstr = String.Join(" ", mdlList.ToArray()); string mdlReferencedListstr = String.Join(" ", mdlReferencedList.ToArray()); writer.AddTableData(new string[] { objNameLink, t.Description, objVisibility.ToString(), trnBest.QualifiedName.ToString(), mdlTrnBest.Name, mdlListstr, trnGen, trnNoGen, mdlReferencedListstr, objListQNames }); } } } writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection(title, success); }
public bool ExecAssignDescriptionToTable(CommandData cmdData) { TablesHelper.AssignDescriptionToTable(cmdData.Parameters); return(true); }
private static string[] ModuleStats(Module mdl) { IOutputService output = CommonServices.Output; IKBService kbserv = UIServices.KB; KBModel kbModel = UIServices.KB.CurrentModel; string listPubObjNotReferenced = ""; string listPirvateObjReferenced = ""; string ListobjOutsideModuleAccessPrivateTable = ""; foreach (KBObject obj in mdl.GetAllMembers()) { string aux = ""; bool isReferencedFromOutside = IsReferencedFromOutside(mdl, obj, out aux); ObjectVisibility objVisibility = RecoverObjectVisibility(obj); if (objVisibility == ObjectVisibility.Public && Functions.isRunable(obj) && !(obj is Transaction)) { if (!isReferencedFromOutside) { listPubObjNotReferenced += Functions.linkObject(obj) + " "; } } // Por un error de GX, no se listan los SDT pues todos quedan como publicos aunque esten marcados como privados. if (objVisibility == ObjectVisibility.Private && isReferencedFromOutside && !(obj is SDT) && !(obj is Folder)) { listPirvateObjReferenced += Functions.linkObject(obj) + " "; } } string objOutsideModuleAccessPrivateTable = ""; string objUpdateOutsideModuleList = ""; string objToMove = ""; //Hago lo mismo para las tablas del modulo. IList <KBObject> tblList = (from r in Table.GetAll(kbModel) where TablesHelper.TableModule(kbModel, r) == mdl select kbModel.Objects.Get(r.Key)).ToList(); foreach (Table tbl in tblList) { string tableName = tbl.Name; ObjectVisibility visibility = TableVisibility(tbl); bool TableReferencedFromOutside = IsReferencedFromOutside(mdl, (KBObject)tbl, out objOutsideModuleAccessPrivateTable); if (TableReferencedFromOutside && (visibility == ObjectVisibility.Private)) { ListobjOutsideModuleAccessPrivateTable += objOutsideModuleAccessPrivateTable + "<BR>" + Environment.NewLine; } else if (!TableReferencedFromOutside && (visibility == ObjectVisibility.Public)) { listPubObjNotReferenced += Functions.linkObject((KBObject)tbl) + " "; } string objUpdateOutsideModuleListTable = ""; foreach (KBObject objUpdateOutsideModule in TablesHelper.ObjectsUpdateTableOutsideModule(kbModel, tbl)) { objUpdateOutsideModuleListTable += Functions.linkObject(objUpdateOutsideModule) + " "; } if (objUpdateOutsideModuleListTable != "") { objUpdateOutsideModuleList += tbl.Name + " (" + objUpdateOutsideModuleListTable + ")<BR>"; } //Veo los objetos que referencian alguna tabla desde fuera del modulo, si tienen alguna tabla de otro modulo //Si son todas de mi modulo, lo pongo en la lista de los objetos a mover a mi modulo. foreach (KBObject objreadOutsideModule in TablesHelper.ObjectsReadTableOutsideModule(tbl)) { if (ListModulesOfReferencedTables(objreadOutsideModule).Count == 1) { objToMove += Functions.linkObject(objreadOutsideModule) + "; "; } } } string[] mdlStats = new string[] { Functions.linkObject(mdl), listPubObjNotReferenced, listPirvateObjReferenced, ListobjOutsideModuleAccessPrivateTable, objUpdateOutsideModuleList, objToMove }; return(mdlStats); }
public bool ExecGenerateSQLScripts(CommandData cmdData) { TablesHelper.GenerateSQLScripts(); return(true); }
private List <CompassNodes> GetInfomapNodes(string skillGuid) { var CompassNodesTable = new TablesHelper <CompassNodes>().CreateTablesHelper(StorageConString, "MapDataCompassNodes"); return(CompassNodesTable.SelectBySingleProperty("PartitionKey", skillGuid)); }
private static void GenerateKBTableGraph(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>"); foreach (Table t in Table.GetAll(model)) { scriptFile.WriteLine(" <node id='" + t.Name + "' label='" + t.Name + "' >"); scriptFile.WriteLine(" <attvalues> <attvalue for='0' value = '" + TablesHelper.TableModule(model, t).Name + "' /> </attvalues>"); scriptFile.WriteLine(" </node>"); foreach (TableRelation relation in t.SuperordinatedTables) { String edge = " <edge id='XXXX' source='" + relation.BaseTable.Name + "' target='" + relation.RelatedTable.Name + "' /> "; if (!aristas.Contains(edge)) { aristas.Add(edge); } } } ; scriptFile.WriteLine(" </nodes>"); //Grabo las aristas scriptFile.WriteLine(" <edges>"); int i = 0; foreach (String s in aristas) { string s2 = s.Replace("XXXX", i.ToString()); scriptFile.WriteLine(" " + s2); i += 1; } ; scriptFile.WriteLine(" </edges>"); scriptFile.WriteLine(" </graph>"); scriptFile.WriteLine("</gexf>"); scriptFile.Close(); }
private static string[] ModuleStats2(Module mdl) { IOutputService output = CommonServices.Output; IKBService kbserv = UIServices.KB; KBModel kbModel = UIServices.KB.CurrentModel; /* * * Dependencias Entrantes * Dependencias Salientes * IE = Salientes / (Entrantes + Salientes) #Componentes Conexos dentro del módulo. * Tiene dependencia cíclicla ? * Largo máximo de dependencias en la que participa. * El módulo tiene objetos públicos no referenciados por externos? */ int cantobj = 0; int cantobjmain = 0; int cantobjPub = 0; int cantInRef = 0; int cantOutRef = 0; foreach (KBObject obj in mdl.GetAllMembers()) { cantobj += 1; string aux = ""; bool isReferencedFromOutside = IsReferencedFromOutside(mdl, obj, out aux); ObjectVisibility objVisibility = RecoverObjectVisibility(obj); if (Functions.isRunable(obj)) { if (objVisibility == ObjectVisibility.Public) { cantobjPub += 1; } if (!isReferencedFromOutside) { cantInRef += 1;; } } } //Hago lo mismo para las tablas del modulo. IList <KBObject> tblList = (from r in Table.GetAll(kbModel) where TablesHelper.TableModule(kbModel, r) == mdl select kbModel.Objects.Get(r.Key)).ToList(); int cntTables = 0; int cntPublicTables = 0; foreach (Table tbl in tblList) { cntTables += 1; string tableName = tbl.Name; ObjectVisibility visibility = TableVisibility(tbl); if (visibility == ObjectVisibility.Public) { cntPublicTables += 1; } string objOutsideModuleAccessPrivateTable = ""; bool TableReferencedFromOutside = IsReferencedFromOutside(mdl, (KBObject)tbl, out objOutsideModuleAccessPrivateTable); if (TableReferencedFromOutside) { cantInRef += 1;; } } int rel = (cantobj == 0 ? 0 : (cantobjPub * 100) / cantobj); string[] mdlStats = new string[] { Functions.linkObject(mdl), mdl.Description, cntTables.ToString(), cntPublicTables.ToString(), cantobj.ToString(), cantobjPub.ToString(), rel.ToString() + " %", cantInRef.ToString(), cantOutRef.ToString() }; return(mdlStats); }
/* * * Dependencias Entrantes * Dependencias Salientes * IE = Salientes / (Entrantes + Salientes) #Componentes Conexos dentro del módulo. * Tiene dependencia cíclicla ? * Largo máximo de dependencias en la que participa. * El módulo tiene objetos públicos no referenciados por externos? */ public static void ListModulesStatisticsTotal() { IKBService kbserv = UIServices.KB; IOutputService output = CommonServices.Output; KBModel kbmodel = kbserv.CurrentModel; bool success = true; int objInRoot = 0; int objInModule = 0; int tblInRoot = 0; int tblInModule = 0; int objTot = 0; int modules = 0; string title = "KBDoctor - List Modules Statistics Total"; output.StartSection(title); // string outputFile = Functions.CreateOutputFile(kbserv, title); // KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); // writer.AddHeader(title); // writer.AddTableHeader(new string[] { "Module", "Description", "Tables", "Public Tables", "Objects", "Public Obj", "Obj/Publ %", "In References", "Out References" }); foreach (KBObject obj in kbserv.CurrentModel.Objects.GetAll()) { if (Functions.hasModule(obj)) { objTot += 1; if (obj is Table) { if (TablesHelper.TableModule(kbmodel, (Table)obj) == kbserv.CurrentModel.GetDesignModel().RootModule) { tblInRoot += 1; } else { tblInModule += 1; } } else { if (obj.Module == kbserv.CurrentModel.GetDesignModel().RootModule) { objInRoot += 1; } else { objInModule += 1; } if (obj is Module) { modules += 1; } } } } int ratio = (objInRoot == 0) ? 0 : (objInModule * 100) / objInRoot; output.AddLine("# Objects: " + objTot + " in Module: " + objInModule.ToString() + " in Root: " + objInRoot.ToString()); output.AddLine("% Modularization: " + ratio.ToString()); output.AddLine("# Tables in Module: " + tblInModule.ToString() + " in Root: " + tblInRoot.ToString()); output.EndSection(title, success); // Functions.AddLineSummary("moduleStats.txt", Resumen); }