Example #1
0
        private static void ListProcedureSource(KBObject obj, StreamWriter file)
        {
            ProcedurePart pp = obj.Parts.Get <ProcedurePart>();

            if (pp != null)
            {
                file.WriteLine(Environment.NewLine + "=== PROCEDURE SOURCE ===");
                file.WriteLine(pp.Source);
            }
        }
Example #2
0
        private static void ListProcedureSource(KBObject obj, StreamWriter file)
        {
            ProcedurePart pp = obj.Parts.Get <ProcedurePart>();

            if (pp != null)
            {
                PrintSectionHeader("PROCEDURE SOURCE", file);
                file.WriteLine(pp.Source);
            }
        }
Example #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);
        }
Example #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 ReplaceSource(KBObject obj, string txtfind, string txtreplace)
        {
            bool cambio = false;

            if (obj is Procedure)
            {
                ProcedurePart Part = obj.Parts.Get <ProcedurePart>();
                if (Part != null)
                {
                    string source  = Part.Source;
                    string source2 = source.Replace(txtfind, txtreplace);
                    source2 = source2.Replace(txtfind.ToLower(), txtreplace);
                    source2 = source2.Replace(txtfind.ToUpper(), txtreplace);

                    if (source != source2)
                    {
                        Part.Source = source2;
                        cambio      = true;
                    }
                }
            }
            return(cambio);
        }
Example #5
0
        private static void CleanAllProcedurePart(KBObject obj)
        {
            ProcedurePart procPart = obj.Parts.Get <ProcedurePart>();

            procPart.Source = "";
        }
Example #6
0
        internal int MergeProcedureSource(ProcedurePart obj, PatternInstanceElement c, string template, bool overwrite)
        {
            string oldValue = obj.Source;
            if (!String.IsNullOrEmpty(template))
            {
                try
                {
                    HParser pOld = new HParser(obj.Source);
                    HParser pNew = new HParser(AppendTemplateOutput(obj.KBObject, obj, c, template));
                    Dictionary<string, string> sNew = pNew.GetSubs();
                    Dictionary<string, string> sOld = pOld.GetSubs(true, sNew.Keys);
                    pOld.DeleteBlocks(new string[] { "Sub" }, new string[] { "EndSub" });
                    pNew.DeleteBlocks(new string[] { "Sub" }, new string[] { "EndSub" });

                    HParser p = (overwrite ? pNew : pOld);
                    p.ReplaceInsertBlockMarked(HParser.BuildBlockMarked(pNew.Text));
                    p.ClearCode();

                    MergeEventCode(sNew, sOld, "Sub", pNew, pOld, overwrite);

                    obj.Source = p.Text;
                }
                catch (Exception ex)
                {
                    throw new TemplateException(obj.KBObject.Name, ex);
                }

            }
            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);
                }
            }
        }