示例#1
0
        internal static void RemoveAttributesWithoutTable(KBModel kbmodel, IOutputService output, out List <string[]> lineswriter)
        {
            lineswriter = new List <string[]>();
            // grabo todos los atributos en una colección
            List <Artech.Genexus.Common.Objects.Attribute> attTodos = new List <Artech.Genexus.Common.Objects.Attribute>();

            foreach (Artech.Genexus.Common.Objects.Attribute a in Artech.Genexus.Common.Objects.Attribute.GetAll(kbmodel))
            {
                attTodos.Add(a);
            }

            // voy borrando todos los atributos que estan en alguna tabla
            foreach (Table t in Table.GetAll(kbmodel))
            {
                foreach (EntityReference reference in t.GetReferences(LinkType.UsedObject))
                {
                    KBObject objRef = KBObject.Get(kbmodel, reference.To);
                    if (objRef is Artech.Genexus.Common.Objects.Attribute)
                    {
                        Artech.Genexus.Common.Objects.Attribute a = (Artech.Genexus.Common.Objects.Attribute)objRef;
                        attTodos.Remove(a);
                    }
                }
            }

            // TODO: Atributos en dataviews

            foreach (Artech.Genexus.Common.Objects.Attribute a in attTodos)
            {
                if (!Utility.AttIsSubtype(a))
                {
                    Utility.KillAttribute(a);
                    string strRemoved = "";
                    try
                    {
                        a.Delete();
                        KBDoctorOutput.Message("Atribute deleted: " + a.Name);
                    }
                    catch (Exception e)
                    {
                        output.AddErrorLine("Can't delete " + a.Name + " Msg: " + e.Message);
                    }
                    string attNameLink = Utility.linkObject(a); //"<a href=\"gx://?Command=fa2c542d-cd46-4df2-9317-bd5899a536eb;OpenObject&name=" + a.Guid.ToString() + "\">" + a.Name + "</a>";
                    strRemoved = "<a href=\"gx://?Command=fa2c542d-cd46-4df2-9317-bd5899a536eb;RemoveObject&guid=" + a.Guid.ToString() + "\">Remove</a>";
                    string Picture = Utility.FormattedTypeAttribute(a);
                    lineswriter.Add(new string[] { strRemoved, attNameLink, a.Description, Picture });
                }
            }
        }