当前位置: 首页>>代码示例>>C#>>正文


C# FormInfo.GetFormField方法代码示例

本文整理汇总了C#中FormInfo.GetFormField方法的典型用法代码示例。如果您正苦于以下问题:C# FormInfo.GetFormField方法的具体用法?C# FormInfo.GetFormField怎么用?C# FormInfo.GetFormField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在FormInfo的用法示例。


在下文中一共展示了FormInfo.GetFormField方法的12个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。

示例1: Import

    /// <summary>
    /// Import files.
    /// </summary>
    private void Import(object parameter)
    {
        try
        {
            object[] parameters = (object[])parameter;
            string[] items = (string[])parameters[0];
            CurrentUserInfo currentUser = (CurrentUserInfo)parameters[3];

            if ((items.Length > 0) && (currentUser != null))
            {
                resultListValues.Clear();
                errorFiles.Clear();
                hdnValue.Value = null;
                hdnSelected.Value = null;
                string siteName = CMSContext.CurrentSiteName;
                string targetAliasPath = ValidationHelper.GetString(parameters[1], null);

                bool imported = false; // Flag - true if one file was imported at least
                bool importError = false; // Flag - true when import failed

                TreeProvider tree = new TreeProvider(currentUser);
                TreeNode tn = tree.SelectSingleNode(siteName, targetAliasPath, TreeProvider.ALL_CULTURES, true, null, false);
                if (tn != null)
                {
                    // Check if CMS.File document type exist and check if document contains required columns (FileName, FileAttachment)
                    DataClassInfo fileClassInfo = DataClassInfoProvider.GetDataClass("CMS.File");
                    if (fileClassInfo == null)
                    {
                        AddError(GetString("newfile.classcmsfileismissing"));
                        return;
                    }
                    else
                    {
                        FormInfo fi = new FormInfo(fileClassInfo.ClassFormDefinition);
                        FormFieldInfo fileFfi = null;
                        FormFieldInfo attachFfi = null;
                        if (fi != null)
                        {
                            fileFfi = fi.GetFormField("FileName");
                            attachFfi = fi.GetFormField("FileAttachment");
                        }
                        if ((fi == null) || (fileFfi == null) || (attachFfi == null))
                        {
                            AddError(GetString("newfile.someofrequiredfieldsmissing"));
                            return;
                        }
                    }

                    DataClassInfo dci = DataClassInfoProvider.GetDataClass(tn.NodeClassName);

                    if (dci != null)
                    {
                        // Check if "file" and "folder" are allowed as a child document under selected document type
                        bool fileAllowed = false;
                        bool folderAllowed = false;
                        DataClassInfo folderClassInfo = DataClassInfoProvider.GetDataClass("CMS.Folder");
                        if ((fileClassInfo != null) || (folderClassInfo != null))
                        {
                            string[] paths;
                            foreach (string fullFileName in items)
                            {
                                paths = fullFileName.Substring(rootPath.Length).Split('\\');
                                // Check file
                                if (paths.Length == 1)
                                {
                                    if (!fileAllowed && (fileClassInfo != null) && !DataClassInfoProvider.IsChildClassAllowed(dci.ClassID, fileClassInfo.ClassID))
                                    {
                                        AddError(GetString("Tools.FileImport.NotAllowedChildClass"));
                                        return;
                                    }
                                    else
                                    {
                                        fileAllowed = true;
                                    }
                                }

                                // Check folder
                                if (paths.Length > 1)
                                {
                                    if (!folderAllowed && (folderClassInfo != null) && !DataClassInfoProvider.IsChildClassAllowed(dci.ClassID, folderClassInfo.ClassID))
                                    {
                                        AddError(GetString("Tools.FileImport.FolderNotAllowedChildClass"));
                                        return;
                                    }
                                    else
                                    {
                                        folderAllowed = true;
                                    }
                                }

                                if (fileAllowed && folderAllowed)
                                {
                                    break;
                                }
                            }
                        }

//.........这里部分代码省略.........
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:101,代码来源:ImportFromServer.aspx.cs

示例2: LoadDataRowFromWebPart

    /// <summary>
    /// Loads the data row data from given web part instance.
    /// </summary>
    /// <param name="dr">DataRow to fill</param>
    /// <param name="webPart">Source web part</param>
    /// <param name="formInfo">Web part form info</param>
    private void LoadDataRowFromWebPart(DataRow dr, WebPartInstance webPart, FormInfo formInfo)
    {
        if (webPart != null)
        {
            foreach (DataColumn column in dr.Table.Columns)
            {
                try
                {
                    bool load = true;
                    // switch by xml version
                    switch (xmlVersion)
                    {
                        case 1:
                            load = webPart.Properties.Contains(column.ColumnName.ToLowerCSafe()) || column.ColumnName.EqualsCSafe("webpartcontrolid", true);
                            break;
                        // Version 0
                        default:
                            // Load default value for Boolean type in old XML version
                            if ((column.DataType == typeof(bool)) && !webPart.Properties.Contains(column.ColumnName.ToLowerCSafe()))
                            {
                                FormFieldInfo ffi = formInfo.GetFormField(column.ColumnName);
                                if (ffi != null)
                                {
                                    webPart.SetValue(column.ColumnName, ffi.GetPropertyValue(FormFieldPropertyEnum.DefaultValue));
                                }
                            }
                            break;
                    }

                    if (load)
                    {
                        var value = webPart.GetValue(column.ColumnName);

                        // Convert value into default format
                        if ((value != null) && (ValidationHelper.GetString(value, String.Empty) != String.Empty))
                        {
                            if (column.DataType == typeof(decimal))
                            {
                                value = ValidationHelper.GetDouble(value, 0, "en-us");
                            }

                            if (column.DataType == typeof(DateTime))
                            {
                                value = ValidationHelper.GetDateTime(value, DateTime.MinValue, "en-us");
                            }
                        }

                        DataHelper.SetDataRowValue(dr, column.ColumnName, value);
                    }
                }
                catch (Exception ex)
                {
                    EventLogProvider.LogException("WebPartProperties", "LOADDATAROW", ex);
                }
            }
        }
    }
开发者ID:dlnuckolls,项目名称:pfh-paypalintegration,代码行数:63,代码来源:WebpartProperties.ascx.cs

示例3: LoadFormDefinition

    /// <summary>
    /// Loads the from definition from selected parameter into a BasicForm control.
    /// </summary>
    /// <param name="actual">If true, data from actual hiddens are loaded</param>
    private void LoadFormDefinition(bool actual)
    {
        MacroRuleTree selected = GetSelected((actual ? hdnParamSelected.Value : hdnLastSelected.Value));
        if (selected != null)
        {
            string paramName = (actual ? hdnParam.Value.ToLowerCSafe() : hdnLastParam.Value.ToLowerCSafe());
            MacroRuleParameter param = selected.Parameters[paramName];
            if (param != null)
            {
                FormInfo fi = new FormInfo(selected.RuleParameters);
                FormFieldInfo ffi = fi.GetFormField(paramName);
                if (ffi != null)
                {
                    fi = new FormInfo();
                    fi.AddFormItem(ffi);

                    // Add fake DisplayName field
                    FormFieldInfo displayName = new FormFieldInfo();
                    displayName.Visible = false;
                    displayName.Name = "DisplayName";
                    displayName.DataType = FieldDataType.Text;
                    fi.AddFormItem(displayName);

                    DataRow row = fi.GetDataRow().Table.NewRow();

                    if (ffi.AllowEmpty && String.IsNullOrEmpty(param.Value))
                    {
                        if (!DataTypeManager.IsString(TypeEnum.Field, ffi.DataType))
                        {
                            row[paramName] = DBNull.Value;
                        }
                    }
                    else
                    {
                        // Convert to a proper type
                        var val = DataTypeManager.ConvertToSystemType(TypeEnum.Field, ffi.DataType, param.Value, CultureHelper.EnglishCulture);
                        if (val != null)
                        {
                            row[paramName] = val;
                        }
                    }

                    formElem.DataRow = row;
                    formElem.FormInformation = fi;
                    formElem.ReloadData();
                }
            }
        }
    }
开发者ID:kbuck21991,项目名称:kentico-blank-project,代码行数:53,代码来源:MacroRuleDesigner.ascx.cs

示例4: LoadDataRowFromWidget

    /// <summary>
    /// Loads the data row data from given web part instance.
    /// </summary>
    /// <param name="dr">DataRow to fill</param>
    private void LoadDataRowFromWidget(DataRow dr, FormInfo fi)
    {
        if (widgetInstance != null)
        {
            foreach (DataColumn column in dr.Table.Columns)
            {
                try
                {
                    bool load = true;
                    // switch by xml version
                    switch (xmlVersion)
                    {
                        case 1:
                            load = widgetInstance.Properties.Contains(column.ColumnName.ToLowerCSafe()) || column.ColumnName.EqualsCSafe("webpartcontrolid", true);
                            break;
                        // Version 0
                        default:
                            // Load default value for Boolean type in old XML version
                            if ((column.DataType == typeof(bool)) && !widgetInstance.Properties.Contains(column.ColumnName.ToLowerCSafe()))
                            {
                                FormFieldInfo ffi = fi.GetFormField(column.ColumnName);
                                if (ffi != null)
                                {
                                    widgetInstance.SetValue(column.ColumnName, ffi.GetPropertyValue(FormFieldPropertyEnum.DefaultValue));
                                }
                            }
                            break;
                    }

                    if (load)
                    {
                        object value = widgetInstance.GetValue(column.ColumnName);

                        // Convert value into default format
                        if ((value != null) && (value.ToString() != ""))
                        {
                            if (column.DataType == typeof(decimal))
                            {
                                value = ValidationHelper.GetDouble(value, 0, "en-us");
                            }

                            if (column.DataType == typeof(DateTime))
                            {
                                value = ValidationHelper.GetDateTime(value, DateTime.Now, "en-us");
                            }
                        }

                        DataHelper.SetDataRowValue(dr, column.ColumnName, value);
                    }
                }
                catch
                {
                }
            }
        }
    }
开发者ID:dlnuckolls,项目名称:pfh-paypalintegration,代码行数:60,代码来源:WidgetProperties.ascx.cs

示例5: Update60


//.........这里部分代码省略.........
                    ffi.Name = "OrderCulture";
                    ffi.DataType = FormFieldDataTypeEnum.Text;
                    ffi.Size = 10;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.LabelControl;
                    ffi.Visible = false;

                    fi.AddFormField(ffi);

                    ffi = new FormFieldInfo();
                    ffi.Name = "OrderIsPaid";
                    ffi.DataType = FormFieldDataTypeEnum.Boolean;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.LabelControl;
                    ffi.Visible = false;

                    fi.AddFormField(ffi);

                    ffi = new FormFieldInfo();
                    ffi.Name = "OrderTotalPriceInMainCurrency";
                    ffi.DataType = FormFieldDataTypeEnum.Decimal;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.LabelControl;
                    ffi.Visible = false;

                    fi.AddFormField(ffi);

                    ffi = fi.GetFormField("OrderStatusID");
                    if (ffi != null)
                    {
                        ffi.AllowEmpty = true;
                        fi.UpdateFormField("OrderStatusID", ffi);
                    }

                    ffi = fi.GetFormField("OrderShippingAddressID");
                    if (ffi != null)
                    {
                        ffi.AllowEmpty = true;
                        fi.UpdateFormField("OrderShippingAddressID", ffi);
                    }

                    dci.ClassFormDefinition = fi.GetXmlDefinition();

                    TableManager tm = new TableManager(dci.ClassConnectionString);
                    dci.ClassXmlSchema = tm.GetXmlSchema("COM_Order");

                    DataClassInfoProvider.SetDataClass(dci);

                    // Generate queries
                    SqlGenerator.GenerateDefaultQueries(dci, true, false);
                    tm.RefreshCustomViews("COM_Order");
                }
            }
        }
        catch (Exception ex)
        {
            evp.LogEvent("Ecommerce.Order - Upgrade", "Upgrade", ex);
        }

        #endregion
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:67,代码来源:UpgradeProcedure.cs

示例6: LoadFormDefinition

    /// <summary>
    /// Loads the from definition from selected parameter into a BasicForm control.
    /// </summary>
    /// <param name="actual">If true, data from actual hiddens are loaded</param>
    private void LoadFormDefinition(bool actual)
    {
        MacroRuleTree selected = GetSelected((actual ? hdnParamSelected.Value : hdnLastSelected.Value));
        if (selected != null)
        {
            string paramName = (actual ? hdnParam.Value.ToLowerCSafe() : hdnLastParam.Value.ToLowerCSafe());
            MacroRuleParameter param = (MacroRuleParameter)selected.Parameters[paramName];
            if (param != null)
            {
                FormInfo fi = new FormInfo(selected.RuleParameters);
                FormFieldInfo ffi = fi.GetFormField(paramName);
                if (ffi != null)
                {
                    fi = new FormInfo(null);
                    fi.AddFormField(ffi);

                    // Add fake DisplayName field
                    FormFieldInfo displayName = new FormFieldInfo();
                    displayName.Visible = false;
                    displayName.Name = "DisplayName";
                    displayName.DataType = FormFieldDataTypeEnum.Text;
                    fi.AddFormField(displayName);

                    DataRow row = fi.GetDataRow().Table.NewRow();

                    if (ffi.AllowEmpty && string.IsNullOrEmpty(param.Value))
                    {
                        if ((ffi.DataType != FormFieldDataTypeEnum.Text) && (ffi.DataType != FormFieldDataTypeEnum.LongText))
                        {
                            row[paramName] = DBNull.Value;
                        }
                    }
                    else
                    {
                        switch (ffi.DataType)
                        {
                            case FormFieldDataTypeEnum.Decimal:
                                row[paramName] = ValidationHelper.GetDouble(param.Value, 0, CultureHelper.EnglishCulture);
                                break;

                            case FormFieldDataTypeEnum.Boolean:
                                row[paramName] = ValidationHelper.GetBoolean(param.Value, false);
                                break;

                            case FormFieldDataTypeEnum.Integer:
                                row[paramName] = ValidationHelper.GetInteger(param.Value, 0);
                                break;

                            case FormFieldDataTypeEnum.DateTime:
                                row[paramName] = ValidationHelper.GetDateTime(param.Value, DataHelper.DATETIME_NOT_SELECTED, CultureHelper.EnglishCulture);
                                break;

                            case FormFieldDataTypeEnum.GUID:
                                Guid guid = ValidationHelper.GetGuid(param.Value, Guid.Empty);
                                if (guid != Guid.Empty)
                                {
                                    row[paramName] = guid;
                                }
                                break;

                            default:
                                row[paramName] = param.Value;
                                break;
                        }
                    }

                    formElem.DataRow = row;
                    formElem.FormInformation = fi;
                    formElem.ReloadData();
                }
            }
        }
    }
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:77,代码来源:MacroRuleDesigner.ascx.cs

示例7: EditForm_OnBeforeSave

    protected void EditForm_OnBeforeSave(object sender, EventArgs e)
    {
        MacroRuleInfo info = EditForm.EditedObject as MacroRuleInfo;
        if (info != null)
        {
            // Generate automatic fields when present in UserText
            FormEngineUserControl control = EditForm.FieldControls["MacroRuleText"];
            if (control != null)
            {
                string userText = ValidationHelper.GetString(control.Value, "");
                if (!string.IsNullOrEmpty(userText))
                {
                    Regex regex = RegexHelper.GetRegex("\\{[-_a-zA-Z0-9]*\\}");
                    MatchCollection match = regex.Matches(userText);
                    if (match.Count > 0)
                    {
                        FormInfo fi = new FormInfo(info.MacroRuleParameters);
                        foreach (Match m in match)
                        {
                            foreach (Capture c in m.Captures)
                            {
                                string name = c.Value.Substring(1, c.Value.Length - 2).ToLowerCSafe();
                                FormFieldInfo ffi = fi.GetFormField(name);
                                if (ffi == null)
                                {
                                    ffi = new FormFieldInfo();
                                    ffi.Name = name;
                                    ffi.DataType = FormFieldDataTypeEnum.Text;
                                    ffi.Size = 100;
                                    ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl;
                                    ffi.Caption = "select operation";
                                    ffi.AllowEmpty = true;
                                    switch (name)
                                    {
                                        case "_is":
                                            ffi.DefaultValue = ";is";
                                            ffi.Settings["controlname"] = "MacroNegationOperator";
                                            ffi.Settings["EditText"] = "false";
                                            ffi.Settings["Options"] = ";is\r\n!;is not";
                                            break;

                                        case "_was":
                                            ffi.DefaultValue = ";was";
                                            ffi.Settings["controlname"] = "MacroNegationOperator";
                                            ffi.Settings["EditText"] = "false";
                                            ffi.Settings["Options"] = ";was\r\n!;was not";
                                            break;

                                        case "_will":
                                            ffi.DefaultValue = ";will";
                                            ffi.Settings["controlname"] = "MacroNegationOperator";
                                            ffi.Settings["EditText"] = "false";
                                            ffi.Settings["Options"] = ";will\r\n!;will not";
                                            break;

                                        case "_has":
                                            ffi.DefaultValue = ";has";
                                            ffi.Settings["controlname"] = "MacroNegationOperator";
                                            ffi.Settings["EditText"] = "false";
                                            ffi.Settings["Options"] = ";has\r\n!;does not have";
                                            break;

                                        case "_perfectum":
                                            ffi.DefaultValue = ";has";
                                            ffi.Settings["controlname"] = "MacroNegationOperator";
                                            ffi.Settings["EditText"] = "false";
                                            ffi.Settings["Options"] = ";has\r\n!;has not";
                                            break;

                                        case "_any":
                                            ffi.DefaultValue = "false;any";
                                            ffi.Settings["controlname"] = "macro_any-all_bool_selector";
                                            ffi.Settings["EditText"] = "false";
                                            ffi.Settings["Options"] = "false;any\r\ntrue;all";
                                            break;

                                        default:
                                            ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl;
                                            ffi.Size = 1000;
                                            ffi.Caption = "enter text";
                                            break;
                                    }

                                    fi.AddFormField(ffi);
                                }
                            }
                        }
                        info.MacroRuleParameters = fi.GetXmlDefinition();
                    }
                }
            }
        }

        if (!string.IsNullOrEmpty(ResourceName))
        {
            EditForm.EditedObject.SetValue("MacroRuleResourceName", ResourceName);
        }
        EditForm.EditedObject.SetValue("MacroRuleIsCustom", !SettingsKeyProvider.DevelopmentMode);
    }
开发者ID:hollycooper,项目名称:Sportscar-Standings,代码行数:99,代码来源:Edit.ascx.cs

示例8: LoadData

    /// <summary>
    /// Loads data for advanced mode
    /// </summary>
    private void LoadData()
    {
        if (!RequestHelper.IsPostBack())
        {
            if (mReportSubscriptionInfo.ReportSubscriptionID > 0)
            {
                // Initial settings
                ucInterval.ScheduleInterval = mReportSubscriptionInfo.ReportSubscriptionInterval;
                chkEnabled.Checked = mReportSubscriptionInfo.ReportSubscriptionEnabled;
                txtEmail.Text = mReportSubscriptionInfo.ReportSubscriptionEmail;
                txtSubject.Text = mReportSubscriptionInfo.ReportSubscriptionSubject;
                chkNonEmpty.Checked = mReportSubscriptionInfo.ReportSubscriptionOnlyNonEmpty;
                ucMacroEditor.Text = mReportSubscriptionInfo.ReportSubscriptionCondition;
            }
            else
            {
                // New item
                chkEnabled.Checked = true;
                txtEmail.Text = MembershipContext.AuthenticatedUser.Email;
                txtSubject.Text = ResHelper.LocalizeString(Report.ReportDisplayName);
                chkNonEmpty.Checked = true;
                ucInterval.DefaultPeriod = SchedulingHelper.PERIOD_DAY;
            }

            FillItems();
        }

        if ((Report != null) && !String.IsNullOrEmpty(Report.ReportParameters) && (Report.ReportParameters != "<form></form>"))
        {
            // Convert field "DateFrom" and "DateTo" to string to be able to display macros
            FormInfo fi = new FormInfo(Report.ReportParameters);
            FormFieldInfo ffi = fi.GetFormField("FromDate");

            if (ffi != null)
            {
                ffi.DataType = FieldDataType.Text;
                ffi.FieldType = FormFieldControlTypeEnum.CalendarControl;
                ffi.Settings["AllowMacros"] = true;
                ffi.Size = 400;
                ffi.AllowEmpty = true;
                ffi.Visible = false;
            }

            ffi = fi.GetFormField("ToDate");
            if (ffi != null)
            {
                ffi.DataType = FieldDataType.Text;
                ffi.FieldType = FormFieldControlTypeEnum.CalendarControl;
                ffi.Settings["AllowMacros"] = true;
                ffi.Size = 400;
                ffi.AllowEmpty = true;
                ffi.Visible = false;
            }

            // Get datarow from forminfo (it contains report parameters passed by querystring)
            DataRow defaultValues = fi.GetDataRow(false);

            // Load default values
            fi.LoadDefaultValues(defaultValues, true);

            // Display basic form, only if any item is visible
            bool display = false;
            foreach (FormFieldInfo field in fi.ItemsList)
            {
                if (field.Visible)
                {
                    display = true;
                    break;
                }
            }

            pnlParametersEnvelope.Visible = display;

            // Loop through all nodes is subscription's XML parameters and replace report's value with current subscription's ones.
            if (mReportSubscriptionInfo.ReportSubscriptionID > 0)
            {
                if (!String.IsNullOrEmpty(mReportSubscriptionInfo.ReportSubscriptionParameters))
                {
                    XmlDocument xml = new XmlDocument();
                    xml.LoadXml(mReportSubscriptionInfo.ReportSubscriptionParameters);
                    foreach (DataColumn col in defaultValues.Table.Columns)
                    {
                        XmlNode node = xml.SelectSingleNode("/Root/" + col.ColumnName);
                        if (node != null)
                        {
                            // In case of different data types use try catch block
                            try
                            {
                                defaultValues[col.ColumnName] = DataHelper.ConvertValue(node.InnerText, col.DataType);
                            }
                            catch (Exception)
                            {
                            }
                        }
                    }
                }
            }
//.........这里部分代码省略.........
开发者ID:kbuck21991,项目名称:kentico-blank-project,代码行数:101,代码来源:SubscriptionEdit.ascx.cs

示例9: GetPrimaryColumn

    /// <summary>
    /// Returns name of the primary key column.
    /// </summary>
    /// <param name="fi">Form info</param>
    /// <param name="bizFormName">Bizform code name</param>
    private static string GetPrimaryColumn(FormInfo fi, string bizFormName)
    {
        string result = null;

        if ((fi != null) && (!string.IsNullOrEmpty(bizFormName)))
        {
            // Try to get field with the name 'bizformnameID'
            FormFieldInfo ffi = fi.GetFormField(bizFormName + "ID");
            if ((ffi != null) && ffi.PrimaryKey)
            {
                result = ffi.Name;
            }
            else
            {
                // Seek primary key column in all fields
                FormFieldInfo[] fields = fi.GetFields(true, true);
                foreach (FormFieldInfo field in fields)
                {
                    if (field.PrimaryKey)
                    {
                        result = field.Name;
                        break;
                    }
                }
            }
        }

        return result;
    }
开发者ID:puentepr,项目名称:kentico-site-example,代码行数:34,代码来源:BizForm_Edit_Data.aspx.cs

示例10: InitActivityRuleControls

    /// <summary>
    /// Initializes controls for activity rule.
    /// </summary>
    private void InitActivityRuleControls(string selectedActivityType)
    {
        ucActivityType.OnSelectedIndexChanged += new EventHandler(ucActivityType_OnSelectedIndexChanged);

        // Init activity selector from  edited object if any
        string activityType = selectedActivityType;
        if ((EditForm.EditedObject != null) && !RequestHelper.IsPostBack())
        {
            ucActivityType.Value = ValidationHelper.GetString(EditForm.Data["RuleParameter"], PredefinedActivityType.ABUSE_REPORT);
            activityType = ucActivityType.SelectedValue;
            PreviousActivityType = activityType;
        }

        // List of ignored columns
        string ignoredColumns = "|activitytype|activitysiteid|activityguid|activityactivecontactid|activityoriginalcontactid|pagevisitid|pagevisitactivityid|searchid|searchactivityid|";

        // List of activities with "ActivityValue"
        StringBuilder sb = new StringBuilder();
        sb.Append("|"); sb.Append(PredefinedActivityType.PURCHASE);
        sb.Append("|"); sb.Append(PredefinedActivityType.PURCHASEDPRODUCT);
        sb.Append("|"); sb.Append(PredefinedActivityType.RATING);
        sb.Append("|"); sb.Append(PredefinedActivityType.POLL_VOTING);
        sb.Append("|"); sb.Append(PredefinedActivityType.PRODUCT_ADDED_TO_SHOPPINGCART);
        sb.Append("|");
        string showActivityValueFor = sb.ToString();

        // Get columns from OM_Activity (i.e. base table for all activities)
        ActivityTypeInfo ati = ActivityTypeInfoProvider.GetActivityTypeInfo(activityType);

        FormInfo fi = new FormInfo(null);

        // Get columns from additional table (if any) according to selected activity type (page visit, search)
        FormInfo additionalFieldsForm = null;
        bool extraFieldsAtEnd = true;

        switch (activityType)
        {
            case PredefinedActivityType.PAGE_VISIT:
            case PredefinedActivityType.LANDING_PAGE:
                // Page visits
                additionalFieldsForm = FormHelper.GetFormInfo(OnlineMarketingObjectType.PAGEVISIT, false);
                break;

            case PredefinedActivityType.INTERNAL_SEARCH:
            case PredefinedActivityType.EXTERNAL_SEARCH:
                // Search
                additionalFieldsForm = FormHelper.GetFormInfo(OnlineMarketingObjectType.SEARCH, false);
                extraFieldsAtEnd = false;
                break;
        }

        // Get the activity form elements
        FormInfo filterFieldsForm = FormHelper.GetFormInfo(OnlineMarketingObjectType.ACTIVITY, true);
        ArrayList elements = filterFieldsForm.GetFormElements(true, false);

        FormCategoryInfo newCategory = null;

        string caption = null;
        string captionKey = null;

        foreach (var elem in elements)
        {
            if (elem is FormCategoryInfo)
            {
                // Form category
                newCategory = (FormCategoryInfo)elem;
            }
            else if (elem is FormFieldInfo)
            {
                // Form field
                FormFieldInfo ffi = (FormFieldInfo)elem;

                // Skip ignored columns
                if (ignoredColumns.IndexOf("|" + ffi.Name.ToLower() + "|") >= 0)
                {
                    continue;
                }

                string controlName = null;
                if (!ffi.PrimaryKey && (fi.GetFormField(ffi.Name) == null))
                {
                    // Set default filters
                    switch (ffi.DataType)
                    {
                        case FormFieldDataTypeEnum.Text:
                        case FormFieldDataTypeEnum.LongText:
                            controlName = "textfilter";
                            ffi.Settings["OperatorFieldName"] = ffi.Name + ".operator";
                            break;

                        case FormFieldDataTypeEnum.DateTime:
                            controlName = "datetimefilter";
                            ffi.Settings["SecondDateFieldName"] = ffi.Name + ".seconddatetime";
                            break;

                        case FormFieldDataTypeEnum.Integer:
                        case FormFieldDataTypeEnum.LongInteger:
//.........这里部分代码省略.........
开发者ID:KuduApps,项目名称:Kentico,代码行数:101,代码来源:Edit.ascx.cs

示例11: InitActivitySettings

    /// <summary>
    /// Initializes controls for activity rule.
    /// </summary>
    /// <param name="selectedActivity">Activity selected in drop-down menu</param>
    private void InitActivitySettings(string selectedActivity)
    {
        // Init activity selector from  edited object if any
        LoadEditedActivityRule(ref selectedActivity);

        string[] ignoredColumns =
        {
            "activitytype",
            "activitysiteid",
            "activityguid",
            "activityactivecontactid",
            "activityoriginalcontactid",
            "pagevisitid",
            "pagevisitactivityid",
            "searchid",
            "searchactivityid"
        };

        string[] activitiesWithValue =
        {
            PredefinedActivityType.PURCHASE,
            PredefinedActivityType.PURCHASEDPRODUCT,
            PredefinedActivityType.RATING,
            PredefinedActivityType.POLL_VOTING,
            PredefinedActivityType.PRODUCT_ADDED_TO_SHOPPINGCART
        };

        // Get columns from OM_Activity (i.e. base table for all activities)
        ActivityTypeInfo ati = ActivityTypeInfoProvider.GetActivityTypeInfo(selectedActivity);
        var fi = new FormInfo();

        // Get columns from additional table (if any) according to selected activity type
        bool extraFieldsAtEnd = true;
        FormInfo additionalFieldsForm = GetActivityAdditionalFields(selectedActivity, ref extraFieldsAtEnd);

        // Get the activity form elements
        FormInfo filterFieldsForm = FormHelper.GetFormInfo(ActivityInfo.OBJECT_TYPE, true);
        IList<IField> elements = filterFieldsForm.GetFormElements(true, false);

        FormCategoryInfo newCategory = null;

        foreach (IField elem in elements)
        {
            if (elem is FormCategoryInfo)
            {
                // Form category
                newCategory = (FormCategoryInfo)elem;
            }
            else if (elem is FormFieldInfo)
            {
                // Form field
                var ffi = (FormFieldInfo)elem;

                // Skip ignored columns
                if (ignoredColumns.Contains(ffi.Name.ToLowerCSafe()))
                {
                    continue;
                }

                if ((!ffi.PrimaryKey) && (fi.GetFormField(ffi.Name) == null))
                {
                    // Skip fields with Guid data type
                    if (ffi.DataType == FieldDataType.Guid)
                    {
                        continue;
                    }

                    // Sets control name based on given datatype of field. Can be overwritten if more proper control is available
                    string controlName = GetControlNameForFieldDataType(ffi);
                    if (!GetControlNameForActivities(ffi, ati, selectedActivity, activitiesWithValue, ref controlName))
                    {
                        continue;
                    }

                    if (controlName != null)
                    {
                        // SKU selector for product
                        ffi.Settings["controlname"] = controlName;
                        ffi.Settings["allowempty"] = controlName.EqualsCSafe("skuselector", true);
                    }

                    // Ensure the category
                    if (newCategory != null)
                    {
                        fi.AddFormCategory(newCategory);
                        newCategory = null;

                        // Extra fields at the beginning
                        if ((!extraFieldsAtEnd) && (additionalFieldsForm != null))
                        {
                            AddExtraActivityFields(ignoredColumns, fi, additionalFieldsForm);
                            additionalFieldsForm = null;
                        }
                    }

                    fi.AddFormItem(ffi);
//.........这里部分代码省略.........
开发者ID:arvind-web-developer,项目名称:csharp-projects-Jemena-Kentico-CMS,代码行数:101,代码来源:Edit.ascx.cs

示例12: btnOk_Click

    private void btnOk_Click(object sender, EventArgs e)
    {
        // Validate all required data for new blog
        string errorMessage = ValidateData();

        if (!LicenseHelper.LicenseVersionCheck(RequestContext.CurrentDomain, FeatureEnum.Blogs, ObjectActionEnum.Insert))
        {
            errorMessage = GetString("cmsdesk.bloglicenselimits");
        }

        // Get current user
        var user = MembershipContext.AuthenticatedUser;

        if (errorMessage == "")
        {
            // Get parent node for new blog
            TreeProvider tree = new TreeProvider(user);
            TreeNode parent = tree.SelectSingleNode(SiteContext.CurrentSiteName, BlogParentPath.TrimEnd('%'), TreeProvider.ALL_CULTURES);
            if (parent != null)
            {
                DataClassInfo blogClass = DataClassInfoProvider.GetDataClassInfo("CMS.Blog");
                if (blogClass == null)
                {
                    return;
                }

                // Check if blog is allowed in selected location
                if (!DocumentHelper.IsDocumentTypeAllowed(parent, blogClass.ClassID))
                {
                    lblError.Visible = true;
                    lblError.Text = GetString("Content.ChildClassNotAllowed");
                    return;
                }

                if (!CheckPermissions || user.IsAuthorizedToCreateNewDocument(parent, "cms.blog"))
                {
                    // Check if blog description allows empty value
                    FormInfo formInfo = new FormInfo(blogClass.ClassFormDefinition);
                    FormFieldInfo fieldInfo = formInfo.GetFormField("BlogDescription");
                    if ((fieldInfo != null) && !fieldInfo.AllowEmpty && String.IsNullOrWhiteSpace(txtDescription.Text))
                    {
                        lblError.Visible = true;
                        lblError.Text = GetString("blogs.newblog.descriptionempty");
                        return;
                    }

                    bool useParentNodeGroupID = tree.UseParentNodeGroupID;
                    TreeNode blogNode;
                    try
                    {
                        // Reflect group document
                        tree.UseParentNodeGroupID = true;

                        // Initialize and create new blog node
                        blogNode = TreeNode.New("cms.blog", tree);
                        blogNode.SetValue("BlogName", txtName.Text.Trim());
                        blogNode.SetValue("BlogDescription", txtDescription.Text.Trim());
                        blogNode.SetValue("BlogAllowAnonymousComments", BlogAllowAnonymousComments);
                        blogNode.SetValue("BlogModerateComments", BlogModerateComments);
                        blogNode.SetValue("BlogOpenCommentsFor", BlogOpenCommentsFor);
                        blogNode.SetValue("BlogSendCommentsToEmail", BlogSendCommentsToEmail);
                        blogNode.SetValue("BlogSideColumnText", BlogSideColumnText);
                        blogNode.SetValue("BlogUseCAPTCHAForComments", BlogUseCAPTCHAForComments);
                        blogNode.SetValue("BlogModerators", BlogModerators);
                        if (BlogTeaser == Guid.Empty)
                        {
                            blogNode.SetValue("BlogTeaser", null);
                        }
                        else
                        {
                            blogNode.SetValue("BlogTeaser", BlogTeaser);
                        }

                        blogNode.SetValue("NodeOwner", user.UserID);

                        if (NewBlogTemplate != null)
                        {
                            // Set the default page template
                            if (NewBlogTemplate == "")
                            {
                                blogNode.SetDefaultPageTemplateID(blogClass.ClassDefaultPageTemplateID);
                            }
                            else
                            {
                                // Set the selected template
                                PageTemplateInfo pti = PageTemplateInfoProvider.GetPageTemplateInfo(NewBlogTemplate);
                                if (pti != null)
                                {
                                    blogNode.NodeTemplateForAllCultures = true;
                                    blogNode.NodeTemplateID = pti.PageTemplateId;
                                }
                            }
                        }

                        blogNode.DocumentName = txtName.Text.Trim();
                        blogNode.DocumentCulture = LocalizationContext.PreferredCultureCode;
                        DocumentHelper.InsertDocument(blogNode, parent, tree);
                    }
                    finally
                    {
//.........这里部分代码省略.........
开发者ID:kbuck21991,项目名称:kentico-blank-project,代码行数:101,代码来源:NewBlog.ascx.cs


注:本文中的FormInfo.GetFormField方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。