Пример #1
0
 /// <summary>
 /// Gets the plain text value.
 /// </summary>
 /// <param name="content">The content.</param>
 /// <returns>System.String.</returns>
 public static string GetPlainTextValue(string content)
 {
     var converter = new HtmlToText();
     return converter.ConvertHtml(content);
 }
Пример #2
0
        private static string GetRichTextFieldValue(IDynamicObject item, PropertyInfo prop, bool isHtml)
        {
            var richText = item.GetValueByPropertyName(prop.Name);
            var converter = new HtmlToText();
            var plainText = converter.ConvertHtml(richText);

            return Encode(plainText, isHtml);
        }
Пример #3
0
        //TODO: Method is too complex. Refactor!
        /// <summary>
        /// Builds the detail report.
        /// </summary>
        /// <param name="reportDocument">The report document.</param>
        public void BuildDetailReport(ICustomReport reportDocument)
        {
            var currentReport = reportDocument.Reports.First();

            var visibleSections = new List<Section>();
            var visibleFields = new List<PropertyInfo>();

            var textHeight = 0.2;
            var valueTextHeight = 0.6;
            var valueMargin = 0.1;
            var fieldMargin = 0.1;
            var sectionMargin = 0.3;

            //This report parameter holds id of the detail item
            _itemId = int.Parse(currentReport.ReportParameters["itemId"].Value.ToString());

            //This report parameter holds the current template system name.
            _processName = currentReport.ReportParameters["processName"].Value.ToString();

            GetEditableRoot(currentReport);

            var itemProperties = _item.GetAllPropertiesForInstance();
            var allItemSections = itemProperties.Where(x => x.Key.Name == "Sections").Reverse()
                                                .SelectMany(x => x.Key.GetValue(x.Value, null) as IList<ISection>)
                                                .Distinct(new SectionEqualityComparerByGuid());

            foreach (Section section in allItemSections)
            {
                var sections = currentReport.ReportParameters["sections"].Value.ToString().Split(';');
                var sectionIsVisible = false;
                var index = 0;

                while (!sectionIsVisible && index < sections.Length)
                {
                    if (sections[index] == section.Name)
                    {
                        sectionIsVisible = true;
                    }
                    index++;
                }

                if (sectionIsVisible)
                {
                    visibleSections.Add(section);
                }
            }

            _fieldAttrDict = GetFieldAttributes(itemProperties.Select(x => x.Key));
            
            var fields = _fieldAttrDict.Where(x => visibleSections.Select(s => s.Name).Contains(x.Value.SectionName))
                                       .Select(x => x.Key);

            foreach (var field in fields)
            {
                var fieldNames = currentReport.ReportParameters["fields"].Value.ToString().Split(';');
                var fieldIsVisible = false;
                var index = 0;

                while (!fieldIsVisible && index < fieldNames.Length)
                {
                    if (fieldNames[index] == field.Name)
                    {
                        fieldIsVisible = true;
                    }
                    index++;
                }

                if (fieldIsVisible)
                {
                    visibleFields.Add(field);
                }
            }

            double startY = 0;
            var availableWidth = currentReport.Width.Value;

            foreach (var section in visibleSections)
            {
                var sectionHeaderSize = new SizeU(new Unit(availableWidth, UnitType.Inch), new Unit(textHeight, UnitType.Inch));
                var headerLoc = new PointU(new Unit(0), new Unit(startY, UnitType.Inch));

                var sectionHeader = new TextBox { Value = section.Name, Location = headerLoc, Size = sectionHeaderSize, StyleName = "Section", Multiline = false, CanGrow = false };
                startY += textHeight + fieldMargin;

                currentReport.Items["detail"].Items.Add(sectionHeader);

                double percentageOfRowUsed = 0;
                var sectionFields = visibleFields.Where(x => _fieldAttrDict[x].SectionName == section.Name).OrderBy(y => _fieldAttrDict[y].FieldPosition).ToArray();

                for (var i = 0; i < sectionFields.Length; i++)
                {
                    if (percentageOfRowUsed + _fieldAttrDict[sectionFields[i]].WidthPercentage > 1.0)
                    {
                        startY += textHeight + valueMargin + valueTextHeight + fieldMargin;
                        percentageOfRowUsed = 0;
                    }

                    var location = new PointU(new Unit((availableWidth * percentageOfRowUsed), UnitType.Inch), new Unit(startY, UnitType.Inch));
                    var fieldPanel = new Panel { Location = location };

                    location = new PointU(Unit.Inch(0), Unit.Inch(0));
                    var fieldHeaderSize = new SizeU(new Unit((availableWidth * _fieldAttrDict[sectionFields[i]].WidthPercentage) - 0.1, UnitType.Inch), new Unit(textHeight, UnitType.Inch));
                    var fieldHeader = new TextBox { Location = location, Size = fieldHeaderSize, StyleName = "Field", Multiline = true, CanGrow = true };
                    fieldHeader.Value = GetDisplayName(sectionFields[i]);

                    var valueLocation = new PointU(Unit.Inch(0), Unit.Inch(textHeight + valueMargin));
                    var valueSize = new SizeU(new Unit((availableWidth * _fieldAttrDict[sectionFields[i]].WidthPercentage) - 0.1, UnitType.Inch), new Unit(valueTextHeight, UnitType.Inch));
                    var fieldValue = new TextBox { Location = valueLocation, Size = valueSize, StyleName = "Value", Multiline = true, CanGrow = true };

                    var backgroundProperty = _item.GetPropertyByName(sectionFields[i].Name + Constants.FieldBackColorPostfix);
                    if (backgroundProperty != null)
                    {
                        var colorAsLong = _item.GetValueByPropertyName(backgroundProperty.Name);

                        if (colorAsLong != 0)
                        {
                            var bytes = BitConverter.GetBytes(colorAsLong);
                            if (bytes[3] == 0) bytes[3] = 255;
                            var color = Color.FromArgb(bytes[3], bytes[2], bytes[1], bytes[0]);
                            fieldValue.Style.BackgroundColor = color;
                        }
                    }

                    var pictureBox = new PictureBox { Location = valueLocation, Size = valueSize, StyleName = "Value" };

                    List<Chart> chartsList = null;

                    Table fieldValueTable = null;

                    var displayFieldPath = string.Format("[{0}]", string.Join("].[", _item.GetFullPropertyPath(sectionFields[i].Name)));

                    if (_fieldAttrDict[sectionFields[i]].FieldEditor == "Approval")
                    {
                        fieldValue.Value = string.Format("=ApprovalEnumConverter({0}.ApprovalState)", displayFieldPath);
                    }
                    else if (_fieldAttrDict[sectionFields[i]].IsSingleCrossRef)
                    {
                        var displayField = _fieldAttrDict[sectionFields[i]].DisplayFieldList[0];
                        var crossRefMember =
                            itemProperties.FirstOrDefault(
                                x => x.Key.Name == string.Format("{0}Member", sectionFields[i].Name));

                        if (!crossRefMember.Equals(default(KeyValuePair<PropertyInfo, IDynamicObject>)))
                        {
                            var crossRefMemberValue = crossRefMember.Key.GetValue(crossRefMember.Value, null) as IDynamicObject;

                            if (crossRefMemberValue != null)
                            {
                                var infoList = TheDynamicTypeManager.GetInfoListById<IInfoList>(
                                                                        _fieldAttrDict[sectionFields[i]].CrossRefProcessName,
                                                                        ((IEditableRoot)crossRefMemberValue).Id);

                                if (infoList.Count > 0)
                                {
                                    var crossRefInfoValue = infoList[0] as IDynamicObject;
                                    var infoProps = crossRefInfoValue.GetAllPropertiesForInstance();

                                    var displayFieldProp = infoProps.FirstOrDefault(x => x.Key.Name == displayField).Key;
                                    if (displayFieldProp != null)
                                    {
                                        fieldValue.Value = displayFieldProp.GetValue(infoProps[displayFieldProp], null).ToString();
                                    }
                                }
                            }
                        }
                    }
                    else if (_fieldAttrDict[sectionFields[i]].IsMultiCrossRef)
                    {
                        var crList = _item.GetValueByPropertyName(sectionFields[i].Name) as ICrossRefItemList;
                        if (crList != null)
                        {
                            foreach (var item in crList)
                            {
                                fieldValue.Value += item + Environment.NewLine;
                            }
                        }
                    }
                    else if (_fieldAttrDict[sectionFields[i]].FieldEditor == typeof(DateTime).Name || _fieldAttrDict[sectionFields[i]].FieldEditor == "ScheduleDate")
                    {
                        fieldValue.Value = string.Format("=GetDateTimeValue({0}, \"{1}\")", displayFieldPath, _fieldAttrDict[sectionFields[i]].DateTimeFormat.Value);
                    }
                    else if (_fieldAttrDict[sectionFields[i]].FieldEditor == "Result")
                    {
                        var resultListFieldName = string.Format("{0}_ResultList", sectionFields[i].Name);
                        var resultist =
                            itemProperties.FirstOrDefault(
                                x => x.Key.Name == resultListFieldName);

                        if (!resultist.Equals(default(KeyValuePair<PropertyInfo, IDynamicObject>)))
                        {
                            var resultistValue = resultist.Key.GetValue(resultist.Value, null) as IEnumerable<ChoiceInfo>;

                            var resultistPath = string.Format("[{0}]", string.Join("].[", _item.GetFullPropertyPath(resultListFieldName)));

                            if (resultistValue != null)
                            {
                                fieldValue.Value = string.Format("=GetChoiceName({0}, {1})", resultistPath, displayFieldPath);
                            }
                        }
                        else
                            fieldValue.Value = string.Format("=Fields.{0}", displayFieldPath);
                    }
                    else if (_fieldAttrDict[sectionFields[i]].FieldEditor == "FileProcess")
                    {
                        if ((sectionFields[i].GetValue(itemProperties[sectionFields[i]], null) as IDynamicObject) != null)
                            fieldValue.Value = string.Format("=Fields.{0}.OriginalFileName", displayFieldPath);
                        else
                            fieldValue.Value = string.Format("=Fields.{0}", displayFieldPath);
                    }
                    else if (_fieldAttrDict[sectionFields[i]].FieldEditor == Constants.ChoiceFieldType)
                    {
                        var xml = sectionFields[i].GetValue(itemProperties[sectionFields[i]], null).ToString();

                        if (!string.IsNullOrEmpty(xml))
                        {
                            var choices = XElement.Parse(xml);
                            var isGlobal = choices.FirstAttribute.Value;

                            if (Convert.ToBoolean(isGlobal))
                            {
                                var id = choices.LastAttribute.Value;
                                var globalChoice = TheDynamicTypeManager.GetEditableRoot<IEditableRoot>(Constants.GlobalChoiceProcessName, Convert.ToInt32(id));

                                var newXml = (string)globalChoice.GetType().GetProperty("ChoiceDetails").GetValue(globalChoice, null);

                                if (!string.IsNullOrEmpty(newXml))
                                    choices = XElement.Parse(newXml);
                            }

                            if (choices.Descendants().Any())
                            {
                                var choiceInfoList = new List<ChoiceInfo>();

                                foreach (var element in choices.Descendants())
                                {
                                    choiceInfoList.Add(new ChoiceInfo
                                    {
                                        Choice = element.Attribute("Choice").Value,
                                        Score = double.Parse(element.Attribute("Score").Value),
                                        AcceptanceCriteria = (ChoiceInfo.AcceptanceCriterias)Enum.Parse(typeof(ChoiceInfo.AcceptanceCriterias), element.Attribute("AcceptanceCriteria").Value, false)
                                    });
                                }

                                var columns = new List<TableColumn>
                                    {
                                        new TableColumn("Choice", "Choice", fieldHeader.Size.Width * 0.5),
                                        new TableColumn("Score", "Score", fieldHeader.Size.Width * 0.2),
                                        new TableColumn("AcceptanceCriteria", "Criteria", fieldHeader.Size.Width * 0.3)
                                    };

                                fieldValueTable = CreateTable(columns);
                                fieldValueTable.Location = valueLocation;
                                fieldValueTable.DataSource = choiceInfoList;
                            }
                        }
                    }
                    else if (_fieldAttrDict[sectionFields[i]].FieldEditor == ColumnTypes.AuditTrail.ToString())
                    {
                        var columns = new List<TableColumn>
                        {
                            new TableColumn("UserName", "UserName", fieldHeader.Size.Width / 6),
                            new TableColumn("ChangeType", "Type", fieldHeader.Size.Width / 6),
                            new TableColumn("FieldName", "FieldName", fieldHeader.Size.Width / 6),
                            new TableColumn("OldValue", "OldValue", fieldHeader.Size.Width / 6),
                            new TableColumn("NewValue", "NewValue", fieldHeader.Size.Width / 6),
                            new TableColumn("UpdateDate", "UpdateDate", fieldHeader.Size.Width / 6)
                        };

                        fieldValueTable = CreateTable(columns);
                        fieldValueTable.Location = valueLocation;
                        var audits = sectionFields[i].GetValue(itemProperties[sectionFields[i]], null);

                        var auditList = ((IEnumerable)audits).Cast<AuditInfo>().ToList();
                        for (var j = 0; j < auditList.Count; j++)
                        {
                            if (!string.IsNullOrEmpty(auditList[j].FieldName))
                            {
                                foreach (var fieldParametrese in _fieldAttrDict)
                                {
                                    if (fieldParametrese.Key.Name == auditList[j].FieldName && fieldParametrese.Value.FieldEditor == "RichText")
                                    {
                                        var converter = new HtmlToText();
                                        var oldValue = converter.ConvertHtml(auditList[j].OldValue as string);
                                        var newValue = converter.ConvertHtml(auditList[j].NewValue as string);

                                        var newAudit = new AuditInfo(auditList[j].Id, auditList[j].ChangeType, auditList[j].ItemId, auditList[j].FieldName, oldValue, newValue, auditList[j].UpdateDate, auditList[j].UserName);
                                        auditList[j] = newAudit;
                                    }
                                }
                            }
                        }

                        fieldValueTable.DataSource = auditList;
                    }
                    else if (_fieldAttrDict[sectionFields[i]].IsReverseCrossRef)
                    {
                        //fieldValue.Value = string.Format("=Fields.{0}.ToString()", displayFieldPath);
                        var item = _item.GetValueByPropertyName(sectionFields[i].Name);

                        if (item != null)
                            fieldValue.Value = item.ToString();
                    }
                    else if (_fieldAttrDict[sectionFields[i]].IsMultiReverseCrossRef)
                    {
                        var list = _item.GetValueByPropertyName(sectionFields[i].Name) as IList;

                        if (list != null)
                        {
                            foreach (IReverseCrossReferenceItem item in list)
                            {
                                fieldValue.Value += item + "\n";
                            }
                        }
                    }
                    else if (_fieldAttrDict[sectionFields[i]].FieldEditor == "RichText")
                    {
                        fieldValue.Value = string.Format("=GetPlainTextValue({0})", displayFieldPath);
                    }
                    else if (_fieldAttrDict[sectionFields[i]].FieldEditor == ColumnTypes.Checklist.ToString())
                    {
                        var meta = new Dictionary<string, Type>();
                        var data = new List<object>();
                        short count = 0;

                        var checklistObject = (ChecklistEdit)sectionFields[i].GetValue(_item, null);

                        // checklist cache data
                        string resultPropertyName = null;
                        if (checklistObject.AnswerProcessList.Count > 0)
                        {
                            var tempProps = ((IEditableRoot)checklistObject.AnswerProcessList[0]).GetAllPropertiesForType();
                            foreach (var prop in tempProps)
                            {
                                var resultAttr = (FieldEditorAttribute)(from d in prop.GetCustomAttributes(typeof(FieldEditorAttribute), false) select d).FirstOrDefault();
                                if (resultAttr != null && resultAttr.DataType == Constants.ResultFieldType)
                                {
                                    resultPropertyName = prop.Name;
                                    break;
                                }
                            }
                        }
                        // end checklist cache

                        var displayFields = sectionFields[i].GetCustomAttributes<ChecklistDisplayFieldAttribute>().ToList();
                        
                        foreach (IEditableRoot editObject in checklistObject.AnswerProcessList)
                        {
                            var properties = editObject.GetAllPropertiesForType();
                            foreach (var property in properties)
                            {
                                if (displayFields.All(x => x.SystemName != property.Name))
                                {
                                    continue;
                                }

                                var csAttr = (CommonSettingsAttribute)(from d in property.GetCustomAttributes(typeof(CommonSettingsAttribute), false) select d).FirstOrDefault();
                                var feAttr = (FieldEditorAttribute)(from d in property.GetCustomAttributes(typeof(FieldEditorAttribute), false) select d).FirstOrDefault();
                                if (csAttr != null && csAttr.Section != null)
                                {
                                    if (checklistObject.AnswerProcessList.IndexOf(editObject) == 0)
                                    {
                                        var columnName = property.Name == resultPropertyName ? "Linked Item" : GetDisplayName(property);

                                        meta.Add(columnName, property.PropertyType == typeof(byte[]) ? typeof(byte[]) : typeof(string));
                                        count++;
                                    }

                                    var value = property.GetValue(editObject, null);
                                    if (value is string && string.IsNullOrWhiteSpace((string)value))
                                    {
                                        data.Add(string.Empty);
                                        continue;
                                    }

                                    //image
                                    if (property.PropertyType == typeof(byte[]))
                                    {
                                        data.Add(value);
                                        continue;
                                    }

                                    //file
                                    if (typeof(IFileProcess).IsAssignableFrom(property.PropertyType))
                                    {
                                        data.Add(((IFileProcess)value).OriginalFileName);
                                        continue;   
                                    }

                                    //sample
                                    if (typeof(ISampleList).IsAssignableFrom(property.PropertyType))
                                    {
                                        var answerList = _item.GetValueByPropertyName(string.Format("{0}List", sectionFields[i].Name));
                                        if (answerList is IEnumerable)
                                        {
                                            var sampleEdit = ((IEnumerable<IEditableRoot>)answerList).FirstOrDefault();

                                            if (sampleEdit != null)
                                            {
                                                var xml = sampleEdit.GetValueByPropertyName(string.Format("{0}{1}", property.Name, Constants.SampleSettingPostfix)) as string;
                                                if (!string.IsNullOrEmpty(xml))
                                                {
                                                    var sampleTypeFieldName = XElement.Parse(xml).Attribute("SampleTypeFieldName").Value;
                                                    var sampleTypeValue = sampleEdit.GetValueByPropertyName(sampleTypeFieldName);

                                                    if (sampleTypeValue != null)
                                                    {
                                                        var sampleType = (SampleTypes)Enum.Parse(typeof(SampleTypes), sampleTypeValue, false);

                                                        var result = new List<string>();
                                                        foreach (ISampleEdit item in (ISampleList)value)
                                                        {
                                                            switch (sampleType)
                                                            {
                                                                case SampleTypes.Boolean:
                                                                    result.Add(string.Format("{0} {1}", item.Label, item.SampleBoolean));
                                                                    break;

                                                                case SampleTypes.Number:
                                                                    result.Add(string.Format("{0} {1}", item.Label, item.SampleNumeric));
                                                                    break;

                                                                case SampleTypes.Alphanumeric:
                                                                    result.Add(string.Format("{0} {1}", item.Label, item.SampleAlphanumeric));
                                                                    break;
                                                            }
                                                        }
                                                        data.Add(string.Join(Environment.NewLine, result));
                                                        continue;
                                                    }
                                                }
                                            }
                                        }
                                    }

                                    if (feAttr != null && resultPropertyName != null && (feAttr.DataType == Constants.ChoiceFieldType || property.Name == resultPropertyName))
                                    {
                                        var choiceProperty = properties.FirstOrDefault(x => x.Name == resultPropertyName);
                                        double? choiceValue = null;
                                        if (choiceProperty != null)
                                        {
                                            choiceValue = (double?)choiceProperty.GetValue(editObject, null);
                                        }

                                        if (choiceValue.HasValue)
                                        {
                                            var resultProperty = properties.FirstOrDefault(x => x.Name == resultPropertyName + Constants.ResultListPostfix);

                                            var choiceInfoList = resultProperty.GetValue(editObject, null) as IEnumerable<ChoiceInfo>;
                                            if (choiceInfoList == null)
                                            {
                                                data.Add(string.Empty);
                                                continue;
                                            }

                                            var choiceInfo = choiceInfoList.FirstOrDefault(x => x.Score != null && x.Score == choiceValue);
                                            if (choiceInfo != null)
                                            {
                                                data.Add(property.Name == resultPropertyName ? choiceInfo.NewItemLinkContent : choiceInfo.Choice);
                                                continue;
                                            }

                                            if (choiceValue == default(double) && choiceInfo == null)
                                            {
                                                data.Add(string.Empty);
                                                continue;
                                            }
                                        }
                                    }

                                    try
                                    {
                                        data.Add(Convert.ToString(value));
                                    }
                                    catch
                                    {
                                        data.Add(string.Empty);
                                    }
                                }
                            }
                        }

                        // populate table
                        var workTable = new DataTable();
                        foreach (var column in meta)
                        {
                            workTable.Columns.Add(column.Key, column.Value);
                        }

                        for (var j = 0; j < data.Count; j += count)
                        {
                            var row = new object[count];
                            for (var k = 0; k < count; k++)
                            {
                                row[k] = data[j + k];
                            }
                            workTable.Rows.Add(row);
                        }

                        // create report table
                        var columns = meta.Select(x => new TableColumn(x.Key, x.Key, fieldHeader.Size.Width / meta.Count, x.Value)).ToList();

                        fieldValueTable = CreateTable(columns);
                        fieldValueTable.Location = valueLocation;
                        fieldValueTable.DataSource = workTable;
                    }
                    else if (_fieldAttrDict[sectionFields[i]].FieldEditor == "Image")
                    {
                        byte[] imageBytes = (byte[])sectionFields[i].GetValue(itemProperties[sectionFields[i]], null);
                        if (imageBytes != null)
                        {
                            var ms = new MemoryStream(imageBytes);

                            if (ms != null && ms.Length > 0)
                            {
                                pictureBox.Value = Image.FromStream(ms);
                                pictureBox.Height = new Unit(((Image) pictureBox.Value).Height, UnitType.Pixel);
                            }
                        }
                    }
                    else if (_fieldAttrDict[sectionFields[i]].FieldEditor == "Checkbox")
                    {
                        if ((bool)_fieldAttrDict[sectionFields[i]].IsSwitchToggle.Value)
                        {
                            fieldValue.Value = string.Format("=GetBoolValue(\"{0}\", \"{1}\", \"{2}\", {3})",
                                                             _fieldAttrDict[sectionFields[i]].UndefinedLabel.Value,
                                                             _fieldAttrDict[sectionFields[i]].TrueLabel.Value,
                                                             _fieldAttrDict[sectionFields[i]].FalseLabel.Value,
                                                             displayFieldPath);
                        }
                        else
                        {
                            fieldValue.Value = string.Format("={0}", displayFieldPath);
                        }
                    }
                    else if (_fieldAttrDict[sectionFields[i]].FieldEditor == Constants.SampleFieldType)
                    {
                        var xml = _item.GetValueByPropertyName(string.Format("{0}{1}", sectionFields[i].Name, Constants.SampleSettingPostfix)) as string;
                        if (!string.IsNullOrEmpty(xml))
                        {
                            var sampleTypeFieldName = XElement.Parse(xml).Attribute("SampleTypeFieldName").Value;
                            var sampleTypeValue = _item.GetValueByPropertyName(sampleTypeFieldName);

                            if (sampleTypeValue != null)
                            {
                                var sampleType = (SampleTypes)Enum.Parse(typeof(SampleTypes), sampleTypeValue, false);

                                var list = _item.GetValueByPropertyName(sectionFields[i].Name);

                                string sampleColumnName = null;
                                switch (sampleType)
                                {
                                    case SampleTypes.Boolean:
                                        sampleColumnName = "SampleBoolean";
                                        break;

                                    case SampleTypes.Number:
                                        sampleColumnName = "SampleNumeric";
                                        break;

                                    case SampleTypes.Alphanumeric:
                                        sampleColumnName = "SampleAlphanumeric";
                                        break;
                                }

                                var columns = new List<TableColumn>
                                    {
                                        new TableColumn("Label", "Nr", fieldHeader.Size.Width/2),
                                        new TableColumn(sampleColumnName, "Value", fieldHeader.Size.Width/2),
                                    };

                                fieldValueTable = CreateTable(columns);
                                fieldValueTable.Location = valueLocation;
                                fieldValueTable.DataSource = list;
                            }
                        }
                    }
                    else if (_fieldAttrDict[sectionFields[i]].FieldEditor == "SpcChart")
                    {
                        //var settings = sectionFields[i].GetValue(itemProperties[sectionFields[i]], null) as string;
                        //chartsList = GetCharts(sectionFields[i], settings, valueLocation, valueSize);

                        fieldValue.Value = "SPC Chart not supported on Easy Report";
                    }

                    else if (_fieldAttrDict[sectionFields[i]].FieldType.ColumnType == ColumnTypes.Numeric || 
                        _fieldAttrDict[sectionFields[i]].FieldType.ColumnType == ColumnTypes.Double || 
                        _fieldAttrDict[sectionFields[i]].FieldType.ColumnType == ColumnTypes.Integer)
                    {
                        fieldValue.Value = string.Format(@"=GetNumericValue(Fields.{0}, ""{1}"", ""{2}"")", displayFieldPath, _fieldAttrDict[sectionFields[i]].Numeric.NumericType, currentReport.ReportParameters["userCurrency"].Value );
                    }
                    else if (_fieldAttrDict[sectionFields[i]].DisplayListField != null)
                    {
                        var displayListProperty = sectionFields[i];
                        var processName = GetDeclaringProcessSystemName(displayListProperty);
                        var itemType = TheDynamicTypeManager.GetDisplayListItemType(processName, displayListProperty.Name);

                        var listOfFields = _fieldAttrDict[sectionFields[i]].DisplayListField.DisplayFieldList;
                        var displayFields = new List<string>();

                        if (!string.IsNullOrEmpty(listOfFields))
                        {
                            displayFields.AddRange(listOfFields.Split('|'));
                        }

                        // populate table
                        var workTable = new DataTable();

                        // Add table columns.
                        foreach (var propertyName in displayFields)
                        {
                            var property = itemType.GetPropertyByName(propertyName);
                            if (property == null)
                                continue;

                            var columnType = property.PropertyType;
                            if (columnType != typeof(byte[]))
                                columnType = typeof(string);

                            var column = workTable.Columns.Add(propertyName, columnType);

                            column.Caption = GetDisplayName(property);
                        }

                        // Add table rows.
                        foreach (IDynamicObject info in _item.GetValueByPropertyName(displayListProperty.Name))
                        {
                            var row = workTable.NewRow();

                            foreach (DataColumn column in workTable.Columns)
                            {
                                var value = info.GetValueByPropertyName(column.ColumnName);

                                if (value == null)
                                    continue;

                                if (value is byte[])
                                {
                                    row[column] = value;
                                }
                                else
                                {
                                    row[column] = value.ToString();
                                }
                            }

                            workTable.Rows.Add(row);
                        }

                        // create report table
                        var columns =
                            workTable.Columns.Cast<DataColumn>()
                                .Select(c => new TableColumn(c.ColumnName, c.Caption, fieldHeader.Size.Width / workTable.Columns.Count, c.DataType))
                                .ToList();

                        fieldValueTable = CreateTable(columns);
                        fieldValueTable.Location = valueLocation;
                        fieldValueTable.DataSource = workTable;
                    }
                    else
                    {
                        fieldValue.Value = string.Format("=Fields.{0}", displayFieldPath);
                    }

                    ReportItem valueItem;

                    if (fieldValueTable != null)
                        valueItem = fieldValueTable;
                    else
                        valueItem = fieldValue;

                    fieldPanel.Size = new SizeU(fieldHeaderSize.Width, Unit.Inch(textHeight + valueTextHeight));

                    if (pictureBox.Value != null)
                    {
                        fieldPanel.Items.AddRange(new ReportItemBase[] { fieldHeader, pictureBox });
                    }
                    else if (chartsList != null && chartsList.Count > 0)
                    {
                        fieldPanel.Items.Add(fieldHeader);
                        foreach (var chart in chartsList)
                            fieldPanel.Items.Add(chart);
                    }
                    else
                    {
                        fieldPanel.Items.AddRange(new[] { fieldHeader, valueItem });
                    }

                    currentReport.Items["detail"].Items.Add(fieldPanel);

                    percentageOfRowUsed += _fieldAttrDict[sectionFields[i]].WidthPercentage;
                }

                startY += sectionMargin + valueTextHeight;
            }
        }