本文整理汇总了C#中FormInfo.AddFormField方法的典型用法代码示例。如果您正苦于以下问题:C# FormInfo.AddFormField方法的具体用法?C# FormInfo.AddFormField怎么用?C# FormInfo.AddFormField使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类FormInfo
的用法示例。
在下文中一共展示了FormInfo.AddFormField方法的11个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: EditForm_OnBeforeSave
protected void EditForm_OnBeforeSave(object sender, EventArgs e)
{
MacroRuleInfo info = EditForm.EditedObject as MacroRuleInfo;
if (info != null)
{
// Generate automatic fields when present in UserText
FormEngineUserControl control = EditForm.FieldControls["MacroRuleText"];
if (control != null)
{
string userText = ValidationHelper.GetString(control.Value, "");
if (!string.IsNullOrEmpty(userText))
{
Regex regex = RegexHelper.GetRegex("\\{[-_a-zA-Z0-9]*\\}");
MatchCollection match = regex.Matches(userText);
if (match.Count > 0)
{
FormInfo fi = new FormInfo(info.MacroRuleParameters);
foreach (Match m in match)
{
foreach (Capture c in m.Captures)
{
string name = c.Value.Substring(1, c.Value.Length - 2).ToLowerCSafe();
FormFieldInfo ffi = fi.GetFormField(name);
if (ffi == null)
{
ffi = new FormFieldInfo();
ffi.Name = name;
ffi.DataType = FormFieldDataTypeEnum.Text;
ffi.Size = 100;
ffi.FieldType = FormFieldControlTypeEnum.CustomUserControl;
ffi.Caption = "select operation";
ffi.AllowEmpty = true;
switch (name)
{
case "_is":
ffi.DefaultValue = ";is";
ffi.Settings["controlname"] = "MacroNegationOperator";
ffi.Settings["EditText"] = "false";
ffi.Settings["Options"] = ";is\r\n!;is not";
break;
case "_was":
ffi.DefaultValue = ";was";
ffi.Settings["controlname"] = "MacroNegationOperator";
ffi.Settings["EditText"] = "false";
ffi.Settings["Options"] = ";was\r\n!;was not";
break;
case "_will":
ffi.DefaultValue = ";will";
ffi.Settings["controlname"] = "MacroNegationOperator";
ffi.Settings["EditText"] = "false";
ffi.Settings["Options"] = ";will\r\n!;will not";
break;
case "_has":
ffi.DefaultValue = ";has";
ffi.Settings["controlname"] = "MacroNegationOperator";
ffi.Settings["EditText"] = "false";
ffi.Settings["Options"] = ";has\r\n!;does not have";
break;
case "_perfectum":
ffi.DefaultValue = ";has";
ffi.Settings["controlname"] = "MacroNegationOperator";
ffi.Settings["EditText"] = "false";
ffi.Settings["Options"] = ";has\r\n!;has not";
break;
case "_any":
ffi.DefaultValue = "false;any";
ffi.Settings["controlname"] = "macro_any-all_bool_selector";
ffi.Settings["EditText"] = "false";
ffi.Settings["Options"] = "false;any\r\ntrue;all";
break;
default:
ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl;
ffi.Size = 1000;
ffi.Caption = "enter text";
break;
}
fi.AddFormField(ffi);
}
}
}
info.MacroRuleParameters = fi.GetXmlDefinition();
}
}
}
}
if (!string.IsNullOrEmpty(ResourceName))
{
EditForm.EditedObject.SetValue("MacroRuleResourceName", ResourceName);
}
EditForm.EditedObject.SetValue("MacroRuleIsCustom", !SettingsKeyProvider.DevelopmentMode);
}
示例2: Update60
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");
//.........这里部分代码省略.........
示例3: ProcessStep2
//.........这里部分代码省略.........
catch
{
}
if (fromExisting)
{
// From existing DB table
dci.ClassXmlSchema = tm.GetXmlSchema(tableName);
string formDef = FormHelper.GetXmlFormDefinitionFromXmlSchema(dci.ClassXmlSchema, false);
fi = new FormInfo(formDef);
}
else
{
// Create empty form definition
fi = new FormInfo("<form></form>");
ffiPrimaryKey = new FormFieldInfo();
// Fill FormInfo object
ffiPrimaryKey.Name = txtPKName.Text;
ffiPrimaryKey.Caption = txtPKName.Text;
ffiPrimaryKey.DataType = FormFieldDataTypeEnum.Integer;
ffiPrimaryKey.DefaultValue = "";
ffiPrimaryKey.Description = "";
ffiPrimaryKey.FieldType = FormFieldControlTypeEnum.CustomUserControl;
ffiPrimaryKey.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLowerCSafe();
ffiPrimaryKey.PrimaryKey = true;
ffiPrimaryKey.System = false;
ffiPrimaryKey.Visible = false;
ffiPrimaryKey.Size = 0;
ffiPrimaryKey.AllowEmpty = false;
// Add field to form definition
fi.AddFormField(ffiPrimaryKey);
dci.ClassXmlSchema = tm.GetXmlSchema(tableName);
}
dci.ClassTableName = tableName;
dci.ClassFormDefinition = fi.GetXmlDefinition();
dci.ClassIsCoupledClass = true;
dci.ClassInheritsFromClassID = ValidationHelper.GetInteger(selInherits.Value, 0);
// Update class in DB
using (CMSActionContext context = new CMSActionContext())
{
// Disable logging into event log
context.LogEvents = false;
DataClassInfoProvider.SetDataClass(dci);
// Ensure inherited fields
if (dci.ClassInheritsFromClassID > 0)
{
DataClassInfo parentCi = DataClassInfoProvider.GetDataClass(dci.ClassInheritsFromClassID);
if (parentCi != null)
{
FormHelper.UpdateInheritedClass(parentCi, dci);
}
}
}
if (Mode == NewClassWizardModeEnum.CustomTable)
{
#region "Custom tables optional columns"
示例4: LoadFormDefinition
/// <summary>
/// Loads the from definition from selected parameter into a BasicForm control.
/// </summary>
/// <param name="actual">If true, data from actual hiddens are loaded</param>
private void LoadFormDefinition(bool actual)
{
MacroRuleTree selected = GetSelected((actual ? hdnParamSelected.Value : hdnLastSelected.Value));
if (selected != null)
{
string paramName = (actual ? hdnParam.Value.ToLowerCSafe() : hdnLastParam.Value.ToLowerCSafe());
MacroRuleParameter param = (MacroRuleParameter)selected.Parameters[paramName];
if (param != null)
{
FormInfo fi = new FormInfo(selected.RuleParameters);
FormFieldInfo ffi = fi.GetFormField(paramName);
if (ffi != null)
{
fi = new FormInfo(null);
fi.AddFormField(ffi);
// Add fake DisplayName field
FormFieldInfo displayName = new FormFieldInfo();
displayName.Visible = false;
displayName.Name = "DisplayName";
displayName.DataType = FormFieldDataTypeEnum.Text;
fi.AddFormField(displayName);
DataRow row = fi.GetDataRow().Table.NewRow();
if (ffi.AllowEmpty && string.IsNullOrEmpty(param.Value))
{
if ((ffi.DataType != FormFieldDataTypeEnum.Text) && (ffi.DataType != FormFieldDataTypeEnum.LongText))
{
row[paramName] = DBNull.Value;
}
}
else
{
switch (ffi.DataType)
{
case FormFieldDataTypeEnum.Decimal:
row[paramName] = ValidationHelper.GetDouble(param.Value, 0, CultureHelper.EnglishCulture);
break;
case FormFieldDataTypeEnum.Boolean:
row[paramName] = ValidationHelper.GetBoolean(param.Value, false);
break;
case FormFieldDataTypeEnum.Integer:
row[paramName] = ValidationHelper.GetInteger(param.Value, 0);
break;
case FormFieldDataTypeEnum.DateTime:
row[paramName] = ValidationHelper.GetDateTime(param.Value, DataHelper.DATETIME_NOT_SELECTED, CultureHelper.EnglishCulture);
break;
case FormFieldDataTypeEnum.GUID:
Guid guid = ValidationHelper.GetGuid(param.Value, Guid.Empty);
if (guid != Guid.Empty)
{
row[paramName] = guid;
}
break;
default:
row[paramName] = param.Value;
break;
}
}
formElem.DataRow = row;
formElem.FormInformation = fi;
formElem.ReloadData();
}
}
}
}
示例5: InitAttributeRuleControls
/// <summary>
/// Initializes controls for attributre rule.
/// </summary>
private void InitAttributeRuleControls(int selectedFieldIndex)
{
FormInfo filterFieldsForm = FormHelper.GetFormInfo(OnlineMarketingObjectType.CONTACT + ".ScoringAttributeRule", false);
fields = filterFieldsForm.GetFields(true, false);
// Sort alphabetically
Array.Sort(fields, delegate(FormFieldInfo a, FormFieldInfo b) { return String.Compare(ResHelper.LocalizeString(a.Caption), ResHelper.LocalizeString(b.Caption)); });
if (filterFieldsForm != null)
{
if ((fields != null) && (fields.Length > 0) && (drpAttribute.Items.Count <= 0))
{
for (int i = 0; i < fields.Length; i++)
{
drpAttribute.Items.Add(new ListItem(fields[i].Caption, fields[i].Name));
}
}
}
if ((EditForm.EditedObject != null) && !RequestHelper.IsPostBack())
{
drpAttribute.SelectedValue = ValidationHelper.GetString(EditForm.Data["RuleParameter"], null);
selectedFieldIndex = drpAttribute.SelectedIndex;
PreviousField = selectedFieldIndex;
}
selectedField = fields[selectedFieldIndex];
FormInfo fi = new FormInfo(null);
fi.AddFormField(selectedField);
LoadForm(formCondition, fi, null);
}
示例6: drpAttribute_SelectedIndexChanged
/// <summary>
/// Selected field changed
/// </summary>
protected void drpAttribute_SelectedIndexChanged(object sender, EventArgs e)
{
PreviousField = drpAttribute.SelectedIndex;
selectedField = fields[PreviousField];
FormInfo fi = new FormInfo(null);
fi.AddFormField(selectedField);
LoadForm(formCondition, fi, null);
}
示例7: InitActivityRuleControls
//.........这里部分代码省略.........
// 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);
}
示例8: AddExtraFields
/// <summary>
/// Adds the extra activity fields to the form
/// </summary>
/// <param name="ignoredColumns">Ignored columns</param>
/// <param name="fi">Form info with the result</param>
/// <param name="additionalFieldsForm">Extra fields</param>
private static void AddExtraFields(string ignoredColumns, FormInfo fi, FormInfo additionalFieldsForm)
{
if (additionalFieldsForm != null)
{
// Additional fields
var formFields = additionalFieldsForm.GetFields(true, false);
foreach (FormFieldInfo ffi in formFields)
{
if (ignoredColumns.IndexOf("|" + ffi.Name.ToLower() + "|") >= 0)
{
continue;
}
ffi.Settings["controlname"] = "textfilter";
fi.AddFormField(ffi);
}
}
}
示例9: wzdNewDocType_NextButtonClick
//.........这里部分代码省略.........
case NewClassWizardModeEnum.CustomTable:
owner = SqlHelperClass.GetDBSchema(CMSContext.CurrentSiteName);
break;
}
if ((owner != "") && (owner.ToLower() != "dbo"))
{
TableManager.ChangeDBObjectOwner(tableName, owner);
tableName = DataHelper.GetSafeOwner(owner) + "." + tableName;
}
}
catch
{
}
// Create empty form definition
fi = new FormInfo("<form></form>");
ffiPrimaryKey = new FormFieldInfo();
// Fill FormInfo object
ffiPrimaryKey.Name = txtPKName.Text;
ffiPrimaryKey.Caption = txtPKName.Text;
ffiPrimaryKey.DataType = FormFieldDataTypeEnum.Integer;
ffiPrimaryKey.DefaultValue = "";
ffiPrimaryKey.Description = "";
ffiPrimaryKey.FieldType = FormFieldControlTypeEnum.CustomUserControl;
ffiPrimaryKey.Settings["controlname"] = Enum.GetName(typeof(FormFieldControlTypeEnum), FormFieldControlTypeEnum.LabelControl).ToLower();
ffiPrimaryKey.PrimaryKey = true;
ffiPrimaryKey.System = false;
ffiPrimaryKey.Visible = true;
ffiPrimaryKey.Size = 0;
ffiPrimaryKey.AllowEmpty = false;
// Add field to form definition
fi.AddFormField(ffiPrimaryKey);
dci.ClassTableName = tableName;
dci.ClassXmlSchema = TableManager.GetXmlSchema(dci.ClassTableName);
dci.ClassFormDefinition = fi.GetXmlDefinition();
dci.ClassIsCoupledClass = true;
dci.ClassInheritsFromClassID = ValidationHelper.GetInteger(selInherits.Value, 0);
// Update class in DB
using (CMSActionContext context = new CMSActionContext())
{
// Disable logging into event log
context.LogEvents = false;
DataClassInfoProvider.SetDataClass(dci);
// Ensure inherited fields
if (dci.ClassInheritsFromClassID > 0)
{
DataClassInfo parentCi = DataClassInfoProvider.GetDataClass(dci.ClassInheritsFromClassID);
if (parentCi != null)
{
FormHelper.UpdateInheritedClass(parentCi, dci);
}
}
}
if (this.Mode == NewClassWizardModeEnum.CustomTable)
{
#region "Custom tables optional columns"
if (chkItemCreatedBy.Checked)
示例10: Upgrade55R2
public static void Upgrade55R2()
{
EventLogProvider evp = new EventLogProvider();
evp.LogEvent("I", DateTime.Now, "Upgrade to 5.5 R2", "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 = "UserSkype";
ffi.DataType = FormFieldDataTypeEnum.Text;
ffi.Size = 100;
ffi.AllowEmpty = true;
ffi.PublicField = false;
ffi.System = true;
ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl;
ffi.Visible = false;
ffi.Caption = "User Skype account";
ffi.DefaultValue = String.Empty;
ffi.Description = String.Empty;
ffi.RegularExpression = String.Empty;
fi.AddFormField(ffi);
ffi = new FormFieldInfo();
ffi.Name = "UserIM";
ffi.DataType = FormFieldDataTypeEnum.Text;
ffi.Size = 100;
ffi.AllowEmpty = true;
ffi.PublicField = false;
ffi.System = true;
ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl;
ffi.Visible = false;
ffi.Caption = "User instant messenger";
ffi.DefaultValue = String.Empty;
ffi.Description = String.Empty;
ffi.RegularExpression = String.Empty;
fi.AddFormField(ffi);
ffi = new FormFieldInfo();
ffi.Name = "UserPhone";
ffi.DataType = FormFieldDataTypeEnum.Text;
ffi.Size = 26;
ffi.AllowEmpty = true;
ffi.PublicField = false;
ffi.System = true;
ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl;
ffi.Visible = false;
ffi.Caption = "User phone";
ffi.DefaultValue = String.Empty;
ffi.Description = "User phone number.";
ffi.RegularExpression = String.Empty;
fi.AddFormField(ffi);
ffi = new FormFieldInfo();
ffi.Name = "UserPosition";
ffi.DataType = FormFieldDataTypeEnum.Text;
ffi.Size = 200;
ffi.AllowEmpty = true;
ffi.PublicField = false;
ffi.System = false;
ffi.FieldType = FormFieldControlTypeEnum.TextBoxControl;
ffi.Visible = false;
ffi.Caption = "Position";
ffi.DefaultValue = String.Empty;
ffi.Description = String.Empty;
ffi.RegularExpression = String.Empty;
fi.AddFormField(ffi);
dci.ClassFormDefinition = fi.GetXmlDefinition();
dci.ClassXmlSchema = TableManager.GetXmlSchema("CMS_UserSettings");
DataClassInfoProvider.SetDataClass(dci);
// Generate queries
SqlGenerator.GenerateDefaultQueries(dci, true, false);
}
}
}
catch (Exception ex)
{
evp.LogEvent("CMS.UserSettings - Upgrade", "Upgrade", ex);
}
#endregion
#region "WebTemplate meta file"
//.........这里部分代码省略.........
示例11: InitAttributeRuleControls
/// <summary>
/// Initializes controls for attributre rule.
/// </summary>
private void InitAttributeRuleControls(int selectedFieldIndex)
{
FormInfo filterFieldsForm = FormHelper.GetFormInfo(OnlineMarketingObjectType.CONTACT + ".ScoringAttributeRule", false);
var query = from formField in filterFieldsForm.GetFields(true, false)
orderby ResHelper.LocalizeString(formField.Caption)
select formField;
fields = query.ToList<FormFieldInfo>();
if ((fields != null) && (drpAttribute.Items.Count == 0))
{
foreach (FormFieldInfo field in fields)
{
drpAttribute.Items.Add(new ListItem(field.Caption, field.Name));
}
}
if ((EditForm.EditedObject != null) && !RequestHelper.IsPostBack())
{
drpAttribute.SelectedValue = ValidationHelper.GetString(EditForm.Data["RuleParameter"], null);
selectedFieldIndex = drpAttribute.SelectedIndex;
PreviousField = selectedFieldIndex;
}
selectedField = fields[selectedFieldIndex];
FormInfo fi = new FormInfo(null);
fi.AddFormField(selectedField);
LoadForm(formCondition, fi, null);
}