Exemplo n.º 1
0
        public static string Attribute(AttributeElement att)
        {
            string defaultThemeClass = att.Instance.Settings.Theme.ReadonlyAttribute;
            if (att.Attribute.Type == eDBType.BINARY)
                defaultThemeClass = att.Instance.Settings.Theme.ReadonlyBlobAttribute;

            string themeClass = GetThemeClass(att, defaultThemeClass);
            Dictionary<string, object> properties = new Dictionary<string, object>();
            GetControlInfo(att, properties);

            return WebForm.Attribute(att.AttributeName, themeClass, null, properties);
        }
Exemplo n.º 2
0
        private bool AddSuggestAttribute(RowElement row, AttributeElement att, Transaction transaction)
        {
            bool ret = false;
            foreach (SettingsSuggestInstanceElement sugg in settings.Template.Suggests)
            {
                bool achou = false;
                foreach (SettingsAttributeDefinitionElement ad in sugg.AttributeDefinitions)
                {
                    if (att.AttributeName.Trim() == ad.Name.Trim() || att.AttributeName.IndexOf(ad.Name) >= 0 || String.IsNullOrEmpty(ad.Name))
                    {
                        if (ad.TypeAll)
                        {
                            achou = true;
                        }
                        else
                        {
                            switch (att.Attribute.Type)
                            {
                                case eDBType.CHARACTER:
                                    if (ad.TypeCharacter) achou = true;
                                    break;
                                case eDBType.VARCHAR:
                                    if (ad.TypeCharacter) achou = true;
                                    break;
                                case eDBType.LONGVARCHAR:
                                    if (ad.TypeCharacter) achou = true;
                                    break;
                                case eDBType.NUMERIC:
                                    if (ad.TypeNumeric) achou = true;
                                    break;
                                case eDBType.INT:
                                    if (ad.TypeNumeric) achou = true;
                                    break;
                                case eDBType.DATE:
                                    if (ad.TypeData) achou = true;
                                    break;
                                case eDBType.DATETIME:
                                    if (ad.TypeData) achou = true;
                                    break;
                            }

                        }
                        if (achou)
                        {
                            if (ad.TypeSize > 0 && ad.TypeSize != att.Attribute.Length)
                                achou = false;
                            if (ad.TypeDecimal > 0 && ad.TypeDecimal != att.Attribute.Decimals)
                                achou = false;

                        }
                        if (achou) break;
                    }
                }

                if (achou)
                {
                    if (sugg.Picture.ToLower() != "none" && sugg.Picture != String.Empty)
                    {
                        att.Picture = sugg.Picture;
                    }

                    if (sugg.Required.ToLower() != "none")
                    {
                        att.Required = sugg.Required;
                    }

                    if (sugg.RequiredMessage != String.Empty)
                    {
                        att.RequiredMessage = sugg.RequiredMessage;
                    }

                    if (sugg.RequiredAfterValidate != SettingsSuggestInstanceElement.RequiredAfterValidateValue.None)
                    {
                        att.RequiredAfterValidate = sugg.RequiredAfterValidate;
                    }

                    if (sugg.Rule.ToLower() != "none")
                    {
                        att.Rule = sugg.Rule;
                    }

                    if (sugg.ValueRule != String.Empty)
                    {
                        att.ValueRule = sugg.ValueRule;
                    }

                    if (sugg.IsValid != String.Empty)
                    {
                        att.IsValid = sugg.IsValid;
                    }

                    if (sugg.Readonly.ToLower() != "none")
                    {
                        att.Readonly = sugg.Readonly.ToLower() == "true" ? true : false;
                    }

                    if (sugg.Visible.ToLower() != "none")
                    {
                        att.Visible = sugg.Visible.ToLower() == "true" ? true : false;
                        if (row != null)
                            row.Visible = sugg.Visible.ToLower() == "true" ? true : false;
                    }
                    if (sugg.AttributeInSameBeforeColumn)
                    {
                        ret = true;
                    }
                    if (sugg.Description != String.Empty)
                    {
                        att.Description = sugg.Description;
                    }
                    if (!String.IsNullOrEmpty(sugg.EventValidation))
                    {
                        att.EventValidation = sugg.EventValidation;
                    }
                    if (!String.IsNullOrEmpty(sugg.MaskPicture))
                    {
                        att.MaskPicture = sugg.MaskPicture;
                        att.Reverse = sugg.Reverse;
                        att.Signed = sugg.Signed;
                        att.UnmaskedChars = sugg.UnmaskedChars;
                        att.UnmaskedValue = sugg.UnmaskedValue;
                    }
                    if (!String.IsNullOrEmpty(sugg.EventStart))
                    {
                        att.EventStart = sugg.EventStart;
                    }

                }
            }
            return ret;
        }
Exemplo n.º 3
0
        private void AddGridStandard(TransactionLevel subLevel, IHPatternInstanceElement nivel, Dictionary<string, int> Counters)
        {
            GridStandardElement grid = new GridStandardElement();
            grid.Name = String.Format("Grid{0}", Counters["GridCounter"]);
            Counters["GridCounter"]++;
            grid.Description = subLevel.Description;

            IDictionary<TransactionAttribute, Artech.Genexus.Common.Objects.Attribute> descAttNames;
            IList<int> toExclude = DefaultFormHelper.CalculateExcluded(subLevel, out descAttNames);

            foreach (TransactionAttribute ta in subLevel.Attributes)
            {
                if (!toExclude.Contains(ta.Attribute.Id))
                {

                    string colTitleProperty = "ColumnTitle";
                    Artech.Genexus.Common.Objects.Attribute attName;
                    if (!descAttNames.TryGetValue(ta, out attName))
                    {
                        attName = ta.Attribute;
                        if (ta.IsLocal)
                            colTitleProperty = "ContextualTitle";
                    }

                    string colTitleExpr = String.Format("={0}.{1}", attName.Name, colTitleProperty);

                    AttributeElement att = new AttributeElement(attName);
                    att.Description = colTitleExpr;
                    grid.Attributes.Add(att);
                }
            }

            if (nivel is FormElement)
            {
                FormElement form = nivel as FormElement;
                ColumnElement col = new ColumnElement();
                col.ColSpan = 2;
                col.Items.Add(grid);
                form.AddRow().Columns.Add(col);
            }
            if (nivel is GridFreeStyleElement)
            {
                GridFreeStyleElement gridnivel = nivel as GridFreeStyleElement;
                gridnivel.Items.Add(grid);
            }
        }
Exemplo n.º 4
0
        private void AddGridFreeStyle(TransactionLevel subLevel, IHPatternInstanceElement nivel, Dictionary<string, int> Counters)
        {
            GridFreeStyleElement grid = new GridFreeStyleElement();
            grid.Name = String.Format("Grid{0}", Counters["GridCounter"]);
            Counters["GridCounter"]++;
            grid.Description = subLevel.Description;

            IDictionary<TransactionAttribute, Artech.Genexus.Common.Objects.Attribute> descAttNames;
            IList<int> toExclude = DefaultFormHelper.CalculateExcluded(subLevel, out descAttNames);

            foreach (IStructureItem structureItem in subLevel.Items)
            {
                if (structureItem is TransactionAttribute)
                {
                    TransactionAttribute trnAttribute = structureItem as TransactionAttribute;
                    if (trnAttribute.IsKey || !toExclude.Contains(trnAttribute.Attribute.Id))
                    {
                        Artech.Genexus.Common.Objects.Attribute attName;
                        if (!descAttNames.TryGetValue(trnAttribute, out attName))
                            attName = trnAttribute.Attribute;

                        string captionProperty = "Title";
                        if (trnAttribute.IsLocal)
                            captionProperty = "ContextualTitle";

                        AttributeElement att = new AttributeElement(attName);
                        att.Description = String.Format("={0}.{1}", attName.Name, captionProperty);

                        grid.Items.Add(att);
                    }

                }
                else if (structureItem is TransactionLevel)
                {
                    TransactionLevel subLevel2 = structureItem as TransactionLevel;
                    bool hasMoreLevels = (subLevel2.Levels.Count > 0);
                    if (hasMoreLevels)
                    {
                        AddGridFreeStyle(subLevel2, grid, Counters);
                    }
                    else
                    {
                        AddGridStandard(subLevel2, grid, Counters);
                    }
                }

            }
            if (nivel is FormElement)
            {
                FormElement form = nivel as FormElement;
                ColumnElement col = new ColumnElement();
                col.ColSpan = 2;
                col.Items.Add(grid);
                form.AddRow().Columns.Add(col);
            }
            if (nivel is GridFreeStyleElement)
            {
                GridFreeStyleElement gridnivel = nivel as GridFreeStyleElement;
                gridnivel.Items.Add(grid);
            }
        }
Exemplo n.º 5
0
 private void AddGridFilterDynamicFilters(FilterElement filterElement, Transaction trn, TransactionLevel level)
 {
     try
     {
         if (settings.DynamicFilters.GenerateDynaicFilters)
         {
             int max = settings.DynamicFilters.MaxAttributes;
             int c = 0;
             foreach (TransactionAttribute ta in level.Attributes)
             {
                 if (ta.Attribute.Type == eDBType.CHARACTER || ta.Attribute.Type == eDBType.VARCHAR || ta.Attribute.Type == eDBType.NUMERIC || ta.Attribute.Type == eDBType.DATE)
                 {
                     AttributeElement at = new AttributeElement(ta.Attribute);
                     at.Description = ta.Attribute.Description;
                     filterElement.Dynamicfilters.Add(at);
                     c++;
                     if (c >= max) break;
                 }
             }
         }
     }
     catch (System.Exception e) {
         System.Windows.Forms.MessageBox.Show("Erro: " + e.Message + Environment.NewLine + e.StackTrace);
     }
 }
Exemplo n.º 6
0
        private void AddFormTransaction(Transaction transaction, FormElement form)
        {
            Dictionary<string, int> Counters = new Dictionary<string, int>();
            Counters.Add("GridCounter", 1);

            //FormElement form = instance.Transaction.Form;

            RowElement row = new RowElement();
            ColumnElement col = null;
            ColumnElement col2 = null;

            Transaction trn = form.Instance.Transaction.Transaction;
            List<Artech.Genexus.Common.Objects.Attribute> lista = new List<Artech.Genexus.Common.Objects.Attribute>();
            if (trn != null && trn != transaction)
            {
                foreach (TransactionAttribute ta2 in trn.Structure.Root.Attributes)
                {
                    lista.Add(ta2.Attribute);
                }

            }
            bool geraAtt = true;

            foreach (IStructureItem item in transaction.Structure.Root.Items)
            {
                if (item is TransactionLevel)
                {
                        TransactionLevel subLevel = item as TransactionLevel;
                        bool hasMoreLevels = (subLevel.Levels.Count > 0);
                        if (hasMoreLevels)
                        {
                            AddGridFreeStyle(subLevel, form, Counters);
                        }
                        else
                        {
                            AddGridStandard(subLevel, form, Counters);
                        }
                }
                if (item is TransactionAttribute)
                {
                    TransactionAttribute ta = item as TransactionAttribute;
                    geraAtt = true;
            //                    if (!ta.is.Properties.GetPropertyValue<bool>(Properties..tra.TransactionAttribute.ShowInDefaultForms))
            //                    {
            //                        geraAtt = false;
            //                    }
                    if (trn != null && trn != transaction)
                    {
                        if (lista.Contains(ta.Attribute))
                        {
                            geraAtt = false;
                        }
                    }

                    if (geraAtt)
                    {
                        AttributeElement ae = new AttributeElement(ta.Attribute);
                        ae.Description = ta.Attribute.ContextualTitleProperty;
                        bool SameBeforeColumn = AddSuggestAttribute(row, ae, transaction);

                        if (col2 != null && (SameBeforeColumn || (settings.Template.InferedAttributeInSameBeforeColumn && ta.IsInferred)))
                        {
                            col2.Add(ae);
                        }
                        else
                        {
                            // Cria Linha
                            form.Add(row);

                            // Cria Coluna de TextBlock
                            col = row.AddColumn();

                            // Cria Textblock
                            TextElement te = col.AddText();
                            te.Name = "tb" + ta.Name;
                            te.Caption = BuildCaption(ta, "=" + ta.Name + ".ContextualTitle");

                            // Cria Coluna de Atributo
                            col2 = row.AddColumn();

                            // Cria Atributo
                            col2.Add(ae);

                            if (ta.IsForeignKey && settings.Template.SuggestEventIsValidForForeignKey && String.IsNullOrEmpty(ae.IsValid))
                            {
                                ae.IsValid = BuildIsValid(transaction, ta);
                            }

                            // Problema trava ao apagar objeto, loop infinito
                            /*
                            if (ta.IsForeignKey && settings.Template.PromptSuggestForeignKey && ae.Link == null)
                            {
                                BuildPrompt(form.Instance,ae, ta, trn);
                            }
                            */

                            row = new RowElement();
                        }
                    }
                }
            }
        }
Exemplo n.º 7
0
        private void BuildPrompt(HPatternInstance instance, AttributeElement ae,TransactionAttribute ta,Transaction trn)
        {
            List<string> listapk = new List<string>();
            foreach (AttributeRelation ar in ta.ForeignKeyTo.KeyAttributes)
            {
                listapk.Add(ar.Related.Name);
            }

            IEnumerable<WebPanel> listaw = WebPanel.GetAll(instance.Model);
            bool geralink = false;
            foreach (WebPanel wobj in listaw)
            {
                // Se este objeto foi gerado pelo Pattern
                if (String.IsNullOrEmpty(settings.Template.PromptSuggestNameContains) || wobj.Name.ToLower().IndexOf(settings.Template.PromptSuggestNameContains.ToLower()) >= 0)
                {
                    // Aqui vamos retirar a o loop infinito, então nunca ira sugerir um prompt dele mesmo
                    bool gera = true;
                    if (wobj.Parent is PatternInstance)
                    {
                        if (((PatternInstance)wobj.Parent).KBObjectKey.Equals(pinstance.KBObjectKey))
                            gera = false;
                    }
                    if (gera)
                    {
                        foreach (Signature sig in wobj.GetSignatures())
                        {
                            if (sig.ParametersCount > 0)
                            {
                                foreach (AttributeRelation ar in ta.ForeignKeyTo.KeyAttributes)
                                {
                                    geralink = false;
                                    foreach (Parameter par in sig.Parameters)
                                    {
                                        if (par.Object.Name.ToLower().IndexOf(ar.Related.Name.ToLower()) >= 0)
                                        {
                                            geralink = true;
                                        }
                                    }
                                    if (!geralink)
                                        break;
                                }
                                if (geralink)
                                {
                                    LinkElement link = new LinkElement();
                                    ae.Links.Add(link);
                                    link = new LinkElement();
                                    link.WebpanelObject = wobj;
                                    link.Tooltip = wobj.Description;

                                    foreach (AttributeRelation ar in ta.ForeignKeyTo.KeyAttributes)
                                    {
                                        link.Parameters.Add(new ParameterElement(ar.Base.Name));
                                    }
                                    break;
                                }
                            }
                            break;
                        }
                    }
                }
                if (geralink)
                {
                    break;
                }
            }
        }
Exemplo n.º 8
0
 private static string GridVariableBC(AttributeElement var)
 {
     string themeClass = GetThemeClass(var, var.Instance.Settings.Theme.ReadonlyGridAttribute);
     Dictionary<string, object> properties = new Dictionary<string, object>();
     properties[Properties.HTMLSFLCOL.ReadOnly] = true;
     GetControlInfo(var, properties,false,true);
     AddCustomRenderColProperties(properties, var);
     return WebForm.GridVariable(var.AttributeName, themeClass, var.Description, var.Visible, null, properties);
 }
Exemplo n.º 9
0
        private static string GridAttributePrompt(AttributeElement att, bool returnonclick)
        {
            string defaultThemeClass = att.Instance.Settings.Theme.ReadonlyGridAttribute;
            if (att.Attribute.Type == eDBType.BINARY)
                defaultThemeClass = att.Instance.Settings.Theme.ReadonlyGridBlobAttribute;

            string themeClass = GetThemeClass(att, defaultThemeClass);
            Dictionary<string, object> properties = new Dictionary<string, object>();
            GetControlInfo(att, properties);
            if (returnonclick)
            {
                properties[Properties.HTMLSFLCOL.ReturnOnClick] = true;
            }
            AddCustomRenderColProperties(properties, att);
            return WebForm.GridAttribute(att.AttributeName, themeClass, att.Description, att.Visible, null, properties);
        }
Exemplo n.º 10
0
        private static string GridAttribute(AttributeElement att)
        {
            string retorno = "";
            try
            {
                HPatternSettings settings = getSettings(att);

                string defaultThemeClass = "";
                if (settings != null)
                {
                    defaultThemeClass = settings.Theme.ReadonlyGridAttribute;
                    if (att.Attribute.Type == eDBType.BINARY)
                    {
                        defaultThemeClass = settings.Theme.ReadonlyGridBlobAttribute;
                    }
                }

                string themeClass = GetThemeClass(att, defaultThemeClass);
                Dictionary<string, object> properties = new Dictionary<string, object>();
                GetControlSize(att, properties);
                AddCustomRenderColProperties(properties, att);
                retorno = WebForm.GridAttribute(att.AttributeName, themeClass, att.Description, att.Visible, null, properties);
            }
            catch (Exception e)
            {
                System.Diagnostics.Debug.WriteLine(e.Message + " " + e.StackTrace);
            }
            return retorno;
        }