Esempio n. 1
0
        internal static void RemoveObjectsNotCalled(KBModel kbmodel, IOutputService output, out List <string[]> lineswriter)
        {
            int    callers;
            string remove    = "";
            bool   continuar = true;

            lineswriter = new List <string[]>();
            do
            {
                continuar = false;
                foreach (KBObject obj in kbmodel.Objects.GetAll())
                {
                    ICallableObject callableObject = obj as ICallableObject;
                    if ((callableObject != null) | (obj is Artech.Genexus.Common.Objects.Attribute)
                        | obj is Artech.Genexus.Common.Objects.Table | obj is Domain | obj is ExternalObject | obj is Image | obj is SDT)
                    {
                        callers = 0;
                        foreach (EntityReference reference in obj.GetReferencesTo(LinkType.UsedObject))
                        {
                            callers = callers + 1;
                        }

                        if (callers == 0)
                        {
                            if ((obj is Transaction) | obj is Table | obj is Artech.Genexus.Common.Objects.Attribute | obj is Domain | obj is Image)
                            {
                                remove = "";
                            }
                            else
                            {
                                remove = "<a href=\"gx://?Command=fa2c542d-cd46-4df2-9317-bd5899a536eb;RemoveObject&guid=" + obj.Guid.ToString() + "\">Remove</a>";
                            }
                            string objNameLink    = Utility.linkObject(obj);
                            string isMainstr      = (Utility.isMain(obj) ? "Main" : string.Empty);
                            string isGeneratedstr = (Utility.isGenerated(obj) ? "Yes" : string.Empty);
                            if (!Utility.isMain(obj))
                            {
                                if (remove != "")
                                {
                                    try
                                    {
                                        obj.Delete();
                                        KBDoctorOutput.Message("REMOVING..." + obj.Name);
                                        remove      = "REMOVED!";
                                        objNameLink = obj.Name;
                                        continuar   = true;
                                    }
                                    catch (Exception e) { };
                                }
                                lineswriter.Add(new string[] { obj.TypeDescriptor.Name, objNameLink, remove, isGeneratedstr, isMainstr });
                            }
                            if ((obj is Transaction) && (obj.GetPropertyValue <bool>(Artech.Genexus.Common.Properties.TRN.GenerateObject)))
                            {
                                try
                                {
                                    obj.SetPropertyValue(Artech.Genexus.Common.Properties.TRN.GenerateObject, false);
                                    CleanObject(obj, output);
                                }
                                catch (Exception e) { };
                            }
                        }
                    }
                }
            } while (continuar);
        }