public static XmlDocument GetObjectNavigationXML(KBObject obj) { XmlDocument doc = new XmlDocument(); IKBService kbserv = UIServices.KB; string fileWildcard = @"" + obj.Name + ".xml"; var searchSubDirsArg = System.IO.SearchOption.AllDirectories; string specpath = Functions.SpcDirectory(kbserv); string[] xFiles = System.IO.Directory.GetFiles(specpath, fileWildcard, searchSubDirsArg); foreach (string x in xFiles) { if (Path.GetFileNameWithoutExtension(x).Equals(obj.Name)) { string xmlstring = NavigationHelper.AddXMLHeader(x); if (!ObjectsHelper.isGeneratedbyPattern(obj)) { doc.LoadXml(xmlstring); } } } return(doc); }
public static void ListObjDiffMasterPage2() { IKBService kbserv = UIServices.KB; Dictionary <string, KBObjectCollection> dic = new Dictionary <string, KBObjectCollection>(); string title = "KBDoctor - Objects"; string outputFile = Functions.CreateOutputFile(kbserv, title); IOutputService output = CommonServices.Output; output.StartSection(title); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); writer.AddHeader(title); output.AddLine("Listing objects..."); writer.AddTableHeader(new string[] { "Tipo", "Object", "Description", "Last Update", "Timestamp" }); foreach (KBObject obj in kbserv.CurrentModel.Objects.GetAll()) { writer.AddTableData(new string[] { obj.TypeDescriptor.Name, obj.Name, obj.Description, obj.LastUpdate.ToString(), obj.Timestamp.ToString() }); } writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection(title, success); }
public static string GetNavigation(KBObject obj) { string specFilePath = GetObjectNavigationFile(obj); //Copy the navigation file to an .xxx file string xmlstring = AddXMLHeader(specFilePath); string tempSpecFilePath = specFilePath.Replace(".xml", ".xxx"); File.WriteAllText(tempSpecFilePath, xmlstring); //Output file IKBService kbserv = UIServices.KB; string navigationPath = Functions.SpcDirectory(kbserv); string navigationFilePath = navigationPath + Path.GetFileNameWithoutExtension(specFilePath) + ".nvg"; XslTransform xsl = NavigationHelper._GetNavigationTemplate(); xsl.Transform(tempSpecFilePath, navigationFilePath); string readText = File.ReadAllText(navigationFilePath); //now clean up all intermediate files File.Delete(tempSpecFilePath); File.Delete(navigationFilePath); return(readText); }
private static void WriteXSLTtoDir() { IKBService kbserv = UIServices.KB; string outputFile = kbserv.CurrentKB.UserDirectory + @"\KBdoctorEv2.xslt"; File.WriteAllText(outputFile, StringResources.specXEv2); }
public static void WriteXSLTtoDir() { IKBService kbserv = UIServices.KB; string outputFile = kbserv.CurrentKB.UserDirectory + @"\NavigationHtmlToText.xslt"; File.WriteAllText(outputFile, Resources.NavigationHTMLToText); }
public static void RemoveAttributeWithoutTable() { IKBService kbserv = UIServices.KB; string title = "KBDoctor - Remove attributes without table"; string outputFile = Functions.CreateOutputFile(kbserv, title); IOutputService output = CommonServices.Output; output.StartSection(title); List <string[]> lineswriter; KBDoctorCore.Sources.API.RemoveAttributesWithoutTable(kbserv.CurrentModel, output, out lineswriter); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); writer.AddHeader(title); writer.AddTableHeader(new string[] { "", "Attribute", "Description", "Data type" }); foreach (string[] line in lineswriter) { writer.AddTableData(line); } writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection(title, success); }
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()); } } }
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); }
public static void ProcesoDirNavigations(string directoryArg, IOutputService output, TextWriter writer2) { IKBService kbserv = UIServices.KB; string fileWildcard = @"*.xml"; var searchSubDirsArg = System.IO.SearchOption.AllDirectories; string[] xFiles = System.IO.Directory.GetFiles(directoryArg, fileWildcard, searchSubDirsArg); int numFiles = 0; foreach (string x in xFiles) { if (!Path.GetFileNameWithoutExtension(x).StartsWith("Gx0")) { if ((numFiles % 200) == 0) { output.AddLine(x); } numFiles += 1; string xmlstring = AddXMLHeader(x); KBObject obj = ExtractObject(xmlstring); if (!ObjectsHelper.isGeneratedbyPattern(obj)) { ProcesoNavigation(xmlstring, output, writer2, obj); } } } }
public static void ProcesoDir(string directoryArg, string newDir, string generator, IOutputService output) { IKBService kbserv = UIServices.KB; string outputFile = kbserv.CurrentKB.UserDirectory + @"\KBdoctorEv2.xslt"; XslTransform xslTransform = new XslTransform(); xslTransform.Load(outputFile); string fileWildcard = @"*.xml"; var searchSubDirsArg = System.IO.SearchOption.AllDirectories; string[] xFiles = System.IO.Directory.GetFiles(directoryArg, fileWildcard, searchSubDirsArg); foreach (string x in xFiles) { if (!Path.GetFileNameWithoutExtension(x).StartsWith("Gx0")) { output.AddLine(x); string xTxt = newDir + generator + Path.GetFileNameWithoutExtension(x) + ".nvg"; string xmlstring = AddXMLHeader(x); string newXmlFile = x.Replace(".xml", ".xxx"); File.WriteAllText(newXmlFile, xmlstring); xslTransform.Transform(newXmlFile, xTxt); // xslt.Transform(newXmlFile, xTxt); File.Delete(newXmlFile); } } }
public static void ObjectsVariablesExternal(KBObject obj, KBDoctorXMLWriter writer, string mainss) { IKBService kbserv = UIServices.KB; string type = ""; string name = ""; string variables = ""; if (KBDoctorCore.Sources.Utility.isGenerated(obj)) { VariablesPart vp = obj.Parts.Get <VariablesPart>(); if (vp != null) { foreach (Variable v in vp.Variables) { type = v.Type.ToString(); name = v.Name; if ((!v.IsStandard) && (v.AttributeBasedOn == null) && (type == "GX_USRDEFTYP")) //|| (type==) || (type == "GX_BUSCOMP_LEVEL") ) { variables += name + " " + type + " "; string txtDimensions = v.GetPropertyValue <string>(Properties.ATT.DataTypeString); writer.AddTableData(new string[] { Functions.linkObject(obj), name, "Data Type." + txtDimensions, mainss }); } } } } }
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); } } } }
public static void GenerateGraph() { IKBService kbserv = UIServices.KB; string title = "KBDoctor - Generate Graph "; string outputFile = Functions.CreateOutputFile(kbserv, title); KBModel model = kbserv.CurrentKB.DesignModel; int ATTNAME_LEN = model.GetPropertyValue <int>("ATTNAME_LEN"); int TBLNAME_LEN = model.GetPropertyValue <int>("TBLNAME_LEN"); int OBJNAME_LEN = model.GetPropertyValue <int>("OBJNAME_LEN"); IOutputService output = CommonServices.Output; output.StartSection(title); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); writer.AddHeader(title); writer.AddTableHeader(new string[] { "Check", "File" }); string Check = ""; string Name = ""; string FileName = ""; /* * Check = "KB Table Graph"; * Name = Functions.CleanFileName(Check); * FileName = kbserv.CurrentKB.UserDirectory + @"\kbdoctor." + Name + ".gexf"; * GenerateKBTableGraph(Name, FileName); * writer.AddTableData(new string[] { Check, Functions.linkFile(FileName) }); * * Check = "KB Object Graph"; * Name = Functions.CleanFileName(Check); * FileName = kbserv.CurrentKB.UserDirectory + @"\kbdoctor." + Name + ".gexf"; * GenerateKBObjectGraph(Name, FileName); * writer.AddTableData(new string[] { Check, Functions.linkFile(FileName) }); */ Check = "KB Object Edges txt"; Name = Functions.CleanFileName(Check); FileName = kbserv.CurrentKB.UserDirectory + @"\kbdoctor." + Name + ".txt"; GenerateKBObjectEdgesTxt(Name, FileName); writer.AddTableData(new string[] { Check, Functions.linkFile(FileName) }); /* * Check = "KB Module Graph"; * Name = Functions.CleanFileName(Check); * FileName = kbserv.CurrentKB.UserDirectory + @"\kbdoctor." + Name + ".gexf"; * GenerateKBModuleGraph(Name, FileName); * writer.AddTableData(new string[] { Check, Functions.linkFile(FileName) }); */ writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection(title, success); }
public static void LoadAndCheckUsedClasses(IKBService kbserv, IOutputService output, StringCollection UsedClasses, StringCollection ThemeClasses, KBDoctorXMLWriter writer) { int cant = 0; foreach (KBObject obj in kbserv.CurrentModel.Objects.GetAll()) { if ((cant % 100) == 0) { KBDoctorOutput.Message("Procesing.." + cant.ToString() + " objects "); } cant += 1; if (((obj is Transaction) || (obj is WebPanel)) && (obj.GetPropertyValue <bool>(Properties.TRN.GenerateObject))) { WebFormPart webForm = obj.Parts.Get <WebFormPart>(); foreach (IWebTag tag in WebFormHelper.EnumerateWebTag(webForm)) { if (tag.Properties != null) { PropertyDescriptor prop = tag.Properties.GetPropertyDescriptorByDisplayName("Class"); if (prop != null) { //arreglar acan cancela con la Evo3. ThemeClassReferenceList miclasslist = new ThemeClassReferenceList(); // try // { // miclasslist = (ThemeClassReferenceList)prop.GetValue(new object()); // } // catch (Exception e) { // KBDoctorOutput.Error("LoadAndCheckUsedClasses:" + e.Message + " " + e.InnerException); // throw e; // }; foreach (ThemeClass miclass in miclasslist.GetThemeClasses(obj.Model)) { if (miclass != null) { string miclstr = miclass.Name.ToLower(); if (!UsedClasses.Contains(miclstr)) { UsedClasses.Add(miclstr); } if (!ThemeClasses.Contains(miclstr)) { bool classEstaEnElTheme = VeoSiClassEstaContenidaEnAlgunaClassDelTheme(ThemeClasses, miclstr); if (!classEstaEnElTheme) { string objName = obj.Name; KBDoctorOutput.Message(" Object : " + obj.Name + " reference class " + miclstr + " which not exist in Theme"); string objNameLink = Functions.linkObject(obj); writer.AddTableData(new string[] { objNameLink, miclstr, " does not exist in theme" }); } } } } } } } } } }
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); }
public bool ExecPrepareComparerNavigation(CommandData cmdData) { IKBService kbserv = UIServices.KB; IOutputService output = CommonServices.Output; KBDoctorCore.Sources.API.PrepareCompareNavigations(kbserv.CurrentKB, output); return(true); }
internal static void RenameVariables() { IKBService kbserv = UIServices.KB; string title = "KBDoctor - Object with variables not based on attribute/domain"; try { string outputFile = Functions.CreateOutputFile(kbserv, title); IOutputService output = CommonServices.Output; output.StartSection("KBDoctor", title); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); writer.AddHeader(title); writer.AddTableHeader(new string[] { "Type", "Name", "Variable", "Attribute", "Domain" }); Domain dom = Functions.DomainByName("Fecha"); //All useful objects are added to a collection foreach (KBObject obj in kbserv.CurrentModel.Objects.GetAll()) { KBDoctorOutput.Message("Procesing.... " + obj.Name + " - " + obj.Type.ToString()); Boolean SaveObj = false; if (Utility.isGenerated(obj) && !ObjectsHelper.isGeneratedbyPattern(obj) && (obj is Transaction || obj is WebPanel || obj is WorkPanel)) { Functions.AddLine("RenameVariables.txt", "##" + obj.Name); List <Variable> lstVariables = VariablesToRename(obj); } } string inputFile = kbserv.CurrentKB.UserDirectory + @"\RenameVariables.txt"; // Input List <String> data = File.ReadAllLines(inputFile).Distinct(StringComparer.CurrentCultureIgnoreCase).ToList(); // Processing data.Sort(); // Output string outputFile2 = kbserv.CurrentKB.UserDirectory + @"\RenameVariables2.txt"; File.WriteAllLines(outputFile2, data.ToArray()); writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection("KBDoctor", title, success); } catch { bool success = false; KBDoctor.KBDoctorOutput.EndSection(title, success); } }
public static void ReplaceDomain() { IKBService kbserv = UIServices.KB; bool success = true; string title = "KBDoctor - Replace domain "; IOutputService output = CommonServices.Output; ReplaceDomain rd = new ReplaceDomain(); DialogResult dr = new DialogResult(); dr = rd.ShowDialog(); if (dr == DialogResult.OK) { output.StartSection(title); Domain od = Functions.DomainByName(rd.originalDomainName); Domain ud = Functions.DomainByName(rd.destDomainName); if (od != null && ud != null) { foreach (EntityReference reference in od.GetReferencesTo()) // LinkType.UsedObject)) { KBObject objRef = KBObject.Get(UIServices.KB.CurrentModel, reference.From); output.AddLine("Procesing " + objRef.Name); if (objRef is Artech.Genexus.Common.Objects.Attribute) { Artech.Genexus.Common.Objects.Attribute att = (Artech.Genexus.Common.Objects.Attribute)objRef; att.DomainBasedOn = ud; att.Save(); } else { VariablesPart vp = objRef.Parts.Get <VariablesPart>(); if (vp != null) { foreach (Variable v in vp.Variables) { if (v.DomainBasedOn == od && !v.IsStandard) { v.DomainBasedOn = ud; } } objRef.Save(); } else { output.AddLine("Replace " + od.Name + " domain manually in object " + objRef.Name); success = false; } } } } output.EndSection(title, success); } }
public static void ClassNotInTheme() { IKBService kbserv = UIServices.KB; string title = "KBDoctor - Class not in Theme"; 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[] { "Object", "Class", "Error" }); //Cargo todas las clases de todos los theme de la KB. StringCollection ThemeClasses = new StringCollection(); LoadThemeClasses(kbserv, output, ThemeClasses); StringCollection UsedClasses = new StringCollection(); //Reviso todos los objeto para ver las class usadas en cada control LoadAndCheckUsedClasses(kbserv, output, UsedClasses, ThemeClasses, writer); foreach (string sd in UsedClasses) { if (!ThemeClasses.Contains(sd)) { writer.AddTableData(new string[] { "", sd, "Application Class not in theme" }); output.AddLine("Application Class not in theme " + sd); } else { ThemeClasses.Remove(sd); } } writer.AddTableData(new string[] { "-----------------", "--------------", "---" }); foreach (string ss in ThemeClasses) { if (!UsedClasses.Contains(ss)) { writer.AddTableData(new string[] { "", ss, "Class not referenced" }); output.AddLine("Class not referenced in application " + ss); } } writer.AddTableData(new string[] { "-------", "-----------------", "--------------" }); writer.AddFooter(); writer.Close(); output.EndSection(title, true); KBDoctorHelper.ShowKBDoctorResults(outputFile); }
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); }
public static void ListLastReports() { IKBService kbserv = UIServices.KB; Dictionary <string, KBObjectCollection> dic = new Dictionary <string, KBObjectCollection>(); string title = "KBDoctor - List last Reports"; 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[] { "Report", "", "Date Generated" }); string[] fileEntries = Directory.GetFiles(kbserv.CurrentKB.UserDirectory, "kbdoctor*.html"); foreach (string fileName in fileEntries) { string dateFilename = ""; int days = (int)(DateTime.Now - File.GetLastWriteTime(fileName)).TotalDays; int hours = (int)(DateTime.Now - File.GetLastWriteTime(fileName)).TotalHours; int mins = (int)(DateTime.Now - File.GetLastWriteTime(fileName)).TotalMinutes; if (days > 0) { dateFilename = days.ToString() + " day(s) ago"; } else if (hours > 0) { dateFilename = hours.ToString() + " hour(s) ago"; } else { dateFilename = mins.ToString() + " minutes(s) ago"; } string shortFilename = Path.GetFileName(fileName); shortFilename = shortFilename.Replace("kbdoctor.", ""); shortFilename = shortFilename.Replace(".html", ""); shortFilename = Regex.Replace(shortFilename, "(\\B[A-Z])", " $1"); string fileLink = "<a href=\"file:///" + fileName + "\">" + shortFilename + "</a>"; writer.AddTableData(new string[] { fileLink, dateFilename, File.GetLastWriteTime(fileName).ToString() }); } writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection(title, success); }
public static void ListObjWarningsErrors() { IKBService kbserv = UIServices.KB; List <string> objWarnErr = new List <string>(); string title = "KBDoctor - Warnings and Errors"; try { string outputFile = Functions.CreateOutputFile(kbserv, title); IOutputService output = CommonServices.Output; output.StartSection("KBDoctor", title); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); writer.AddHeader(title); GxModel gxModel = kbserv.CurrentKB.DesignModel.Environment.TargetModel.GetAs <GxModel>(); var fileWildcardsArg = new[] { "*.xml" }; var directoryArg = KBDoctorHelper.SpcDirectory(kbserv); var searchSubDirsArg = System.IO.SearchOption.AllDirectories; var ignoreCaseArg = true; writer.AddTableHeader(new string[] { "Error Type", "ObjClass", "Object", "Description", "UserName", "Observation" }); SearchNVGFiles(output, writer, fileWildcardsArg, directoryArg, searchSubDirsArg, "<Error>", ignoreCaseArg, objWarnErr); SearchNVGFiles(output, writer, fileWildcardsArg, directoryArg, searchSubDirsArg, "deprecated", ignoreCaseArg, objWarnErr); SearchNVGFiles(output, writer, fileWildcardsArg, directoryArg, searchSubDirsArg, "<Warning>", ignoreCaseArg, objWarnErr); SearchNVGFiles(output, writer, fileWildcardsArg, directoryArg, searchSubDirsArg, "<Icon>client<", ignoreCaseArg, objWarnErr); SearchNVGFiles(output, writer, fileWildcardsArg, directoryArg, searchSubDirsArg, "<JoinLocation>0</JoinLocation>", ignoreCaseArg, objWarnErr); writer.AddFooter(); //agrego lista de objetos para que sea facil hacerle un BUILD WITH THIS ONLY string lstObjWarn = ""; string puntoycoma = ""; foreach (string objstr in objWarnErr) { lstObjWarn += puntoycoma + Path.GetFileNameWithoutExtension(objstr); puntoycoma = ";"; } writer.AddTableData(new string[] { lstObjWarn }); writer.AddTableData(new string[] { " " + objWarnErr.Count.ToString() }); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection("KBDoctor", title, success); } catch { bool success = false; KBDoctor.KBDoctorOutput.EndSection(title, success); } }
public static void ListMainObj() { IKBService kbserv = UIServices.KB; Dictionary <string, KBObjectCollection> dic = new Dictionary <string, KBObjectCollection>(); string title = "KBDoctor - Main Objects"; try { string outputFile = Functions.CreateOutputFile(kbserv, title); IOutputService output = CommonServices.Output; output.StartSection("KBDoctor", title); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); writer.AddHeader(title); writer.AddTableHeader(new string[] { "Type", "Object", "Description", "Module", "Public", "Generator", "Protocol", "Last Update" }); KBCategory mainCategory = Functions.MainCategory(kbserv.CurrentModel); foreach (KBObject obj in mainCategory.AllMembers) { if (obj != null) { string desc = obj.Description.Replace(",", " "); desc = desc.Replace(">", ""); desc = desc.Replace("<", ""); string objAppGenerator = obj.GetPropertyValueString("AppGenerator"); string objProtocol = obj.GetPropertyValueString("CALL_PROTOCOL"); string isGenerated = KBDoctorCore.Sources.Utility.isGenerated(obj) ? "Yes" : ""; writer.AddTableData(new string[] { obj.TypeDescriptor.Name + " ", Functions.linkObject(obj), desc, obj.Module.Name, obj.IsPublic.ToString(), objAppGenerator, objProtocol, obj.LastUpdate.ToShortDateString() }); KBDoctorOutput.Message(obj.TypeDescriptor.Name + "," + obj.Name + "," + obj.Description); //+ "," + obj.Timestamp.ToString()); } } writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection("KBDoctor", title, success); } catch { bool success = false; KBDoctor.KBDoctorOutput.EndSection(title, success); } }
private static XslTransform _GetNavigationTemplate() { IKBService kbserv = UIServices.KB; string outputFile = kbserv.CurrentKB.UserDirectory + @"\NavigationHtmlToText.xslt"; XslTransform xsl = new XslTransform(); xsl.Load(outputFile); return(xsl); }
public static void ListProc() { IKBService kbserv = UIServices.KB; Dictionary <string, KBObjectCollection> dic = new Dictionary <string, KBObjectCollection>(); string title = "KBDoctor - Procedure"; try { string outputFile = Functions.CreateOutputFile(kbserv, title); KBModel kbmodel = kbserv.CurrentModel; IOutputService output = CommonServices.Output; output.StartSection("KBDoctor", title); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); writer.AddHeader(title); writer.AddTableHeader(new string[] { "Type", "Object", "Commit ", "Module", "Public", "Generator", "Protocol", "Last Update" }); string commitOnExit = ""; foreach (KBObject obj in kbmodel.Objects.GetAll()) { commitOnExit = ""; if (obj is Procedure) { if (obj.VersionDate >= DateTime.Now.AddDays(-45)) { object aux = obj.GetPropertyValue("CommitOnExit"); if (aux != null) { commitOnExit = aux.ToString(); } } writer.AddTableData(new string[] { obj.TypeDescriptor.Name + " ", Functions.linkObject(obj), commitOnExit, obj.Module.Name, obj.IsPublic.ToString(), "", "", obj.LastUpdate.ToShortDateString() }); KBDoctorOutput.Message(obj.TypeDescriptor.Name + "," + obj.Name + "," + obj.Description); //+ "," + obj.Timestamp.ToString()); } } writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection("KBDoctor", title, success); } catch { bool success = false; KBDoctor.KBDoctorOutput.EndSection(title, success); } }
/// <summary> /// Crea un procedure con todos los SDT seleccionados por el usuario. /// </summary> public static void CreateProcedureSDT() { IKBService kB = UIServices.KB; if (kB != null && kB.CurrentModel != null) { SelectObjectOptions selectObjectOption = new SelectObjectOptions(); selectObjectOption.MultipleSelection = true; KBModel kbModel = UIServices.KB.CurrentModel; Artech.Genexus.Common.Objects.Procedure proc = new Artech.Genexus.Common.Objects.Procedure(kbModel); string procName = "SDTForceGenerate"; proc.Name = procName; proc.ProcedurePart.Source = "// Generated by KBDoctor, to generate SDT source"; proc.SetPropertyValue("IsMain", true); proc.Save(); //MUESTRO LOS SDT A REGENERAR selectObjectOption.ObjectTypes.Add(KBObjectDescriptor.Get <SDT>()); foreach (KBObject kBObject in UIServices.SelectObjectDialog.SelectObjects(selectObjectOption)) { SDT sdtObj = (SDT)kBObject; CodeGeneration.AddSDTVariable(kbModel, proc, sdtObj); Application.DoEvents(); } proc.Save(); //Para cada uno de los generadores del environment, genero el proc con los SDT. GxModel gm = UIServices.KB.WorkingEnvironment.TargetModel.GetAs <GxModel>(); foreach (var gen in gm.Environments) { int generator = gen.Generator; KBObject copy = BLServices.KnowledgeManager.Clone(proc); copy.Name = procName + "_" + generator.ToString(); copy.SetPropertyValue(Artech.Genexus.Common.Properties.TRN.Generator, new EnvironmentCategoryReference { Definition = gen }); UIServices.Objects.Save(copy); GenexusUIServices.Build.Rebuild(copy.Key); do { Application.DoEvents(); } while (GenexusUIServices.Build.IsBuilding); copy.Delete(); } proc.Delete(); } }
private static void GenerateSILFile(string name, string fileName) { IKBService kbserv = UIServices.KB; KBModel model = kbserv.CurrentModel; StreamWriter scriptFile = new StreamWriter(fileName); Dictionary <string, HashSet <string> > dic = new Dictionary <string, HashSet <string> >(); KBDoctorOutput.Message("Generating " + name); string[] modulosGeneXus = new string[] { "Client", "Common", "SD", "Server", "Social", "Configuration", "Notifications" , "UI", "iOS", "Media", "Notifications", "Store", "Synchronization" }; foreach (KBObject obj in model.Objects.GetAll()) { string objName = obj.Name; string nombrenodo = NombreNodoMinimized(obj); string mdlObjName = ModulesHelper.ObjectModuleName(obj); if (!modulosGeneXus.Contains(mdlObjName)) { if (mdlObjName != null && IncludedInGraph(obj)) { if (!dic.ContainsKey(mdlObjName)) { HashSet <string> set = new HashSet <string>(new List <string> { nombrenodo }); dic.Add(mdlObjName, set); } else { dic[mdlObjName].Add(nombrenodo); } } } } foreach (string mdl in dic.Keys) { string modulename = mdl; string nodos = ""; string vacioOcoma = " "; foreach (string objname in dic[mdl]) { nodos += vacioOcoma + objname; vacioOcoma = ", "; } if (nodos != "") { scriptFile.WriteLine("SS(" + modulename + ".ss) = " + nodos); } } scriptFile.Close(); }
private static void _WriteJScripttoDir() { IKBService kbserv = UIServices.KB; string outputFile = kbserv.CurrentKB.UserDirectory + @"\jquery_latest.js"; //File.WriteAllText(outputFile, StringResources.jquery_latest); outputFile = kbserv.CurrentKB.UserDirectory + @"\jquery_tablesorter.js"; // File.WriteAllText(outputFile, StringResources.jquery_tablesorter); }
// This is where you implement whatever you want to do // when this command is invoked public bool ExecGeneraWebxmlCommand(CommandData cmdData) { DateTime inicio = DateTime.Now; IKBService kbserv = UIServices.KB; if (kbserv != null && kbserv.CurrentKB != null) { try { SaveFileDialog SFD = new SaveFileDialog(); SFD.Filter = "web.xml file (web.xml)|"; SFD.FileName = "web.xml"; DialogResult Res = SFD.ShowDialog(); if (Res == DialogResult.OK) { string filename = SFD.FileName; if (!filename.ToLower().EndsWith("xml")) { filename = filename + ".xml"; } string xml = "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n" + "<web-app xmlns:xsi=\"http://www.w3.org/2001/XMLSchema-instance\" " + "xmlns=\"http://java.sun.com/xml/ns/javaee\" " + "xmlns:web=\"http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd\" " + "xsi:schemaLocation=\"http://java.sun.com/xml/ns/j2ee http://java.sun.com/xml/ns/j2ee/web-app_2_4.xsd\" " + "version=\"2.4\">\n" + "<listener><listener-class>com.genexus.webpanels.ServletEventListener</listener-class></listener>\n" + "<listener><listener-class>com.genexus.webpanels.SessionEventListener</listener-class></listener>\n"; KBModel model = kbserv.CurrentKB.WorkingEnvironment.DesignModel; string servletTemplate = "<servlet-mapping><servlet-name>{objName}</servlet-name><url-pattern>/{objName}</url-pattern> </servlet-mapping> \n" + "<servlet> <servlet-name>{objName}</servlet-name><servlet-class>{objName}</servlet-class> </servlet>\n"; foreach (KBObject obj in Transaction.GetAll(model)) { string servlet = servletTemplate.Replace("{objName}", obj.Name); xml += servlet; } foreach (KBObject obj in WebPanel.GetAll(model)) { string servlet = servletTemplate.Replace("{objName}", obj.Name); xml += servlet; } xml += "</web-app>"; File.WriteAllText(filename, xml); MessageBox.Show("Archivo generado en " + SFD.FileName); } } catch (Exception e) { MessageBox.Show(e.Message, "Error while exporting the KB"); } } return(true); }
public static void RecomendedModule() { IKBService kbserv = UIServices.KB; Dictionary <string, KBObjectCollection> dic = new Dictionary <string, KBObjectCollection>(); string title = "KBDoctor - Recomended module"; string outputFile = Functions.CreateOutputFile(kbserv, title); IOutputService output = CommonServices.Output; output.StartSection(title); string sw = ""; KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); writer.AddHeader(title); int numObj = 0; writer.AddTableHeader(new string[] { "Type", "Object", "Module", "List of modules" }); 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)) { foreach (KBObject obj in module.GetAllMembers()) { if (Functions.hasModule(obj)) { output.AddLine(obj.Name); string moduleListString = ""; foreach (Module mod in ListModulesOfReferencedTables(obj)) { moduleListString += mod.Name + " "; } if (obj.Module.Name != moduleListString.Trim() && moduleListString.Trim() != "") { writer.AddTableData(new string[] { obj.TypeDescriptor.Name + " ", Functions.linkObject(obj), obj.Module.Name, moduleListString }); } } } } writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection(title, success); }