private void AddTransactionAttributes(AttributesElement attributesElement, TransactionLevel level, IEnumerable<TransactionAttribute> attris, AttributeTitle descType) { IDictionary<TransactionAttribute, Gx.Attribute> attRelations = null; if (level != null) attRelations = DefaultFormHelper.CalculateRelations(level); bool ehSelection = false; if (attributesElement.Parent is SelectionElement) { ehSelection = true; } foreach (TransactionAttribute attri in attris) { bool gera = true; foreach (SettingsDefaultFilterElement filter in settings.DefaultFilters.DefaultFilters) { if (ehSelection && filter.Selection) { if (filter.Attribute != null) { if (filter.Attribute.Name == attri.Name) { if (!filter.InGridSelection) { gera = false; } } } if (gera) { if (!String.IsNullOrEmpty(filter.PartName)) { if (attri.Name.IndexOf(filter.PartName, StringComparison.InvariantCultureIgnoreCase) >= 0) { if (!filter.InGridSelection) { gera = false; } } } } } } if (gera || attri.IsKey) { // Don't show those attributes that are "normally" invisible. // For example, XId if it is a dynamic combo with descriptions from XName (providing XName is present). bool visible = true; if (attRelations != null && attRelations.ContainsKey(attri)) { Gx.Attribute relatedAtt = attRelations[attri]; if (level.ContainsAttribute(relatedAtt, false)) visible = false; } if (attri.IsKey && !gera) { visible = false; } string desc = attri.GetTitle(descType); if (descType == AttributeTitle.Column && attri.Attribute.ColumnTitle.Replace(" ", "").ToLower() == attri.Name.ToLower()) { desc = attri.Attribute.ContextualTitleProperty; } AddTransactionAttribute(attributesElement, attri, BuildCaption(settings.Labels.GridCaption, attri, desc), visible, false); } } }
private void AddPromptAttributes(AttributesElement attributesElement, TransactionLevel level, IEnumerable<TransactionAttribute> attris, AttributeTitle descType) { if (settings.Template.PromptSuggestGridPrimaryKey) { foreach (TransactionAttribute ta in level.PrimaryKey) { bool carrega = true; foreach (SettingsDefaultFilterElement filter in settings.DefaultFilters.DefaultFilters) { if (filter.Prompt) { if (filter.Attribute != null) { if (filter.Attribute.Name == ta.Name) { if (!filter.InGrid) { carrega = false; } } } } } if (ta.IsKey || carrega) { bool visivel = true; if (ta.IsKey && !carrega) { visivel = false; } AddTransactionAttribute(attributesElement, ta, BuildCaption(settings.Labels.GridCaption, ta, ta.GetTitle(descType)), visivel, false); } //AddTransactionAttribute(attributesElement, ta, ta.GetTitle(descType), true, false); } } TransactionAttribute da = level.Transaction.Structure.Root.DescriptionAttribute; if (da != null) { AddTransactionAttribute(attributesElement, da, BuildCaption(settings.Labels.GridCaption,da, da.GetTitle(descType)), true, false); //AddTransactionAttribute(attributesElement, da, da.GetTitle(descType), true, false); } else { IDictionary<TransactionAttribute, Gx.Attribute> attRelations = null; if (level != null) attRelations = DefaultFormHelper.CalculateRelations(level); foreach (TransactionAttribute attri in attris) { // Don't show those attributes that are "normally" invisible. // For example, XId if it is a dynamic combo with descriptions from XName (providing XName is present). bool visible = true; if (attRelations != null && attRelations.ContainsKey(attri)) { Gx.Attribute relatedAtt = attRelations[attri]; if (level.ContainsAttribute(relatedAtt, false)) visible = false; } AddTransactionAttribute(attributesElement, attri, BuildCaption(settings.Labels.GridCaption,attri, attri.GetTitle(descType)), true, false); //AddTransactionAttribute(attributesElement, attri, attri.GetTitle(descType), visible, false); if (visible) { break; } } } }
private void AddTransactionAttribute(AttributesElement attributesElement, TransactionAttribute att, string description, bool visible, bool forbidAutolink) { AttributeElement attElement = attributesElement.AddAttribute(att.Attribute); attElement.Description = description; attElement.Visible = visible; attElement.Autolink = (!forbidAutolink); }