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 PrepareComparerNavigation() { string title = "KBDoctor - Prepare Comparer Navigation Files"; IOutputService output = CommonServices.Output; output.StartSection(title); Stopwatch stopWatch = new Stopwatch(); stopWatch.Start(); IKBService kbserv = UIServices.KB; string directoryArg = KBDoctorHelper.NvgComparerDirectory(kbserv); string fechahora = String.Format("{0:yyyy-MM-dd-HHmm}", DateTime.Now); string newDir = directoryArg + @"\NVG-" + fechahora + @"\"; Directory.CreateDirectory(newDir); WriteXSLTtoDir(); foreach (string d in Directory.GetDirectories(KBDoctorHelper.SpcDirectory(kbserv), "NVG", System.IO.SearchOption.AllDirectories)) { string generator = d.Replace(KBDoctorHelper.SpcDirectory(kbserv), ""); generator = generator.Replace("NVG_", ""); generator = @"\" + generator.Replace(@"\", "_") + "_"; generator = generator.Replace("NVG_", ""); ProcesoDir(d, newDir, generator, output); } stopWatch.Stop(); // Get the elapsed time as a TimeSpan value. TimeSpan ts = stopWatch.Elapsed; // Format and display the TimeSpan value. string elapsedTime = String.Format("{0:00}:{1:00}:{2:00}.{3:00}", ts.Hours, ts.Minutes, ts.Seconds, ts.Milliseconds / 10); output.AddLine(title + " elepsed time: " + elapsedTime); output.EndSection(title, true); }
public static void AttUpdated() { IKBService kbserv = UIServices.KB; string title = "KBDoctor - Where update this attribute? :"; string outputFile = Functions.CreateOutputFile(kbserv, title); IOutputService output = CommonServices.Output; output.StartSection(title); AskAttributeandTable at = new AskAttributeandTable(); DialogResult dr = new DialogResult(); dr = at.ShowDialog(); if (dr == DialogResult.OK) { string tblName = at.tblName; string attName = at.attName; List <string> Objlist = new List <string>(); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); writer.AddHeader(title + attName + " in table " + tblName); writer.AddTableHeader(new string[] { "Object", "Description", "Type", "Navigation File" }); int IndFiles = 0; // IKBService kbserv = UIServices.KB; string directoryArg = KBDoctorHelper.SpcDirectory(kbserv); string fileWildcard = @"*.xml"; var searchSubDirsArg = System.IO.SearchOption.AllDirectories; string[] xFiles = System.IO.Directory.GetFiles(directoryArg, fileWildcard, searchSubDirsArg); foreach (string x in xFiles) { // output.AddLine(x); IndFiles += 1; if (IndFiles % 100 == 0) { output.AddLine(" Procesing " + IndFiles.ToString() + " navigation files."); } string filename = Path.GetFileNameWithoutExtension(x); if (!Objlist.Contains(filename)) { Objlist.Add(filename); if (!Path.GetFileNameWithoutExtension(x).StartsWith("Gx0")) { string xmlstring = AddXMLHeader(x); if (ObjectUpdateTable(xmlstring, tblName, attName)) { KBObject obj = ExtractObject(xmlstring); if (obj == null) { writer.AddTableData(new string[] { "Can't find object", "", "", x }); } else if (KBDoctorCore.Sources.Utility.isGenerated(obj) || obj.GetPropertyValue <bool>("idISBUSINESSCOMPONENT")) { writer.AddTableData(new string[] { Functions.linkObject(obj), obj.Description, obj.TypeDescriptor.Name, x }); } } } } } writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection(title, success); } }
public static void ListObjSimilarNavigation() { IKBService kbserv = UIServices.KB; List <string> objWarnErr = new List <string>(); string title = "KBDoctor - Similar Navigations"; string outputFile = Functions.CreateOutputFile(kbserv, title); IOutputService output = CommonServices.Output; output.StartSection(title); KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8); string path2 = kbserv.CurrentKB.UserDirectory + "Navigation.txt"; try { File.Delete(path2); } catch (Exception e) {}; Stream stream = File.Open(path2, FileMode.OpenOrCreate, FileAccess.Write); TextWriter writer2 = new StreamWriter(stream); writer.AddHeader(title); GxModel gxModel = kbserv.CurrentKB.DesignModel.Environment.TargetModel.GetAs <GxModel>(); var fileWildcardsArg = new[] { "*.xml" }; var directoryArg = KBDoctorHelper.SpcDirectory(kbserv); writer.AddTableHeader(new string[] { "Type", "Tables", "Attributes", "Object/Line/Event" }); foreach (string d in Directory.GetDirectories(directoryArg, "NVG", System.IO.SearchOption.AllDirectories)) { ProcesoDirNavigations(d, output, writer2); } writer2.Close(); // string inFile = @"Navigation.txt"; string outFile = kbserv.CurrentKB.UserDirectory + @"NavigationOrdered.csv"; var contents = File.ReadAllLines(path2); //string[] q = contents.Distinct().ToArray(); Array.Sort(contents); File.WriteAllLines(outFile, contents); string clave = ""; string objetos = ""; string objeto = ""; string objetosAnterior = ""; int numObj = 1; string claveanterior = ""; string tableanterior = ""; string attanterior = ""; string LevelTypeanterior = ""; TextFieldParser parser = new TextFieldParser(outFile); parser.TextFieldType = FieldType.Delimited; parser.SetDelimiters(","); while (!parser.EndOfData) { //Process row string[] fields = parser.ReadFields(); string LevelType = fields[0].Replace(" ", "_"); string Tables = fields[1]; string Atts = fields[2]; string ObjLink = fields[3]; string ObjEvent = fields[4]; string ObjLine = fields[5]; clave = LevelType + Tables + Atts; objeto = ObjLink + " / " + ObjLine + " / " + ObjEvent + "<BR>"; if (clave == claveanterior) { if (!objetos.Contains(objeto)) { objetos += objeto; numObj += 1; } } else { if (numObj > 1) { writer.AddTableData(new string[] { LevelTypeanterior, tableanterior, attanterior, objetosAnterior }); } objetos = objeto; numObj = 1; } claveanterior = clave; tableanterior = Tables; attanterior = Atts; LevelTypeanterior = LevelType; objetosAnterior = objetos; } parser.Close(); writer.AddFooter(); writer.Close(); KBDoctorHelper.ShowKBDoctorResults(outputFile); bool success = true; output.EndSection(title, success); }