Beispiel #1
0
        private static void CleanSDT(Artech.Genexus.Common.Objects.Attribute a, IOutputService output, KBObject objRef)
        {
            if (objRef is SDT)
            {
                output.AddLine("Cleaning SDT references to " + a.Name + " in " + objRef.Name);
                SDTStructurePart sdtstruct = objRef.Parts.Get <SDTStructurePart>();

                foreach (IStructureItem structItem in sdtstruct.Root.Items)
                {
                    SDTItem sdtItem = (SDTItem)structItem;
                    if (sdtItem.BasedOn.Key == a.Key)
                    {
                        output.AddLine("..." + sdtItem.Name + " based on  " + a.Name);
                        eDBType type   = sdtItem.Type;
                        int     length = sdtItem.Length;
                        bool    signed = sdtItem.Signed;
                        string  desc   = sdtItem.Description;
                        int     dec    = sdtItem.Decimals;

                        //Modifico la variable, para que no se base en el atributo.
                        sdtItem.AttributeBasedOn = null;
                        sdtItem.Type             = type;
                        sdtItem.Decimals         = dec;
                        sdtItem.Description      = desc;
                        sdtItem.Length           = length;
                        sdtItem.Signed           = signed;
                    }
                }
            }
        }
Beispiel #2
0
 internal static void SDTBasedOnAttDomain(List <KBObject> objs, IOutputService output)
 {
     foreach (KBObject obj in objs)
     {
         if (obj is SDT)
         {
             SDTStructurePart sdtstruct         = obj.Parts.Get <SDTStructurePart>();
             bool             hasItemNotBasedOn = false;
             string           itemnames         = "";
             foreach (IStructureItem structItem in sdtstruct.Root.Items)
             {
                 if (structItem is SDTItem)
                 {
                     SDTItem sdtItem = (SDTItem)structItem;
                     if (sdtItem.BasedOn == null && sdtItem.AttributeBasedOn == null && Utility.TypeHasToBeInDomain(sdtItem.Type))
                     {
                         hasItemNotBasedOn = true;
                         itemnames        += sdtItem.Name + " ";
                     }
                 }
             }
             if (hasItemNotBasedOn)
             {
                 OutputError err = new OutputError("SDT with items without domain: " + itemnames, MessageLevel.Warning, new KBObjectAnyPosition(obj));
                 output.Add("KBDoctor", err);
             }
         }
     }
 }
Beispiel #3
0
        internal static void CleanSDT(Artech.Genexus.Common.Objects.Attribute a, IOutputService output, KBObject objRef)
        {
            if (objRef is SDT)
            {
                output.AddLine("Cleaning SDT references to " + a.Name + " in " + objRef.Name);
                SDTStructurePart sdtstruct = objRef.Parts.Get <SDTStructurePart>();

                foreach (IStructureItem structItem in sdtstruct.Root.Items)
                {
                    SDTItem sdtItem = (SDTItem)structItem;

                    //Esto es para permitir trabajar con Evo3 y la 15.
                    EntityKey myKey = new EntityKey(a.Key);
#if EVO3
                    myKey = sdtItem.BasedOn.ObjKey;
#else
                    myKey = sdtItem.BasedOn.Key;
#endif
                    //Termina compilacion condicional.

                    if (sdtItem.BasedOn != null && myKey == a.Key)
                    {
                        output.AddLine("..." + sdtItem.Name + " based on  " + a.Name);
                        eDBType type   = sdtItem.Type;
                        int     length = sdtItem.Length;
                        bool    signed = sdtItem.Signed;
                        string  desc   = sdtItem.Description;
                        int     dec    = sdtItem.Decimals;

                        //Modifico la variable, para que no se base en el atributo.
                        sdtItem.AttributeBasedOn = null;
                        sdtItem.Type             = type;
                        sdtItem.Decimals         = dec;
                        sdtItem.Description      = desc;
                        sdtItem.Length           = length;
                        sdtItem.Signed           = signed;
                    }
                }
            }
        }
Beispiel #4
0
        private static void CleanSDT(Artech.Genexus.Common.Objects.Attribute a, IOutputService output, KBObject objRef)
        {
            if (objRef is SDT)
            {
                output.AddLine("Cleaning SDT references to " + a.Name + " in " + objRef.Name);
                SDTStructurePart sdtstruct = objRef.Parts.Get <SDTStructurePart>();

                foreach (IStructureItem structItem in sdtstruct.Root.Items)
                {
                    try
                    {
                        SDTItem sdtItem = (SDTItem)structItem;

                        EntityKey myKey = KBDoctorCore.Sources.Utility.KeyOfBasedOn_CompatibleConEvo3(sdtItem);

                        if (sdtItem.BasedOn != null && myKey == a.Key)
                        {
                            output.AddLine("..." + sdtItem.Name + " based on  " + a.Name);
                            eDBType type   = sdtItem.Type;
                            int     length = sdtItem.Length;
                            bool    signed = sdtItem.Signed;
                            string  desc   = sdtItem.Description;
                            int     dec    = sdtItem.Decimals;

                            //Modifico la variable, para que no se base en el atributo.
                            sdtItem.AttributeBasedOn = null;
                            sdtItem.Type             = type;
                            sdtItem.Decimals         = dec;
                            sdtItem.Description      = desc;
                            sdtItem.Length           = length;
                            sdtItem.Signed           = signed;
                        }
                    }
                    catch (Exception e) { output.AddErrorLine(e.Message); };
                }
            }
        }
Beispiel #5
0
 internal int MergeSDTStructure(SDTStructurePart obj, PatternInstanceElement c, string template, bool overwrite)
 {
     string oldValue = getSDTStructure(obj);
     if (!String.IsNullOrEmpty(template))
     {
         string newValue = AppendTemplateOutputXml(obj.KBObject, obj, c, template);
         if (oldValue == newValue)
         {
             return 0;
         }
         try
         {
             XmlReader xr = new XmlTextReader(new StringReader(newValue));
             BLServices.KnowledgeManager.ImportInPart(xr, obj);
         }
         catch (Exception e)
         {
             throw new TemplateException("ImportInPart - "+template+": "+e.Message, (e.InnerException != null ? e.InnerException : e), obj.KBObject.Name);
         }
     }
     return (oldValue != getSDTStructure(obj) ? 1 : 0);
 }
Beispiel #6
0
 internal string getSDTStructure(SDTStructurePart obj)
 {
     StringBuilder sb = new StringBuilder();
     TextWriter tw = new StringWriter(sb);
     obj.Serialize(tw, SerializationMode.FullContent);
     return sb.ToString();
 }