private void AddGridFilterConditions(FilterElement filterElement, Transaction trn, TransactionLevel level) { // Currently only the description attribute is added. if (level.DescriptionAttribute != null) AddFilterCondition(filterElement, level.DescriptionAttribute.Attribute); foreach (SettingsDefaultFilterElement filter in settings.DefaultFilters.DefaultFilters) { bool roda = false; if (filter.Selection) { if (filterElement.Parent is SelectionElement) { roda = true; } } if (filter.Prompt) { if (filterElement.Parent is PromptElement) { roda = true; } } if (roda) { if (filter.Attribute != null) { if (trn.Structure.Root.ContainsAttribute(filter.Attribute, false)) { if (!String.IsNullOrEmpty(filter.Value)) { filterElement.AddCondition(filter.Value); } } } } } }
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); } }
private void AddSuborTabTrnLevel(ViewElement viewElement, Transaction trn, TransactionLevel subLevel) { TabElement tabElement = viewElement.AddTab(subLevel.Name); tabElement.Name = subLevel.Description; tabElement.Wcname = trn.Name + subLevel.Name + "WC"; tabElement.Description = subLevel.Description; tabElement.Type = TabElement.TypeValue.Grid; tabElement.Page = TabElement.PageValue.Default; AddGridTabAttributes(tabElement, trn, subLevel, subLevel.Attributes); }
public static string GetDefinedBy(TransactionLevel trn) { string ret = ""; foreach (TransactionAttribute ta in trn.Attributes) { if (ta.IsKey || ta.IsDescriptionAttribute || !ta.IsInferred) { if (ret == String.Empty || (!ta.IsInferred && !ta.IsKey && !ta.IsForeignKey)) { ret = ta.Name; } } } if (ret != String.Empty) ret = "Defined By " + ret; return ret; }
private void AddParallelTabs(ViewElement viewElement, Transaction trn, TransactionLevel level) { foreach (Transaction parallel in level.AssociatedTable.AssociatedTransactions) { if (!parallel.Equals(trn)) { TabElement tabElement = viewElement.AddTab(parallel.Name); tabElement.Name = parallel.Description; tabElement.Wcname = trn.Name + parallel.Name; tabElement.Type = TabElement.TypeValue.Tabular; AddTrn(parallel, tabElement); AddTabularTabAttributes(tabElement, parallel, parallel.Structure.Root); AddActions(tabElement); } } }
private void AddPromptParameter(PromptElement prompt, TransactionLevel level) { foreach (TransactionAttribute ta in level.PrimaryKey) { bool carrega = true; bool notnull = false; foreach (SettingsDefaultFilterElement filter in settings.DefaultFilters.DefaultFilters) { if (filter.Prompt) { if (filter.Attribute != null) { if (filter.Attribute.Name == ta.Name) { if (!filter.Parm) { carrega = false; } else { if (filter.ParmNotNull) { notnull = true; } } } } } } if (carrega) { ParameterElement par = prompt.AddParameter(ta.Name); if (notnull) { par.Null = false; } } } if (settings.Template.PromptSuggestParmDescription) { if (level.DescriptionAttribute != null) { prompt.AddParameter(level.DescriptionAttribute.Name); } } }
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 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); } }
private void AddTabularTab(ViewElement viewElement, Transaction trn, TransactionLevel level, string lvlName, string wcDescription, bool needActions) { string code = "General"; TabElement tabElement = viewElement.AddTab(code); tabElement.Name = viewElement.Instance.Settings.Labels.GeneralTab; tabElement.Wcname = lvlName + "General"; tabElement.Description = wcDescription + " Info"; tabElement.Type = TabElement.TypeValue.Tabular; AddTabularTabAttributes(tabElement, trn, level); if (needActions) AddActions(tabElement); }
private void AddTabularTabAttributes(TabElement tabNode, Transaction trn, TransactionLevel level) { tabNode.Attributes = new AttributesElement(); AddTransactionAttributes(tabNode.Attributes, level, level.Attributes, AttributeTitle.Single); AddSuggestActionsTab(tabNode.Actions, tabNode.Instance.Settings); }
private void AddTabs(Transaction trn, ViewElement viewNode, string lvlName, string lvlDescription, TransactionLevel level, bool needActions) { // General tab AddTabularTab(viewNode, trn, level, lvlName, lvlDescription, needActions); //viewNode.Instance.Settings.Template.TitleImage // Tabs for parallel transactions. if (viewNode.Instance.Settings.Template.TabsForParallelTransactions) { if (trn.Structure.Root == level && level.AssociatedTable.AssociatedTransactions.Count > 1) AddParallelTabs(viewNode, trn, level); } // Tabs for subordinations. AddSuborTabs(viewNode, trn, level); }
private static string LeafLevel(TransactionLevel TransactionLevel, Dictionary<string, int> Counters) { StringBuilder ret = new StringBuilder(); string levelFullName = TransactionLevel.FullType.Replace(".", "_"); IDictionary<TransactionAttribute, Artech.Genexus.Common.Objects.Attribute> descAttNames; IList<int> toExclude = DefaultFormHelper.CalculateExcluded(TransactionLevel, out descAttNames); ret.AppendLine(WebForm.BeginGrid("Grid" + levelFullName, null, null, null, null, Properties.HTMLSFL.BackColorStyle_Enum.Header, null, null)); foreach (TransactionAttribute trnAttribute in TransactionLevel.Attributes) { if (!toExclude.Contains(trnAttribute.Attribute.Id)) { string colTitleProperty = "ColumnTitle"; Artech.Genexus.Common.Objects.Attribute attName; if (!descAttNames.TryGetValue(trnAttribute, out attName)) { attName = trnAttribute.Attribute; if (trnAttribute.IsLocal) colTitleProperty = "ContextualTitle"; } string colTitleExpr = String.Format("={0}.{1}", attName.Name, colTitleProperty); ret.AppendLine(WebForm.GridAttribute(trnAttribute.Name, null, colTitleExpr)); } } ret.AppendLine(WebForm.EndGrid()); return ret.ToString(); }
private static string InnerLevel(TransactionLevel TransactionLevel, System.Collections.Generic.Dictionary<string,int> Counters) { StringBuilder ret = new StringBuilder(); ret.AppendLine("<tr>"); ret.AppendLine("<td>"); ret.AppendLine(WebForm.BeginTable("Table" + (Counters["TableCounter"]++).ToString(), "Table")); IDictionary<TransactionAttribute, Artech.Genexus.Common.Objects.Attribute> descAttNames; IList<int> toExclude = DefaultFormHelper.CalculateExcluded(TransactionLevel, out descAttNames); int attributesCounter = 0; foreach (TransactionAttribute trnAttribute in TransactionLevel.PrimaryKey) { attributesCounter++; bool getButton = (TransactionLevel.Parent == null) && (attributesCounter == TransactionLevel.PrimaryKey.Count); ret.AppendLine( Heurys.Patterns.HPattern.Helpers.Template.OneAttribute(trnAttribute,Counters,getButton,descAttNames)); } foreach (Artech.Common.Helpers.Structure.IStructureItem structureItem in TransactionLevel.Items) { if (structureItem is TransactionAttribute) { TransactionAttribute trnAttribute = structureItem as TransactionAttribute; if (!trnAttribute.IsKey && !toExclude.Contains(trnAttribute.Attribute.Id)) { ret.AppendLine( Heurys.Patterns.HPattern.Helpers.Template.OneAttribute(trnAttribute,Counters,false,descAttNames)); } } else if (structureItem is TransactionLevel) { ret.AppendLine("<tr>"); ret.AppendLine("<td colspan=\"2\">"); TransactionLevel subLevel = structureItem as TransactionLevel; bool hasMoreLevels = (subLevel.Levels.Count > 0); if (hasMoreLevels) { ret.AppendLine("<br/>"); ret.AppendLine(WebForm.BeginTable("Table" + (Counters["TableCounter"]++).ToString(), "Table95")); ret.AppendLine("<tr>"); ret.AppendLine("<td class=\"SubTitle\">"); ret.AppendLine(WebForm.TextBlock("Title" + subLevel.Name, "", subLevel.Description)); ret.AppendLine("</td>"); ret.AppendLine("</tr>"); ret.AppendLine(WebForm.EndTable()); ret.AppendLine("<hr class=\"HRDefault\" />"); ret.AppendLine("<gxFreeStyle border=\"1\" freestyle=\"1\" gxProp=\"ControlName=Grid"+ (Counters["GridCounter"]++).ToString() +";class=FreeStyleGrid\">"); ret.AppendLine(InnerLevel(subLevel,Counters)); ret.AppendLine("</gxFreeStyle>"); } else { ret.AppendLine("<br/>"); ret.AppendLine(WebForm.BeginTable("Table" + (Counters["TableCounter"]++).ToString(), "Table95")); ret.AppendLine("<tr>"); ret.AppendLine("<td class=\"SubTitle\">"); ret.AppendLine(WebForm.TextBlock("Title" + subLevel.Name, "", subLevel.Description)); ret.AppendLine("</td>"); ret.AppendLine("</tr>"); ret.AppendLine(WebForm.EndTable()); ret.AppendLine("<hr class=\"HRDefault\" />"); ret.AppendLine( Heurys.Patterns.HPattern.Helpers.Template.LeafLevel(subLevel,Counters)); } ret.AppendLine("</td>"); ret.AppendLine("</tr>"); } } ret.AppendLine(WebForm.EndTable()); ret.AppendLine("</td>"); ret.AppendLine("</tr>"); return ret.ToString(); }
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); } }
private void AddView(Transaction trn, LevelElement levelElement, bool backToSelection, IList<TransactionAttribute> pk, TransactionLevel level, string viewName, string description, bool needActions, IList<TransactionAttribute> fixedAttris) { levelElement.View = new ViewElement(); levelElement.View.Description = FormatString(levelElement.Instance.Settings.Labels.ViewDescription, description); levelElement.View.BackToSelection = backToSelection; levelElement.View.MasterPage = ViewElement.MasterPageValue.Default; string trnCaption = (level.DescriptionAttribute != null ? String.Format("{0}.ToString()", level.DescriptionAttribute.Name) : String.Format("\"{0}\"", trn.Description)); levelElement.View.Caption = trnCaption; AddParameters(levelElement.View, false, pk); if (level.DescriptionAttribute != null) fixedAttris.Add(level.DescriptionAttribute); levelElement.View.FixedData = new FixedDataElement(); AddFixedDataAttributes(levelElement.View.FixedData, level, fixedAttris); AddTabs(trn, levelElement.View, viewName, description, level, needActions); }
private void AddGridOrders(IGridObject gridObject, Transaction trn, TransactionLevel level) { // Default order, by description attribute (if applicable). TransactionAttribute descAtt = level.DescriptionAttribute; if (descAtt != null && (descAtt.Attribute.Type != eDBType.BINARY && descAtt.Attribute.Type != eDBType.LONGVARCHAR) && (descAtt.Attribute.Class != AttributeClass.HORIZONTAL && descAtt.Attribute.Class != AttributeClass.VERTICAL)) { OrderElement orderElement = AddOrder(gridObject, descAtt.Attribute.ContextualTitleProperty); AddOrderAttribute(orderElement, descAtt, descAtt.Attribute.ContextualTitleProperty, true); } }
private string MakeTabUniqueId(TransactionLevel level, TransactionLevelRelation subord, ViewElement viewElement) { // If a table is subordinated to the level's base table more than once, then it is indexed // (i.e. "Client1", "Client2", "Client3"). Otherwise the table name is used ("Client"). int currentIndex = 0; bool addedIndex = false; string tabCode = subord.RelatedLevel.Name; while (viewElement.FindTab(tabCode) != null) { if (addedIndex) { // Remove this index to try with next one. Debug.Assert(tabCode.EndsWith(currentIndex.ToString())); tabCode = tabCode.Substring(0, subord.RelatedLevel.Name.Length); } currentIndex++; tabCode = tabCode + currentIndex.ToString(); addedIndex = true; } return tabCode; }
private void AddGridTabAttributes(TabElement tabElement, Transaction trn, TransactionLevel level, IList<TransactionAttribute> atts) { tabElement.Attributes = new AttributesElement(); AddTransactionAttributes(tabElement.Attributes, level, atts, AttributeTitle.Column); AddSuggestActionsTab(tabElement.Actions, tabElement.Instance.Settings); }
private void AddFixedDataAttributes(FixedDataElement fixedDataNode, TransactionLevel level, IList<TransactionAttribute> fixedAtts) { AddTransactionAttributes(fixedDataNode.Attributes, null, fixedAtts, AttributeTitle.Single); }
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 AddGridFilter(IGridObject gridObject, Transaction trn, TransactionLevel level) { gridObject.Filter = new FilterElement(); AddGridFilterAttributes(gridObject.Filter, trn, level); AddGridFilterConditions(gridObject.Filter, trn, level); AddGridFilterDynamicFilters(gridObject.Filter, trn, level); }
private void AddSuborTabs(ViewElement tabsNode, Transaction trn, TransactionLevel fatherLvl) { // Tabs for each transaction level subordinated to the first one. List<Table> tablesInTrnLvls = new List<Table>(); foreach (TransactionLevel suborLvl in fatherLvl.Levels) { AddSuborTabTrnLevel(tabsNode, trn, suborLvl); tablesInTrnLvls.Add(suborLvl.AssociatedTable); } // Tabs for other subordinated tables (by FK). foreach (TransactionLevelRelation relation in fatherLvl.GetSubordinations()) { if (!fatherLvl.Levels.Contains(relation.RelatedLevel) && !tablesInTrnLvls.Contains(relation.RelatedTransaction.Structure.Root.AssociatedTable)) { string tabId = MakeTabUniqueId(fatherLvl, relation, tabsNode); AddSuborTabTransaction(tabsNode, tabId, relation); } } }
private void AddGridFilterAttributes(FilterElement filterElement, Transaction trn, TransactionLevel level) { // Currently only the description attribute is added. if (level.DescriptionAttribute != null) AddFilterAttribute(filterElement, trn.Model, level.DescriptionAttribute.Name, BuildCaption(settings.Labels.FilterCaption,level.DescriptionAttribute,level.DescriptionAttribute.Attribute.ContextualTitleProperty), null, String.Empty); }
public TransactionAttribute(TransactionLevel level) { Level = level; }
public TransactionAttribute(TransactionLevel level, int timeoutSecond = 10) { Level = level; TimeoutSecond = timeoutSecond; }