Example #1
0
        internal static string GetWebRootProperty(KnowledgeBase KB, string GeneratorName)
        {
            KBModel          targetmodel      = KB.DesignModel.Environment.TargetModel;
            GxModel          arg              = targetmodel.GetAs <GxModel>();
            PropertiesObject propertiesObject = null;
            GxEnvironment    environment;

            foreach (GxEnvironment current in arg.Environments)
            {
                if (current.EnvironmentCategory.Name.ToLower().Trim() == GeneratorName.ToLower().Trim())
                {
                    environment      = current;
                    propertiesObject = PropertiesObject.GetFrom(current);
                }
            }
            string salida;

            if (propertiesObject == null)
            {
                salida = "";
            }
            else
            {
                salida = propertiesObject.GetPropertyValueString("WebRoot");
            }
            return(salida);
        }
Example #2
0
        public static void ListObjWarningsErrors()
        {
            IKBService    kbserv     = UIServices.KB;
            List <string> objWarnErr = new List <string>();

            string title = "KBDoctor - Warnings and Errors";

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

                IOutputService output = CommonServices.Output;
                output.StartSection("KBDoctor", title);

                KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8);

                writer.AddHeader(title);
                GxModel gxModel = kbserv.CurrentKB.DesignModel.Environment.TargetModel.GetAs <GxModel>();

                var fileWildcardsArg = new[] { "*.xml" };
                var directoryArg     = KBDoctorHelper.SpcDirectory(kbserv);
                var searchSubDirsArg = System.IO.SearchOption.AllDirectories;
                var ignoreCaseArg    = true;

                writer.AddTableHeader(new string[] { "Error Type", "ObjClass", "Object", "Description", "UserName", "Observation" });

                SearchNVGFiles(output, writer, fileWildcardsArg, directoryArg, searchSubDirsArg, "<Error>", ignoreCaseArg, objWarnErr);
                SearchNVGFiles(output, writer, fileWildcardsArg, directoryArg, searchSubDirsArg, "deprecated", ignoreCaseArg, objWarnErr);
                SearchNVGFiles(output, writer, fileWildcardsArg, directoryArg, searchSubDirsArg, "<Warning>", ignoreCaseArg, objWarnErr);
                SearchNVGFiles(output, writer, fileWildcardsArg, directoryArg, searchSubDirsArg, "<Icon>client<", ignoreCaseArg, objWarnErr);
                SearchNVGFiles(output, writer, fileWildcardsArg, directoryArg, searchSubDirsArg, "<JoinLocation>0</JoinLocation>", ignoreCaseArg, objWarnErr);


                writer.AddFooter();
                //agrego lista de objetos para que sea facil hacerle un BUILD WITH THIS ONLY
                string lstObjWarn = "";
                string puntoycoma = "";
                foreach (string objstr in objWarnErr)
                {
                    lstObjWarn += puntoycoma + Path.GetFileNameWithoutExtension(objstr);
                    puntoycoma  = ";";
                }
                writer.AddTableData(new string[] { lstObjWarn });
                writer.AddTableData(new string[] { "  " + objWarnErr.Count.ToString() });

                writer.Close();


                KBDoctorHelper.ShowKBDoctorResults(outputFile);
                bool success = true;
                output.EndSection("KBDoctor", title, success);
            }
            catch
            {
                bool success = false;
                KBDoctor.KBDoctorOutput.EndSection(title, success);
            }
        }
Example #3
0
        /// <summary>
        /// Crea un procedure con todos los SDT seleccionados por el usuario.
        /// </summary>
        public static void CreateProcedureSDT()
        {
            IKBService kB = UIServices.KB;

            if (kB != null && kB.CurrentModel != null)
            {
                SelectObjectOptions selectObjectOption = new SelectObjectOptions();
                selectObjectOption.MultipleSelection = true;
                KBModel kbModel = UIServices.KB.CurrentModel;

                Artech.Genexus.Common.Objects.Procedure proc = new Artech.Genexus.Common.Objects.Procedure(kbModel);
                string procName = "SDTForceGenerate";

                proc.Name = procName;
                proc.ProcedurePart.Source = "// Generated by KBDoctor, to generate SDT source";
                proc.SetPropertyValue("IsMain", true);
                proc.Save();

                //MUESTRO LOS SDT A REGENERAR
                selectObjectOption.ObjectTypes.Add(KBObjectDescriptor.Get <SDT>());
                foreach (KBObject kBObject in UIServices.SelectObjectDialog.SelectObjects(selectObjectOption))
                {
                    SDT sdtObj = (SDT)kBObject;
                    CodeGeneration.AddSDTVariable(kbModel, proc, sdtObj);
                    Application.DoEvents();
                }

                proc.Save();


                //Para cada uno de los generadores del environment, genero el proc con los SDT.

                GxModel gm = UIServices.KB.WorkingEnvironment.TargetModel.GetAs <GxModel>();

                foreach (var gen in gm.Environments)
                {
                    int generator = gen.Generator;

                    KBObject copy = BLServices.KnowledgeManager.Clone(proc);
                    copy.Name = procName + "_" + generator.ToString();
                    copy.SetPropertyValue(Artech.Genexus.Common.Properties.TRN.Generator, new EnvironmentCategoryReference {
                        Definition = gen
                    });
                    UIServices.Objects.Save(copy);

                    GenexusUIServices.Build.Rebuild(copy.Key);

                    do
                    {
                        Application.DoEvents();
                    } while (GenexusUIServices.Build.IsBuilding);
                    copy.Delete();
                }
                proc.Delete();
            }
        }
Example #4
0
        public static string NvgComparerDirectory(IKBService kbserv)
        {
            GxModel gxModel = kbserv.CurrentKB.DesignModel.Environment.TargetModel.GetAs <GxModel>();
            string  dir     = Path.Combine(SpcDirectory(kbserv), "NvgComparer");

            try
            {
                Directory.CreateDirectory(dir);
            }
            catch (Exception e) { }
            return(dir);
        }
Example #5
0
        internal static string NvgComparerDirectory(KnowledgeBase KB)
        {
            GxModel gxModel = KB.DesignModel.Environment.TargetModel.GetAs <GxModel>();
            string  dir     = Path.Combine(SpcDirectory(KB), "NvgComparer");

            try
            {
                Directory.CreateDirectory(dir);
            }
            catch (Exception e) { }

            return(dir);
        }
Example #6
0
        public static string SpcDirectory(IKBService kbserv)
        {
            GxModel gxModel = kbserv.CurrentKB.DesignModel.Environment.TargetModel.GetAs <GxModel>();

            return(kbserv.CurrentKB.Location + string.Format(@"\GXSPC{0:D3}\", gxModel.Model.Id));
        }
Example #7
0
        public static void ListObjSimilarNavigation()
        {
            IKBService    kbserv     = UIServices.KB;
            List <string> objWarnErr = new List <string>();

            string title      = "KBDoctor - Similar Navigations";
            string outputFile = Functions.CreateOutputFile(kbserv, title);


            IOutputService output = CommonServices.Output;

            output.StartSection(title);

            KBDoctorXMLWriter writer = new KBDoctorXMLWriter(outputFile, Encoding.UTF8);

            string path2 = kbserv.CurrentKB.UserDirectory + "Navigation.txt";

            try
            {
                File.Delete(path2);
            } catch (Exception e) {};

            Stream     stream  = File.Open(path2, FileMode.OpenOrCreate, FileAccess.Write);
            TextWriter writer2 = new StreamWriter(stream);

            writer.AddHeader(title);
            GxModel gxModel = kbserv.CurrentKB.DesignModel.Environment.TargetModel.GetAs <GxModel>();

            var fileWildcardsArg = new[] { "*.xml" };
            var directoryArg     = KBDoctorHelper.SpcDirectory(kbserv);

            writer.AddTableHeader(new string[] { "Type", "Tables", "Attributes", "Object/Line/Event" });

            foreach (string d in Directory.GetDirectories(directoryArg, "NVG", System.IO.SearchOption.AllDirectories))
            {
                ProcesoDirNavigations(d, output, writer2);
            }

            writer2.Close();

            //    string inFile = @"Navigation.txt";
            string outFile  = kbserv.CurrentKB.UserDirectory + @"NavigationOrdered.csv";
            var    contents = File.ReadAllLines(path2);

            //string[]  q = contents.Distinct().ToArray();
            Array.Sort(contents);
            File.WriteAllLines(outFile, contents);

            string clave           = "";
            string objetos         = "";
            string objeto          = "";
            string objetosAnterior = "";
            int    numObj          = 1;

            string claveanterior     = "";
            string tableanterior     = "";
            string attanterior       = "";
            string LevelTypeanterior = "";

            TextFieldParser parser = new TextFieldParser(outFile);

            parser.TextFieldType = FieldType.Delimited;
            parser.SetDelimiters(",");
            while (!parser.EndOfData)
            {
                //Process row
                string[] fields    = parser.ReadFields();
                string   LevelType = fields[0].Replace(" ", "_");
                string   Tables    = fields[1];
                string   Atts      = fields[2];
                string   ObjLink   = fields[3];
                string   ObjEvent  = fields[4];
                string   ObjLine   = fields[5];

                clave  = LevelType + Tables + Atts;
                objeto = ObjLink + " / " + ObjLine + " / " + ObjEvent + "<BR>";
                if (clave == claveanterior)
                {
                    if (!objetos.Contains(objeto))
                    {
                        objetos += objeto;
                        numObj  += 1;
                    }
                }
                else
                {
                    if (numObj > 1)
                    {
                        writer.AddTableData(new string[] { LevelTypeanterior, tableanterior, attanterior, objetosAnterior });
                    }
                    objetos = objeto;
                    numObj  = 1;
                }
                claveanterior     = clave;
                tableanterior     = Tables;
                attanterior       = Atts;
                LevelTypeanterior = LevelType;
                objetosAnterior   = objetos;
            }
            parser.Close();

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


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

            output.EndSection(title, success);
        }
Example #8
0
        internal static string SpcDirectory(KnowledgeBase KB)
        {
            GxModel gxModel = KB.DesignModel.Environment.TargetModel.GetAs <GxModel>();

            return(KB.Location + string.Format(@"\GXSPC{0:D3}\", gxModel.Model.Id));
        }