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
        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))
                        {
                            KBDoctorOutput.Message(tabs + "XCOPY " + objRef.Name + ".DLL %DESTINO% "); //+ " (" + obj.TypeDescriptor.Name + ")" );
                        }
                        AddReferencedObj(objColl, objRef, RefTabs);
                    }
                }
            }
        }
Beispiel #3
0
        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 )
                    KBDoctorOutput.Message(x);
                    numFiles += 1;

                    string xmlstring = AddXMLHeader(x);

                    KBObject obj = ExtractObject(xmlstring);
                    // if (!ObjectsHelper.isGeneratedbyPattern(obj))
                    // {
                    ProcesoNavigation(xmlstring, output, writer2, obj);
                    /// }
                }
            }
        }
Beispiel #4
0
        public static StringCollection LoadUsedClasses()
        {
            StringCollection UsedClasses = new StringCollection();

            foreach (KBObject obj in UIServices.KB.CurrentModel.Objects.GetAll())
            {
                //ShowSomeMessages("Processing " + obj.Name);
                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)
                            {
                                var    val     = prop.GetValue(tag);
                                string miclstr = val.ToString();
                                if (!UsedClasses.Contains(miclstr))
                                {
                                    KBDoctorOutput.Message("Class : " + miclstr + " in " + obj.Name + " Tag: " + tag.Type.ToString());
                                    UsedClasses.Add(miclstr);
                                }
                            }
                        }
                    }
                }
            }
            return(UsedClasses);
        }
Beispiel #5
0
        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"))
                {
                    KBDoctorOutput.Message(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);
                }
            }
        }
Beispiel #6
0
        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;
                    KBDoctorOutput.Message("");
                    output.AddWarningLine("START Componente conexo " + i.ToString());

                    ComponenteConexo(obj, visited);

                    output.AddWarningLine("FIN Componente conexo " + i.ToString());
                }
            }
        }
Beispiel #7
0
        private static void AddFileWithWarningsErrors(IOutputService output, KBDoctorXMLWriter writer, string containsTextArg, string file)
        {
            KBDoctorOutput.Message(file);
            string objName = Path.GetFileNameWithoutExtension(file);

            containsTextArg = containsTextArg.Replace("<", "");
            containsTextArg = containsTextArg.Replace(">", "");
            containsTextArg = containsTextArg.Replace("Icon", "");


            string[] ns = new[] { "Objects" };

            bool objExists = false;

            foreach (KBObject obj in UIServices.KB.CurrentModel.Objects.GetByPartialName(ns, objName))
            {
                objExists = true;
                if (obj.Name == objName)
                {
                    string spcTxt = ExtractSpcInfo(file, containsTextArg);
                    writer.AddTableData(new string[] { containsTextArg, obj.TypeDescriptor.Name, Functions.linkObject(obj), obj.Description, obj.UserName, spcTxt });
                }
            }
            if (!objExists)
            {
                writer.AddTableData(new string[] { containsTextArg, "", objName, "Don't exist", "", file });
            }
        }
Beispiel #8
0
        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)
                {
                    KBDoctorOutput.Message("set DESTINO=" + objLocation);
                    KBDoctorOutput.Message("XCOPY " + Dircopia + obj.Name + ".dll %DESTINO%");

                    if (obj is Procedure)
                    {
                        letra = "a";
                    }
                    if (obj is WorkPanel)
                    {
                        letra = "u";
                    }
                    if (obj is Transaction)
                    {
                        letra = "";
                    }

                    KBDoctorOutput.Message("XCOPY " + Dircopia + letra + obj.Name + ".dll %DESTINO%");
                    AddReferencedObj(objColl, obj, "");
                }
            }
            return(objColl);
        }
Beispiel #9
0
        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" });
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Beispiel #10
0
        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);
            }
        }
Beispiel #11
0
        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);
            }
        }
Beispiel #12
0
        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);
            }
        }
Beispiel #13
0
        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("KBDoctor", 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);
                        KBDoctorOutput.Message("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
                            {
                                KBDoctorOutput.Message("Replace " + od.Name + " domain manually in object " + objRef.Name);
                                success = false;
                            }
                        }
                    }
                }
                output.EndSection("KBDoctor", title, success);
            }
        }
Beispiel #14
0
        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();
        }
Beispiel #15
0
        private static void GenerateMDGGraph2(string name, string fileName)
        {
            IKBService kbserv = UIServices.KB;
            KBModel    model  = kbserv.CurrentModel;

            // IOutputService output = CommonServices.Output;
            StreamWriter             nodesFiles = new StreamWriter(kbserv.CurrentKB.UserDirectory + @"\kbdoctor.Nodes.CSV");
            Dictionary <string, int> aristas    = new Dictionary <string, int>();

            KBDoctorOutput.Message("Generating " + name);

            string objRefName = "";

            foreach (KBObject objRef in model.Objects.GetAll())
            {
                objRefName = NombreNodo(objRef);
                if (IncludedInGraph(objRef))
                {
                    nodesFiles.WriteLine(objRefName + " " + ModulesHelper.ObjectModuleName(objRef));

                    foreach (EntityReference r in objRef.GetReferencesTo())
                    {
                        KBObject obj = KBObject.Get(objRef.Model, r.From);

                        if ((obj != null) && (Functions.isRunable(obj)) && (obj != objRef))
                        {
                            string objName = NombreNodo(obj);
                            if (IncludedInGraph(obj))
                            {
                                int weight = ReferenceWeight(obj, objRef);
                                AgregoArista(aristas, objName, objRefName, weight);
                            }
                        }
                    }
                }
            }

            //Cargo todas las transacciones y sus tablas generadas
            foreach (Table tbl in Table.GetAll(model))
            {
                Transaction trn    = Artech.Genexus.Common.Services.GenexusBLServices.Tables.GetBestAssociatedTransaction(model, tbl.Key);
                int         weight = ReferenceWeight(trn, tbl);
                AgregoArista(aristas, NombreNodo(trn), NombreNodo(tbl), weight);
            }
            nodesFiles.Close();

            StreamWriter scriptFile = new StreamWriter(fileName);

            foreach (string arista in aristas.Keys)
            {
                scriptFile.WriteLine(arista + " " + aristas[arista]);
            }
            scriptFile.Close();
        }
Beispiel #16
0
 private static void SearchNVGFiles(IOutputService output, KBDoctorXMLWriter writer, string[] fileWildcardsArg, string directoryArg, System.IO.SearchOption searchSubDirsArg, string containsTextArg, bool ignoreCaseArg, List <string> objWarnErr)
 {
     KBDoctorOutput.Message(">>Searching for " + containsTextArg);
     foreach (string file in FindInFiles(directoryArg, containsTextArg, ignoreCaseArg, searchSubDirsArg, (string[])fileWildcardsArg))
     {
         if (!objWarnErr.Contains(file))
         {
             AddFileWithWarningsErrors(output, writer, containsTextArg, file);
             objWarnErr.Add(file);
         }
     }
 }
Beispiel #17
0
        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();

            KBDoctorOutput.Message("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();
        }
Beispiel #18
0
        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;
            KBDoctorOutput.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 = LoadThemeClasses();

            StringCollection UsedClasses = LoadUsedClasses();


            foreach (string sd in UsedClasses)
            {
                if (!ThemeClasses.Contains(sd))
                {
                    writer.AddTableData(new string[] { "", sd, "Application Class not in theme" });
                    KBDoctorOutput.Message("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" });
                    KBDoctorOutput.Message("Class not referenced in application " + ss);
                }
            }
            writer.AddTableData(new string[] { "-------", "-----------------", "--------------" });
            writer.AddFooter();
            writer.Close();
            KBDoctorOutput.EndSection(title, true);

            KBDoctorHelper.ShowKBDoctorResults(outputFile);
        }
Beispiel #19
0
        public static void AddINParmRule()
        {
            // Object with parm() rule without in: out: or inout:
            IKBService     kbserv = UIServices.KB;
            IOutputService output = CommonServices.Output;
            string         title  = "KBDoctor - ADD IN: to Parm() rule";

            output.StartSection("KBDoctor", title);
            try
            {
                string outputFile = Functions.CreateOutputFile(kbserv, title);


                KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8);
                writer.AddHeader(title);
                writer.AddTableHeader(new string[] { "Object", "Description", "Tipo" });
                int cantObjChanged = 0;

                SelectObjectOptions selectObjectOption = new SelectObjectOptions
                {
                    MultipleSelection = true
                };
                //   selectObjectOption.ObjectTypes.Add(KBObjectDescriptor.Get<Procedure>());
                // selectObjectOption.ObjectTypes.Add(KBObjectDescriptor.Get<WebPanel>());

                foreach (KBObject obj in UIServices.SelectObjectDialog.SelectObjects(selectObjectOption))
                {
                    if (obj.Description.StartsWith("Work With"))
                    {
                        writer.AddTableData(new string[] { obj.Name, obj.Description, obj.TypeDescriptor.Name });
                        obj.Description = obj.Description.Replace("Work With ", "Trabajar con ");
                        obj.Save();
                    }
                }

                writer.AddFooter();
                writer.Close();

                bool success = true;
                KBDoctorOutput.EndSection(title, success);
                KBDoctorOutput.Message("Object changed " + cantObjChanged.ToString());

                KBDoctorHelper.ShowKBDoctorResults(outputFile);
            }
            catch
            {
                bool success = false;
                KBDoctor.KBDoctorOutput.EndSection(title, success);
            }
        }
Beispiel #20
0
        private static void GenerateMDGMinimized(string name, string fileName)
        {
            IKBService kbserv = UIServices.KB;
            KBModel    model  = kbserv.CurrentModel;

            Dictionary <string, int> aristas = new Dictionary <string, int>();

            KBDoctorOutput.Message("Generating " + name);

            string objRefName = "";

            foreach (KBObject objRef in model.Objects.GetAll())
            {
                objRefName = NombreNodoMinimized(objRef);
                if (IncludedInGraph(objRef))
                {
                    foreach (EntityReference r in objRef.GetReferencesTo())
                    {
                        KBObject obj = KBObject.Get(objRef.Model, r.From);

                        if ((obj != null) && (Functions.isRunable(obj)) && (obj != objRef))
                        {
                            string objName = NombreNodoMinimized(obj);
                            if (objName != objRefName && IncludedInGraph(obj))
                            {
                                int weight = ReferenceWeight(obj, objRef);
                                AgregoArista(aristas, objName, objRefName, weight);
                            }
                        }
                    }
                }
            }

            //Cargo todas las transacciones y sus tablas generadas
            foreach (Table tbl in Table.GetAll(model))
            {
                //int weight = ReferenceWeight(tbl.BestAssociatedTransaction, tbl);
                //AgregoArista(aristas, NombreNodoMinimized(tbl.BestAssociatedTransaction), NombreNodoMinimized(tbl), weight);
            }


            StreamWriter scriptFile = new StreamWriter(fileName);

            foreach (string arista in aristas.Keys)
            {
                scriptFile.WriteLine(arista + " " + aristas[arista]);
            }
            scriptFile.Close();
        }
Beispiel #21
0
        private static void VisitNode(KBObjectCollection visited, KBObject obj, KBObject objRef)
        {
            IOutputService output = CommonServices.Output;

            if (isNode(objRef))
            {
                KBDoctorOutput.Message(NombreNodo(obj) + ";" + NombreNodo(objRef));

                if (!visited.Contains(objRef))
                {
                    visited.Add(objRef);
                    ComponenteConexo(objRef, visited);
                }
            }
        }
Beispiel #22
0
        private static void GenerateKBTableGraphSatsuma(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();

            KBDoctorOutput.Message("Generating " + name);

            scriptFile.WriteLine("      </edges>");
            scriptFile.WriteLine("  </graph>");
            scriptFile.WriteLine("</gexf>");
            scriptFile.Close();
        }
Beispiel #23
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 #24
0
        public static void ListKeyVarchar()
        {
            IKBService kbserv = UIServices.KB;

            string title      = "KBDoctor - Attributes Varchar that is Primary Key in some table";
            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[] { "Attribute", "Description", "Data type", "Domain", "Tables" });

            foreach (Table t in Table.GetAll(kbserv.CurrentModel))
            {
                KBDoctorOutput.Message("Processing... " + t.Name);
                string objNameLink = Functions.linkObject(t); //"<a href=\"gx://?Command=fa2c542d-cd46-4df2-9317-bd5899a536eb;OpenObject&name=" + t.Guid.ToString() + "\">" + t.Name + "</a>";


                foreach (TableAttribute attr in t.TableStructure.PrimaryKey)
                {
                    if ((attr.Attribute.Type == Artech.Genexus.Common.eDBType.VARCHAR) || (attr.Attribute.Type == Artech.Genexus.Common.eDBType.LONGVARCHAR))
                    {
                        KBDoctorOutput.Message("Processing " + attr.Name);
                        if (!Functions.AttIsSubtype(attr))
                        {
                            string domLink     = DomainLinkFromAttribute(attr);
                            string attNameLink = Functions.linkObject(attr); //"<a href=\"gx://?Command=fa2c542d-cd46-4df2-9317-bd5899a536eb;OpenObject&name=" + attr.Guid.ToString() + "\">" + attr.Name + "</a>";
                            string Picture     = Utility.FormattedTypeAttribute(attr);
                            writer.AddTableData(new string[] { attNameLink, attr.Attribute.Description, Picture, domLink, t.Name });
                        }
                    }
                }
            }

            writer.AddFooter();
            writer.Close();

            KBDoctorHelper.ShowKBDoctorResults(outputFile);
            bool success = true;

            output.EndSection("KBDoctor", title, success);
        }
Beispiel #25
0
        private static StringCollection LoadThemeClasses()
        {
            StringCollection ThemeClasses = new StringCollection();

            foreach (Theme thm in Theme.GetAll(UIServices.KB.CurrentModel))
            {
                KBDoctorOutput.Message("Procesing theme .." + thm.Name);
                ThemeStylesPart part = thm.Parts.Get <ThemeStylesPart>();
                foreach (Artech.Genexus.Common.Objects.Themes.ThemeStyle thmclass in part.GetAllStyles())
                {
                    string thmstr = thmclass.Name;
                    if (!ThemeClasses.Contains(thmstr) && (!(thmstr.Contains("Dragging") || thmstr.Contains("AcceptDrag") || thmstr.Contains("NoAcceptDrag")))) //Excluyo clases especiales
                    {
                        ThemeClasses.Add(thmstr.ToLower());
                    }
                }
            }
            return(ThemeClasses);
        }
Beispiel #26
0
        internal static void ListAttributes()
        {
            IKBService kbserv = UIServices.KB;
            // Dictionary<string, string> myDict = new Dictionary<string, string>();

            string title = "KBDoctor - List Attributes";

            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[] { "Attribute", "Description", "Data type", "Domain", "ControlType", "Subtype", "Title", "Column Title", "Contextual", "IsFormula" });

                foreach (Artech.Genexus.Common.Objects.Attribute a in Artech.Genexus.Common.Objects.Attribute.GetAll(kbserv.CurrentModel))
                {
                    string Picture       = Utility.FormattedTypeAttribute(a);
                    string domlink       = a.DomainBasedOn == null ? " " : Functions.linkObject(a.DomainBasedOn);
                    string superTypeName = a.SuperTypeKey == null ? " " : a.SuperType.Name;
                    string controlType   = a.GetPropertyValueString("ControlType");
                    KBDoctorOutput.Message("Procesing " + a.Name);
                    string isFormula = a.Formula == null ? "" : "*";
                    writer.AddTableData(new string[] { Functions.linkObject(a), a.Description, Picture, domlink, controlType, superTypeName, a.Title, a.ColumnTitle, a.ContextualTitleProperty, isFormula });
                }

                writer.AddFooter();
                writer.Close();

                KBDoctorHelper.ShowKBDoctorResults(outputFile);
                bool success = true;
                KBDoctor.KBDoctorOutput.EndSection(title, success);
            }
            catch
            {
                bool success = false;
                KBDoctor.KBDoctorOutput.EndSection(title, success);
            }
        }
Beispiel #27
0
        public static void PrepareComparerNavigation()
        {
            string         title  = "KBDoctor - Prepare Comparer Navigation Files";
            IOutputService output = CommonServices.Output;

            output.StartSection("KBDoctor", 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);

            KBDoctorOutput.Message(title + " elepsed time: " + elapsedTime);
            output.EndSection("KBDoctor", title, true);
        }
Beispiel #28
0
        /*
         * public static void LoadUsedClasses(ollection UsedClasses)
         * {
         *
         *  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 is ThemeClass) && (obj.GetPropertyValue<bool>(Properties.TRN.GenerateObject)))
         *      {
         *          WebFormPart webForm = obj.Parts.Get<WebFormPart>();
         *
         *          KBDoctorOutput.Message( " Object : " + obj.Name);
         *
         *          foreach (IWebTag tag in WebFormHelper.EnumerateWebTag(webForm))
         *          {
         *              if (tag.Properties != null)
         *              {
         *
         *                  PropertyDescriptor prop = tag.Properties.GetPropertyDescriptorByDisplayName("Class");
         *                  if (prop != null)
         *                  {
         *
         *                      ThemeClassReferenceList miclasslist = new ThemeClassReferenceList();
         *                      try
         *                      {
         *                          miclasslist = (ThemeClassReferenceList)prop.GetValue(new object());
         *                      }
         *                      catch (Exception e) { Console.WriteLine(e.InnerException); };
         *
         *                      foreach (ThemeClass miclass in miclasslist.GetThemeClasses(obj.Model))
         *                      {
         *                          if (miclass != null)
         *                          {
         *                              string miclstr = miclass.Root.Description + '-' + miclass.Name.ToLower();
         *                              if (!UsedClasses.Contains(miclstr))
         *                              {
         *                                  UsedClasses.Add(miclstr);
         *                              }
         *                          }
         *                      }
         *                  }
         *              }
         *          }
         *      }
         *  }
         * }
         */
        public static void ClassUsed()
        {
            IKBService kbserv = UIServices.KB;

            string title = "KBDoctor - Classes Used";

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

                // IOutputService output = CommonServices.Output;
                KBDoctorOutput.StartSection(title);

                KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8);
                writer.AddHeader(title);
                writer.AddTableHeader(new string[] { "Class", "Error" });

                StringCollection UsedClasses  = LoadUsedClasses();
                StringCollection ThemeClasses = new StringCollection();
                //Reviso todos los objeto para ver las class usadas en cada control

                foreach (string sd in UsedClasses)
                {
                    writer.AddTableData(new string[] { sd, "" });
                    KBDoctorOutput.Message("Application Class used " + sd);
                }

                writer.AddTableData(new string[] { "-----------------", "--------------", "---" });

                writer.AddFooter();
                writer.Close();
                KBDoctorOutput.EndSection(title, true);

                KBDoctorHelper.ShowKBDoctorResults(outputFile);
            }
            catch
            {
                bool success = false;
                KBDoctor.KBDoctorOutput.EndSection(title, success);
            }
        }
Beispiel #29
0
        public static void ListObjDiffMasterPage2()
        {
            IKBService kbserv = UIServices.KB;

            Dictionary <string, KBObjectCollection> dic = new Dictionary <string, KBObjectCollection>();

            string title = "KBDoctor - 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);

                KBDoctorOutput.Message("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("KBDoctor", title, success);
            }
            catch
            {
                bool success = false;
                KBDoctor.KBDoctorOutput.EndSection(title, success);
            }
        }
Beispiel #30
0
        private static void ProcessObjectsInCategory(IOutputService output, KBCategory Category)
        {
            bool stay     = true;
            int  pasada   = 1;
            int  borrados = 0;

            do
            {
                KBDoctorOutput.Message("Pass number " + pasada.ToString() + ". Cleaned objects: " + borrados.ToString());
                stay = false;

                foreach (KBObject obj in Category.AllMembers)
                {
                    if ((obj is Transaction) || (obj is Table) || (obj is Image) || (obj is Artech.Genexus.Common.Objects.Group) || (obj is DataView))
                    {
                        KBDoctorOutput.Message("Skipping " + obj.Name);
                    }
                    else
                    {
                        try
                        {
                            obj.Delete();
                            KBDoctorOutput.Message("Removing : " + obj.Name);
                            stay      = true;
                            borrados += 1;
                        }
                        catch
                        {
                            KBDoctorOutput.Message("ERROR: Can't remove :" + obj.Name);
                        }
                    }
                }



                pasada += 1;
            } while (stay);
        }