示例#1
0
    public static Tuple<DataItem, DataItemReport> CaptureReport(
      this IScreenItem item, IScreenLoc Start, ScreenContent Content)
    {
      string captureText = null;
      DataItem dataItem = null;
      DataItemReport itemReport = null;
      ContentItemBase contentItem = null;

      // get the content item at the rowcol location.
      bool rc = true;
      IScreenAtomic atomicItem = null;

      // adjust screen loc of the item by start pos of the section it is contained in.
      var adjRow = Start.RowNum - 1;
      var adjCol = Start.ColNum - 1;
      var loc = new OneScreenLoc(
        item.ScreenLoc.RowNum + adjRow, item.ScreenLoc.ColNum + adjCol);
      var zeroLoc = loc.ToZeroRowCol();

      if (item.ItemType != ShowItemType.Section)
      {
        rc = Content.FieldDict.TryGetValue(zeroLoc, out contentItem);
        atomicItem = item as IScreenAtomic;
      }

      if (rc == false)
      {
      }

      else if (item.ItemType == ShowItemType.Section)
      {
        var sectionItem = item as IScreenSection;
        itemReport = sectionItem.CaptureReport(Content);
      }

      else if (item.ItemType == ShowItemType.Field)
      {
        if ((contentItem is ContentField) == true)
        {
          var contentField = contentItem as ContentField;
          dataItem = new DataItem(item.ItemName, contentField.GetShowText(Content));
          captureText = item.ItemName + "=" + contentField.GetShowText(Content);
        }
      }

      // match fixed literal
      else if (item.ItemType == ShowItemType.Literal)
      {
        if ((contentItem is ContentText) == true)
        {
          var contentText = contentItem as ContentText;
          var itemLit = item as IScreenLiteral;
          var ctValue = contentText.GetShowText(Content).TrimEndWhitespace();
        }
      }

      return new Tuple<DataItem, DataItemReport>(dataItem, itemReport);
    }
        public static DataItemReport CaptureReport(this IScreenSection section, ScreenContent Content)
        {
            var sb            = new StringBuilder();
            var sectionHeader = section as ISectionHeader;
            var sectionDim    = section.CalcDim();
            var itemReport    = new DataItemReport();

            IScreenLoc start = section.ScreenLoc;
            {
                start = start.NewInstance(start.RowNum, start.ColNum);
            }

            int  repeatIx  = 0;
            bool endOfRows = false;

            while (endOfRows == false)
            {
                if ((repeatIx > 0) && (repeatIx >= section.RepeatCount))
                {
                    break;
                }
                repeatIx += 1;

                // section is a subfile. subfile row can be blank. If blank consider as
                // the end of rows of the subfile. So no need to match.
                bool rowIsBlank = false;
                if (section.PurposeCode == ScreenPurposeCode.ReportDetail)
                {
                    if (Content.RowIsBlank(start.RowNum) == true)
                    {
                        rowIsBlank = true;
                    }
                }

                // a blank row. no more rows to match.
                if (rowIsBlank == true)
                {
                    endOfRows = true;
                }

                if (endOfRows == false)
                {
                    var report = sectionHeader.CaptureToReport(start, Content);
                    var combo  = DataItemReport.CombineVertically(itemReport, report);
                    itemReport = combo;
                }
                start.RowNum += 1;
            }

            return(itemReport);
        }
示例#3
0
        public static DataItemReport CaptureToReport(
            this ISectionHeader section, IScreenLoc Start, ScreenContent Content)
        {
            var report = new DataItemReport();
            var row    = new DataItemList();

            // capture item data from each item of the section that is marked for capture.
            // ( by default, all ScreenField items are captured. )
            foreach (var item in section.Items)
            {
                var rv         = item.CaptureReport(Start, Content);
                var dataItem   = rv.Item1;
                var itemReport = rv.Item2;

                if (dataItem != null)
                {
                    report.Columns.Add(dataItem.ToColumnDefn());
                    row.Add(dataItem);
                }

                // this item is a section. The capture function returned a DataItemReport
                // contains the data of the report. Join that report with what has been
                // captured up to this point.
                if (itemReport != null)
                {
                    var comboReport = DataItemReport.CombineHorizontally(report, itemReport);
                    report = comboReport;
                }
            }

            if (row.Count > 0)
            {
                report.Rows.Add(row);
            }

            return(report);
        }