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); } }
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); }
//规范化数据-BUSINESS_ID private void FormatData() { DatasetVector dtVector = GetSCZT(); if (dtVector != null) { string strBS_ID = m_strBusiness_id; string strFilter = string.Format(" length({0})=5", strBS_ID); Recordset recdst = dtVector.Query(strFilter, CursorType.Dynamic); if (recdst.RecordCount > 0) { int iDex = recdst.GetFieldInfos().IndexOf(strBS_ID); recdst.Batch.Begin(); while (!recdst.IsEOF) { string strValue = string.Format("0{0}", recdst.GetString(iDex)); recdst.SetFieldValue(iDex, strValue); recdst.MoveNext(); } recdst.Batch.Update(); MessageBox.Show("规范数据完毕"); } } }