Beispiel #1
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 #2
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 #3
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 #4
0
        public static void RenameAttributesAndTables()
        {
            string message = "This option rename Objects (attributes, tables and objects) to significant name length. " +
                             Environment.NewLine + Environment.NewLine + "Do you have KB BACKUP? ";
            const string caption = "ATTENTION!!";
            var          result  = MessageBox.Show(message, caption,
                                                   MessageBoxButtons.YesNo,
                                                   MessageBoxIcon.Exclamation);

            // If the no button was pressed ...
            if (result == DialogResult.Yes)
            {
                IKBService kbserv = UIServices.KB;
                KBModel    model  = kbserv.CurrentKB.DesignModel;

                int ATTNAME_LEN = model.GetPropertyValue <int>("ATTNAME_LEN");
                int TBLNAME_LEN = model.GetPropertyValue <int>("TBLNAME_LEN");
                int OBJNAME_LEN = model.GetPropertyValue <int>("OBJNAME_LEN");

                string title = "KBDoctor - Rename Objects to significant name length";
                try
                {
                    string            outputFile = Functions.CreateOutputFile(kbserv, title);
                    KBDoctorXMLWriter writer     = new KBDoctorXMLWriter(outputFile, Encoding.UTF8);
                    writer.AddHeader(title);
                    writer.AddTableHeader(new string[] { "Type", "Object", "Description" });

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

                    foreach (KBObject obj in kbserv.CurrentModel.Objects.GetAll())
                    {
                        Boolean SaveObj = false;
                        if ((obj is Artech.Genexus.Common.Objects.Attribute) && (obj.Name.Length > ATTNAME_LEN))
                        {
                            KBDoctorOutput.Message("RENAMING ATTRIBUTE " + obj.Name + " to " + obj.Name.Substring(0, ATTNAME_LEN));
                            obj.Name = obj.Name.Substring(0, ATTNAME_LEN);
                            SaveObj  = true;
                        }
                        else
                        {
                            if (((obj is Table) || (obj is Index)) && (obj.Name.Length > TBLNAME_LEN))
                            {
                                KBDoctorOutput.Message("RENAMING TABLE/INDEX " + obj.Name + " to " + obj.Name.Substring(0, TBLNAME_LEN));
                                obj.Name = obj.Name.Substring(0, TBLNAME_LEN);
                                SaveObj  = true;
                            }
                            else
                            {
                                if ((obj.Name.Length > OBJNAME_LEN) && ObjectsHelper.isGeneratedbyPattern(obj))
                                {
                                    KBDoctorOutput.Message("RENAMING OBJECT " + obj.Name + " to " + obj.Name.Substring(0, OBJNAME_LEN));
                                    obj.Name = obj.Name.Substring(0, OBJNAME_LEN);
                                    SaveObj  = true;
                                }
                            }
                        }
                        if (SaveObj)
                        {
                            string attNameLink = Functions.linkObject(obj);
                            writer.AddTableData(new string[] { attNameLink, obj.Description, obj.TypeDescriptor.Name });
                            try
                            {
                                obj.Save();
                            }
                            catch (Exception e)
                            {
                                KBDoctorOutput.Message("ERROR saving  .. " + obj.Name + " - " + e.Message);
                            }
                        }
                    }
                    writer.AddFooter();
                    writer.Close();

                    KBDoctorHelper.ShowKBDoctorResults(outputFile);
                    bool success = true;
                    KBDoctorOutput.EndSection(title, success);
                }
                catch
                {
                    bool success = false;
                    KBDoctor.KBDoctorOutput.EndSection(title, success);
                }
            }
        }