示例#1
0
    public static ScreenItemInstance FindItem(
      this IScreenItem item, IScreenLoc Start, IScreenLoc FindZeroLoc, 
      ScreenContent Content)
    {
      ScreenItemInstance findItem = null;

      if (item.ItemType == ShowItemType.Section)
      {
        var sectionItem = item as IScreenSection;
        findItem = sectionItem.FindItem(Start, FindZeroLoc, Content);
      }

      else
      {
        // 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();

        var itemAtomic = item as IScreenAtomic;
        var range = new ScreenLocRange(zeroLoc, itemAtomic.Length, Content.ScreenDim);
        if (range.Contains(FindZeroLoc) == true)
          findItem = new ScreenItemInstance(item, range.From);
      }

      return findItem;
    }
示例#2
0
        /// <summary>
        /// capture the data of the screen to a DataItemReport class.
        /// </summary>
        /// <param name="Defn"></param>
        /// <param name="Content"></param>
        /// <returns></returns>
        public static DataItemReport CaptureToReport(this IScreenDefn Defn, ScreenContent Content)
        {
            ISectionHeader sectionHeader = Defn as ISectionHeader;
            var            start         = new OneScreenLoc(1, 1);
            var            itemReport    = sectionHeader.CaptureToReport(start, Content);

            return(itemReport);
        }
示例#3
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);
    }
示例#4
0
        public static ScreenItemInstance FindItem(
            this IScreenDefn Defn, IScreenLoc FindLoc, ScreenContent Content)
        {
            ScreenItemInstance found = null;

            ISectionHeader sectionHeader = Defn as ISectionHeader;
            var            start         = new OneScreenLoc(1, 1);

            found = sectionHeader.FindItem(start, FindLoc, Content);

            return(found);
        }
示例#5
0
        /// <summary>
        /// determine if the ScreenDefn matches the screen content.
        /// </summary>
        /// <param name="Content"></param>
        /// <returns></returns>
        public static bool Match(this IScreenDefn Defn, ScreenContent Content)
        {
            bool isMatch = true;

            // BgnTemp
            // SpecialLogFile.AppendTextLines(this.ToColumnReport());
            // EndTemp

            // extract all ContentText on the screen. Add to FieldDict.
            Content.AddAllContentText();

            ISectionHeader sectionHeader = Defn as ISectionHeader;
            var            start         = new OneScreenLoc(1, 1);

            isMatch = sectionHeader.Match(start, Content, Defn.ScreenName);

            return(isMatch);
        }
示例#6
0
        /// <summary>
        /// capture the data of the screen to a DataTable class.
        /// </summary>
        /// <param name="Defn"></param>
        /// <param name="Content"></param>
        /// <returns></returns>
        public static EnhancedDataTable Capture(
            this IScreenDefn Defn, ScreenContent Content,
            ScreenItemInstance ItemInstance = null)
        {
            ISectionHeader sectionHeader = Defn as ISectionHeader;
            var            start         = new OneScreenLoc(1, 1);
            var            report        = sectionHeader.CaptureToReport(start, Content);
            var            table         = report.ToDataTable();

            // mark the selected datarow in the dataTable.
            int rownum = 0;

            if ((ItemInstance != null) && (ItemInstance.RepeatNum > 0))
            {
                rownum = ItemInstance.RepeatNum - 1;
            }
            table.MarkSelectedRow(rownum);

            return(table);
        }
示例#7
0
    public static bool Match(
      this IScreenItem item, IScreenLoc Start, ScreenContent Content, 
      string DebugInfo)
    {
      bool isMatch = true;
      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();

      // item is not a section. Get the field or literal located at the item loc.
      if (item.ItemType != ShowItemType.Section)
      {
        atomicItem = item as IScreenAtomic;
      }

      if ((rc == false) && ( 1 == 2))
      {
        if ( item.IsOptional == false )
          isMatch = false;
      }

      else if ((isMatch == true) && (item.ItemType == ShowItemType.Section))
      {
        var sectionItem = item as IScreenSection;
        isMatch = sectionItem.Match(Content, DebugInfo);
      }

      else if ((isMatch == true) && (item.ItemType == ShowItemType.Field))
      {
        var fieldItem = item as IScreenField;
        rc = Content.FieldDict.TryGetValue(zeroLoc, out contentItem);
        if (rc == false)
          isMatch = false;
        
        // can match a screen field to a literal, but only if the field is output
        // only.
        else if ((contentItem is ContentText) 
          && (fieldItem.Usage != ShowUsage.Output))
          isMatch = false;

        else if ((contentItem is ContentField) == false)
          isMatch = false;
        else
        {
          var contentField = contentItem as ContentField;
          if (contentField.LL_Length != atomicItem.Length)
            isMatch = false;
        }
      }

      // match screen literal to actual content on the screen. The content can be
      // either a field or a literal. But the content has to match one of the 
      // values of the screen literal.
      else if ((isMatch == true) && (item.ItemType == ShowItemType.Literal))
      {
        // screen literal has a dsply attr. advance ....
        if ( atomicItem.DsplyAttr.IsNullOrEmpty( ) == false )
        {
          zeroLoc = zeroLoc.Advance(1) as ZeroRowCol;
        }

        var buf = Content.GetContentBytes_NonNull(zeroLoc, atomicItem.Length);
        var itemLit = item as IScreenLiteral;
        var contentText = buf.EbcdicBytesToString().TrimEndWhitespace();

        // match the screen defn item to the screen content.
        isMatch = itemLit.MatchValue(contentText);

        // failed the match. But if the item content is blank. And this screen
        // item is optional then that is ok.
        if ((isMatch == false) && (item.IsOptional == true) && (contentText.Length == 0))
          isMatch = true;
      }

      else if (isMatch == true)
      {
        throw new Exception("unrecognized screen item type");
      }

      return isMatch;
    }
        /// <summary>
        /// find the item within the screen section.
        /// </summary>
        /// <param name="section"></param>
        /// <param name="Start"></param>
        /// <param name="FindLoc"></param>
        /// <param name="Content"></param>
        /// <returns></returns>
        public static ScreenItemInstance FindItem(
            this IScreenSection section, IScreenLoc Start, IScreenLoc FindLoc,
            ScreenContent Content)
        {
            ScreenItemInstance foundItem = null;
            var header     = section as ISectionHeader;
            var sectionDim = section.CalcDim();

            var adjRow = Start.RowNum - 1;
            var adjCol = Start.ColNum - 1;
            var start  = new OneScreenLoc(
                section.ScreenLoc.RowNum + adjRow, section.ScreenLoc.ColNum + adjCol);

            int  repeatIx  = 0;
            bool endOfRows = false;
            int  loopCx    = 0;

            while (foundItem == null)
            {
                if (section.PurposeCode != ScreenPurposeCode.ReportDetail)
                {
                    if (loopCx > 0)
                    {
                        break;
                    }
                }
                else
                {
                    if (repeatIx >= section.GetRepeatCount())
                    {
                        break;
                    }
                    repeatIx += 1;
                }
                loopCx += 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)
                {
                    foundItem = header.FindItem(start, FindLoc, Content);
                    if (foundItem != null)
                    {
                        foundItem.RepeatNum = repeatIx;
                        break;
                    }
                }
                start.RowNum += 1;
            }

            return(foundItem);
        }