Ejemplo n.º 1
0
        protected override SchemaRow ReadRow(ExcelWorksheet schemaWorksheet, int row)
        {
            if (row > schemaWorksheet.Dimension.End.Row)
            {
                return(null);
            }

            FlatFileSchemaRow schemaRow = new FlatFileSchemaRow();

            schemaRow.Grouping        = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, GroupingIndex);
            schemaRow.Loop            = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, LoopIndex);
            schemaRow.Segment         = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, SegmentIndex);
            schemaRow.DataElementTag  = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, DataElementTagIndex);
            schemaRow.DataElementName = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, DataElementNameIndex);

            base.ReadBasicRowData(schemaWorksheet, schemaRow, row);

            // Check for invalid loop names
            if (string.IsNullOrWhiteSpace(schemaRow.Loop) == false &&
                string.Equals(schemaRow.Loop, "n/a", StringComparison.InvariantCultureIgnoreCase) == false &&
                schemaRow.Loop.Trim().Contains('|'))
            {
                AddValidationResult(ResultType.Error, row, GCExcelReaderHelper.GetColumnIndex(MinMaxIndex), string.Format("Invalid loop value {0}", schemaRow.Loop));
            }

            return(schemaRow);
        }
Ejemplo n.º 2
0
        protected override bool IsDataTypeRowsOver(SchemaRow schemaRow, int row)
        {
            FlatFileSchemaRow flatFileSchemaRow = schemaRow as FlatFileSchemaRow;

            return(string.IsNullOrEmpty(flatFileSchemaRow.Segment) == false);
        }
Ejemplo n.º 3
0
        private IPluglet GetSegment(ExcelWorksheet schemaWorksheet, ref int row, out string nextLoopName)
        {
            nextLoopName = null;
            // TODO: Handle this in better way
            if (row > schemaWorksheet.Dimension.End.Row)
            {
                return(null);
            }

            // Currently setting Min and Max for segment is hard coded as 0, 1, since these values are not present in excel
            int segmentMinOccur = 0;
            int segmentMaxOccur = 100;

            // First read Segment row
            FlatFileSchemaRow segmentRow = ReadRow(schemaWorksheet, row) as FlatFileSchemaRow;

            while (segmentRow != null && string.IsNullOrWhiteSpace(segmentRow.Segment) == true)
            {
                row++;
                segmentRow = ReadRow(schemaWorksheet, row) as FlatFileSchemaRow;
            }

            if (segmentRow == null)
            {
                return(null);
            }


            nextLoopName    = segmentRow.Loop;
            segmentMinOccur = string.Compare(segmentRow.MandatoryFlag, "Y", true) == 0 ? 1 : 0;
            segmentMaxOccur = string.Compare(segmentRow.MandatoryFlag, "N", true) == 0 ? 0 : 1000;

            IPluglet segment = new Pluglet(segmentRow.Segment, segmentRow.DataElementTag, (PlugletType)Enum.Parse(typeof(PlugletType), "Segment"), null
                                           , segmentMinOccur, segmentMaxOccur);

            if (string.IsNullOrWhiteSpace(segmentRow.Loop) == false)
            {
                segment.Name = segmentRow.Loop;
            }

            ++row;

            IPluglet dataPluglet = null;

            int  minOccurs, maxOccurs;
            bool isIgnore;
            int  tempRow;

            // Now read all data elements till groupping column has some value (indicates new Segment started)
            while ((segmentRow = ReadRow(schemaWorksheet, row) as FlatFileSchemaRow) != null)
            {
                if (string.IsNullOrEmpty(segmentRow.Segment) == false)
                {
                    break;
                }

                // TODO: What about mandatory flag value 'X'?
                minOccurs = string.Compare(segmentRow.MandatoryCode, "M", true) == 0 && string.Compare(segmentRow.MandatoryFlag, "Y", true) == 0 ? 1 : 0;
                maxOccurs = string.Compare(segmentRow.MandatoryFlag, "N", true) == 0 ? 0 : 1;
                isIgnore  = string.Compare(segmentRow.IgnoreFlag, "I", true) == 0;

                dataPluglet = new Pluglet(segmentRow.DataElementTag, segmentRow.DataElementName,
                                          (PlugletType)Enum.Parse(typeof(PlugletType), "Data"), segment, minOccurs, maxOccurs, isIgnore);
                ++row;

                dataPluglet.DataType = ReadDataType(segmentRow, schemaWorksheet, segment.Path, ref row);
            }

            FillInMissingChildren(segment);
            return(segment);
        }