private void ProcessAjaxPostBack()
    {
        if (RequestHelper.IsPostBack())
        {
            string eventArgument = Request.Params.Get("__EVENTARGUMENT");

            if (!string.IsNullOrEmpty(eventArgument))
            {
                string[] data = eventArgument.Split(':');

                FormFieldInfo ffi;
                switch (data[0])
                {
                case "loadSettings":
                {
                    FieldName = data[1];
                    LoadSettings(FieldName);
                }
                break;

                case "remove":
                {
                    // Hide selected field from form
                    FieldName = string.Empty;
                    HideField(data[2]);
                    mReloadForm = true;
                    pnlSettings.Update();
                }
                break;

                case "hideSettingsPanel":
                {
                    FieldName = string.Empty;
                    pnlSettings.Update();
                }
                break;

                case "saveSettings":
                {
                    ffi = mFormInfo.GetFormField(FieldName);
                    FormFieldInfo originalFieldInfo = (FormFieldInfo)ffi.Clone();
                    pnlSettings.SaveSettings(ffi);
                    SaveFormDefinition(originalFieldInfo, ffi);
                    mReloadField = true;
                }
                break;

                case "addField":
                {
                    ffi       = PrepareNewField(data[1]);
                    FieldName = ffi.Name;
                    AddField(ffi, data[2], ValidationHelper.GetInteger(data[3], -1));
                    LoadSettings(FieldName);
                    mReloadForm = true;
                }
                break;
                }
            }
        }
    }
Example #2
0
    /// <summary>
    /// Used only for alternative forms. If current field in class allows empty then it returns TRUE.
    /// </summary>
    private bool GetFormAllowEmpty()
    {
        // Check if field exists in class
        FormInfo      fi = FormHelper.GetFormInfo(ClassName, false);
        FormFieldInfo ffi;

        if (fi != null)
        {
            ffi = fi.GetFormField(FieldInfo.Name);
            if (ffi != null)
            {
                return(ffi.AllowEmpty);
            }
        }

        // Check if field exists in coupled class
        if (!String.IsNullOrEmpty(CoupledClassName))
        {
            fi = FormHelper.GetFormInfo(CoupledClassName, false);
            if (fi != null)
            {
                ffi = fi.GetFormField(FieldInfo.Name);
                if (ffi != null)
                {
                    return(ffi.AllowEmpty);
                }
            }
        }

        return(false);
    }
Example #3
0
    /// <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);
    }
    /// <summary>
    /// Raise callback method.
    /// </summary>
    public void RaiseCallbackEvent(string eventArgument)
    {
        if (!string.IsNullOrEmpty(eventArgument) && (FormInfo != null))
        {
            string[] data = eventArgument.Split(':');

            // Check that data are in proper format
            if (data.Length >= 3)
            {
                switch (data[0])
                {
                case "move":
                    int    position  = ValidationHelper.GetInteger(data[3], -1);
                    string category  = data[2];
                    string fieldName = data[1];

                    // Check field existence
                    FormFieldInfo field = FormInfo.GetFormField(fieldName);
                    string        errorMessage;
                    if (field != null)
                    {
                        // Move field to new position
                        FormInfo.MoveFormFieldToPositionInCategory(fieldName, category, position);
                        errorMessage = SaveFormDefinition();
                    }
                    else
                    {
                        errorMessage = GetString("editedobject.notexists");
                    }
                    mCallbackResult = PrepareCallbackResult(string.Empty, errorMessage);
                    break;
                }
            }
        }
    }
    /// <summary>
    /// Loads DataRow for BasicForm with data from FormFieldInfo settings and optionally with form control's default values.
    /// </summary>
    /// <param name="loadDefaultValues">Indicates if data container should be initialized with form control's default data</param>
    private DataRowContainer GetData(bool loadDefaultValues)
    {
        DataRowContainer result = new DataRowContainer(FormInfo.GetDataRow(loadDefaultValues));

        if (loadDefaultValues)
        {
            // Load default values for visible properties (values of hidden form control properties shouldn't be stored in form definition)
            FormInfo.LoadDefaultValues(result, FormResolveTypeEnum.None, true);
        }

        if (Settings != null)
        {
            // Load settings of the existing field
            foreach (string columnName in Settings.Keys)
            {
                if (result.ContainsColumn(columnName))
                {
                    object value        = Settings[columnName];
                    var    settingField = FormInfo.GetFormField(columnName);

                    if (!String.IsNullOrEmpty(Convert.ToString(value)) && IsDataTypeValid(value, settingField))
                    {
                        result[columnName] = DataTypeManager.ConvertToSystemType(TypeEnum.Field, settingField.DataType, value, SystemContext.EnglishCulture);
                    }
                }
            }
        }
        return(result);
    }
    /// <summary>
    /// Loads field settings to the Settings panel.
    /// </summary>
    /// <param name="fieldName">Field name</param>
    private void LoadSettings(string fieldName)
    {
        FormFieldInfo ffi = FormInfo.GetFormField(fieldName);

        pnlSettings.LoadSettings(ffi);
        pnlSettings.Update();
    }
    protected void Page_Load(object sender, EventArgs e)
    {
        if (CustomTableItem != null)
        {
            DataClassInfo dci = DataClassInfoProvider.GetDataClassInfo(CustomTableItem.CustomTableClassName);
            if (dci != null)
            {
                // Get class form definition
                FormInfo fi = FormHelper.GetFormInfo(dci.ClassName, false);

                string         fieldCaption;
                FormFieldInfo  ffi;
                IDataContainer item = CustomTableItem;

                StringBuilder sb = new StringBuilder();
                sb.Append("<table class=\"table table-hover\">");
                // Table header
                sb.AppendFormat("<thead><tr class=\"unigrid-head\"><th>{0}</th><th class=\"main-column-100\">{1}</th></tr></thead><tbody>", GetString("customtable.data.nametitle"), GetString("customtable.data.namevalue"));

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

                // Go through the columns
                foreach (string columnName in item.ColumnNames)
                {
                    // Get field caption
                    ffi = fi.GetFormField(columnName);
                    if (ffi == null)
                    {
                        fieldCaption = columnName;
                    }
                    else
                    {
                        string caption = ffi.GetPropertyValue(FormFieldPropertyEnum.FieldCaption, resolver);
                        if (string.IsNullOrEmpty(caption))
                        {
                            fieldCaption = columnName;
                        }
                        else
                        {
                            fieldCaption = ResHelper.LocalizeString(caption);
                        }
                    }

                    sb.AppendFormat("<tr><td><strong>{0}</strong></td><td class=\"wrap-normal\">{1}</td></tr>", fieldCaption, HTMLHelper.HTMLEncode(ValidationHelper.GetString(item.GetValue(columnName), String.Empty)));
                }
                sb.Append("</tbody></table>");

                ltlContent.Text = sb.ToString();
            }
            else
            {
                ltlContent.Text = GetString("editedobject.notexists");
            }
        }
        else
        {
            ltlContent.Text = GetString("editedobject.notexists");
        }
    }
Example #8
0
    /// <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 (mWidgetInstance != null)
        {
            foreach (DataColumn column in dr.Table.Columns)
            {
                try
                {
                    bool load = true;
                    // switch by xml version
                    switch (mXmlVersion)
                    {
                    case 1:
                        load = mWidgetInstance.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)) && !mWidgetInstance.Properties.Contains(column.ColumnName.ToLowerCSafe()))
                        {
                            FormFieldInfo ffi = fi.GetFormField(column.ColumnName);
                            if (ffi != null)
                            {
                                mWidgetInstance.SetValue(column.ColumnName, ffi.GetPropertyValue(FormFieldPropertyEnum.DefaultValue));
                            }
                        }
                        break;
                    }

                    if (load)
                    {
                        object value = mWidgetInstance.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");
                            }
                        }

                        if (!DataHelper.IsEmpty(value))
                        {
                            DataHelper.SetDataRowValue(dr, column.ColumnName, value);
                        }
                    }
                }
                catch
                {
                }
            }
        }
    }
        private bool VerifyFieldExists(DataClassInfo customTable, string column, FormFieldDataTypeEnum?expectedType = null)
        {
            if (customTable == null)
            {
                return(false);
            }

            var formInfo = new FormInfo(customTable.ClassFormDefinition);

            if (!formInfo.FieldExists(column))
            {
                HandleError(string.Format("The custom table {0} does not contain the column '{1}'", customTable.ClassName, column));
                return(false);
            }

            var fieldInfo = formInfo.GetFormField(column);

            if (expectedType.HasValue && fieldInfo.DataType != expectedType)
            {
                HandleError(string.Format("The column '{0}.{1}' expected to be type '{2}' but found to be type '{3}",
                                          customTable.ClassName, column, expectedType, fieldInfo.DataType));
                return(false);
            }

            return(true);
        }
    /// <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;
                }
            }
        }
    }
Example #11
0
    /// <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
                {
                    var  safeColumnName = column.ColumnName.ToLowerInvariant();
                    bool load           = true;
                    // switch by xml version
                    switch (xmlVersion)
                    {
                    case 1:
                        load = webPart.Properties.Contains(safeColumnName) || string.Equals("webpartcontrolid", safeColumnName, StringComparison.OrdinalIgnoreCase);
                        break;

                    // Version 0
                    default:
                        // Load default value for Boolean type in old XML version
                        if ((column.DataType == typeof(bool)) && !webPart.Properties.Contains(safeColumnName))
                        {
                            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);
                }
            }
        }
    }
Example #12
0
    /// <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>
    private void LoadDataRowFromWebPart(DataRow dr, WebPartInstance webPart, FormInfo fi)
    {
        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 = fi.GetFormField(column.ColumnName);
                        if (ffi != null)
                        {
                            webPart.SetValue(column.ColumnName, ffi.DefaultValue);
                        }
                    }
                    break;
                }

                if (load)
                {
                    object 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
            {
            }
        }
    }
    /// <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();
                }
            }
        }
    }
    /// <summary>
    /// Loads field settings to the Settings panel.
    /// </summary>
    /// <param name="fieldName">Field name</param>
    private void LoadSettings(string fieldName)
    {
        FormFieldInfo ffi = FormInfo.GetFormField(fieldName);

        if (ffi != null)
        {
            pnlSettings.LoadSettings(ffi);
            pnlSettings.Update();
        }
        else
        {
            mReloadForm = true;
        }
    }
    /// <summary>
    /// Hides field.
    /// </summary>
    /// <param name="fieldName">Name of field that should be hidden</param>
    /// <returns>Error message if an error occurred</returns>
    private string HideField(string fieldName)
    {
        if (!string.IsNullOrEmpty(fieldName))
        {
            FormFieldInfo ffiSelected = FormInfo.GetFormField(fieldName);
            if (ffiSelected == null)
            {
                return(GetString("editedobject.notexists"));
            }

            ffiSelected.Visible = false;
            return(SaveFormDefinition());
        }
        return(string.Empty);
    }
Example #16
0
        /// <inheritdoc />
        public void Update(IWebPartField field)
        {
            var formInfo  = new FormInfo(field.WebPart.WebPartProperties);
            var fieldInfo = formInfo.GetFormField(field.Name);

            fieldInfo.AllowEmpty   = field.AllowEmpty;
            fieldInfo.Caption      = field.Caption;
            fieldInfo.DataType     = field.DataType;
            fieldInfo.DefaultValue = field.DefaultValue;
            fieldInfo.Size         = field.Size;

            formInfo.UpdateFormField(field.Name, fieldInfo);

            field.WebPart.WebPartProperties = formInfo.GetXmlDefinition();

            this.SaveFormUpdates(field.WebPart);
        }
Example #17
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>
    /// Ensures unique field name.
    /// </summary>
    /// <param name="name">Field name</param>
    private string GetUniqueFieldName(string name)
    {
        int    uniqueIndex = 1;
        bool   unique      = false;
        string uniqueName  = name;

        while (!unique)
        {
            if (FormInfo.GetFormField(uniqueName) == null)
            {
                unique = true;
            }
            else
            {
                uniqueName = name + "_" + uniqueIndex;
                uniqueIndex++;
            }
        }
        return(uniqueName);
    }
Example #19
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);
                    }
                }
            }
        }
Example #20
0
    /// <summary>
    /// Loads DataRow container for BasicForm with widget properties.
    /// </summary>
    private DataRowContainer GetWidgetProperties()
    {
        var result = new DataRowContainer(widgetTypeFormInfo.GetDataRow());

        foreach (var property in widgetInstance.Properties)
        {
            if (property.Value == null)
            {
                continue;
            }

            var formField = widgetTypeFormInfo.GetFormField(property.Name);
            if (formField == null)
            {
                continue;
            }

            result[property.Name] = DataTypeManager.ConvertToSystemType(TypeEnum.Field, formField.DataType, property.Value, CultureHelper.EnglishCulture);
        }

        return(result);
    }
Example #21
0
    public string ReturnCaptionValue(string fieldname)
    {
        if (Session["FormInfo"] != null)
        {
            // Create form info from class form definition
            FormInfo      info  = (FormInfo)Session["FormInfo"];
            FormFieldInfo field = info.GetFormField(fieldname);

            if (field != null)
            {
                return(field.Caption);
            }
            else
            {
                return("");
            }
        }
        else
        {
            return("");
        }
    }
        /// <summary>
        /// Get related pages for a Pages field specified on a component.
        /// </summary>
        /// <param name="component">The component that has the Pages field.</param>
        /// <param name="fieldName">The code name of the Pages field on the component.</param>
        /// <returns>The related pages for the specified component field.</returns>
        public static IEnumerable <TreeNode> GetRelatedDocumentsForComponent(this IContentComponent component, string fieldName)
        {
            TreeNode parent = component.Parent;

            if (parent == null)
            {
                return(Enumerable.Empty <TreeNode>());
            }

            FormInfo      form      = FormHelper.GetFormInfo(component.NodeClassName, false);
            FormFieldInfo formField = form.GetFormField(fieldName);

            if (formField == null)
            {
                return(Enumerable.Empty <TreeNode>());
            }

            string relationshipNameCodeName = RelationshipNameInfoProvider.GetAdHocRelationshipNameCodeName(parent.NodeClassName, formField);

            RelationshipNameInfo relationshipNameInfo = RelationshipNameInfoProvider.GetRelationshipNameInfo(relationshipNameCodeName);

            var relationshipQuery = DocumentHelper.GetDocuments()
                                    .Culture(parent.DocumentCulture)
                                    .CombineWithDefaultCulture(parent.TreeProvider.GetCombineWithDefaultCulture(parent.Site.SiteName))
                                    .Published(!parent.IsLastVersion)
                                    .PublishedVersion(!parent.IsLastVersion)
                                    .WithCoupledColumns()
                                    .InRelationWith(
                parent.NodeGUID,
                relationshipNameCodeName,
                RelationshipSideEnum.Left
                );

            return(RelationshipInfoProvider.ApplyRelationshipOrderData(
                       relationshipQuery,
                       parent.NodeID,
                       relationshipNameInfo.RelationshipNameId
                       ));
        }
    /// <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)
                            {
                            }
                        }
                    }
                }
            }

            mParameters = defaultValues;
            pnlFromToParams.Visible = !SetTimeControls();

            // Set basic form parameters
            formElem.DataRow = defaultValues;
            formElem.SubmitButton.Visible = false;
            formElem.SubmitButton.RegisterHeaderAction = false;
            formElem.FormInformation = fi;
            formElem.SiteName = SiteContext.CurrentSiteName;
            formElem.Mode = FormModeEnum.Update;
            formElem.Visible = true;
        }
        else
        {
            pnlParametersEnvelope.Visible = false;
            pnlFromToParams.Visible = false;
        }
    }
    /// <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;
                                }
                            }
                        }

                        // Check if user is allowed to create new file document
                        if (fileAllowed && !currentUser.IsAuthorizedToCreateNewDocument(tn, "CMS.File"))
                        {
                            AddError(GetString("accessdenied.notallowedtocreatedocument"));
                            return;
                        }

                        // Check if user is allowed to create new folder document
                        if (folderAllowed && !currentUser.IsAuthorizedToCreateNewDocument(tn, "CMS.Folder"))
                        {
                            AddError(GetString("accessdenied.notallowedtocreatedocument"));
                            return;
                        }
                    }

                    string cultureCode = ValidationHelper.GetString(parameters[2], "");
                    string[] fileList = new string[1];
                    string[] relativePathList = new string[1];

                    // Begin log
                    AddLog(GetString("tools.fileimport.importingprogress"));

                    string msgImported = GetString("Tools.FileImport.Imported");
                    string msgFailed = GetString("Tools.FileImport.Failed");

                    // Insert files selected in datagrid to list of files to import
                    foreach (string fullFileName in items)
                    {
                        // Import selected files only
                        fileList[0] = fullFileName;
                        relativePathList[0] = fullFileName.Substring(rootPath.Length);

                        // Remove extension if needed
                        if (!chkIncludeExtension.Checked)
                        {
                            relativePathList[0] = Regex.Replace(relativePathList[0], "(.*)\\..*", "$1");
                        }

                        try
                        {
                            FileImport.ImportFiles(siteName, targetAliasPath, cultureCode, fileList, relativePathList, currentUser.UserID, chkDeleteImported.Checked);

                            // Import of a file succeeded, fill the output lists
                            resultListValues.Add(new string[] { fullFileName, msgImported, true.ToString() });

                            imported = true; // One file was imported
                            AddLog(HTMLHelper.HTMLEncode(fullFileName));
                        }
                        catch (Exception ex)
                        {
                            // File import failed
                            errorFiles.Add(fullFileName);
                            importError = true;

                            // Fill the output lists
                            resultListValues.Add(new string[] { fullFileName, msgFailed + " (" + HTMLHelper.HTMLEncode(ex.Message) + ")", false.ToString() });

                            AddError(msgFailed + " (" + HTMLHelper.HTMLEncode(ex.Message) + ")");

                            // Abort importing the rest of files for serious exceptions
                            if (!(ex is UnauthorizedAccessException))
                            {
                                return;
                            }
                        }
                    }
                }
                // Specified alias path not found
                else
                {
                    AddError(GetString("Tools.FileImport.AliasPathNotFound"));
                    return;
                }

                if (filesList.Count > 0)
                {
                    if (!importError)
                    {
                        if (imported)
                        {
                            AddError(GetString("Tools.FileImport.FilesWereImported"));
                            return;
                        }
                    }
                    else
                    {
                        AddError(GetString("Tools.FileImport.FilesNotImported"));
                        return;
                    }
                }
            }
            // No items selected to import
            else
            {
                AddError(GetString("Tools.FileImport.FilesNotImported"));
                return;
            }
        }
        catch (ThreadAbortException ex)
        {
            string state = ValidationHelper.GetString(ex.ExceptionState, string.Empty);
            if (state == CMSThread.ABORT_REASON_STOP)
            {
                // When canceled
            }
            else
            {
                // Log error
                LogExceptionToEventLog(ex);
            }
        }
        catch (Exception ex)
        {
            // Log error
            LogExceptionToEventLog(ex);
        }
    }
Example #25
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);
            }
        }
    }
    /// <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();
                }
            }
        }
    }
    /// <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);
                }
            }
        }
    }
    /// <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;
            }
        }
    }
    /// <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();
                }
            }
        }
    }
    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
                    {
                        tree.UseParentNodeGroupID = useParentNodeGroupID;
                    }

                    if (RedirectToNewBlog)
                    {
                        // Redirect to the new blog
                        URLHelper.Redirect(DocumentURLProvider.GetUrl(blogNode));
                    }
                    else
                    {
                        // Display info message
                        lblInfo.Visible = true;
                        lblInfo.Text = GetString("General.ChangesSaved");
                    }
                }
                else
                {
                    // Not authorized to create blog
                    errorMessage = GetString("blogs.notallowedtocreate");
                }
            }
            else
            {
                // Parent node was not found
                errorMessage = GetString("Blogs.NewBlog.PathNotFound");
            }
        }

        if (errorMessage == "")
        {
            return;
        }

        // Display error message
        lblError.Visible = true;
        lblError.Text = errorMessage;
    }
Example #31
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;
        }
    }
    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);
    }
Example #33
0
    protected void Page_Load(object sender, EventArgs e)
    {
        StringSafeDictionary <object> decodedProperties = new StringSafeDictionary <object>();

        foreach (DictionaryEntry param in Properties)
        {
            // Decode special CK editor char
            String str = String.Empty;
            if (param.Value != null)
            {
                str = param.Value.ToString().Replace("%25", "%");
            }

            decodedProperties[(string)param.Key] = HttpUtility.UrlDecode(str);
        }
        Properties = decodedProperties;

        string widgetName = ValidationHelper.GetString(Properties["name"], String.Empty);

        // Widget name must be specified
        if (String.IsNullOrEmpty(widgetName))
        {
            AddErrorWebPart("widgets.invalidname", null);
            return;
        }

        WidgetInfo wi = WidgetInfoProvider.GetWidgetInfo(widgetName);

        if (wi == null)
        {
            AddErrorWebPart("widget.failedtoload", null);
            return;
        }

        WebPartInfo wpi = WebPartInfoProvider.GetWebPartInfo(wi.WidgetWebPartID);

        if (wpi == null)
        {
            return;
        }

        //no widgets can be used as inline
        if (!wi.WidgetForInline)
        {
            AddErrorWebPart("widgets.cantbeusedasinline", null);
            return;
        }

        try
        {
            FormInfo fi = null;
            DataRow  dr = null;

            using (var cs = new CachedSection <FormInfo>(ref fi, 1440, (PortalContext.ViewMode == ViewModeEnum.LiveSite), null, "inlinewidgetcontrol", wi.WidgetID, wpi.WebPartID))
            {
                if (cs.LoadData)
                {
                    // Merge widget and it's parent webpart properties
                    string props = FormHelper.MergeFormDefinitions(wpi.WebPartProperties, wi.WidgetProperties);

                    // Prepare form
                    const WidgetZoneTypeEnum zoneType = WidgetZoneTypeEnum.Editor;
                    fi = PortalFormHelper.GetWidgetFormInfo(wi.WidgetName, zoneType, props, true, wi.WidgetDefaultValues);

                    // Apply changed values
                    dr = fi.GetDataRow();
                    fi.LoadDefaultValues(dr);

                    if (cs.Cached)
                    {
                        cs.CacheDependency = CacheHelper.GetCacheDependency("cms.webpart|byid|" + wpi.WebPartID + "\n" + "cms.widget|byid|" + wi.WidgetID);
                    }

                    cs.Data = fi;
                }
            }

            // Get datarow
            if (dr == null)
            {
                dr = fi.GetDataRow();
                fi.LoadDefaultValues(dr);
            }

            // Incorporate inline parameters to datarow
            string publicFields = ";containertitle;container;";
            if (wi.WidgetPublicFileds != null)
            {
                publicFields += ";" + wi.WidgetPublicFileds.ToLowerCSafe() + ";";
            }

            // Load the widget control
            string url = null;

            // Set widget layout
            WebPartLayoutInfo wpli = WebPartLayoutInfoProvider.GetWebPartLayoutInfo(wi.WidgetLayoutID);

            if (wpli != null)
            {
                // Load specific layout through virtual path
                url = wpli.Generalized.GetVirtualFileRelativePath(WebPartLayoutInfo.EXTERNAL_COLUMN_CODE, wpli.WebPartLayoutVersionGUID);
            }
            else
            {
                // Load regularly
                url = WebPartInfoProvider.GetWebPartUrl(wpi, false);
            }

            CMSAbstractWebPart control = (CMSAbstractWebPart)Page.LoadUserControl(url);
            control.PartInstance = new WebPartInstance();

            // Use current page placeholder
            control.PagePlaceholder = PortalHelper.FindParentPlaceholder(this);

            // Set all form values to webpart
            foreach (DataColumn column in dr.Table.Columns)
            {
                object value      = dr[column];
                string columnName = column.ColumnName.ToLowerCSafe();

                //Resolve set values by user
                if (Properties.Contains(columnName))
                {
                    FormFieldInfo ffi = fi.GetFormField(columnName);
                    if ((ffi != null) && ffi.Visible && ((ffi.DisplayIn == null) || !ffi.DisplayIn.Contains(FormInfo.DISPLAY_CONTEXT_DASHBOARD)))
                    {
                        value = Properties[columnName];
                    }
                }

                // Resolve macros in defined in default values
                if (!String.IsNullOrEmpty(value as string))
                {
                    // Do not resolve macros for public fields
                    if (publicFields.IndexOfCSafe(";" + columnName + ";") < 0)
                    {
                        // Check whether current column
                        bool avoidInjection = control.SQLProperties.Contains(";" + columnName + ";");

                        // Resolve macros
                        MacroSettings settings = new MacroSettings()
                        {
                            AvoidInjection = avoidInjection,
                        };
                        value = control.ContextResolver.ResolveMacros(value.ToString(), settings);
                    }
                }

                control.PartInstance.SetValue(column.ColumnName, value);
            }

            control.PartInstance.IsWidget = true;

            // Load webpart content
            control.OnContentLoaded();

            // Add webpart to controls collection
            Controls.Add(control);

            // Handle DisableViewstate setting
            control.EnableViewState = !control.DisableViewState;
        }

        catch (Exception ex)
        {
            AddErrorWebPart("widget.failedtoload", ex);
        }
    }
    /// <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);
                }
            }
        }

        // Extra fields at the end
        if ((extraFieldsAtEnd) && (additionalFieldsForm != null))
        {
            // Ensure the category for extra fields
            if (newCategory != null)
            {
                fi.AddFormCategory(newCategory);
            }

            AddExtraActivityFields(ignoredColumns, fi, additionalFieldsForm);
        }

        LoadActivityForm(fi, selectedActivity);
    }
Example #35
0
    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
                    {
                        tree.UseParentNodeGroupID = useParentNodeGroupID;
                    }

                    if (RedirectToNewBlog)
                    {
                        // Redirect to the new blog
                        URLHelper.Redirect(UrlResolver.ResolveUrl(DocumentURLProvider.GetUrl(blogNode)));
                    }
                    else
                    {
                        // Display info message
                        lblInfo.Visible = true;
                        lblInfo.Text    = GetString("General.ChangesSaved");
                    }
                }
                else
                {
                    // Not authorized to create blog
                    errorMessage = GetString("blogs.notallowedtocreate");
                }
            }
            else
            {
                // Parent node was not found
                errorMessage = GetString("Blogs.NewBlog.PathNotFound");
            }
        }

        if (errorMessage == "")
        {
            return;
        }

        // Display error message
        lblError.Visible = true;
        lblError.Text    = errorMessage;
    }
    public static void Update60()
    {
        EventLogProvider evp = new EventLogProvider();
        evp.LogEvent("I", DateTime.Now, "Upgrade to 6.0", "Upgrade - Start");

        DataClassInfo dci = null;

        #region "CMS.UserSettings"

        try
        {
            dci = DataClassInfoProvider.GetDataClass("cms.usersettings");
            if (dci != null)
            {
                FormInfo fi = new FormInfo(dci.ClassFormDefinition);
                if (fi != null)
                {
                    FormFieldInfo ffi = new FormFieldInfo();
                    ffi.Name = "UserAuthenticationGUID";
                    ffi.DataType = FormFieldDataTypeEnum.GUID;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.LabelControl;
                    ffi.Visible = false;

                    fi.AddFormField(ffi);

                    ffi = new FormFieldInfo();
                    ffi.Name = "UserBounces";
                    ffi.DataType = FormFieldDataTypeEnum.Integer;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl;
                    ffi.Visible = false;
                    ffi.Caption = "UserBounces";

                    fi.AddFormField(ffi);

                    ffi = new FormFieldInfo();
                    ffi.Name = "UserLinkedInID";
                    ffi.DataType = FormFieldDataTypeEnum.Text;
                    ffi.Size = 100;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.LabelControl;
                    ffi.Visible = false;

                    fi.AddFormField(ffi);

                    ffi = new FormFieldInfo();
                    ffi.Name = "UserLogActivities";
                    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 = "UserPasswordRequestHash";
                    ffi.DataType = FormFieldDataTypeEnum.Text;
                    ffi.Size = 100;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.LabelControl;
                    ffi.Visible = false;

                    fi.AddFormField(ffi);

                    dci.ClassFormDefinition = fi.GetXmlDefinition();

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

                    DataClassInfoProvider.SetDataClass(dci);

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

        #endregion

        #region "Ecommerce - Customer"

        try
        {
            dci = DataClassInfoProvider.GetDataClass("ecommerce.customer");
            if (dci != null)
            {
                FormInfo fi = new FormInfo(dci.ClassFormDefinition);
                if (fi != null)
                {
                    FormFieldInfo ffi = new FormFieldInfo();
                    ffi.Name = "CustomerSiteID";
                    ffi.DataType = FormFieldDataTypeEnum.Integer;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl;
                    ffi.Visible = false;

                    fi.AddFormField(ffi);

                    TableManager tm = new TableManager(dci.ClassConnectionString);

                    dci.ClassFormDefinition = fi.GetXmlDefinition();
                    dci.ClassXmlSchema = tm.GetXmlSchema("COM_Customer");

                    DataClassInfoProvider.SetDataClass(dci);

                    // Generate queries
                    SqlGenerator.GenerateDefaultQueries(dci, true, false);

                    tm.RefreshCustomViews("COM_Customer");
                }
            }
        }
        catch (Exception ex)
        {
            evp.LogEvent("Ecommerce.Customer - Upgrade", "Upgrade", ex);
        }

        #endregion

        #region "Ecommerce - Order"

        try
        {
            dci = DataClassInfoProvider.GetDataClass("ecommerce.order");
            if (dci != null)
            {
                FormInfo fi = new FormInfo(dci.ClassFormDefinition);
                if (fi != null)
                {
                    FormFieldInfo ffi = new FormFieldInfo();
                    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

        #region "Ecommerce - OrderItem"

        try
        {
            dci = DataClassInfoProvider.GetDataClass("ecommerce.orderitem");
            if (dci != null)
            {
                FormInfo fi = new FormInfo(dci.ClassFormDefinition);
                if (fi != null)
                {
                    FormFieldInfo ffi = new FormFieldInfo();
                    ffi.Name = "OrderItemBundleGUID";
                    ffi.DataType = FormFieldDataTypeEnum.GUID;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.LabelControl;
                    ffi.Visible = false;

                    fi.AddFormField(ffi);

                    ffi = new FormFieldInfo();
                    ffi.Name = "OrderItemIsPrivate";
                    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 = "OrderItemPrice";
                    ffi.DataType = FormFieldDataTypeEnum.Decimal;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.LabelControl;
                    ffi.Visible = false;

                    fi.AddFormField(ffi);

                    ffi = new FormFieldInfo();
                    ffi.Name = "OrderItemSendNotification";
                    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 = "OrderItemSKU";
                    ffi.DataType = FormFieldDataTypeEnum.LongText;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.LabelControl;
                    ffi.Visible = false;

                    fi.AddFormField(ffi);

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

                    fi.AddFormField(ffi);

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

                    fi.AddFormField(ffi);

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

                    fi.AddFormField(ffi);

                    dci.ClassFormDefinition = fi.GetXmlDefinition();

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

                    DataClassInfoProvider.SetDataClass(dci);

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

        #endregion

        #region "Ecommerce - Shopping cart item"

        try
        {
            dci = DataClassInfoProvider.GetDataClass("ecommerce.shoppingcartitem");
            if (dci != null)
            {
                FormInfo fi = new FormInfo(dci.ClassFormDefinition);
                if (fi != null)
                {
                    FormFieldInfo ffi = new FormFieldInfo();
                    ffi.Name = "CartItemBundleGUID";
                    ffi.DataType = FormFieldDataTypeEnum.GUID;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.LabelControl;
                    ffi.Visible = false;

                    fi.AddFormField(ffi);

                    ffi = new FormFieldInfo();
                    ffi.Name = "CartItemIsPrivate";
                    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 = "CartItemPrice";
                    ffi.DataType = FormFieldDataTypeEnum.Decimal;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.LabelControl;
                    ffi.Visible = false;

                    fi.AddFormField(ffi);

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

                    fi.AddFormField(ffi);

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

                    fi.AddFormField(ffi);

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

                    dci.ClassFormDefinition = fi.GetXmlDefinition();

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

                    DataClassInfoProvider.SetDataClass(dci);

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

        #endregion

        #region "Ecommerce - SKU"

        try
        {
            dci = DataClassInfoProvider.GetDataClass("ecommerce.sku");
            if (dci != null)
            {
                FormInfo fi = new FormInfo(dci.ClassFormDefinition);
                if (fi != null)
                {
                    FormFieldInfo ffi = new FormFieldInfo();
                    ffi.Name = "SKUBundleInventoryType";
                    ffi.DataType = FormFieldDataTypeEnum.Text;
                    ffi.Size = 50;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.LabelControl;
                    ffi.Visible = false;

                    fi.AddFormField(ffi);

                    ffi = new FormFieldInfo();
                    ffi.Name = "SKUConversionName";
                    ffi.DataType = FormFieldDataTypeEnum.Text;
                    ffi.Size = 100;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.LabelControl;
                    ffi.Visible = false;

                    fi.AddFormField(ffi);

                    ffi = new FormFieldInfo();
                    ffi.Name = "SKUConversionValue";
                    ffi.DataType = FormFieldDataTypeEnum.Text;
                    ffi.Size = 200;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.LabelControl;
                    ffi.Visible = false;

                    fi.AddFormField(ffi);

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

                    fi.AddFormField(ffi);

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

                    fi.AddFormField(ffi);

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

                    fi.AddFormField(ffi);

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

                    fi.AddFormField(ffi);

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

                    fi.AddFormField(ffi);

                    ffi = new FormFieldInfo();
                    ffi.Name = "SKUNeedsShipping";
                    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 = "SKUPrivateDonation";
                    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 = "SKUProductType";
                    ffi.DataType = FormFieldDataTypeEnum.Text;
                    ffi.Size = 50;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.LabelControl;
                    ffi.Visible = false;

                    fi.AddFormField(ffi);

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

                    fi.AddFormField(ffi);

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

                    fi.AddFormField(ffi);

                    ffi = new FormFieldInfo();
                    ffi.Name = "SKUValidity";
                    ffi.DataType = FormFieldDataTypeEnum.Text;
                    ffi.Size = 50;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.LabelControl;
                    ffi.Visible = false;

                    fi.AddFormField(ffi);

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

                    fi.AddFormField(ffi);

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

                    dci.ClassFormDefinition = fi.GetXmlDefinition();

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

                    DataClassInfoProvider.SetDataClass(dci);

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

        #endregion

        #region "Community - Group"

        try
        {
            dci = DataClassInfoProvider.GetDataClass("Community.Group");
            if (dci != null)
            {
                FormInfo fi = new FormInfo(dci.ClassFormDefinition);
                if (fi != null)
                {
                    FormFieldInfo ffi = new FormFieldInfo();
                    ffi.Name = "GroupLogActivity";
                    ffi.DataType = FormFieldDataTypeEnum.Boolean;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.CheckBoxControl;
                    ffi.Visible = true;
                    ffi.DefaultValue = "true";
                    ffi.Caption = "GroupLogActivity";

                    fi.AddFormField(ffi);

                    dci.ClassFormDefinition = fi.GetXmlDefinition();

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

                    DataClassInfoProvider.SetDataClass(dci);

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

        #endregion

        #region "Newsletter - Subscriber"

        try
        {
            dci = DataClassInfoProvider.GetDataClass("newsletter.subscriber");
            if (dci != null)
            {
                FormInfo fi = new FormInfo(dci.ClassFormDefinition);
                if (fi != null)
                {
                    FormFieldInfo ffi = new FormFieldInfo();
                    ffi.Name = "SubscriberBounces";
                    ffi.DataType = FormFieldDataTypeEnum.Boolean;
                    ffi.AllowEmpty = true;
                    ffi.PublicField = false;
                    ffi.System = true;
                    ffi.FieldType = FormFieldControlTypeEnum.LabelControl;
                    ffi.Visible = false;

                    fi.AddFormField(ffi);

                    dci.ClassFormDefinition = fi.GetXmlDefinition();

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

                    DataClassInfoProvider.SetDataClass(dci);

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

        #endregion

        #region "CMS.Document"

        try
        {
            dci = DataClassInfoProvider.GetDataClass("cms.document");
            if (dci != null)
            {
                SearchSettings ss = dci.ClassSearchSettingsInfos;
                SearchSettingsInfo ssi = ss.GetSettingsInfo("42f446ee-9818-4596-8124-54a38f64aa05");
                if (ssi != null)
                {
                    ssi.Searchable = true;
                    ss.SetSettingsInfo(ssi);
                }

                DataClassInfoProvider.SetDataClass(dci);
            }
        }
        catch (Exception ex)
        {
            evp.LogEvent("CMS.Document - Upgrade", "Upgrade", ex);
        }

        #endregion

        // Set the path to the upgrade package
        mUpgradePackagePath = HttpContext.Current.Server.MapPath("~/CMSSiteUtils/Import/upgrade_55R2_60.zip");

        mWebsitePath = HttpContext.Current.Server.MapPath("~/");

        TableManager dtm = new TableManager(null);

        // Update all views
        dtm.RefreshDocumentViews();

        // Set data version
        ObjectHelper.SetSettingsKeyValue("CMSDataVersion", "6.0");

        // Clear hashtables
        CMSObjectHelper.ClearHashtables();

        // Clear the cache
        CacheHelper.ClearCache(null, true);

        // Drop the routes
        CMSMvcHandler.DropAllRoutes();

        // Init the Mimetype helper (required for the Import)
        MimeTypeHelper.LoadMimeTypes();

        CMSThread thread = new CMSThread(Upgrade60Import);
        thread.Start();
    }
Example #37
0
    /// <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 <IDataDefinitionItem> elements = filterFieldsForm.GetFormElements(true, false);

        FormCategoryInfo newCategory = null;

        foreach (IDataDefinitionItem 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);
                }
            }
        }

        // Extra fields at the end
        if ((extraFieldsAtEnd) && (additionalFieldsForm != null))
        {
            // Ensure the category for extra fields
            if (newCategory != null)
            {
                fi.AddFormCategory(newCategory);
            }

            AddExtraActivityFields(ignoredColumns, fi, additionalFieldsForm);
        }

        LoadActivityForm(fi, selectedActivity);
    }
Example #38
0
    /// <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:
                            controlName = "numberfilter";
                            ffi.Settings["OperatorFieldName"] = ffi.Name + ".operator";
                            break;

                        case FormFieldDataTypeEnum.GUID:
                            continue;
                    }

                    // For item ID and detail ID fields use control defined in activity type
                    if (String.Compare(ffi.Name, "ActivityItemID", true) == 0)
                    {
                        if (ati.ActivityTypeMainFormControl == null)
                        {
                            continue;
                        }

                        if (ati.ActivityTypeMainFormControl != String.Empty)
                        {
                            // Check if user defined control exists
                            FormUserControlInfo fui = FormUserControlInfoProvider.GetFormUserControlInfo(ati.ActivityTypeMainFormControl);
                            if (fui != null)
                            {
                                controlName = ati.ActivityTypeMainFormControl;
                            }
                        }

                        // Set detailed caption
                        captionKey = "activityitem." + activityType;
                        caption = GetString(captionKey);
                        if (!caption.Equals(captionKey, StringComparison.InvariantCultureIgnoreCase))
                        {
                            ffi.Caption = caption;
                        }
                    }
                    else if (String.Compare(ffi.Name, "ActivityItemDetailID", true) == 0)
                    {
                        if (ati.ActivityTypeDetailFormControl == null)
                        {
                            continue;
                        }

                        if (ati.ActivityTypeDetailFormControl != String.Empty)
                        {
                            // Check if user defined control exists
                            FormUserControlInfo fui = FormUserControlInfoProvider.GetFormUserControlInfo(ati.ActivityTypeDetailFormControl);
                            if (fui != null)
                            {
                                controlName = ati.ActivityTypeDetailFormControl;
                            }
                        }

                        // Set detailed caption
                        captionKey = "activityitemdetail." + activityType;
                        caption = GetString(captionKey);
                        if (!caption.Equals(captionKey, StringComparison.InvariantCultureIgnoreCase))
                        {
                            ffi.Caption = caption;
                        }
                    }
                    else if (String.Compare(ffi.Name, "ActivityNodeID", true) == 0)
                    {
                        // Document selector for NodeID
                        controlName = "selectdocument";
                    }
                    else if (String.Compare(ffi.Name, "ActivityCulture", true) == 0)
                    {
                        // Culture selector for culture
                        controlName = "sitecultureselector";
                    }
                    else if (String.Compare(ffi.Name, "ActivityValue", true) == 0)
                    {
                        // Show activity value only for relevant activity types
                        if (!ati.ActivityTypeIsCustom && (showActivityValueFor.IndexOf("|" + activityType + "|",  StringComparison.InvariantCultureIgnoreCase) < 0))
                        {
                            continue;
                        }
                    }

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

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

                        newCategory = null;

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

                            additionalFieldsForm = null;
                        }
                    }

                    fi.AddFormField(ffi);
                }
            }
        }

        // Extra fields at end
        if (extraFieldsAtEnd && (additionalFieldsForm != null))
        {
            // Ensure the category for extra fields
            if (newCategory != null)
            {
                fi.AddFormCategory(newCategory);

                newCategory = null;
            }

            AddExtraFields(ignoredColumns, fi, additionalFieldsForm);
        }

        LoadForm(activityFormCondition, fi, activityType);
    }
Example #39
0
    /// <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);
        var      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.IndexOfCSafe("|" + ffi.Name.ToLowerCSafe() + "|") >= 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:
                        controlName = "numberfilter";
                        ffi.Settings["OperatorFieldName"] = ffi.Name + ".operator";
                        break;

                    case FormFieldDataTypeEnum.GUID:
                        continue;
                    }

                    // For item ID and detail ID fields use control defined in activity type
                    if (CMSString.Compare(ffi.Name, "ActivityItemID", true) == 0)
                    {
                        if (ati.ActivityTypeMainFormControl == null)
                        {
                            continue;
                        }

                        if (ati.ActivityTypeMainFormControl != String.Empty)
                        {
                            // Check if user defined control exists
                            FormUserControlInfo fui = FormUserControlInfoProvider.GetFormUserControlInfo(ati.ActivityTypeMainFormControl);
                            if (fui != null)
                            {
                                controlName = ati.ActivityTypeMainFormControl;
                            }
                        }

                        // Set detailed caption
                        captionKey = "activityitem." + activityType;
                        caption    = GetString(captionKey);
                        if (!caption.EqualsCSafe(captionKey, true))
                        {
                            ffi.Caption = caption;
                        }
                    }
                    else if (CMSString.Compare(ffi.Name, "ActivityItemDetailID", true) == 0)
                    {
                        if (ati.ActivityTypeDetailFormControl == null)
                        {
                            continue;
                        }

                        if (ati.ActivityTypeDetailFormControl != String.Empty)
                        {
                            // Check if user defined control exists
                            FormUserControlInfo fui = FormUserControlInfoProvider.GetFormUserControlInfo(ati.ActivityTypeDetailFormControl);
                            if (fui != null)
                            {
                                controlName = ati.ActivityTypeDetailFormControl;
                            }
                        }

                        // Set detailed caption
                        captionKey = "activityitemdetail." + activityType;
                        caption    = GetString(captionKey);
                        if (!caption.EqualsCSafe(captionKey, true))
                        {
                            ffi.Caption = caption;
                        }
                    }
                    else if (CMSString.Compare(ffi.Name, "ActivityNodeID", true) == 0)
                    {
                        // Document selector for NodeID
                        controlName = "selectdocument";
                    }
                    else if (CMSString.Compare(ffi.Name, "ActivityCulture", true) == 0)
                    {
                        // Culture selector for culture
                        controlName = "sitecultureselector";
                    }
                    else if (CMSString.Compare(ffi.Name, "ActivityValue", true) == 0)
                    {
                        // Show activity value only for relevant activity types
                        if (!ati.ActivityTypeIsCustom && (showActivityValueFor.IndexOfCSafe("|" + activityType + "|", true) < 0))
                        {
                            continue;
                        }
                    }

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

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

                        newCategory = null;

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

                            additionalFieldsForm = null;
                        }
                    }

                    fi.AddFormField(ffi);
                }
            }
        }

        // Extra fields at end
        if (extraFieldsAtEnd && (additionalFieldsForm != null))
        {
            // Ensure the category for extra fields
            if (newCategory != null)
            {
                fi.AddFormCategory(newCategory);

                newCategory = null;
            }

            AddExtraFields(ignoredColumns, fi, additionalFieldsForm);
        }

        LoadForm(activityFormCondition, fi, activityType);
    }
    /// <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
                {
                }
            }
        }
    }
Example #41
0
    /// <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)
                            {
                            }
                        }
                    }
                }
            }


            mParameters             = defaultValues;
            pnlFromToParams.Visible = !SetTimeControls();

            // Set basic form parameters
            formElem.DataRow = defaultValues;
            formElem.SubmitButton.Visible = false;
            formElem.SubmitButton.RegisterHeaderAction = false;
            formElem.FormInformation = fi;
            formElem.SiteName        = SiteContext.CurrentSiteName;
            formElem.Mode            = FormModeEnum.Update;
            formElem.Visible         = true;
        }
        else
        {
            pnlParametersEnvelope.Visible = false;
            pnlFromToParams.Visible       = false;
        }
    }
    /// <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;
    }