/// <summary> /// </summary> protected override void DoWork(CodeActivityContext context) { PlainText.Set(context, null); Html.Set(context, null); DataTable dataTable = FieldData.Get(context); var format = (MergeFieldUtility.MergeFieldsOutputFormats)OutputFormat.Get(context); IList <IQEnum> columns = Columns.Get(context); if (dataTable.Columns.Count == 0) { PlainText.Set(context, MergeFieldUtility.NO_DATA); return; } // create a new table that contains only the user selected columns var filteredTable = FilterTable(dataTable, columns); var statusList = GetStatusList(dataTable); string result; switch (format) { case MergeFieldUtility.MergeFieldsOutputFormats.Table: case MergeFieldUtility.MergeFieldsOutputFormats.TableNoLines: case MergeFieldUtility.MergeFieldsOutputFormats.TableNoHeader: case MergeFieldUtility.MergeFieldsOutputFormats.TableNoLinesNoHeader: bool showHeader = format == MergeFieldUtility.MergeFieldsOutputFormats.Table || format == MergeFieldUtility.MergeFieldsOutputFormats.TableNoLines; bool showLines = format == MergeFieldUtility.MergeFieldsOutputFormats.Table || format == MergeFieldUtility.MergeFieldsOutputFormats.TableNoHeader; if (filteredTable.Rows.Count == 0 && !showHeader) { PlainText.Set(context, MergeFieldUtility.NO_DATA); } else { result = ConvertToHtml(filteredTable, showHeader, showLines, statusList); Html.Set(context, result); } break; case MergeFieldUtility.MergeFieldsOutputFormats.List: // use html format for the same look and feel (line spacing) result = ConvertToHtmlParagraph(filteredTable, " ", "<br>", statusList); Html.Set(context, result); break; case MergeFieldUtility.MergeFieldsOutputFormats.Paragraph: if (statusList == null || statusList.Count <= 0) { result = ConvertToParagraph(filteredTable, " ", "; "); PlainText.Set(context, result); } else { result = ConvertToHtmlParagraph(filteredTable, " ", "; ", statusList); Html.Set(context, result); } break; } }