예제 #1
0
    /// <summary>
    /// Reloads control with data.
    /// </summary>
    public void Reload()
    {
        // Display or hide source field selection
        if ((Mode == FieldEditorModeEnum.ClassFormDefinition) && (fi != null) && !IsAlternativeForm)
        {
            // Fill source field drop down list
            pnlSourceField.Visible = true;

            // Add document name source field
            drpSourceField.Items.Clear();

            DataClassInfo dci = DataClassInfoProvider.GetDataClass(ClassName);
            if ((dci != null) && dci.ClassIsProduct)
            {
                drpSourceField.Items.Add(new ListItem(GetString("TemplateDesigner.ImplicitProductSourceField"), ""));
            }
            else
            {
                drpSourceField.Items.Add(new ListItem(GetString("TemplateDesigner.ImplicitSourceField"), ""));
            }

            // Add alias name source field
            drpSourceAliasField.Items.Clear();
            drpSourceAliasField.Items.Add(new ListItem(GetString("TemplateDesigner.DefaultSourceField"), ""));

            AddField(drpSourceAliasField, "NodeID");
            AddField(drpSourceAliasField, "DocumentID");

            var columnNames = fi.GetColumnNames();
            if (columnNames != null)
            {
                // Add attribute list item to the list of attributes
                foreach (string name in columnNames)
                {
                    FormFieldInfo ffiColumn = fi.GetFormField(name);
                    // Don't add primary key field
                    if (!ffiColumn.PrimaryKey)
                    {
                        AddField(drpSourceField, name);
                    }
                    AddField(drpSourceAliasField, name);
                }
            }

            // Set selected value
            if (dci != null)
            {
                if (drpSourceField.Items.FindByValue(dci.ClassNodeNameSource) != null)
                {
                    drpSourceField.SelectedValue = dci.ClassNodeNameSource;
                }

                if (drpSourceAliasField.Items.FindByValue(dci.ClassNodeAliasSource) != null)
                {
                    drpSourceAliasField.SelectedValue = dci.ClassNodeAliasSource;
                }
            }
        }
    }
예제 #2
0
    /// <summary>
    /// Get form columns.
    /// </summary>
    private List <string> GetExistingColumns()
    {
        if (FormInfo != null)
        {
            return(FormInfo.GetColumnNames(false));
        }

        return(null);
    }
예제 #3
0
    /// <summary>
    /// Gets existing columns from form info
    /// </summary>
    /// <param name="sort">Indicates if the columns should be sorted</param>
    private List <string> GetExistingColumns(bool sort)
    {
        var existingColumns = FormInfo.GetColumnNames();

        if (sort)
        {
            existingColumns.Sort(StringComparer.InvariantCultureIgnoreCase);
        }

        return(existingColumns);
    }
예제 #4
0
    /// <summary>
    /// Gets existing columns from form info
    /// </summary>
    /// <param name="sort">Indicates if the columns should be sorted</param>
    private List <string> GetExistingColumns(bool sort)
    {
        List <string> existingColumns = new List <string>();

        string[] cols = FormInfo.GetColumnNames();
        foreach (string col in cols)
        {
            existingColumns.Add(col);
        }
        if (sort)
        {
            existingColumns.Sort(StringComparer.InvariantCultureIgnoreCase);
        }

        return(existingColumns);
    }
예제 #5
0
        /// <summary>
        /// Loads columns from given data class info.
        /// </summary>
        /// <param name="dci">DataClassInfo containing columns definitions</param>
        private void LoadColumns(DataClassInfo dci)
        {
            // Get info object based on form definition
            FormInfo fi = FormHelper.GetFormInfo(dci.ClassName, false);

            // Get column names from form info
            List <string> columnNames = fi.GetColumnNames();

            if (columnNames != null)
            {
                foreach (string name in columnNames)
                {
                    var ffi = fi.GetFormField(name);

                    // Add text fields to collection
                    if (DataTypeManager.IsString(TypeEnum.Field, ffi.DataType) && !ExcludeFields.Contains(name))
                    {
                        CMSUserProperties.Add(name);
                    }
                }
            }
        }
예제 #6
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Get custom table id from url
        customTableId = QueryHelper.GetInteger("customtableid", 0);

        dci = DataClassInfoProvider.GetDataClassInfo(customTableId);

        // Set edited object
        EditedObject = dci;

        // If class exists and is custom table
        if ((dci != null) && dci.ClassIsCustomTable)
        {
            // Ensure that object belongs to current site or user has access to site manager
            if (!CurrentUser.CheckPrivilegeLevel(UserPrivilegeLevelEnum.GlobalAdmin) && (dci.AssignedSites[SiteContext.CurrentSiteName] == null))
            {
                RedirectToInformation(GetString("general.notassigned"));
            }

            PageTitle.TitleText = GetString("customtable.data.selectdisplayedfields");
            CurrentMaster.DisplayActionsPanel = true;

            // Check 'Read' permission
            if (!dci.CheckPermissions(PermissionsEnum.Read, SiteContext.CurrentSiteName, MembershipContext.AuthenticatedUser))
            {
                ShowError(String.Format(GetString("customtable.permissiondenied.read"), dci.ClassName));
                plcContent.Visible = false;
                return;
            }

            HeaderActions.AddAction(new HeaderAction
            {
                Text          = GetString("UniSelector.SelectAll"),
                OnClientClick = "ChangeFields(true); return false;",
                ButtonStyle   = ButtonStyle.Default,
            });

            HeaderActions.AddAction(new HeaderAction
            {
                Text          = GetString("UniSelector.DeselectAll"),
                OnClientClick = "ChangeFields(false); return false;",
                ButtonStyle   = ButtonStyle.Default,
            });

            if (!RequestHelper.IsPostBack())
            {
                Hashtable reportFields = new Hashtable();

                // Get report fields
                if (!String.IsNullOrEmpty(dci.ClassShowColumns))
                {
                    reportFields.Clear();

                    foreach (string field in dci.ClassShowColumns.Split(';'))
                    {
                        // Add field key to hastable
                        reportFields[field] = null;
                    }
                }

                // Get columns names
                FormInfo fi          = FormHelper.GetFormInfo(dci.ClassName, false);
                var      columnNames = fi.GetColumnNames(false);

                if (columnNames != null)
                {
                    MacroResolver resolver = MacroResolverStorage.GetRegisteredResolver(FormHelper.FORM_PREFIX + dci.ClassName);
                    FormFieldInfo ffi;
                    ListItem      item;
                    foreach (string name in columnNames)
                    {
                        ffi = fi.GetFormField(name);

                        // Add checkboxes to the list
                        item = new ListItem(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(GetFieldCaption(ffi, name, resolver))), name);
                        if (reportFields.Contains(name))
                        {
                            // Select checkbox if field is reported
                            item.Selected = true;
                        }
                        chkListFields.Items.Add(item);
                    }
                }
            }
        }
        else
        {
            ShowError(GetString("customtable.notcustomtable"));
            CurrentMaster.FooterContainer.Visible = false;
        }
    }
예제 #7
0
 /// <summary>
 /// Get form columns.
 /// </summary>
 private List <string> GetExistingColumns()
 {
     return(FormInfo?.GetColumnNames(false, i => i.System));
 }
    /// <summary>
    /// Reloads control with data.
    /// </summary>
    public void Reload()
    {
        // Check if provided class name exists
        DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(ClassName);

        if (dci == null)
        {
            return;
        }

        // Display or hide source field selection
        if (dci.ClassIsDocumentType && (FormInfo != null) && !IsAlternativeForm && !IsInheritedForm)
        {
            // Fill source field drop down list
            pnlSourceField.Visible = true;

            // Add document name source field
            drpSourceField.Items.Clear();
            drpSourceField.Items.Add(new ListItem(GetString(dci.ClassIsProduct ? "TemplateDesigner.ImplicitProductSourceField" : "TemplateDesigner.ImplicitSourceField"), ""));

            // Add alias name source field
            drpSourceAliasField.Items.Clear();
            drpSourceAliasField.Items.Add(new ListItem(GetString("TemplateDesigner.DefaultSourceField"), ""));

            AddField(drpSourceAliasField, "NodeID");
            AddField(drpSourceAliasField, "DocumentID");

            var columnNames = FormInfo.GetColumnNames();
            if (columnNames != null)
            {
                // Add attribute list item to the list of attributes
                foreach (string name in columnNames)
                {
                    FormFieldInfo ffiColumn = FormInfo.GetFormField(name);

                    // Add only text fields
                    if (ffiColumn.IsNodeNameSourceCandidate())
                    {
                        AddField(drpSourceField, name);
                    }

                    // Add all fields which allow to be used as alias
                    var dataType = DataTypeManager.GetDataType(TypeEnum.Field, ffiColumn.DataType);
                    if ((dataType != null) && dataType.AllowAsAliasSource)
                    {
                        AddField(drpSourceAliasField, name);
                    }
                }
            }

            // Set selected value
            if (drpSourceField.Items.FindByValue(dci.ClassNodeNameSource) != null)
            {
                drpSourceField.SelectedValue = dci.ClassNodeNameSource;
            }

            if (drpSourceAliasField.Items.FindByValue(dci.ClassNodeAliasSource) != null)
            {
                drpSourceAliasField.SelectedValue = dci.ClassNodeAliasSource;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (EditedObject == null)
        {
            RedirectToAccessDenied(GetString("general.invalidparameters"));
        }

        Save += btnOK_Click;

        var user = MembershipContext.AuthenticatedUser;

        // Check permissions for Forms application
        if (!user.IsAuthorizedPerUIElement("cms.form", "Form"))
        {
            RedirectToUIElementAccessDenied("cms.form", "Form");
        }

        // Check 'ReadData' permission
        if (!user.IsAuthorizedPerResource("cms.form", "ReadData", SiteInfoProvider.GetSiteName(FormInfo.FormSiteID)))
        {
            RedirectToAccessDenied("cms.form", "ReadData");
        }

        // Check authorized roles for this form
        if (!FormInfo.IsFormAllowedForUser(MembershipContext.AuthenticatedUser.UserName, SiteContext.CurrentSiteName))
        {
            RedirectToAccessDenied(GetString("Bizforms.FormNotAllowedForUserRoles"));
        }

        List <String> columnNames  = null;
        DataClassInfo dci          = null;
        Hashtable     reportFields = new Hashtable();
        FormInfo      fi           = null;

        // Initialize controls
        PageTitle.TitleText = GetString("BizForm_Edit_Data_SelectFields.Title");
        CurrentMaster.DisplayActionsPanel = true;

        HeaderActions.AddAction(new HeaderAction
        {
            Text          = GetString("UniSelector.SelectAll"),
            OnClientClick = "ChangeFields(true); return false;",
            ButtonStyle   = ButtonStyle.Default,
        });

        HeaderActions.AddAction(new HeaderAction
        {
            Text          = GetString("UniSelector.DeselectAll"),
            OnClientClick = "ChangeFields(false); return false;",
            ButtonStyle   = ButtonStyle.Default,
        });

        if (!RequestHelper.IsPostBack())
        {
            if (FormInfo != null)
            {
                // Get dataclass info
                dci = DataClassInfoProvider.GetDataClassInfo(FormInfo.FormClassID);

                if (dci != null)
                {
                    // Get columns names
                    fi = FormHelper.GetFormInfo(dci.ClassName, false);

                    columnNames = fi.GetColumnNames(false, i => i.System);
                }

                // Get report fields
                if (String.IsNullOrEmpty(FormInfo.FormReportFields))
                {
                    reportFields = LoadReportFields(columnNames);
                }
                else
                {
                    reportFields.Clear();

                    foreach (string field in FormInfo.FormReportFields.Split(';'))
                    {
                        // Add field key to hastable
                        reportFields[field] = null;
                    }
                }

                if (columnNames != null)
                {
                    FormFieldInfo ffi  = null;
                    ListItem      item = null;

                    MacroResolver resolver = MacroResolverStorage.GetRegisteredResolver(FormHelper.FORM_PREFIX + FormInfo.ClassName);

                    foreach (string name in columnNames)
                    {
                        ffi = fi.GetFormField(name);

                        // Add checkboxes to the list
                        item = new ListItem(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(GetFieldCaption(ffi, name, resolver))), name);
                        if (reportFields.Contains(name))
                        {
                            // Select checkbox if field is reported
                            item.Selected = true;
                        }
                        chkListFields.Items.Add(item);
                    }
                }
            }
        }
    }
    /// <summary>
    /// Reloads control with data.
    /// </summary>
    public void Reload()
    {
        // Check if provided class name exists
        DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(ClassName);

        if (dci == null)
        {
            return;
        }

        FormInfo = new FormInfo(dci.ClassFormDefinition);

        // Display or hide source field selection
        if (dci.ClassIsDocumentType && (FormInfo != null) && !IsAlternativeForm && !IsInheritedForm)
        {
            // Fill source field drop down list
            pnlSourceField.Visible = true;

            // Add document name source field
            drpSourceField.Items.Clear();

            drpSourceField.Items.Add(new ListItem(GetString(dci.ClassIsProduct ? "TemplateDesigner.ImplicitProductSourceField" : "TemplateDesigner.ImplicitSourceField"), ""));

            // Add alias name source field
            drpSourceAliasField.Items.Clear();
            drpSourceAliasField.Items.Add(new ListItem(GetString("TemplateDesigner.DefaultSourceField"), ""));

            AddField(drpSourceAliasField, "NodeID");
            AddField(drpSourceAliasField, "DocumentID");

            var columnNames = FormInfo.GetColumnNames();
            if (columnNames != null)
            {
                // Add attribute list item to the list of attributes
                foreach (string name in columnNames)
                {
                    FormFieldInfo ffiColumn = FormInfo.GetFormField(name);

                    // Add only text fields
                    if (!ffiColumn.PrimaryKey && !ffiColumn.AllowEmpty && ((ffiColumn.DataType == FieldDataType.Text) || (ffiColumn.DataType == FieldDataType.LongText)))
                    {
                        AddField(drpSourceField, name);
                    }

                    // Add all fields except file and document attachment fields
                    if ((ffiColumn.DataType != FieldDataType.File) && (ffiColumn.DataType != FieldDataType.DocAttachments))
                    {
                        AddField(drpSourceAliasField, name);
                    }
                }
            }

            if (drpSourceField.Items.FindByValue(dci.ClassNodeNameSource) != null)
            {
                drpSourceField.SelectedValue = dci.ClassNodeNameSource;
            }

            if (drpSourceAliasField.Items.FindByValue(dci.ClassNodeAliasSource) != null)
            {
                drpSourceAliasField.SelectedValue = dci.ClassNodeAliasSource;
            }
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        CurrentMaster.Title.TitleText     = GetString("customtable.data.selectdisplayedfields");
        CurrentMaster.Title.TitleImage    = GetImageUrl("CMSModules/CMS_CustomTables/selectfields.png");
        CurrentMaster.DisplayActionsPanel = true;

        // Get custom table id from url
        customTableId = QueryHelper.GetInteger("customtableid", 0);

        dci = DataClassInfoProvider.GetDataClass(customTableId);
        // Set edited object
        EditedObject = dci;

        // If class exists
        if (dci != null)
        {
            // Check 'Read' permission
            if (!CMSContext.CurrentUser.IsAuthorizedPerResource("cms.customtables", "Read") &&
                !CMSContext.CurrentUser.IsAuthorizedPerClassName(dci.ClassName, "Read"))
            {
                ShowError(String.Format(GetString("customtable.permissiondenied.read"), dci.ClassName));
                plcContent.Visible = false;
                return;
            }

            HeaderActions.AddAction(new HeaderAction()
            {
                ImageUrl      = GetImageUrl("Design/Controls/UI/selectall.png"),
                Text          = GetString("UniSelector.SelectAll"),
                OnClientClick = "ChangeFields(true); return false;"
            });

            HeaderActions.AddAction(new HeaderAction()
            {
                ImageUrl      = GetImageUrl("Design/Controls/UI/deselectall.png"),
                Text          = GetString("UniSelector.DeselectAll"),
                OnClientClick = "ChangeFields(false); return false;"
            });

            Hashtable reportFields = new Hashtable();

            FormInfo fi = null;

            if (!RequestHelper.IsPostBack())
            {
                btnOk.Text     = GetString("General.OK");
                btnCancel.Text = GetString("General.Cancel");

                // Get report fields
                if (!String.IsNullOrEmpty(dci.ClassShowColumns))
                {
                    reportFields.Clear();

                    foreach (string field in dci.ClassShowColumns.Split(';'))
                    {
                        // Add field key to hastable
                        reportFields[field] = null;
                    }
                }

                // Get columns names
                fi = FormHelper.GetFormInfo(dci.ClassName, false);
                var columnNames = fi.GetColumnNames();

                if (columnNames != null)
                {
                    FormFieldInfo ffi  = null;
                    ListItem      item = null;
                    foreach (string name in columnNames)
                    {
                        ffi = fi.GetFormField(name);

                        // Add checkboxes to the list
                        item = new ListItem(HTMLHelper.HTMLEncode(ResHelper.LocalizeString(GetFieldCaption(ffi, name))), name);
                        if (reportFields.Contains(name))
                        {
                            // Select checkbox if field is reported
                            item.Selected = true;
                        }
                        chkListFields.Items.Add(item);
                    }
                }
            }
        }
    }
 /// <summary>
 /// Get form columns.
 /// </summary>
 private List <string> GetExistingColumns()
 {
     return(FormInfo.GetColumnNames());
 }
예제 #13
0
    protected void Page_Load(object sender, EventArgs e)
    {
        // Check permissions for CMS Desk -> Tools
        CurrentUserInfo user = CMSContext.CurrentUser;

        if (!user.IsAuthorizedPerUIElement("CMS.Desk", "Tools"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Desk", "Tools");
        }

        // Check permissions for CMS Desk -> Tools -> BizForms
        if (!user.IsAuthorizedPerUIElement("CMS.Tools", "Form"))
        {
            RedirectToCMSDeskUIElementAccessDenied("CMS.Tools", "Form");
        }

        // Check 'ReadData' permission
        if (!user.IsAuthorizedPerResource("cms.form", "ReadData"))
        {
            RedirectToCMSDeskAccessDenied("cms.form", "ReadData");
        }

        // Get form id from url
        formId = QueryHelper.GetInteger("formid", 0);

        BizFormInfo bfi = BizFormInfoProvider.GetBizFormInfo(formId);

        EditedObject = bfi;

        if (bfi != null)
        {
            // Check authorized roles for this form
            if (!bfi.IsFormAllowedForUser(CMSContext.CurrentUser.UserName, CMSContext.CurrentSiteName))
            {
                RedirectToAccessDenied(GetString("Bizforms.FormNotAllowedForUserRoles"));
            }
        }

        string[]      columnNames  = null;
        DataClassInfo dci          = null;
        Hashtable     reportFields = new Hashtable();
        FormInfo      fi           = null;

        // Initialize controls
        this.CurrentMaster.Title.TitleText     = GetString("BizForm_Edit_Data_SelectFields.Title");
        this.CurrentMaster.Title.TitleImage    = GetImageUrl("CMSModules/CMS_Form/selectfields.png");
        this.CurrentMaster.DisplayActionsPanel = true;

        btnSelectAll.Text = GetString("BizForm_Edit_Data_SelectFields.SelectAll");

        if (!RequestHelper.IsPostBack())
        {
            btnOk.Text     = GetString("General.OK");
            btnCancel.Text = GetString("General.Cancel");

            if (bfi != null)
            {
                // Get dataclass info
                dci = DataClassInfoProvider.GetDataClass(bfi.FormClassID);

                if (dci != null)
                {
                    // Get columns names
                    fi = FormHelper.GetFormInfo(dci.ClassName, false);

                    columnNames = fi.GetColumnNames();
                }

                // Get report fields
                if (String.IsNullOrEmpty(bfi.FormReportFields))
                {
                    reportFields = LoadReportFields(columnNames);
                }
                else
                {
                    reportFields.Clear();

                    foreach (string field in bfi.FormReportFields.Split(';'))
                    {
                        // Add field key to hastable
                        reportFields[field] = null;
                    }
                }

                if (columnNames != null)
                {
                    foreach (string name in columnNames)
                    {
                        FormFieldInfo ffi = fi.GetFormField(name);

                        // Add checkboxes to the list
                        ListItem item = new ListItem(ResHelper.LocalizeString(GetFieldCaption(ffi, name)), name);
                        if (reportFields.Contains(name))
                        {
                            // Select checkbox if field is reported
                            item.Selected = true;
                        }
                        chkListFields.Items.Add(item);
                    }
                }
            }
        }
    }