Example #1
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 #2
0
 private void DeleteObjectAndReferences(KBModel model, List <KBObject> parents)
 {
     parents.ForEach(p => parents.AddRange(model.Objects.GetAllChildren(p)));
     KBObject.Delete(parents);
 }