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); }
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); } }
private static void AddReferencedObj(KBObjectCollection objColl, KBObject obj, string tabs) { IKBService kbserv = UIServices.KB; IOutputService output = CommonServices.Output; objColl.Add(obj); string RefTabs = tabs + " "; if (ObjectsHelper.IsCallalable(obj)) { foreach (EntityReference reference in obj.GetReferences()) { KBObject objRef = KBObject.Get(obj.Model, reference.To); if ((objRef != null) && !(objColl.Contains(objRef)) && (reference.ReferenceType == ReferenceType.Hard) && (ObjectsHelper.IsCallalable(objRef))) { if (!(objRef is Procedure)) { output.AddLine(tabs + "XCOPY " + objRef.Name + ".DLL %DESTINO% "); //+ " (" + obj.TypeDescriptor.Name + ")" ); } AddReferencedObj(objColl, objRef, RefTabs); } } } }
private static void GenerateKBConexComponentGraph(string name) { IKBService kbserv = UIServices.KB; KBModel model = kbserv.CurrentModel; int i = 0; string fileName = name + i + ".gexf"; KBObjectCollection visited = new KBObjectCollection(); IEnumerable <KBObject> listObjNode = (from r in model.Objects.GetAll() where isNode(r) select model.Objects.Get(r.Key)); foreach (KBObject obj in listObjNode) { if (!visited.Contains(obj)) { i += 1; visited.Add(obj); IOutputService output = CommonServices.Output; output.AddLine(""); output.AddWarningLine("START Componente conexo " + i.ToString()); ComponenteConexo(obj, visited); output.AddWarningLine("FIN Componente conexo " + i.ToString()); } } }
private static KBObjectCollection CreatLocationCollection(string location) { KBObjectCollection objColl = new KBObjectCollection(); IKBService kB = UIServices.KB; IOutputService output = CommonServices.Output; KBCategory mainCategory = KBCategory.Get(kB.CurrentModel, "Main Programs"); foreach (KBObject obj in mainCategory.AllMembers) { string objLocation = (string)obj.GetProperty("AppLocation").Value; if (objLocation == "") { obj.SilentSetPropertyValue("AppLocation", "WEB"); } string objAppGenerator = obj.GetPropertyValueString("AppGenerator"); string Dircopia; if (objAppGenerator.ToUpper().Contains("WEB")) { Dircopia = "Web\\bin\\"; } else { Dircopia = "bin\\"; } if (objLocation == null) { objLocation = "none"; } string letra = ""; if (location == objLocation) { output.AddLine("set DESTINO=" + objLocation); output.AddLine("XCOPY " + Dircopia + obj.Name + ".dll %DESTINO%"); if (obj is Procedure) { letra = "a"; } if (obj is WorkPanel) { letra = "u"; } if (obj is Transaction) { letra = ""; } output.AddLine("XCOPY " + Dircopia + letra + obj.Name + ".dll %DESTINO%"); AddReferencedObj(objColl, obj, ""); } } return(objColl); }
private static void AddLineKBInterfazSource(KBDoctorXMLWriter writer, KBObject obj, string texto, string tipo, string sourceWOComments, string mainss) { string callTree = ""; KBObjectCollection objColl = new KBObjectCollection(); if (sourceWOComments.Contains(texto)) { writer.AddTableData(new string[] { Functions.linkObject(obj), "", "CMD." + texto, mainss }); } }
public static void AddObjectsReferenceTo(KBObject obj, KBObjectCollection objToBuild, KBDoctorXMLWriter writer) { foreach (EntityReference refe in obj.GetReferencesTo()) { KBObject objRef = KBObject.Get(obj.Model, refe.From); if (objRef != null && KBObjectHelper.IsSpecifiable(objRef) && !objToBuild.Contains(objRef) && KBDoctorCore.Sources.Utility.isGenerated(objRef)) { objToBuild.Add(objRef); writer.AddTableData(new string[] { objRef.QualifiedName.ToString(), objRef.Description, obj.QualifiedName.ToString() + " (" + obj.TypeDescriptor.Name + ")" }); } } }
private static void MarkReachables(IOutputService output, KBObject obj, KBObjectCollection reachablesObjects) { reachablesObjects.Add(obj); foreach (EntityReference reference in obj.GetReferences(LinkType.UsedObject)) { KBObject objRef = KBObject.Get(obj.Model, reference.To); if ((objRef != null) && !reachablesObjects.Contains(objRef)) { MarkReachables(output, objRef, reachablesObjects); } } }
private static void ComponenteConexo(KBObject obj, KBObjectCollection visited) { foreach (EntityReference r in obj.GetReferencesTo()) { KBObject objRef = KBObject.Get(obj.Model, r.From); VisitNode(visited, obj, objRef); } foreach (EntityReference r in obj.GetReferences()) { KBObject objRef = KBObject.Get(obj.Model, r.To); VisitNode(visited, obj, objRef); } }
private static void VisitNode(KBObjectCollection visited, KBObject obj, KBObject objRef) { IOutputService output = CommonServices.Output; if (isNode(objRef)) { output.AddLine(NombreNodo(obj) + ";" + NombreNodo(objRef)); if (!visited.Contains(objRef)) { visited.Add(objRef); ComponenteConexo(objRef, visited); } } }
public static void BuildModule() { IKBService kbserv = UIServices.KB; KBModel kbModel = UIServices.KB.CurrentModel; IOutputService output = CommonServices.Output; bool success = true; string title = "KBDoctor - Build Module"; output.StartSection(title); string outputFile = Functions.CreateOutputFile(kbserv, title); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); writer.AddHeader(title); writer.AddTableHeader(new string[] { "Object", "Description", "Visibility" }); KBObjectCollection objToBuild = new KBObjectCollection(); SelectObjectOptions selectObjectOption = new SelectObjectOptions(); selectObjectOption.MultipleSelection = true; selectObjectOption.ObjectTypes.Add(KBObjectDescriptor.Get <Module>()); foreach (Module mdl in UIServices.SelectObjectDialog.SelectObjects(selectObjectOption)) { foreach (KBObject o in CreateListObjectsModuleAndReferences(kbModel, mdl, writer)) { objToBuild.Add(o); } } writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); GenexusUIServices.Build.BuildWithTheseOnly(objToBuild.Keys); do { Application.DoEvents(); } while (GenexusUIServices.Build.IsBuilding); output.EndSection("KBDoctor", true); }
private static bool ValidateParms(KBObject obj) { bool result = true; // Object with parm() rule without in: out: or inout: IKBService kbserv = UIServices.KB; ICallableObject callableObject = obj as ICallableObject; if (callableObject != null) { foreach (Signature signature in callableObject.GetSignatures()) { Boolean someInOut = false; foreach (Parameter parm in signature.Parameters) { if (parm.Accessor.ToString() == "PARM_INOUT") { someInOut = true; break; } } if (someInOut) { string ruleParm = Functions.ExtractRuleParm(obj); if (ruleParm != "") { int countparms = ruleParm.Split(new char[] { ',' }).Length; int countsemicolon = ruleParm.Split(new char[] { ':' }).Length - 1; if (countparms != countsemicolon) { string objNameLink = Functions.LinkObject(obj); KBObjectCollection objColl = new KBObjectCollection(); result = false; } } } } } return(result); }
public static void List2(KBObject obj, string objLocation, Dictionary <string, KBObjectCollection> dic, KBDoctorXMLWriter writer) { string objMasterPage = obj.GetPropertyValueString("MasterPage"); writer.AddTableData(new string[] { obj.TypeDescriptor.Name, Functions.linkObject(obj), objLocation, objMasterPage }); if (ObjectsHelper.IsCallalable(obj)) { foreach (EntityReference reference in obj.GetReferences()) { KBObject objRef = KBObject.Get(obj.Model, reference.To); string typeDescriptor = obj.TypeDescriptor.Name; List <string> list = new List <string> { "WebPanel", "Transaction", "WorkPanel" }; if ((objRef != null) && list.Contains(typeDescriptor) && (reference.ReferenceType == ReferenceType.Hard)) { int count = 0; string locations = ""; KBObjectCollection objColl = new KBObjectCollection(); foreach (string loc in dic.Keys) { if ((loc != objLocation) && (list.Contains(objRef.TypeDescriptor.Name))) { dic.TryGetValue(loc, out objColl); if (objColl.Contains(obj)) { locations += " " + loc; count += 1; } } } if (count > 0) { string objRefMasterPage = objRef.GetPropertyValueString("MasterPage"); writer.AddTableData(new string[] { "+-----Called >>" + objRef.TypeDescriptor.Name, Functions.linkObject(objRef), count.ToString() + "-" + locations, objRefMasterPage }); } } } } }
private static KBObjectCollection ObjectsReferencesFromOutside(KBObject obj) { KBObjectCollection objCol = new KBObjectCollection(); string mdlName = ObjectModuleName(obj); foreach (EntityReference refer in obj.GetReferencesTo()) { KBObject objRef = KBObject.Get(obj.Model, refer.From); if (objRef != null && Functions.isRunable(objRef)) { string mdlNameRef = ObjectModuleName(objRef); if (mdlNameRef != mdlName) { if (obj is Table) { objCol.Add(obj); } } } } return(objCol); }
public static string MainsOf(KBObject obj, KBObjectCollection objColl, string callTree) { string mains = ""; if (!objColl.Contains(obj)) { objColl.Add(obj); if (obj.GetPropertyValue <bool>("IsMain")) { string objAppGenerator = obj.GetPropertyValueString("AppGenerator"); if (objAppGenerator.Contains("Java Win") && callTree.Contains("HMaster")) { mains = ""; } else { mains = callTree + "/" + Functions.linkObject(obj) + "(" + objAppGenerator + ")<BR> "; } } else { callTree += obj.Name + "/"; foreach (EntityReference reference in obj.GetReferencesTo()) { KBObject objRef = KBObject.Get(obj.Model, reference.From); if ((objRef != null) && (obj.Name != objRef.Name) && (reference.ReferenceType == ReferenceType.Hard) && reference.LinkType == LinkType.UsedObject /*&& (obj.TypeDescriptor.Name != "MasterPage")*/ && !objColl.Contains(objRef)) { mains += MainsOf(objRef, objColl, callTree); } } } } return(mains); }
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 static void ObjectsWINWEB() { IKBService kbserv = UIServices.KB; KBModel design = kbserv.CurrentModel; SpecificationListHelper helper = new SpecificationListHelper(design.Environment.TargetModel); string title = "KBDoctor - Objects called win y web"; 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[] { "Name", "Value", "Observation" }); foreach (KBObject obj in kbserv.CurrentModel.Objects.GetAll()) { if (obj is Procedure || obj is Transaction) { output.AddLine("Procesing up " + obj.Name); IEnumerable <int> generatorTypes = GetObjectGenerators(obj.Key); string objNamePrior = ""; int count = 0; foreach (int genType in generatorTypes) { count += 1; } if (count > 1) { KBObjectCollection objColl = new KBObjectCollection(); string mainss = ""; output.AddLine("Procesing down " + obj.Name); foreach (EntityReference reference in obj.GetReferences()) { KBObject objRef = KBObject.Get(obj.Model, reference.To); if ((objRef != null) && (objRef is WorkPanel || objRef is WebPanel) && (reference.ReferenceType == ReferenceType.Hard)) //&& (objRef.TypeDescriptor.Name != "MasterPage") ) { if (objNamePrior != obj.Name) { string callTree = ""; mainss = MainsOf(obj, objColl, callTree); } writer.AddTableData(new string[] { Functions.linkObject(obj), Functions.linkObject(objRef), mainss }); objNamePrior = obj.Name; } } } } } writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection(title, success); }
public static void KBInterfaces() { IKBService kbserv = UIServices.KB; KBModel design = kbserv.CurrentModel; SpecificationListHelper helper = new SpecificationListHelper(design.Environment.TargetModel); string outputFile = kbserv.CurrentKB.UserDirectory + @"\kbdoctor.KBInterfaces.html"; if (File.Exists(outputFile)) { File.Delete(outputFile); } string titulo = "KBDoctor - KB Interfaces"; IOutputService output = CommonServices.Output; output.StartSection(titulo); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); writer.AddHeader(titulo); writer.AddTableHeader(new string[] { "Object", "Variable", "Type", "mains" }); foreach (KBObject obj in kbserv.CurrentModel.Objects.GetAll()) { if (obj != null) { output.AddLine("Procesing " + obj.Name); IEnumerable <int> generatorTypes = KbStats.GetObjectGenerators(obj.Key); string objNamePrior = ""; KBObjectCollection objColl = new KBObjectCollection(); string tipo = ""; string mainss = ""; foreach (EntityReference reference in obj.GetReferences()) { KBObject objRef = KBObject.Get(obj.Model, reference.To); if (objRef != null) { if (objRef is ExternalObject) { tipo = "External Object:" + objRef.GetPropertyValueString("ExoType"); writer.AddTableData(new string[] { Functions.linkObject(obj), Functions.linkObject(objRef), tipo, mainss }); } else { if (objRef is MissingKBObject) { tipo = "Missing Object"; writer.AddTableData(new string[] { Functions.linkObject(obj), Functions.linkObject(objRef), tipo, mainss }); } } } } string sourceWOComments = Functions.ExtractComments(Functions.ObjectSourceUpper(obj)); sourceWOComments = sourceWOComments.Replace("\t", " "); AddLineKBInterfazSource(writer, obj, "SHELL ", "CMD.", sourceWOComments, mainss); AddLineKBInterfazSource(writer, obj, "JAVA ", "CMD.", sourceWOComments, mainss); AddLineKBInterfazSource(writer, obj, "CSHARP ", "CMD.", sourceWOComments, mainss); AddLineKBInterfazSource(writer, obj, "SQL ", "CMD.", sourceWOComments, mainss); ObjectsVariablesExternal(obj, writer, mainss); if (obj is Transaction || obj is WebPanel) { UserControlUsageCheck(obj, writer, mainss); } } } writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection(titulo, success); }
public static void ObjectsReferenced() { // Object with parm() rule without in: out: or inout: IKBService kbserv = UIServices.KB; IOutputService output = CommonServices.Output; string title = "KBDoctor - Object referenced by object "; output.StartSection(title); string outputFile = Functions.CreateOutputFile(kbserv, title); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); SelectObjectOptions selectObjectOption = new SelectObjectOptions(); selectObjectOption.MultipleSelection = false; KBModel kbModel = UIServices.KB.CurrentModel; KBObjectCollection objRefCollection = new KBObjectCollection(); foreach (KBObject obj in UIServices.SelectObjectDialog.SelectObjects(selectObjectOption)) { if (obj != null) { title += obj.Name + "-" + obj.Description; writer.AddHeader(title); writer.AddTableHeader(new string[] { "Object", "Description", "Commit on Exit", "Update DB?", "Commit in Source", "Do Commit", "Timestamp", "Last Update" }); MarkReachables(output, obj, objRefCollection); } } string commitOnExit = ""; string commitInSource = ""; string UpdateInsertDelete = ""; string doCommit = ""; foreach (KBObject objRef in objRefCollection) { if (objRef is Procedure) { object aux = objRef.GetPropertyValue("CommitOnExit"); if (aux != null) { commitOnExit = aux.ToString() == "Yes" ? "YES" : " "; } UpdateInsertDelete = ObjectUpdateDB(objRef)?"YES":""; Procedure prc = (Procedure)objRef; if (Functions.ExtractComments(prc.ProcedurePart.Source.ToString().ToUpper()).Contains("COMMIT")) { commitInSource = "YES"; } else { commitInSource = ""; } if (((commitOnExit == "YES") && (UpdateInsertDelete == "YES")) || (commitInSource == "YES")) { doCommit = "YES"; } else { doCommit = ""; } writer.AddTableData(new string[] { Functions.linkObject(objRef), objRef.Description, commitOnExit, UpdateInsertDelete, commitInSource, doCommit, objRef.Timestamp.ToString(), objRef.LastUpdate.ToString() }); } } writer.AddFooter(); writer.Close(); bool success = true; output.EndSection(title, success); KBDoctorHelper.ShowKBDoctorResults(outputFile); }