Example #1
0
        private static void CleanVariablesBasedInAttribute(Artech.Genexus.Common.Objects.Attribute a, IOutputService output, KBObject objRef)
        {
            output.AddLine("Cleaning variables references to " + a.Name + " in " + objRef.Name);

            VariablesPart vp = objRef.Parts.Get <VariablesPart>();

            if (vp != null)
            {
                foreach (Variable v in vp.Variables)
                {
                    if (!v.IsStandard)
                    {
                        if ((v.AttributeBasedOn != null) && (a.Name == v.AttributeBasedOn.Name))
                        {
                            output.AddLine("&" + v.Name + " based on  " + a.Name);
                            eDBType type   = v.Type;
                            int     length = v.Length;
                            bool    signed = v.Signed;
                            string  desc   = v.Description;
                            int     dec    = v.Decimals;

                            //Modifico la variable, para que no se base en el atributo.
                            v.AttributeBasedOn = null;
                            v.Type             = type;
                            v.Decimals         = dec;
                            v.Description      = desc;
                            v.Length           = length;
                            v.Signed           = signed;
                        }
                    }
                }
            }
        }
Example #2
0
        private static void CleanSDT(Artech.Genexus.Common.Objects.Attribute a, IOutputService output, KBObject objRef)
        {
            if (objRef is SDT)
            {
                output.AddLine("Cleaning SDT references to " + a.Name + " in " + objRef.Name);
                SDTStructurePart sdtstruct = objRef.Parts.Get <SDTStructurePart>();

                foreach (IStructureItem structItem in sdtstruct.Root.Items)
                {
                    SDTItem sdtItem = (SDTItem)structItem;
                    if (sdtItem.BasedOn.Key == a.Key)
                    {
                        output.AddLine("..." + sdtItem.Name + " based on  " + a.Name);
                        eDBType type   = sdtItem.Type;
                        int     length = sdtItem.Length;
                        bool    signed = sdtItem.Signed;
                        string  desc   = sdtItem.Description;
                        int     dec    = sdtItem.Decimals;

                        //Modifico la variable, para que no se base en el atributo.
                        sdtItem.AttributeBasedOn = null;
                        sdtItem.Type             = type;
                        sdtItem.Decimals         = dec;
                        sdtItem.Description      = desc;
                        sdtItem.Length           = length;
                        sdtItem.Signed           = signed;
                    }
                }
            }
        }
Example #3
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)
                {
                    output.AddLine("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) {
                                    // Excepción no implementada
                                    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;
                                                output.AddLine(" 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" });
                                            }
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #4
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)
                {
                    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);
        }
Example #5
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(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);
            }
        }
Example #6
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;

            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);
        }
Example #7
0
        public static void CleanObject(KBObject obj, IOutputService output)
        {
            int totalvarremoved = 0;

            output.AddLine("Cleaning object " + obj.Name);
            if (obj is Transaction)
            {
                KBDoctorCore.Sources.API.CleanKBObjectVariables(obj, output);
                CleanAllRules(obj);
                CleanAllWebForm(obj);
                CleanAllWInForm(obj);
                CleanAllEvents(obj);
                CleanAllVars(obj);
                obj.SetPropertyValue(Artech.Genexus.Common.Properties.TRN.MasterPage, WebPanelReference.NoneRef);
            }

            if (obj is Procedure)
            {
                CleanAllRules(obj);
                CleanAllProcedurePart(obj);
                CleanAllConditions(obj);
                CleanAllVars(obj);
            }
            if (obj is WebPanel)
            {
                CleanAllRules(obj);
                CleanAllWebForm(obj);
                CleanAllEvents(obj);
                CleanAllConditions(obj);
                CleanAllVars(obj);
            }
            if (obj is WorkPanel)
            {
                CleanAllRules(obj);
                CleanAllWInForm(obj);
                CleanAllEvents(obj);
                CleanAllConditions(obj);
                CleanAllVars(obj);
            }

            try
            {
                obj.Save();
            }
            catch (Exception e)
            {
                output.AddLine("Can't clean " + obj.Name + " Message: " + e.Message + "--" + e.StackTrace);
            }
        }
Example #8
0
        /*
         *
         * Dependencias Entrantes
         * Dependencias Salientes
         * IE = Salientes / (Entrantes + Salientes)
         #Componentes Conexos dentro del módulo.
         * Tiene dependencia cíclicla ?
         * Largo máximo de dependencias en la que participa.
         * El módulo tiene objetos públicos no referenciados por externos?
         */

        public static void ListModulesStatistics()
        {
            IKBService     kbserv     = UIServices.KB;
            IOutputService output     = CommonServices.Output;
            bool           success    = true;
            int            objInRoot  = 0;
            int            objSinRoot = 0;
            string         title      = "KBDoctor - List Modules Statistics";

            output.StartSection(title);
            string            outputFile = Functions.CreateOutputFile(kbserv, title);
            KBDoctorXMLWriter writer     = new KBDoctorXMLWriter(outputFile, Encoding.UTF8);

            writer.AddHeader(title);
            writer.AddTableHeader(new string[] { "Module", "Description", "Tables", "Public Tables", "Objects", "Public Obj", "Obj/Publ %", "In References", "Out References" });

            SelectObjectOptions selectObjectOption = new SelectObjectOptions();

            selectObjectOption.MultipleSelection = true;
            selectObjectOption.ObjectTypes.Add(KBObjectDescriptor.Get <Module>());
            foreach (Module mdl in UIServices.SelectObjectDialog.SelectObjects(selectObjectOption))
            {
                output.AddLine(mdl.Name + "....");
                string[] mdlStat = ModuleStats2(mdl);

                if (mdl.Name == "Root Module")
                {
                    objInRoot = Int32.Parse(mdlStat[4]);
                }
                else
                {
                    if (Int32.Parse(mdlStat[2]) != 0)
                    {
                        objSinRoot = objSinRoot + Int32.Parse(mdlStat[4]);
                    }
                }
                writer.AddTableData(mdlStat);
            }
            output.AddLine("");
            output.EndSection(title, success);
            int    ratio   = (objInRoot == 0) ? 0 : (objSinRoot * 100) / objInRoot;
            string Resumen = "Obj in Modules, Obj Root, Ratio  " + objSinRoot.ToString() + "," + objInRoot.ToString() + "," + ratio.ToString();

            writer.AddTableData(new string[] { Resumen });
            writer.AddFooter();
            writer.Close();
            KBDoctorHelper.ShowKBDoctorResults(outputFile);
            Functions.AddLineSummary("moduleStats.txt", Resumen);
        }
Example #9
0
        public static void LoadUsedClasses(IKBService kbserv, IOutputService output, StringCollection UsedClasses)
        {
            int cant = 0;

            foreach (KBObject obj in kbserv.CurrentModel.Objects.GetAll())
            {
                if ((cant % 100) == 0)
                {
                    output.AddLine("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>();

                    output.AddLine(" 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);
                                        }
                                    }
                                }
                            }
                        }
                    }
                }
            }
        }
Example #10
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))
                        {
                            output.AddLine(tabs + "XCOPY " + objRef.Name + ".DLL %DESTINO% "); //+ " (" + obj.TypeDescriptor.Name + ")" );
                        }
                        AddReferencedObj(objColl, objRef, RefTabs);
                    }
                }
            }
        }
Example #11
0
        public static bool ExportObjectInTextFormat(IList <KBObject> objects)
        {
            IOutputService output = CommonServices.Output;

            output.SelectOutput(OutputId);

            string title = Resources.AppName + " - Generate objects in text format";

            output.StartSection(title);

            bool success = true;

            try
            {
                string outputPath = GetKBCodeReviewDirectory();
                Functions.WriteXSLTtoDir();
                foreach (KBObject obj in objects)
                {
                    output.AddLine(obj.GetFullName());
                    WriteObjectToTextFile(obj, outputPath);
                }
            }
            catch (Exception)
            {
                success = false;
                throw;
            }
            finally
            {
                output.EndSection(title, success);
                output.UnselectOutput(OutputId);
            }

            return(success);
        }
Example #12
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)
                    {
                        output.AddLine(x);
                    }
                    numFiles += 1;

                    string xmlstring = AddXMLHeader(x);

                    KBObject obj = ExtractObject(xmlstring);
                    if (!ObjectsHelper.isGeneratedbyPattern(obj))
                    {
                        ProcesoNavigation(xmlstring, output, writer2, obj);
                    }
                }
            }
        }
Example #13
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"))
                {
                    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);
                }
            }
        }
Example #14
0
        private static void AddFileWithWarningsErrors(IOutputService output, KBDoctorXMLWriter writer, string containsTextArg, string file)
        {
            output.AddLine(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 });
            }
        }
Example #15
0
        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);
        }
Example #16
0
        private static List <string> EqualWSDLDirectories(string pathSource, string pathNew, IOutputService output)
        {
            string fileWildcard     = @"*.*";
            var    searchSubDirsArg = System.IO.SearchOption.AllDirectories;

            string[]      FilesDirectorySource = System.IO.Directory.GetFiles(pathSource, fileWildcard, searchSubDirsArg);
            List <string> Diffs = new List <string>();

            foreach (string fileSourcePath in FilesDirectorySource)
            {
                string fileNewPath = Path.Combine(pathNew, Path.GetFileName(fileSourcePath));
                if (File.Exists(fileNewPath))
                {
                    FileInfo fileNew    = new FileInfo(fileNewPath);
                    FileInfo fileSource = new FileInfo(fileSourcePath);
                    if (!Utility.FilesAreEqual(fileSource, fileNew))
                    {
                        Diffs.Add(fileSourcePath);
                    }
                }
                else
                {
                    output.AddLine("-- No existe: " + fileNewPath);
                }
            }
            return(Diffs);
        }
Example #17
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;
                    output.AddLine("");
                    output.AddWarningLine("START Componente conexo " + i.ToString());

                    ComponenteConexo(obj, visited);

                    output.AddWarningLine("FIN Componente conexo " + i.ToString());
                }
            }
        }
Example #18
0
        public static bool WriteOutput(string msg)
        {
            string         consoleMsg = '[' + Resources.AppName + "]:" + msg;
            IOutputService output     = InitializeGXOutput();

            output.AddLine(consoleMsg);
            return(true);
        }
Example #19
0
 public static void GXWrtLineConsole(IOutputService output, string text)
 {
     if (output == null)
     {
         output = CommonServices.Output;
     }
     output.AddLine(text);
 }
Example #20
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(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))
            {
                output.AddLine("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))
                    {
                        output.AddLine("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     = Functions.ReturnPicture(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(title, success);
        }
Example #21
0
        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);
        }
Example #22
0
        internal static void PrepareComparerNavigation(KnowledgeBase KB, IOutputService output)
        {
            string title = "KBDoctor - Prepare Comparer Navigation Files";

            output.StartSection(title);
            Stopwatch stopWatch = new Stopwatch();

            stopWatch.Start();
            string directoryArg = Utility.NvgComparerDirectory(KB);
            string fechahora    = String.Format("{0:yyyy-MM-dd-HHmm}", DateTime.Now);
            string newDir       = directoryArg + @"\NVG-" + fechahora + @"\";

            try
            {
                Directory.CreateDirectory(newDir);
                Utility.WriteXSLTtoDir(KB);
                string   pathspcdir = Utility.SpcDirectory(KB);
                string[] paths      = Directory.GetDirectories(Utility.SpcDirectory(KB), "NVG", System.IO.SearchOption.AllDirectories);
                foreach (string d in paths)
                {
                    output.AddLine("Procesando directorio: " + d);
                    string generator = d.Replace(Utility.SpcDirectory(KB), "");
                    generator = generator.Replace("NVG_", "");
                    generator = @"\" + generator.Replace(@"\", "_") + "_";
                    generator = generator.Replace("NVG_", "");

                    ProcesoDir(KB, 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);
            }
            catch (Exception e) {
                output.AddErrorLine(e.Message);
            }
        }
Example #23
0
        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);
        }
Example #24
0
        public static void MarkPublicObjects()
        {
            IKBService     kbserv  = UIServices.KB;
            IOutputService output  = CommonServices.Output;
            bool           success = true;
            string         title   = "KBDoctor - Mark Public Object";

            output.StartSection(title);
            string            outputFile = Functions.CreateOutputFile(kbserv, title);
            KBDoctorXMLWriter writer     = new KBDoctorXMLWriter(outputFile, Encoding.UTF8);

            writer.AddHeader(title);
            writer.AddTableHeader(new string[] { "Object", "Type", "Description", "Visibility" });

            MakeAllObjectPublic(kbserv, output);

            foreach (KBObject obj in kbserv.CurrentModel.Objects.GetAll())
            {
                output.AddLine("Object " + obj.Name);
                ICallableObject callableObject = obj as ICallableObject;
                if (((callableObject != null) || obj is ExternalObject || obj is SDT || obj is DataSelector) && (!(obj is Transaction)))
                {
                    ObjectVisibility objVisibility = obj.GetPropertyValue <ObjectVisibility>("ObjectVisibility");

                    ObjectVisibility newObjVisibility = RecoverVisibility(obj);

                    if (objVisibility != newObjVisibility)
                    {
                        obj.SetPropertyValue("ObjectVisibility", newObjVisibility);
                        Functions.SaveObject(output, obj);
                        string objNameLink = Functions.linkObject(obj);
                        writer.AddTableData(new string[] { objNameLink, obj.TypeDescriptor.Name, obj.Description, newObjVisibility.ToString() });
                        output.AddLine("....Change Object " + obj.Name);
                    }
                }
            }
            output.AddLine("");
            output.EndSection(title, success);
            writer.AddFooter();
            writer.Close();
            KBDoctorHelper.ShowKBDoctorResults(outputFile);
        }
Example #25
0
        internal static void RenameVariables()
        {
            IKBService kbserv     = UIServices.KB;
            string     title      = "KBDoctor - Object with variables not based on attribute/domain";
            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[] { "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())
            {
                output.AddLine("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(title, success);
        }
Example #26
0
 private static void SearchNVGFiles(IOutputService output, KBDoctorXMLWriter writer, string[] fileWildcardsArg, string directoryArg, System.IO.SearchOption searchSubDirsArg, string containsTextArg, bool ignoreCaseArg, List <string> objWarnErr)
 {
     output.AddLine(">>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);
         }
     }
 }
Example #27
0
        public static void ListWithoutDomain()
        {
            IKBService kbserv = UIServices.KB;
            Dictionary <string, string> myDict = new Dictionary <string, string>();

            string title      = "KBDoctor - Attributes without domain";
            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[] { "Attribute", "Description", "Data type", "Suggested Domains" });

            foreach (Artech.Genexus.Common.Objects.Attribute a in Artech.Genexus.Common.Objects.Attribute.GetAll(kbserv.CurrentModel))
            {
                string Picture   = Functions.ReturnPicture(a);
                bool   isSubtype = Functions.AttIsSubtype(a);
                if ((a.DomainBasedOn == null) && !isSubtype)
                {
                    // search for domains with the same data type
                    output.AddLine("Procesing " + a.Name);
                    string suggestedDomains = "";
                    string value            = "";

                    /*
                     * //busco el
                     * if (myDict.TryGetValue(Picture, out value))
                     * {
                     *  suggestedDomains = value;
                     * }
                     * else
                     * {
                     *  suggestedDomains = SuggestedDomains(kbserv, a);
                     * }
                     */
                    string attNameLink = Functions.linkObject(a); // "<a href=\"gx://?Command=fa2c542d-cd46-4df2-9317-bd5899a536eb;OpenObject&name=" + a.Guid.ToString() + "\">" + a.Name + "</a>";
                    writer.AddTableData(new string[] { attNameLink, a.Description, Picture, suggestedDomains });
                }
            }

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

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

            output.EndSection(title, success);
        }
Example #28
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();

            output.AddLine("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();
        }
Example #29
0
        internal static void CleanSDT(Artech.Genexus.Common.Objects.Attribute a, IOutputService output, KBObject objRef)
        {
            if (objRef is SDT)
            {
                output.AddLine("Cleaning SDT references to " + a.Name + " in " + objRef.Name);
                SDTStructurePart sdtstruct = objRef.Parts.Get <SDTStructurePart>();

                foreach (IStructureItem structItem in sdtstruct.Root.Items)
                {
                    SDTItem sdtItem = (SDTItem)structItem;

                    //Esto es para permitir trabajar con Evo3 y la 15.
                    EntityKey myKey = new EntityKey(a.Key);
#if EVO3
                    myKey = sdtItem.BasedOn.ObjKey;
#else
                    myKey = sdtItem.BasedOn.Key;
#endif
                    //Termina compilacion condicional.

                    if (sdtItem.BasedOn != null && myKey == a.Key)
                    {
                        output.AddLine("..." + sdtItem.Name + " based on  " + a.Name);
                        eDBType type   = sdtItem.Type;
                        int     length = sdtItem.Length;
                        bool    signed = sdtItem.Signed;
                        string  desc   = sdtItem.Description;
                        int     dec    = sdtItem.Decimals;

                        //Modifico la variable, para que no se base en el atributo.
                        sdtItem.AttributeBasedOn = null;
                        sdtItem.Type             = type;
                        sdtItem.Decimals         = dec;
                        sdtItem.Description      = desc;
                        sdtItem.Length           = length;
                        sdtItem.Signed           = signed;
                    }
                }
            }
        }
Example #30
0
        public static void ListMainObj()
        {
            IKBService kbserv = UIServices.KB;


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

            string title      = "KBDoctor - Main Objects";
            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[] { "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() });


                    output.AddLine(obj.TypeDescriptor.Name + "," + obj.Name + "," + obj.Description);     //+ "," + obj.Timestamp.ToString());
                }
            }
            writer.AddFooter();
            writer.Close();

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

            output.EndSection(title, success);
        }