public void NonNullableNumericToBoolReaderLine() { var result = new ReaderLine(Col.NonNullableNumericToBool); Assert.IsTrue(result.ToString() == "newItem.BatteryHorseShoe = rd.GetFieldValue<bool>(rd.GetOrdinal(__BatteryHorseShoe));"); Assert.IsTrue(result.ToString(true) == "newItem.BatteryHorseShoe = await rd.GetFieldValueAsync<bool>(rd.GetOrdinal(__BatteryHorseShoe));"); }
public void NullableNumericBigUnsignedReaderLine() { var result = new ReaderLine(Col.NullableNumericBigUnsigned); Assert.IsTrue(result.ToString() == "newItem.CrateCase = rd.IsDBNull(rd.GetOrdinal(__CrateCase)) ? null : rd.GetFieldValue<ulong?>(rd.GetOrdinal(__CrateCase));"); Assert.IsTrue(result.ToString(true) == "newItem.CrateCase = await rd.IsDBNullAsync(rd.GetOrdinal(__CrateCase)) ? null : await rd.GetFieldValueAsync<ulong?>(rd.GetOrdinal(__CrateCase));"); }
public void NullableStringColumnReaderLine() { var result = new ReaderLine(Col.NullableString); Assert.IsTrue(result.ToString() == "newItem.SnakeCasePuppies = rd.IsDBNull(rd.GetOrdinal(__SnakeCasePuppies)) ? null : rd.GetFieldValue<string>(rd.GetOrdinal(__SnakeCasePuppies));"); Assert.IsTrue(result.ToString(true) == "newItem.SnakeCasePuppies = await rd.IsDBNullAsync(rd.GetOrdinal(__SnakeCasePuppies)) ? null : await rd.GetFieldValueAsync<string>(rd.GetOrdinal(__SnakeCasePuppies));"); }
// 复制读者记录 int BuildReaderRecords( string strReaderDbNameParam, long lOldCount, ref long lProgress, ref long lIndex, out string strError) { strError = ""; int nRet = 0; lProgress += lIndex; using (SQLiteConnection connection = new SQLiteConnection(this._connectionString)) { connection.Open(); long lRet = this.Channel.SearchReader(stop, strReaderDbNameParam, "", // (lIndex + 1).ToString() + "-", // -1, "__id", "left", // this.textBox_queryWord.Text == "" ? "left" : "exact", // 原来为left 2007/10/18 changed "zh", null, // strResultSetName // "", // strSearchStyle "", //strOutputStyle, // (bOutputKeyCount == true ? "keycount" : ""), out strError); if (lRet == -1) return -1; if (lRet == 0) return 0; long lHitCount = lRet; AdjustProgressRange(lOldCount, lHitCount); long lStart = lIndex; long lCount = lHitCount - lIndex; DigitalPlatform.CirculationClient.localhost.Record[] searchresults = null; string strStyle = "id,cols,format:@coldef:*/barcode|*/department|*/readerType|*/name|*/state"; // 读者库名 --> 图书馆代码 Hashtable librarycode_table = new Hashtable(); List<ReaderLine> lines = new List<ReaderLine>(); // 装入浏览格式 for (; ; ) { Application.DoEvents(); // 出让界面控制权 if (stop != null && stop.State != 0) { strError = "检索共命中 " + lHitCount.ToString() + " 条,已装入 " + lStart.ToString() + " 条,用户中断..."; return -1; } lRet = this.Channel.GetSearchResult( stop, null, // strResultSetName lStart, lCount, strStyle, // bOutputKeyCount == true ? "keycount" : "id,cols", "zh", out searchresults, out strError); if (lRet == -1) { strError = "检索共命中 " + lHitCount.ToString() + " 条,已装入 " + lStart.ToString() + " 条," + strError; return -1; } if (lRet == 0) { return 0; } // 处理浏览结果 for (int i = 0; i < searchresults.Length; i++) { DigitalPlatform.CirculationClient.localhost.Record searchresult = searchresults[i]; ReaderLine line = new ReaderLine(); line.ReaderRecPath = searchresult.Path; line.ReaderBarcode = searchresult.Cols[0]; line.Department = searchresult.Cols[1]; line.ReaderType = searchresult.Cols[2]; line.Name = searchresult.Cols[3]; line.State = searchresult.Cols[4]; string strReaderDbName = Global.GetDbName(searchresult.Path); string strLibraryCode = (string)librarycode_table[strReaderDbName]; if (string.IsNullOrEmpty(strLibraryCode) == true) { strLibraryCode = this.MainForm.GetReaderDbLibraryCode(strReaderDbName); librarycode_table[strReaderDbName] = strLibraryCode; } line.LibraryCode = strLibraryCode; lines.Add(line); } #if NO if (lines.Count >= INSERT_BATCH || ((lStart + searchresults.Length >= lHitCount || lCount - searchresults.Length <= 0) && lines.Count > 0) ) #endif { // 插入一批读者记录 nRet = ReaderLine.AppendReaderLines( connection, lines, true, // 用 false 可以在测试阶段帮助发现重叠插入问题 out strError); if (nRet == -1) return -1; lIndex += lines.Count; lines.Clear(); } lStart += searchresults.Length; lCount -= searchresults.Length; // lIndex += searchresults.Length; lProgress += searchresults.Length; // stop.SetProgressValue(lProgress); SetProgress(lProgress); stop.SetMessage(strReaderDbNameParam + " " + lStart.ToString() + "/" + lHitCount.ToString() + " " + GetProgressTimeString(lProgress)); if (lStart >= lHitCount || lCount <= 0) break; } if (lines.Count > 0) { Debug.Assert(false, ""); } return 0; } }