Esempio n. 1
0
        private static void ListEvents(KBObject obj, StreamWriter file)
        {
            EventsPart ep = obj.Parts.Get <EventsPart>();

            if (ep != null)
            {
                PrintSectionHeader("EVENTS SOURCE", file);
                file.WriteLine(ep.Source);
            }
        }
Esempio n. 2
0
        private static void ListEvents(KBObject obj, StreamWriter file)
        {
            EventsPart ep = obj.Parts.Get <EventsPart>();

            if (ep != null)
            {
                file.WriteLine(Environment.NewLine + "=== EVENTS SOURCE ===");
                file.WriteLine(ep.Source);
            }
        }
Esempio n. 3
0
        public static bool CheckObjUsesVariable(Variable v, KBObject obj)
        {
            bool varused = true;

            if (!v.IsStandard)
            {
                varused = false;
                ProcedurePart pp = obj.Parts.Get <ProcedurePart>();
                if (pp != null)
                {
                    varused = VariableIsUsedInText(pp.Source, v.Name);
                }
                if (!varused)
                {
                    RulesPart rp = obj.Parts.Get <RulesPart>();
                    if (rp != null)
                    {
                        varused = VariableIsUsedInText(rp.Source, v.Name);
                    }
                }
                if (!varused)
                {
                    ConditionsPart cp = obj.Parts.Get <ConditionsPart>();
                    if (cp != null)
                    {
                        varused = VariableIsUsedInText(cp.Source, v.Name);
                    }
                }
                if (!varused)
                {
                    EventsPart ep = obj.Parts.Get <EventsPart>();
                    if (ep != null)
                    {
                        varused = VariableIsUsedInText(ep.Source, v.Name);
                    }
                }
                if (!varused)
                {
                    WebFormPart fp = obj.Parts.Get <WebFormPart>();
                    if (fp != null)
                    {
                        varused = VariableIsUsedInWebForm(fp, v.Id);;
                    }
                }
            }
            return(varused);
        }
Esempio n. 4
0
        /// <summary>
        /// Cambia los objetos que tienen source o eventos.
        /// </summary>
        /// <param name="obj">Objeto a cambiar</param>
        /// <param name="txtfind">texto a buscar</param>
        /// <param name="txtreplace">texto a remplazar</param>
        public static bool ReplaceEvents(KBObject obj, string txtfind, string txtreplace)
        {
            bool cambio = false;

            if ((obj is Transaction) || (obj is WebPanel) || (obj is WorkPanel))
            {
                EventsPart evPart = obj.Parts.Get <EventsPart>();
                if (evPart != null)
                {
                    string evsource = evPart.Source;

                    string source2 = Regex.Replace(evsource, txtfind, txtreplace, RegexOptions.IgnoreCase);
                    source2 = source2.Replace(txtfind.ToLower(), txtreplace);
                    source2 = source2.Replace(txtfind.ToUpper(), txtreplace);
                    if (evsource != source2)
                    {
                        evPart.Source = source2;
                        cambio        = true;
                    }
                }
            }
            return(cambio);
        }
Esempio n. 5
0
        private static void CleanAllEvents(KBObject obj)
        {
            EventsPart evPart = obj.Parts.Get <EventsPart>();

            evPart.Source = "";
        }
Esempio n. 6
0
 internal int MergeEvents(EventsPart obj, PatternInstanceElement c, string template, bool overwrite)
 {
     if (!String.IsNullOrEmpty(template))
     {
         return MergeEvents(obj, AppendTemplateOutput(obj.KBObject, obj, c, template), overwrite);
     }
     return 0;
 }
Esempio n. 7
0
        internal static int MergeEvents(EventsPart obj, string novo, bool overwrite)
        {
            string oldValue = obj.Source;
            HParser pNew = new HParser(novo);
            HParser pOld = new HParser(obj.Source);

            Dictionary<string, string> eNew = null;
            Dictionary<string, string> eOld = null;

            try
            {

                // Eventos
                eNew = pNew.GetEvents();
                eOld = pOld.GetEvents(true, eNew.Keys);
                MergeEventCode(eNew, eOld, "Event", pNew, pOld, overwrite);

                // Subs
                eNew = pNew.GetSubs();
                eOld = pOld.GetSubs(true, eNew.Keys);
                MergeEventCode(eNew, eOld, "Sub", pNew, pOld, overwrite);

                obj.Source = (overwrite ? pNew.Text : pOld.Text);
            }
            catch (Exception e)
            {
                throw new TemplateException("MergeEvents: "+e.Message, (e.InnerException != null ? e.InnerException : e), obj.KBObject.Name);
            }
            return (oldValue != obj.Source ? 1 : 0);
        }
        private static void WriteObjectContent(KBObject obj, StreamWriter file)
        {
            RulesPart rp = obj.Parts.Get <RulesPart>();

            if (rp != null)
            {
                file.WriteLine(Environment.NewLine + "=== RULES ===");
                file.WriteLine(rp.Source);
            }

            EventsPart ep = obj.Parts.Get <EventsPart>();

            if (ep != null)
            {
                file.WriteLine(Environment.NewLine + "=== EVENTS SOURCE ===");
                file.WriteLine(ep.Source);
            }

            switch (obj.TypeDescriptor.Name)
            {
            case "Attribute":

                Artech.Genexus.Common.Objects.Attribute att = (Artech.Genexus.Common.Objects.Attribute)obj;

                file.WriteLine(Functions.ReturnPicture(att));
                if (att.Formula == null)
                {
                    file.WriteLine("");
                }
                else
                {
                    file.WriteLine(att.Formula.ToString());
                }
                break;

            case "Procedure":
                ProcedurePart pp = obj.Parts.Get <ProcedurePart>();
                if (pp != null)
                {
                    file.WriteLine(Environment.NewLine + "=== PROCEDURE SOURCE ===");
                    file.WriteLine(pp.Source);
                }
                break;

            case "Transaction":
                StructurePart sp = obj.Parts.Get <StructurePart>();
                if (sp != null)
                {
                    file.WriteLine(Environment.NewLine + "=== STRUCTURE ===");
                    file.WriteLine(sp.ToString());
                }
                break;

            case "WorkPanel":
                break;

            case "WebPanel":
                break;

            case "WebComponent":
                break;

            case "Table":
                Table tbl = (Table)obj;

                foreach (TableAttribute attr in tbl.TableStructure.Attributes)
                {
                    String line = "";
                    if (attr.IsKey)
                    {
                        line = "*";
                    }
                    else
                    {
                        line = " ";
                    }

                    line += attr.Name + "  " + attr.GetPropertiesObject().GetPropertyValueString("DataTypeString") + "-" + attr.GetPropertiesObject().GetPropertyValueString("Formula");

                    if (attr.IsExternalRedundant)
                    {
                        line += " External_Redundant";
                    }

                    line += " Null=" + attr.IsNullable;
                    if (attr.IsRedundant)
                    {
                        line += " Redundant";
                    }

                    file.WriteLine(line);
                }
                break;


            case "SDT":
                SDT sdtToList = (SDT)obj;
                if (sdtToList != null)
                {
                    file.WriteLine(Environment.NewLine + "=== STRUCTURE ===");
                    ListStructure(sdtToList.SDTStructure.Root, 0, file);
                }
                break;

            default:

                //Unknown object. Use export format.
                file.Write(SerializeObject(obj).ToString());
                break;
            }

            file.WriteLine(Environment.NewLine + "====== PROPERTIES =======");
            foreach (Property prop in obj.Properties)
            {
                if (!prop.IsDefault)
                {
                    file.WriteLine(prop.Name + " -> " + prop.Value.ToString());
                }
                else
                {
                    if ((prop.Name == "CommitOnExit") || (prop.Name == "TRNCMT") || (prop.Name == "GenerateObject"))
                    {
                        file.WriteLine(prop.Name + " -> " + prop.Value.ToString());
                    }
                }
            }

            //CATEGORIES
            IEnumerable <Artech.Udm.Framework.References.EntityReference> refe = obj.GetReferences();

            string        GUIDCatString = "00000000-0000-0000-0000-000000000006";
            List <string> categories    = new List <string>();

            foreach (Artech.Udm.Framework.References.EntityReference reference in refe)
            {
                Guid   GUIDRefTo       = reference.To.Type;
                string GUIDRefToString = GUIDRefTo.ToString();

                if (GUIDRefToString == GUIDCatString)
                {
                    KBCategory cat = KBCategory.Get(UIServices.KB.CurrentModel, reference.To.Id);
                    categories.Add(cat.Name);
                }
            }

            if (categories.Count > 0)
            {
                file.WriteLine(Environment.NewLine + "====== CATEGORIES =======");
                foreach (string name in categories)
                {
                    file.WriteLine(name);
                }
            }
        }