Exemplo n.º 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();
                        output.AddLine("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.ReturnPicture(a);
                    lineswriter.Add(new string[] { strRemoved, attNameLink, a.Description, Picture });
                }
            }
        }
Exemplo n.º 2
0
        internal static void AttributeHasDomain(List <KBObject> objs, IOutputService output)
        {
            foreach (KBObject obj in objs)
            {
                if (obj is Artech.Genexus.Common.Objects.Attribute)
                {
                    Artech.Genexus.Common.Objects.Attribute a = (Artech.Genexus.Common.Objects.Attribute)obj;
                    string Picture   = Utility.ReturnPicture(a);
                    bool   isSubtype = Utility.AttIsSubtype(a);

                    if ((a.DomainBasedOn == null) && !isSubtype && Utility.AttHasToBeInDomain(a))
                    {
                        OutputError err = new OutputError("Attribute without domain: " + a.Name, MessageLevel.Warning, new KBObjectAnyPosition(obj));
                        output.Add("KBDoctor", err);
                    }
                }
            }
        }