Пример #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);
        }
        private void ReadMetadata(ExcelWorksheet schemaWorksheet)
        {
            int    row;
            string cellValue;

            for (row = 1; row < schemaWorksheet.Dimension.End.Row; ++row)
            {
                cellValue = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, 1);
                if (cellValue == null)
                {
                    continue;
                }

                if (string.Compare("Root Node", cellValue, true) == 0)
                {
                    RootNodeName = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, 3);

                    if (string.IsNullOrWhiteSpace(RootNodeName))
                    {
                        AddValidationResult(ResultType.Error, row, GCExcelReaderHelper.GetColumnIndex(3), string.Format("Root node name is empty", cellValue));
                    }

                    break;
                }
            }
        }
        protected override SchemaRow ReadRow(ExcelWorksheet schemaWorksheet, int row)
        {
            if (row > schemaWorksheet.Dimension.End.Row)
            {
                return(null);
            }

            XmlFileSchemaRow schemaRow = new XmlFileSchemaRow();

            // Read all first 5 cell value
            for (int i = 0; i < 5; i++)
            {
                schemaRow.ElementName = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, i + 1);
                if (string.IsNullOrWhiteSpace(schemaRow.ElementName) == false)
                {
                    schemaRow.Level = i + 1;
                    break;
                }
            }

            base.ReadBasicRowData(schemaWorksheet, schemaRow, row);

            // If data type is not-null then set IsLeafNode flag true
            schemaRow.IsLeafNode = !string.IsNullOrWhiteSpace(schemaRow.DataType);

            return(schemaRow);
        }
        protected override SchemaRow ReadRow(ExcelWorksheet schemaWorksheet, int row)
        {
            if (row > schemaWorksheet.Dimension.End.Row)
            {
                return(null);
            }

            X12SchemaRow schemaRow = new X12SchemaRow();

            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);

            // This code was added during contingency field handling, however maps migration project generate spec certs without contingencies and hence the following code was removed.
            // if (string.IsNullOrWhiteSpace(schemaRow.DataElementTag) == false && string.Compare(schemaRow.DataElementTag, "HL03", true) == 0)
            //        schemaRow.IsTriggerField = true;

            // 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);
        }
Пример #5
0
        private void ReadMetadata(DocumentPlug documentPlug, ExcelWorksheet schemaWorksheet)
        {
            int    row;
            string cellValue;
            int    delimiterCount = 0;

            for (row = 1; row < schemaWorksheet.Dimension.End.Row && delimiterCount < 2; ++row)
            {
                // column 1 has name 'Element Segment' or 'Segment Delimiter'
                // Column 3 has delimiter
                cellValue = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, 1);
                if (cellValue == null)
                {
                    continue;
                }

                if (string.Compare("Element Delimiter", cellValue, true) == 0)
                {
                    cellValue = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, 3);
                    // delimiter can be more than 1 char,
                    // split the string by ' ', convert each string to int
                    documentPlug.ElementDelimiters = GetDelimiters(cellValue);

                    if (documentPlug.ElementDelimiters == null)
                    {
                        AddValidationResult(ResultType.Error, row, GCExcelReaderHelper.GetColumnIndex(3), string.Format("'{0}' is invalid element delimiter", cellValue));
                    }

                    delimiterCount++;
                }
                else
                if (string.Compare("Segment Delimiter", cellValue, true) == 0)
                {
                    cellValue = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, 3);
                    documentPlug.SegmentDelimiters = GetDelimiters(cellValue);

                    if (documentPlug.SegmentDelimiters == null)
                    {
                        AddValidationResult(ResultType.Error, row, GCExcelReaderHelper.GetColumnIndex(3), string.Format("'{0}' is invalid segment delimiter", cellValue));
                    }

                    delimiterCount++;
                }
            }
        }
        protected void ReadBasicRowData(ExcelWorksheet schemaWorksheet, SchemaRow schemaRow, int row)
        {
            if (row > schemaWorksheet.Dimension.End.Row)
            {
                return;
            }

            schemaRow.MandatoryCode   = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, MandatoryCodeIndex);
            schemaRow.DataType        = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, DataTypeIndex);
            schemaRow.MinMaxLength    = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, MinMaxIndex);
            schemaRow.EnumCode        = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, EnumCodeIndex);
            schemaRow.EnumName        = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, EnumNameIndex);
            schemaRow.EnumFlag        = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, EnumFlagIndex, true);
            schemaRow.MandatoryFlag   = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, MandatoryFlagIndex, true);
            schemaRow.IgnoreFlag      = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, IgnoreFlagIndex, true);
            schemaRow.Contingencies   = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, ContingenciesIndex, true);
            schemaRow.ContingencyType = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, ContingencyTypeIndex, true);

            if (TriggerFieldIndex != -1)
            {
                string triggerFieldText = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, TriggerFieldIndex, true);
                if (string.IsNullOrWhiteSpace(triggerFieldText) == false && triggerFieldText.Trim().ToUpperInvariant().Equals(TriggerFieldValue))
                {
                    schemaRow.IsTriggerField = true;
                }
            }

            if (string.IsNullOrWhiteSpace(schemaRow.EnumFlag))
            {
                schemaRow.EnumFlag = "?";
            }

            if (string.IsNullOrWhiteSpace(schemaRow.MandatoryFlag))
            {
                schemaRow.MandatoryFlag = "";
            }

            if (string.IsNullOrWhiteSpace(schemaRow.IgnoreFlag))
            {
                schemaRow.IgnoreFlag = "P";
            }
        }
Пример #7
0
        private void ReadMessageDomainIds(ExcelWorksheet schemaWorksheet, int row, BizRuleSet bizRuleSet)
        {
            int domainIdIndex = 3;
            int domainId;

            while (true)
            {
                string cellValue = GCExcelReaderHelper.ReadCell(schemaWorksheet, row, domainIdIndex);

                // Stop if cell value is non-integer
                if (cellValue == null || int.TryParse(cellValue, out domainId) == false)
                {
                    return;
                }

                bizRuleSet.MessageDomainIds.Add(domainId);

                domainIdIndex++;
            }
        }
Пример #8
0
        private List <string> ReadBizRuleRow(ExcelWorksheet schemaWorksheet, int columnCount, ref int row)
        {
            while (row <= schemaWorksheet.Dimension.End.Row &&
                   GCExcelReaderHelper.ReadCell(schemaWorksheet, row, 1) == null)
            {
                row++;
            }

            if (row > schemaWorksheet.Dimension.End.Row)
            {
                return(null);
            }

            List <string> bizRuleRow = new List <string>();

            for (int i = 1; i <= columnCount; i++)
            {
                bizRuleRow.Add(GCExcelReaderHelper.ReadCell(schemaWorksheet, row, i));
            }

            return(bizRuleRow);
        }