示例#1
0
    protected void MappingItemRepeater_ItemDataBound(object sender, RepeaterItemEventArgs e)
    {
        LocalizedLabel  literal      = e.Item.FindControl("FieldNameLiteral") as LocalizedLabel;
        CMSDropDownList dropDownList = e.Item.FindControl("AttributeNamesDropDownList") as CMSDropDownList;
        FormFieldInfo   fieldInfo    = e.Item.DataItem as FormFieldInfo;

        literal.Text = ResHelper.LocalizeString(fieldInfo.GetDisplayName(MacroContext.CurrentResolver));
        dropDownList.Items.Add(new ListItem(String.Empty, String.Empty));
        dropDownList.Items.AddRange(mContext.EntityInfo.Items.Select(x => new ListItem(ResHelper.LocalizeString(x.DisplayName), x.Name)).ToArray());
        mAttributeNamesDropDownLists.Add(fieldInfo.Name, dropDownList);
    }
    /// <summary>
    /// Returns field caption of the specified column.
    /// </summary>
    /// <param name="ffi">Form field info</param>
    /// <param name="columnName">Column name</param>
    protected string GetFieldCaption(FormFieldInfo ffi, string columnName, MacroResolver resolver)
    {
        string fieldCaption = string.Empty;

        // get field caption
        if (ffi != null)
        {
            fieldCaption = ffi.GetDisplayName(resolver);
        }
        if (string.IsNullOrEmpty(fieldCaption))
        {
            fieldCaption = columnName;
        }

        return(fieldCaption);
    }
    /// <summary>
    /// Creates and initializes a new instance of the Panel class with the specified Data.com contact mapping, and returns it.
    /// </summary>
    /// <param name="formInfo">The CMS contact form info.</param>
    /// <param name="entityInfo">The Data.com contact entity info.</param>
    /// <param name="mapping">The Data.com contact mapping.</param>
    /// <returns>A new instance of the Panel class initialized with the specified Data.com contact mapping.</returns>
    private Panel CreateMappingPanel(FormInfo formInfo, EntityInfo entityInfo, EntityMapping mapping)
    {
        Panel mappingPanel = new Panel {
            CssClass = "mapping"
        };

        mappingPanel.Controls.Add(CreateHeaderPanel());
        foreach (IField formItem in formInfo.ItemsList)
        {
            FormFieldInfo formField = formItem as FormFieldInfo;
            if (formField != null)
            {
                EntityMappingItem mappingItem = mapping.GetItem(formField.Name);
                if (mappingItem != null)
                {
                    EntityAttributeInfo entityAttribute = entityInfo.GetAttributeInfo(mappingItem.EntityAttributeName);
                    if (entityAttribute != null)
                    {
                        Panel row = new Panel {
                            CssClass = "control-group-inline"
                        };
                        mappingPanel.Controls.Add(row);

                        Panel formFieldPanel = new Panel {
                            CssClass = "input-width-60 cms-form-group-text"
                        };
                        row.Controls.Add(formFieldPanel);
                        formFieldPanel.Controls.Add(new Literal {
                            Text = ResHelper.LocalizeString(formField.GetDisplayName(MacroContext.CurrentResolver))
                        });

                        Panel entityAttributePanel = new Panel {
                            CssClass = "input-width-60 cms-form-group-text"
                        };
                        row.Controls.Add(entityAttributePanel);
                        entityAttributePanel.Controls.Add(new Literal {
                            Text = ResHelper.LocalizeString(entityAttribute.DisplayName)
                        });
                    }
                }
            }
        }

        return(mappingPanel);
    }
示例#4
0
    /// <summary>
    /// Creates and initializes a new instance of the Panel class with the specified Data.com contact mapping, and returns it.
    /// </summary>
    /// <param name="formInfo">The CMS contact form info.</param>
    /// <param name="entityInfo">The Data.com contact entity info.</param>
    /// <param name="mapping">The Data.com contact mapping.</param>
    /// <returns>A new instance of the Panel class initialized with the specified Data.com contact mapping.</returns>
    private Panel CreateMappingPanel(FormInfo formInfo, EntityInfo entityInfo, EntityMapping mapping)
    {
        Panel mappingPanel = new Panel {
            CssClass = "mapping"
        };
        HtmlTable mappingTable = new HtmlTable();

        mappingTable.Controls.Add(CreateHeaderPanel());
        mappingPanel.Controls.Add(mappingTable);

        foreach (IDataDefinitionItem formItem in formInfo.ItemsList)
        {
            FormFieldInfo formField = formItem as FormFieldInfo;
            if (formField != null)
            {
                EntityMappingItem mappingItem = mapping.GetItem(formField.Name);
                if (mappingItem != null)
                {
                    EntityAttributeInfo entityAttribute = entityInfo.GetAttributeInfo(mappingItem.EntityAttributeName);
                    if (entityAttribute != null)
                    {
                        HtmlTableRow row = new HtmlTableRow();
                        mappingTable.Controls.Add(row);

                        HtmlTableCell formFieldCell = new HtmlTableCell();
                        formFieldCell.Controls.Add(new Literal {
                            Text = ResHelper.LocalizeString(formField.GetDisplayName(MacroContext.CurrentResolver))
                        });

                        HtmlTableCell entityAttributeCell = new HtmlTableCell();
                        entityAttributeCell.Controls.Add(new Literal {
                            Text = ResHelper.LocalizeString(entityAttribute.DisplayName)
                        });

                        row.Controls.Add(formFieldCell);
                        row.Controls.Add(entityAttributeCell);
                    }
                }
            }
        }

        return(mappingPanel);
    }
示例#5
0
    protected void gridData_OnLoadColumns()
    {
        if ((bfi != null) && (FormInfo != null))
        {
            // Update the actions command argument
            foreach (var action in gridData.GridActions.Actions)
            {
                ((Action)action).CommandArgument = primaryColumn;
            }

            // Get existing columns names
            var columnList = GetExistingColumns();

            string columns = bfi.FormReportFields;
            if (!string.IsNullOrEmpty(columns))
            {
                var selectedColumns = GetSelectedColumns(columns);

                columnList = columnList.Intersect(selectedColumns, StringComparer.InvariantCultureIgnoreCase).ToList();

                // Set columns which should be retrieved in query and ensure primary column
                gridData.Columns = (!columnList.Contains(primaryColumn, StringComparer.InvariantCultureIgnoreCase) ? "[" + primaryColumn + "],[" : "[") + columnList.Join("],[") + "]";
            }

            // Get macro resolver for current form
            MacroResolver resolver = MacroResolverStorage.GetRegisteredResolver(FormHelper.FORM_PREFIX + dci.ClassName);

            // Loop trough all columns
            int lastIndex = columnList.Count - 1;
            for (int i = 0; i <= lastIndex; i++)
            {
                string column = columnList[i];

                // Get field caption
                FormFieldInfo ffi = FormInfo.GetFormField(column);

                string fieldCaption;
                if (ffi == null)
                {
                    fieldCaption = column;
                }
                else
                {
                    string caption = ffi.GetDisplayName(resolver);
                    fieldCaption = (String.IsNullOrEmpty(caption)) ? column : ResHelper.LocalizeString(caption);
                }

                Column columnDefinition = new Column
                {
                    Caption            = fieldCaption,
                    Source             = column,
                    ExternalSourceName = ((ffi != null) && ffi.DataType.Equals(FieldDataType.Date, StringComparison.OrdinalIgnoreCase)) ? DATE_TRANSFORMATION : null,
                    AllowSorting       = true,
                    Wrap = false
                };

                if (i == lastIndex)
                {
                    // Stretch last column
                    columnDefinition.Width = "100%";
                }

                gridData.GridColumns.Columns.Add(columnDefinition);
            }
        }
    }
示例#6
0
    private MappingItem GetMappingItem()
    {
        string name = SourceDropDownList.SelectedValue;

        if (!String.IsNullOrEmpty(name))
        {
            if (name.StartsWithCSafe("Field-"))
            {
                name = name.Remove(0, "Field-".Length);
                FormFieldInfo fieldInfo = FormInfo.GetFormField(name);
                if (fieldInfo != null)
                {
                    return(new MappingItem(EntityAttributeModel, name, ResHelper.LocalizeString(fieldInfo.GetDisplayName(MacroContext.CurrentResolver)), MappingItemSourceTypeEnum.Field));
                }
            }
            else if (name.StartsWithCSafe("MetaField-"))
            {
                name = name.Remove(0, "MetaField-".Length);
                switch (name)
                {
                case "CompanyName":
                    return(new MappingItem(EntityAttributeModel, name, GetString("sf.metasource.companyname"), MappingItemSourceTypeEnum.MetaField));

                case "Description":
                    return(new MappingItem(EntityAttributeModel, name, GetString("sf.metasource.description"), MappingItemSourceTypeEnum.MetaField));

                case "Country":
                    return(new MappingItem(EntityAttributeModel, name, GetString("sf.metasource.country"), MappingItemSourceTypeEnum.MetaField));

                case "State":
                    return(new MappingItem(EntityAttributeModel, name, GetString("sf.metasource.state"), MappingItemSourceTypeEnum.MetaField));
                }
            }
            else if (name.StartsWithCSafe("PicklistEntry-"))
            {
                name = name.Remove(0, "PicklistEntry-".Length);
                PicklistEntry entry = EntityAttributeModel.PicklistEntries.SingleOrDefault(x => x.IsActive && x.Value == name);
                if (entry != null)
                {
                    return(new MappingItem(EntityAttributeModel, name, entry.Label, MappingItemSourceTypeEnum.PicklistEntry));
                }
            }
        }

        return(null);
    }
    /// <summary>
    /// Returns field caption of the specified column.
    /// </summary>
    /// <param name="ffi">Form field info</param>
    /// <param name="columnName">Column name</param>    
    protected string GetFieldCaption(FormFieldInfo ffi, string columnName, MacroResolver resolver)
    {
        string fieldCaption = string.Empty;

        // get field caption
        if (ffi != null)
        {
            fieldCaption = ffi.GetDisplayName(resolver);
        }
        if (string.IsNullOrEmpty(fieldCaption))
        {
            fieldCaption = columnName;
        }

        return fieldCaption;
    }
    protected void gridData_OnLoadColumns()
    {
        if ((bfi != null) && (FormInfo != null))
        {
            var    columnList = new List <string>();
            string columns    = bfi.FormReportFields;
            if (string.IsNullOrEmpty(columns))
            {
                columnList = GetExistingColumns();
            }
            else
            {
                // Get existing columns names
                var existingColumns = GetExistingColumns();

                // Get selected columns
                var selectedColumns = GetSelectedColumns(columns);

                columns     = string.Empty;
                columnNames = string.Empty;
                StringBuilder sb = new StringBuilder();

                // Remove nonexisting columns
                foreach (string col in selectedColumns)
                {
                    if (existingColumns.Contains(col))
                    {
                        columnList.Add(col);
                        sb.Append(",[").Append(col).Append("]");
                    }
                }
                columnNames = sb.ToString();

                // Ensure primary key
                if (!(columnNames.Contains(primaryColumn) || columnNames.Contains(primaryColumn)))
                {
                    columnNames = ",[" + primaryColumn + "]" + columnNames;
                }

                columnNames = columnNames.TrimStart(',');
            }

            // Get macro resolver for current form
            MacroResolver resolver = MacroResolverStorage.GetRegisteredResolver(FormHelper.FORM_PREFIX + dci.ClassName);

            // Loop trough all columns
            for (int i = 0; i < columnList.Count; i++)
            {
                string column = columnList[i];

                // Get field caption
                FormFieldInfo ffi = FormInfo.GetFormField(column);

                string fieldCaption = null;
                if (ffi == null)
                {
                    fieldCaption = column;
                }
                else
                {
                    string caption = ffi.GetDisplayName(resolver);
                    fieldCaption = (string.IsNullOrEmpty(caption)) ? column : ResHelper.LocalizeString(caption);
                }

                Column columnDefinition = new Column
                {
                    Caption      = fieldCaption,
                    Source       = column,
                    AllowSorting = true,
                    Wrap         = false
                };

                if (i == columnList.Count - 1)
                {
                    // Stretch last column
                    columnDefinition.Width = "100%";
                }

                gridData.GridColumns.Columns.Add(columnDefinition);
            }
        }
    }