Beispiel #1
0
        public bool ReadNextRecord(out string[] record)
        {
            record = new string[recordset.GetFieldCount()];
            if (hasReadHeader)
            {
                bool hasRead = recordset.Read();
                if (hasRead)
                {
                    for (int i = 0; i < record.Length; i++)
                    {
                        record[i] = recordset.GetString(i);
                    }
                }

                return(hasRead);
            }
            else
            {
                for (int i = 0; i < record.Length; i++)
                {
                    record[i] = recordset.GetFieldName(i);
                }
                hasReadHeader = true;
                return(true);
            }
        }
Beispiel #2
0
        private DiscrepancyType InitialMatch(TableData[] datas, DiscrepancyOutputter outputter)
        {
            string query = BuildOnlyMatchableRowsQuiery();
            MatchedRecordComparer comparer = new MatchedRecordComparer(data, settings, outputter);
            Recordset             matches  = db.QueryResult(query);
            DiscrepancyType       result   = DiscrepancyType.NONE;

            while (matches.Read())
            {
                string[] matchedRecord    = new string[matches.GetFieldCount() - HASH_FIELDS_COUNT];
                int      nextIndexToWrite = 0;
                for (int i = 0; i < matches.GetFieldCount(); i++)
                {
                    // Skip hash fields.
                    if (i == HASH_FIELD_INDEX || i == datas[0].columnCount + 2)
                    {
                        continue;
                    }

                    matchedRecord[nextIndexToWrite++] = matches.GetString(i);
                }

                string[] first, second;
                ExtractRecords(matchedRecord, datas[0].columnCount + 1, datas[1].columnCount + 1, out first, out second);
                DiscrepancyType type = comparer.Compare(first, second);

                if (type > result)
                {
                    result = type;
                }
            }
            matches.Close();

            return(result);
        }
        private Dictionary <string, List <string[]> > GroupByHash(Recordset recordset)
        {
            Dictionary <string, List <string[]> > result = new Dictionary <string, List <string[]> >();

            while (recordset.Read())
            {
                // Read record.
                string[] record = new string[recordset.GetFieldCount()];
                for (int i = 0; i < record.Length; i++)
                {
                    record[i] = recordset.GetString(i);
                }

                // Group.
                if (!result.ContainsKey(record[0]))
                {
                    List <string[]> list = new List <string[]>();
                    list.Add(record);
                    result.Add(record[0], list);
                }
                else
                {
                    result[record[0]].Add(record);
                }
            }

            return(result);
        }