private static void SetTextFieldMetadata(ColumnMetadata columnMetadata, IFieldMetadata field) { var textField = field as TextFieldMetadata; if (textField != null) { columnMetadata.IsRichText = textField.IsRichText; } }
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 SetImageFieldMetadata(ColumnMetadata columnMetadata, IFieldMetadata field) { var imageField = field as ImageFieldMetadata; if (imageField != null) { columnMetadata.ImageWidth = imageField.SearchWidth; columnMetadata.ImageHeight = imageField.SearchHeight; } }
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; } }
private static void SetDateTimeFieldMetadata(ColumnMetadata columnMetadata, IFieldMetadata field) { var dateTimeField = field as DateTimeFieldMetadata; if (dateTimeField != null) { columnMetadata.DateTimeFormat = dateTimeField.DateTimeFormat; } }
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; } }
private static object FormatImageColumn(IInfoClass infoItem, ColumnMetadata column) { var bytes = infoItem.GetValueByPropertyName(column.SystemName) as byte[]; if (bytes != null && bytes.Length > 0) { var width = column.ImageWidth ?? Constants.DefaultImageWidthOnSearch; var height = column.ImageHeight ?? Constants.DefaultImageHeightOnSearch; bytes = Utils.ResizeImage(bytes, width, height); } return bytes; }
private object FormatBackcolorColumn(IInfoClass infoItem, ColumnMetadata column) { var argb = (long)infoItem.GetValueByPropertyName(column.SystemName); if (argb == 0) { // 0 represents no color. return null; } return ColorTranslator.ToHtml(argb); }
private static object FormatApprovalColumn(IInfoClass infoItem, ColumnMetadata column) { var approvalState = ApprovalStates.NotReadyForApproval; var propertyValue = (string)infoItem.GetValueByPropertyName(column.SystemName); if (!string.IsNullOrEmpty(propertyValue)) { approvalState = (ApprovalStates)Enum.Parse(typeof(ApprovalStates), propertyValue); } return approvalState.GetDisplayName(); }
private object FormatColumn(IInfoClass infoItem, ColumnMetadata column) { switch (column.ColumnType) { case ColumnTypes.Approval: return FormatApprovalColumn(infoItem, column); case ColumnTypes.FieldBackcolor: return FormatBackcolorColumn(infoItem, column); case ColumnTypes.Image: return FormatImageColumn(infoItem, column); default: return infoItem.GetValueByPropertyName(column.SystemName); } }