/// <summary>
    /// Gets FormEngineUserControl instance for the input SettingsKeyInfo object.
    /// </summary>
    /// <param name="key">SettingsKeyInfo</param>
    /// <param name="groupNo">Number representing index of the processing settings group</param>
    /// <param name="keyNo">Number representing index of the processing SettingsKeyInfo</param>
    private FormEngineUserControl GetFormEngineUserControl(SettingsKeyInfo key, int groupNo, int keyNo)
    {
        string controlNameOrPath = key.KeyEditingControlPath;

        if (string.IsNullOrEmpty(controlNameOrPath))
        {
            return(null);
        }

        // Try to get form control by its name
        FormEngineUserControl control = null;
        var formUserControl           = FormUserControlInfoProvider.GetFormUserControlInfo(controlNameOrPath);

        if (formUserControl != null)
        {
            var formProperties = formUserControl.UserControlMergedParameters;

            if (formUserControl.UserControlParentID > 0)
            {
                // Get parent user control
                var parentFormUserControl = FormUserControlInfoProvider.GetFormUserControlInfo(formUserControl.UserControlParentID);
                if (parentFormUserControl != null)
                {
                    formUserControl = parentFormUserControl;
                }
            }

            // Create FormInfo and load control
            control = Page.LoadUserControl(FormUserControlInfoProvider.GetFormUserControlUrl(formUserControl)) as FormEngineUserControl;
            if (control != null)
            {
                FormInfo fi = FormHelper.GetFormControlParameters(controlNameOrPath, formProperties, false);
                control.LoadDefaultProperties(fi);

                if (!string.IsNullOrEmpty(key.KeyFormControlSettings))
                {
                    control.FieldInfo = FormHelper.GetFormControlSettingsFromXML(key.KeyFormControlSettings);
                    control.LoadControlFromFFI();
                }
            }
        }
        else
        {
            // Try to load the control
            try
            {
                control = Page.LoadUserControl(controlNameOrPath) as FormEngineUserControl;
            }
            catch (Exception ex)
            {
                EventLogProvider.LogException("Settings", "LoadControl", ex);
            }
        }

        if (control == null)
        {
            return(null);
        }

        control.ID         = string.Format(@"key{0}{1}", groupNo, keyNo);
        control.IsLiveSite = false;

        return(control);
    }
Пример #2
0
    /// <summary>
    /// Gets FormEngineUserControl instance for the input SettingsKeyInfo object.
    /// </summary>
    /// <param name="key">SettingsKeyInfo</param>
    /// <param name="groupNo">Number representing index of the processing settings group</param>
    /// <param name="keyNo">Number representing index of the processing SettingsKeyInfo</param>
    private FormEngineUserControl GetFormEngineUserControl(SettingsKeyInfo key, int groupNo, int keyNo)
    {
        if (string.IsNullOrEmpty(key.KeyEditingControlPath))
        {
            return(null);
        }

        // Try to get form control by its name
        FormEngineUserControl control = null;
        var formUserControl           = FormUserControlInfoProvider.GetFormUserControlInfo(key.KeyEditingControlPath);

        if (formUserControl != null)
        {
            var fileName       = "";
            var formProperties = "";

            if (formUserControl.UserControlParentID > 0)
            {
                // Get parent user control
                var parentFormUserControl = FormUserControlInfoProvider.GetFormUserControlInfo(formUserControl.UserControlParentID);
                if (parentFormUserControl != null)
                {
                    fileName       = parentFormUserControl.UserControlFileName;
                    formProperties = formUserControl.UserControlMergedParameters;
                }
            }
            else
            {
                // Current user control info
                fileName       = formUserControl.UserControlFileName;
                formProperties = formUserControl.UserControlParameters;
            }

            // Create FormInfo and load control
            control = Page.LoadUserControl(fileName) as FormEngineUserControl;
            if (control != null)
            {
                FormInfo fi = FormHelper.GetFormControlParameters(formUserControl.UserControlCodeName, formProperties, true);
                control.LoadDefaultProperties(fi);

                if (!string.IsNullOrEmpty(key.KeyFormControlSettings))
                {
                    control.FieldInfo = FormHelper.GetFormControlSettingsFromXML(key.KeyFormControlSettings);
                    control.LoadControlFromFFI();
                }
            }
        }
        else
        {
            // Try to load the control
            try
            {
                control = Page.LoadUserControl(key.KeyEditingControlPath) as FormEngineUserControl;
            }
            catch
            {
            }
        }

        if (control == null)
        {
            return(null);
        }

        control.ID         = string.Format(@"key{0}{1}", groupNo, keyNo);
        control.IsLiveSite = false;

        if (string.IsNullOrEmpty(key.KeyEditingControlPath))
        {
            return(control);
        }

        // Set properties to the specific controls
        switch (key.KeyEditingControlPath.ToLowerCSafe())
        {
        // Class names selectors
        case "~/cmsformcontrols/classes/selectclassnames.ascx":
            control.SetValue("SiteID", 0);
            break;
        }

        return(control);
    }