Beispiel #1
0
        private static string NombreNodoMinimized(KBObject obj)
        {
            string objName = "";

            if (obj != null)
            {
                objName = obj.Name + ":" + obj.TypeDescriptor.Name;
                if (obj.GetPropertyValue <bool>(KBObjectProperties.IsGeneratedObject))
                {
                    if (InstanceManager.IsInstanceObject(obj, out PatternDefinition pattern))
                    {
                        if (obj.Parent.Parent != null)
                        {
                            objName = NombreNodo(obj.Parent.Parent);
                        }
                        else
                        {
                            KBDoctorOutput.Error("Don't exist Parent.Parent of " + objName);
                        }
                    }
                }
                else
                {
                    if (obj is Table t)
                    {
                        //objName = NombreNodo(t.BestAssociatedTransaction);
                    }
                }
            }
            return(objName);
        }
Beispiel #2
0
        public static void ShowKBDoctorResults(string outputFile)
        {
            UIServices.ToolWindows.ShowToolWindow(KBDoctorToolWindow.guid);
            UIServices.ToolWindows.FocusToolWindow(KBDoctorToolWindow.guid);
            IToolWindow ikbdtw;

            if (UIServices.ToolWindows.TryGet(KBDoctorToolWindow.guid, out ikbdtw))
            {
                KBDoctorToolWindow kbdtw = (KBDoctorToolWindow)ikbdtw;
                kbdtw.Navigate(outputFile);
            }
            else
            {
                KBDoctorOutput.Error("Error trying to show results.");
            }
        }
Beispiel #3
0
        public static void ListObjSimilarNavigation()
        {
            IKBService    kbserv     = UIServices.KB;
            List <string> objWarnErr = new List <string>();

            string title = "KBDoctor - Similar Navigations";

            try
            {
                string outputFile = Functions.CreateOutputFile(kbserv, title);


                IOutputService output = CommonServices.Output;
                output.StartSection("KBDoctor", 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;
                KBDoctor.KBDoctorOutput.EndSection(title, success);
            }
            catch (Exception ex)
            {
                bool success = false;
                KBDoctorOutput.Error(ex.Message);
                KBDoctor.KBDoctorOutput.EndSection(title, success);
            }
        }