//Indexer used to access FieldMetadata. // //Return null if corresponding FieldMetadata object not found //or if _fieldMetadataCollection hasn't been populated yet. // //The entry for a given fldname might also be null if an error occured while //attempting to create the FieldMetadata object. This could occur if metadata about //the field in def.Fld (was dat FieldInfo) is invalid. // //See the constructor of FieldMetadata class for more info. public IFieldMetadata this[string fldname] { get { if (_fieldMetadataCollection == null) { return(null); } else { IFieldMetadata result = null; try { //Dictionary object throws a KeyNotFoundException if fldname is not //a valid key result = _fieldMetadataCollection[fldname.ToUpper()]; } catch { result = null; } return(result); } } }
/// <summary> /// Initializes a new instance of the <see cref="DisplayFieldMetadata"/> class. /// </summary> /// <param name="name"> /// The display field name. /// </param> /// <param name="field"> /// The field. /// </param> /// <param name="joinFields"> /// The join fields. /// </param> public DisplayFieldMetadata(string name, IFieldMetadata field, IEnumerable<IReferenceFieldMetadata> joinFields) { if (string.IsNullOrEmpty(name)) throw new ArgumentException(@"Name is null or empty.", "name"); if (field == null) throw new ArgumentNullException("field"); if (joinFields == null) throw new ArgumentNullException("joinFields"); _name = name; _field = field; _joinFields = new ReadOnlyCollection<IReferenceFieldMetadata>(joinFields.ToArray()); }
private FieldImpl(IFieldMetadata metadata, Item parent) { _metadata = metadata; Parent = parent; }
private FieldImpl(IFieldMetadata metadata, Item parent) { _metadata = metadata; Parent = parent; }
/// <summary> /// Build data input control for specified field metadata. /// </summary> /// <param name="fieldMetadata"></param> /// <returns></returns> public override ExtensionDataInputControl BuildDataInputControl(IFieldMetadata fieldMetadata) { DateTimeFieldMetadata metadata = fieldMetadata as DateTimeFieldMetadata; WebControls.PlaceHolder placeHolder = new WebControls.PlaceHolder(); string textBoxId = string.Format(CultureInfo.InvariantCulture, "DTFM{0}_{1}", WebUtility.ConvertControlId(metadata.Name), metadata.Ordinal > 0 ? metadata.Ordinal : int.MaxValue); this.dateTimePicker = new DateTimePicker { ID = textBoxId, TextMode = WebControls.TextBoxMode.SingleLine, CssClass = "textboxShort", MaxLength = 32 }; placeHolder.Controls.Add(this.dateTimePicker); if (metadata.IsRequired) { LiteralControl requiredLabel = new LiteralControl("<span class=\"required\">*</span>"); placeHolder.Controls.Add(requiredLabel); } if (!(HttpContext.Current.Handler as Page).IsPostBack && metadata.DefaultValue != null) this.dateTimePicker.SelectedValue = metadata.GetDefaultValue().Value as DateTime?; return new ExtensionDataInputControl { Control = placeHolder, OccupiedControlCells = 1 }; }
public static bool IsActivityParty(this IFieldMetadata fieldMetadata) { return(fieldMetadata.FieldType == RecordFieldType.ActivityParty); }
private FieldImpl(IFieldMetadata metadata, Item parent) { this.metadata = metadata; this.Parent = parent; }
/* * Call this to populate FieldMetadata collection. DatabaseTable must be set first. * * Returns a List<string> containing any errors encounted. * * If no errors then List.Count == 0. * * Field Metadata is only added for fields passed in the formFields Dictionary. * * */ public List <string> RefreshFieldMetadata(Dictionary <string, DataFieldControl> formFields) { List <string> errors = new List <string>(); try { using (SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["sqlDataConnection.ConnectionString"])) { _fieldMetadataCollection = new Dictionary <string, IFieldMetadata>(); SqlCommand cmd = new SqlCommand(); cmd.Connection = conn; cmd.CommandText = "def.spGetFieldMetadata_with_tooltip"; cmd.CommandType = CommandType.StoredProcedure; cmd.Parameters.AddWithValue("@tblname", DatabaseTable); conn.Open(); SqlDataReader r = cmd.ExecuteReader(); //Create and add field metadata to collection if field in metadata is used in form. //Also set DataFieldControl's reference to its corresponding FieldMetadata object. // while (r.Read()) { if (formFields.ContainsKey(r["FldName"].ToString().ToUpper())) { IFieldMetadata fm = null; try { fm = new FieldMetadata(r["FldName"].ToString(), r["FieldDataType"].ToString(), r["FieldLabel"].ToString(), r["ValueRequired"].ToString(), r["DoubleEntryRequired"].ToString(), r["Read_Only"].ToString(), r["MaxVal"].ToString(), r["MinVal"].ToString(), r["RegEx"].ToString(), r["RegExDescription"].ToString(), r["ValidList"].ToString(), r["MissVal"].ToString(), r["FieldNameAndLabel"].ToString() ); } catch (Exception e) { //An error occured while creating FieldMetadata object errors.Add(e.Message); } //add to collection. Convert key value to all upper case //because dictionary is case sensitive. // //fm will be null if an error was thrown by FieldMetadata contructor. _fieldMetadataCollection.Add(r["FldName"].ToString().ToUpper(), fm); //set DataFieldControls's reference to field metadata formFields[r["FldName"].ToString().ToUpper()].FieldMetadata = fm; } } r.Close(); //_fieldMetadataCollection now should contain a FieldMetadata object for each //field that exists in both the form and in the database metadata. //A field's FieldMetadata object might be null if database metadata was invalid. // //Add notifications for fields that exist in form but not in metadata or those //whose FieldMetadata object couldn't be created. // //if (_dataEntryController.CheckForMissingFieldMetadata) //{ // foreach (string fldname in formFields.Keys) // { // if (_fieldMetadataCollection.ContainsKey(fldname) == false || _fieldMetadataCollection[fldname] == null) // { // errors.Add(fldname + " form field metadata is missing or invalid."); // } // } //} } } catch (Exception e) { //some unanticipated error occured _fieldMetadataCollection = null; errors.Add(e.Message); } return(errors); }
private static ColumnMetadata CreateFileUrlColumnMetadata(IFieldMetadata fileField) { return new ColumnMetadata { SystemName = fileField.Name + Constants.Url, ColumnType = ColumnTypes.String, IsVisible = false }; }
private static ColumnMetadata CreateBackcolorColumnMetadata(IFieldMetadata field) { var backcolorField = field.BackcolorField; return new ColumnMetadata { SystemName = backcolorField.Name, ColumnType = backcolorField.ColumnType, IsVisible = false }; }
private static void SetTextFieldMetadata(ColumnMetadata columnMetadata, IFieldMetadata field) { var textField = field as TextFieldMetadata; if (textField != null) { columnMetadata.IsRichText = textField.IsRichText; } }
private static void SetImageFieldMetadata(ColumnMetadata columnMetadata, IFieldMetadata field) { var imageField = field as ImageFieldMetadata; if (imageField != null) { columnMetadata.ImageWidth = imageField.SearchWidth; columnMetadata.ImageHeight = imageField.SearchHeight; } }
private static void SetNumericFieldMetadata(ColumnMetadata columnMetadata, IFieldMetadata field) { var numericField = field as NumericFieldMetadata; if (numericField != null) { columnMetadata.NumericType = numericField.NumericType; columnMetadata.DecimalDigits = numericField.DecimalDigits; } }
private static void SetDateTimeFieldMetadata(ColumnMetadata columnMetadata, IFieldMetadata field) { var dateTimeField = field as DateTimeFieldMetadata; if (dateTimeField != null) { columnMetadata.DateTimeFormat = dateTimeField.DateTimeFormat; } }
private static void SetBooleanFieldMetadata(ColumnMetadata columnMetadata, IFieldMetadata field) { var booleanField = field as BooleanFieldMetadata; if (booleanField != null) { columnMetadata.UndefinedLabel = booleanField.UndefinedLabel; columnMetadata.FalseLabel = booleanField.FalseLabel; columnMetadata.TrueLabel = booleanField.TrueLabel; } }
/// <summary> /// Build data input control for specified field metadata. /// </summary> /// <param name="fieldMetadata"></param> /// <returns></returns> public override ExtensionDataInputControl BuildDataInputControl(IFieldMetadata fieldMetadata) { StringFieldMetadata metadata = fieldMetadata as StringFieldMetadata; int controlOccupiedCells = metadata.MaxLengthSpecified && metadata.MaxLength > 256 ? int.MaxValue : 1; WebControls.PlaceHolder placeHolder = new WebControls.PlaceHolder(); string textBoxId = string.Format(CultureInfo.InvariantCulture, "SFM{0}_{1}", WebUtility.ConvertControlId(metadata.Name), metadata.Ordinal > 0 ? metadata.Ordinal : int.MaxValue); WebControls.TextBoxMode textBoxMode = controlOccupiedCells == 1 ? WebControls.TextBoxMode.SingleLine : WebControls.TextBoxMode.MultiLine; string cssClass = controlOccupiedCells == 1 ? "textboxShort" : "textboxarea textboxLong"; this.textBox = new TextBox { ID = textBoxId, TextMode = textBoxMode, CssClass = cssClass }; if (metadata.MaxLengthSpecified) this.textBox.MaxLength = metadata.MaxLength; placeHolder.Controls.Add(this.textBox); if (metadata.IsRequired) { LiteralControl requiredLabel = new LiteralControl("<span class=\"required\">*</span>"); placeHolder.Controls.Add(requiredLabel); } if (!(HttpContext.Current.Handler as Page).IsPostBack && !string.IsNullOrEmpty(metadata.Default)) this.textBox.Text = metadata.Default; return new ExtensionDataInputControl { Control = placeHolder, OccupiedControlCells = controlOccupiedCells }; }
/* * Call this to populate FieldMetadata collection. DatabaseTable must be set first. * * Returns a List<string> containing any errors encounted. * * If no errors then List.Count == 0. * * Field Metadata is only added for fields passed in the formFields Dictionary. * * */ public List <string> RefreshFieldMetadata(Dictionary <string, DataFieldControl> formFields) { List <string> errors = new List <string>(); try { _fieldMetadataCollection = new Dictionary <string, IFieldMetadata>(); //Updated June 2018, now need to set user context SQL_utils sqlx = new SQL_utils("data"); string user = sqlx.GetUserNameFromIdentity(); string sqlcode = String.Format("EXEC sec.spSetUserContext 'jeffmun'; exec spDEF_GetFieldMetadata '{0}'", DatabaseTable); //string sqlcode = String.Format("exec spDEF_GetFieldMetadata '{0}'", DatabaseTable); DataTable dt_flds = sqlx.DataTable_from_SQLstring(sqlcode); //Here to fix Feb2021!! sqlx.Close(); foreach (DataRow row in dt_flds.Rows) { if (formFields.ContainsKey(row["databasefield"].ToString().ToUpper())) { IFieldMetadata fm = null; try { fm = new FieldMetadata(row["databasefield"].ToString(), row["fielddatatype"].ToString(), row["fieldlabel"].ToString(), row["valuerequired"].ToString(), row["maxval"].ToString(), row["minval"].ToString(), row["regex"].ToString(), row["regexdescription"].ToString(), row["validlist"].ToString(), row["missval"].ToString()); //add to collection. Convert key value to all upper case //because dictionary is case sensitive. // //fm will be null if an error was thrown by FieldMetadata contructor. string fldname = row["databasefield"].ToString().ToUpper(); if (fm != null) { _fieldMetadataCollection.Add(fldname, fm); } //set DataFieldControls's reference to field metadata formFields[row["DatabaseField"].ToString().ToUpper()].FieldMetadata = fm; } catch (Exception e) { //An error occured while creating FieldMetadata object errors.Add(e.Message); } } } //using (SqlConnection conn = new SqlConnection(ConfigurationManager.AppSettings["sqlDataConnection.ConnectionString"])) //{ // _fieldMetadataCollection = new Dictionary<string, IFieldMetadata>(); // SqlCommand cmd = new SqlCommand(); // cmd.Connection = conn; // //cmd.CommandText = "spDEF_GetFieldMetadata"; // //cmd.CommandType = CommandType.StoredProcedure; // //cmd.Parameters.AddWithValue("@DatabaseTable", DatabaseTable); // //cmd.CommandText = sqlcode; // //cmd.CommandType = CommandType.Text; // //conn.Open(); // //SqlDataReader r = cmd.ExecuteReader(); // ////Create and add field metadata to collection if field in metadata is used in form. // ////Also set DataFieldControl's reference to its corresponding FieldMetadata object. // //// // //while (r.Read()) // //{ // // if (formFields.ContainsKey(r["DatabaseField"].ToString().ToUpper())) // // { // // IFieldMetadata fm = null; // // try // // { // // fm = new FieldMetadata(r["DatabaseField"].ToString(), // // r["FieldDataType"].ToString(), // // r["FieldLabel"].ToString(), // // r["ValueRequired"].ToString(), // // r["MaxVal"].ToString(), // // r["MinVal"].ToString(), // // r["RegEx"].ToString(), // // r["RegExDescription"].ToString(), // // r["ValidList"].ToString(), // // r["MissVal"].ToString()); // // } // // catch (Exception e) // // { // // //An error occured while creating FieldMetadata object // // errors.Add(e.Message); // // } // // //add to collection. Convert key value to all upper case // // //because dictionary is case sensitive. // // // // // //fm will be null if an error was thrown by FieldMetadata contructor. // // _fieldMetadataCollection.Add(r["databasefield"].ToString().ToUpper(), fm); // // //set DataFieldControls's reference to field metadata // // formFields[r["DatabaseField"].ToString().ToUpper()].FieldMetadata = fm; // // } // //} // //r.Close(); // ////_fieldMetadataCollection now should contain a FieldMetadata object for each // ////field that exists in both the form and in the database metadata. // ////A field's FieldMetadata object might be null if database metadata was invalid. // //// // ////Add notifications for fields that exist in form but not in metadata or those // ////whose FieldMetadata object couldn't be created. // //// // ////if (_dataEntryController.CheckForMissingFieldMetadata) // ////{ // //// foreach (string databaseField in formFields.Keys) // //// { // //// if (_fieldMetadataCollection.ContainsKey(databaseField) == false || _fieldMetadataCollection[databaseField] == null) // //// { // //// errors.Add(databaseField + " form field metadata is missing or invalid."); // //// } // //// } // ////} //} } catch (Exception e) { //some unanticipated error occured _fieldMetadataCollection = null; errors.Add(e.Message); } return(errors); }
/// <summary> /// Determines if this process or one of its base processes contains the specified field. /// </summary> /// <param name="field"> /// The field. /// </param> /// <returns> /// <c>true</c> if the process contains the specified field; otherwise, <c>false</c>. /// </returns> public bool ContainsField(IFieldMetadata field) { if (field == null) throw new ArgumentNullException("field"); if (_fieldMap.ContainsValue(field)) { return true; } return BaseProcess != null && !NonInheritedFields.Contains(field.Name) && BaseProcess.ContainsField(field); }
private static void SetFieldMetadata(ColumnMetadata columnMetadata, IFieldMetadata field) { columnMetadata.Header = field.DisplayName; columnMetadata.SystemName = field.Name; columnMetadata.ColumnType = field.ColumnType; if (field.BackcolorField != null) { columnMetadata.BackgroundColorColumnName = field.BackcolorField.Name; } switch (field.ColumnType) { case ColumnTypes.Boolean: SetBooleanFieldMetadata(columnMetadata, field); break; case ColumnTypes.DateTime: SetDateTimeFieldMetadata(columnMetadata, field); break; case ColumnTypes.Double: case ColumnTypes.Integer: case ColumnTypes.Numeric: SetNumericFieldMetadata(columnMetadata, field); break; case ColumnTypes.Image: SetImageFieldMetadata(columnMetadata, field); break; case ColumnTypes.String: SetTextFieldMetadata(columnMetadata, field); break; } }
/// <summary> /// Attempts to get the field with the specified name declared by this process or one of its base processes. /// </summary> /// <param name="fieldName"> /// The field name. /// </param> /// <param name="field"> /// The field. /// </param> /// <returns> /// True if the field is found in current process or one of its base processes; otherwise, false. /// </returns> public bool TryGetField(string fieldName, out IFieldMetadata field) { if (_fieldMap.TryGetValue(fieldName, out field)) { return true; } return BaseProcess != null && !NonInheritedFields.Contains(fieldName) && BaseProcess.TryGetField(fieldName, out field); }
/// <summary> /// Convert propertyValue to IFieldValue interface /// </summary> /// <param name="fieldMetadata">The field metadata of specified property name.</param> /// <param name="propertyName">Property name.</param> /// <param name="propertyValue">Property value.</param> /// <returns>IFieldValue interface</returns> /// <exception cref="NotSupportedException">When propertyValue's type is not supported</exception> private static IFieldValue ConvertToFieldValueInterface(IFieldMetadata fieldMetadata, string propertyName, object propertyValue) { if (propertyValue == null) return null; #region If field metadata is predefined. if (fieldMetadata != null) { string exceptionMessage = string.Format(CultureInfo.InvariantCulture, "The property \"{0}\" with value \"{1}\" doesn't match the field metadata type \"{2}\".", propertyName, propertyValue, fieldMetadata.Type); switch (fieldMetadata.Type) { case FieldType.DateTime: if (propertyValue is DateTime) return LocalizationUtility.ConvertClientTimeToUtcTime((DateTime)propertyValue).FieldValue(); else if (propertyValue is DateTime?) { DateTime? dateTimePropertyValue = (DateTime?)propertyValue; if (!dateTimePropertyValue.HasValue) return null; return LocalizationUtility.ConvertClientTimeToUtcTime(dateTimePropertyValue.Value).FieldValue(); } else throw new NotSupportedException(exceptionMessage); case FieldType.Decimal: if (propertyValue is decimal) return ((decimal)propertyValue).FieldValue(); else if (propertyValue is decimal?) return ((decimal?)propertyValue).FieldValue(); else throw new NotSupportedException(exceptionMessage); case FieldType.Hierarchy: if (propertyValue is HierarchyNodeValueCollection) return (propertyValue as HierarchyNodeValueCollection).FieldValue(); else return new HierarchyNodeValueCollection { propertyValue.ToString() }.FieldValue(); case FieldType.Integer: if (propertyValue is int) return ((int)propertyValue).FieldValue(); else if (propertyValue is int?) return ((int?)propertyValue).FieldValue(); else throw new NotSupportedException(exceptionMessage); case FieldType.Enumeration: if (propertyValue is EnumerationValueCollection) return (propertyValue as EnumerationValueCollection).FieldValue(); else return new EnumerationValueCollection { propertyValue.ToString() }.FieldValue(); case FieldType.String: if (propertyValue is string) return (propertyValue as string).FieldValue(); else return propertyValue.ToString().FieldValue(); } } #endregion #region if field metadata is undefined, here trys to guess the property type if (propertyValue is string) return (propertyValue as string).FieldValue(); else if (propertyValue is DateTime) return LocalizationUtility.ConvertClientTimeToUtcTime((DateTime)propertyValue).FieldValue(); else if (propertyValue is DateTime?) { DateTime? dateTimePropertyValue = (DateTime?)propertyValue; if (!dateTimePropertyValue.HasValue) return null; return LocalizationUtility.ConvertClientTimeToUtcTime(dateTimePropertyValue.Value).FieldValue(); } else if (propertyValue is decimal) return ((decimal)propertyValue).FieldValue(); else if (propertyValue is decimal?) return ((decimal?)propertyValue).FieldValue(); else if (propertyValue is int) return ((int)propertyValue).FieldValue(); else if (propertyValue is int?) return ((int?)propertyValue).FieldValue(); else if (propertyValue is HierarchyNodeValueCollection) return (propertyValue as HierarchyNodeValueCollection).FieldValue(); else if (propertyValue is EnumerationValueCollection) return (propertyValue as EnumerationValueCollection).FieldValue(); throw new NotSupportedException(string.Format(Resources.FieldNotSupportSpecifiedValueType, propertyName, propertyValue.GetType())); #endregion }
private static FilterMemberDefinition CreateFilterMemberDefinition(IFieldMetadata field) { var memberDefinition = new FilterMemberDefinition { FieldName = field.Name, ColumnName = GetFilterMemberColumnName(field), DisplayName = field.DisplayName, MemberType = GetMemberType(field), IncludeInAdminFilters = field.Name != Constants.CurrentStateColumnName, IncludeInUserFilters = true }; var dateTimeField = field as DateTimeFieldMetadata; if (dateTimeField != null) { memberDefinition.DateTimeFormat = dateTimeField.DateTimeFormat; } var referenceField = field as IReferenceFieldMetadata; if (referenceField != null) { memberDefinition.ReferencedProcessSystemName = referenceField.ReferencedProcess.Name; } var crossReferenceField = field as CrossReferenceFieldMetadata; if (crossReferenceField != null && crossReferenceField.Name != Constants.CurrentStateColumnName) { memberDefinition.DetailFields = GetDetailFields(crossReferenceField.DetailedViewDisplayFields); } var reverseCrossReferenceField = field as ReverseCrossReferenceFieldMetadata; if (reverseCrossReferenceField != null) { memberDefinition.DetailFields = GetDetailFields(reverseCrossReferenceField.DetailedViewDisplayFields); } var treeViewField = field as TreeViewFieldMetadata; if (treeViewField != null) { memberDefinition.DetailFields = GetDetailFields(treeViewField.DetailedViewDisplayFields); } return memberDefinition; }
public static bool IsMultiline(this IFieldMetadata fieldMetadata) { return(fieldMetadata.FieldType == RecordFieldType.Memo || fieldMetadata.TextFormat == TextFormat.TextArea); }
private static string GetFilterMemberColumnName(IFieldMetadata field) { switch (field.ColumnType) { case ColumnTypes.Reference: case ColumnTypes.MultiReference: case ColumnTypes.ReverseReference: case ColumnTypes.ReverseMultiReference: case ColumnTypes.TreeView: return field.Name + Constants.IdColumnName; } return field.Name; }
/// <summary> /// Build data input control for specified field metadata. /// </summary> /// <param name="fieldMetadata"></param> /// <returns></returns> public override ExtensionDataInputControl BuildDataInputControl(IFieldMetadata fieldMetadata) { EnumerationFieldMetadata metadata = fieldMetadata as EnumerationFieldMetadata; WebControls.PlaceHolder placeHolder = new WebControls.PlaceHolder(); if (metadata.SelectionMode == SelectionModes.Single) { string comboBoxId = string.Format(CultureInfo.InvariantCulture, "SLTFM{0}_{1}", WebUtility.ConvertControlId(metadata.Name), metadata.Ordinal > 0 ? metadata.Ordinal : int.MaxValue); this.ComboBoxFieldValue = new ComboBox { ID = comboBoxId, Editable = false, ForceSelection = true, Mode = ComboBoxDataSourceModes.Local, Width = 154 }; foreach (ExtensionModel.SelectionItem selectionItem in metadata.Items.OrderBy(item => item.Name)) this.ComboBoxFieldValue.Items.Add(new WebControls.ListItem(selectionItem.Name, selectionItem.Value) { Selected = selectionItem.Selected }); placeHolder.Controls.Add(this.ComboBoxFieldValue); if (metadata.IsRequired) { LiteralControl requiredLabel = new LiteralControl("<span class=\"required\">*</span>"); placeHolder.Controls.Add(requiredLabel); } return new ExtensionDataInputControl { Control = placeHolder, OccupiedControlCells = 1 }; } else { string checkBoxGroupId = string.Format(CultureInfo.InvariantCulture, "SLTFM{0}_{1}", WebUtility.ConvertControlId(metadata.Name), metadata.Ordinal > 0 ? metadata.Ordinal : int.MaxValue); this.CheckBoxGroupFieldValue = new CheckBoxGroup { ID = checkBoxGroupId, RepeatDirection = System.Web.UI.WebControls.RepeatDirection.Horizontal, RepeatLayout = System.Web.UI.WebControls.RepeatLayout.Flow }; foreach (ExtensionModel.SelectionItem selectionItem in metadata.Items.OrderBy(item => item.Name)) this.CheckBoxGroupFieldValue.Items.Add(new WebControls.ListItem(selectionItem.Name, selectionItem.Value) { Selected = selectionItem.Selected }); placeHolder.Controls.Add(this.CheckBoxGroupFieldValue); if (metadata.IsRequired) { LiteralControl requiredLabel = new LiteralControl("<span class=\"required\">*</span>"); placeHolder.Controls.Add(requiredLabel); } return new ExtensionDataInputControl { Control = placeHolder, OccupiedControlCells = int.MaxValue }; } }
private static FilterDataType GetMemberType(IFieldMetadata field) { if (field.Name == Constants.CurrentStateColumnName) { return FilterDataType.State; } switch (field.ColumnType) { case ColumnTypes.Integer: return FilterDataType.Int; case ColumnTypes.String: case ColumnTypes.Frequency: case ColumnTypes.AutoNumber: case ColumnTypes.SampleType: case ColumnTypes.SamplingTechnique: case ColumnTypes.Label: return FilterDataType.String; case ColumnTypes.Reference: case ColumnTypes.MultiReference: case ColumnTypes.ReverseReference: case ColumnTypes.ReverseMultiReference: case ColumnTypes.TreeView: return FilterDataType.Reference; case ColumnTypes.Numeric: case ColumnTypes.Double: return FilterDataType.Double; case ColumnTypes.Boolean: return FilterDataType.Boolean; case ColumnTypes.DateTime: return FilterDataType.DateTime; case ColumnTypes.Approval: return FilterDataType.Approval; default: return FilterDataType.String; } }
private FieldImpl(IFieldMetadata metadata, Object parent) { _metadata = metadata; Parent = parent; }
private IEnumerable<FilterMemberValue> GetReferenceFieldValues( IFieldMetadata referenceField, DisplayFieldMetadata displayField, IList<DisplayFieldMetadata> detailsFields) { using (new BypassPropertyCheckContext()) { var items = DynamicTypeManager.GetReferenceList<IReferenceItem>( referenceField.DeclaringProcess.Name, referenceField.Name, null, null, int.MaxValue, 0, null); detailsFields = detailsFields.Where(CanIncludeInMemberDetails).ToArray(); return items.OrderBy(x => x.GetValueByPropertyName(displayField.Name)).Select(x => CreateMemberValue(x, displayField, detailsFields)).ToList(); } }
/// <summary> /// Build data input control for specified field metadata. /// </summary> /// <param name="fieldMetadata"></param> /// <returns></returns> public abstract ExtensionDataInputControl BuildDataInputControl(IFieldMetadata fieldMetadata);
private static IProcessMetadata GetReferencedProcess(IFieldMetadata field) { var singleCR = field as SingleCrossReferenceFieldMetadata; if (singleCR != null) { return singleCR.ReferencedProcess; } var multiCR = field as MultiCrossReferenceFieldMetadata; if (multiCR != null) { return multiCR.ReferencedProcess; } throw new NotSupportedException( string.Format( CultureInfo.InvariantCulture, "The field '{0}' from process '{1}' is not a valid reference field.", field.Name, field.DeclaringProcess.Name)); }
/// <summary> /// Build data input control for specified field metadata. /// </summary> /// <param name="fieldMetadata"></param> /// <returns></returns> public override ExtensionDataInputControl BuildDataInputControl(IFieldMetadata fieldMetadata) { IntegerFieldMetadata metadata = fieldMetadata as IntegerFieldMetadata; WebControls.PlaceHolder placeHolder = new WebControls.PlaceHolder(); string textBoxId = string.Format(CultureInfo.InvariantCulture, "IFM{0}_{1}", WebUtility.ConvertControlId(metadata.Name), metadata.Ordinal > 0 ? metadata.Ordinal : int.MaxValue); this.integerTextBox = new IntegerTextBox { ID = textBoxId, TextMode = WebControls.TextBoxMode.SingleLine, CssClass = "textboxShort", MaxLength = 32, AllowNegative = true }; placeHolder.Controls.Add(this.integerTextBox); if (metadata.IsRequired) { LiteralControl requiredLabel = new LiteralControl("<span class=\"required\">*</span>"); placeHolder.Controls.Add(requiredLabel); } if (!(HttpContext.Current.Handler as Page).IsPostBack && metadata.DefaultSpecified) this.integerTextBox.Value = metadata.Default; return new ExtensionDataInputControl { Control = placeHolder, OccupiedControlCells = 1 }; }
private static string GetFilter(IFieldMetadata field, TableAliasCollection aliasCollection) { var singleCR = field as SingleCrossReferenceFieldMetadata; if (singleCR != null) return GetFilter(singleCR, aliasCollection); var multiCR = field as MultiCrossReferenceFieldMetadata; if (multiCR != null) return GetFilter(multiCR, aliasCollection); throw new NotSupportedException( string.Format( CultureInfo.InvariantCulture, "The field '{0}' from process '{1}' is not a valid reference field.", field.Name, field.DeclaringProcess.Name)); }
private static HtmlTableCell CreateControlCell(HtmlTableRow row, IFieldMetadata fieldMetadata, ExtensionDataInputControl dataInputControl) { HtmlTableCell labelCell = new HtmlTableCell("td"); labelCell.Attributes["class"] = "c1"; labelCell.NoWrap = true; labelCell.InnerText = fieldMetadata.Name + ": "; row.Cells.Add(labelCell); HtmlTableCell controlCell = new HtmlTableCell("td"); HtmlTableCell lastControlCell = controlCell; controlCell.Attributes["class"] = "c2"; controlCell.NoWrap = true; controlCell.ColSpan = dataInputControl.OccupiedControlCells != int.MaxValue ? dataInputControl.OccupiedControlCells * 2 - 1 : 5; row.Cells.Add(controlCell); controlCell.Controls.Add(dataInputControl.Control); return lastControlCell; }
private static IEnumerable<IParameterBuilder> GetParameterBuilders(IFieldMetadata field) { var singleCR = field as SingleCrossReferenceFieldMetadata; if (singleCR != null) return GetParameterBuilders(singleCR); var multiCR = field as MultiCrossReferenceFieldMetadata; if (multiCR != null) return GetParameterBuilders(multiCR); throw CreateNotSupportedException(field); }
private static NotSupportedException CreateNotSupportedException(IFieldMetadata field) { return new NotSupportedException( string.Format( CultureInfo.InvariantCulture, "The field '{0}' from process '{1}' is not a valid reference field.", field.Name, field.DeclaringProcess.Name)); }
/// <summary> /// Initializes a new instance of the <see cref="DisplayFieldMetadata"/> class. /// </summary> /// <param name="name"> /// The display field name. /// </param> /// <param name="field"> /// The field. /// </param> public DisplayFieldMetadata(string name, IFieldMetadata field) : this(name, field, Enumerable.Empty<IReferenceFieldMetadata>()) { }
private FieldImpl(IFieldMetadata metadata, Item parent) { this.metadata = metadata; this.Parent = parent; }
private static ColumnMetadata CreateColumnMetadata(GridColumn column, IFieldMetadata field) { var columnMetadata = CreateColumnMetadata(column); SetFieldMetadata(columnMetadata, field); return columnMetadata; }