// 获取浏览记录 public long DoBrowse( BrowseList listView, string strLang, DigitalPlatform.Stop stop, string strResultSetName, string strOutputStyle, out string strError) { strError = ""; Record[] records = null; long nStart = 0; long nPerCount = -1; int nCount = 0; bool bOutputKeyID = StringUtil.IsInList("keyid", strOutputStyle); long lTotalCount = -1; for (; ; ) { DoIdle(); // 出让控制权,避免CPU资源耗费过度 if (stop != null) { if (stop.State != 0) { strError = "用户中断"; return -1; } } nPerCount = -1; // 2013/2/12 REDO: try { IAsyncResult soapresult = this.ws.BeginGetRecords( strResultSetName, nStart, nPerCount, strLang, strOutputStyle, //"id,cols", null, null); for (; ; ) { DoIdle(); // 出让控制权,避免CPU资源耗费过度 bool bRet = soapresult.AsyncWaitHandle.WaitOne(100, false); if (bRet == true) break; } if (this.m_ws == null) { strError = "用户中断"; this.ErrorCode = ChannelErrorCode.RequestCanceled; return -1; } Result result = this.ws.EndGetRecords( out records, soapresult); if (result.Value == -1) { // 2011/4/21 if (result.ErrorCode == ErrorCodeValue.NotLogin && this.Container != null) { // return: // -1 error // 0 login failed // 1 login succeed int nRet = this.UiLogin("", out strError); if (nRet == -1 || nRet == 0) { return -1; } goto REDO; } ConvertErrorCode(result); strError = result.ErrorString; return -1; } else { Debug.Assert(records != null, "WebService GetRecords() API record参数返回值不应为null"); lTotalCount = result.Value; if (nStart == 0 && stop != null) stop.SetProgressRange(0, lTotalCount); } if (records != null) { nCount += records.Length; } listView.BeginUpdate(); try { // 做事 for (int i = 0; i < records.Length; i++) { DoIdle(); // 出让控制权,避免CPU资源耗费过度 if (stop != null) { if (stop.State != 0) { strError = "用户中断"; return -1; } stop.SetMessage("正在装入 " + Convert.ToString(nStart + i) + " / " + ((lTotalCount == -1) ? "?" : Convert.ToString(lTotalCount))); } Record record = records[i]; string[] cols = null; if (bOutputKeyID == true) { cols = new string[(record.Cols == null ? 0 : record.Cols.Length) + 1]; cols[0] = BuildDisplayKeyString(record.Keys); if (cols.Length > 1) Array.Copy(record.Cols, 0, cols, 1, cols.Length - 1); } else cols = record.Cols; listView.NewLine(record.Path + " @" + this.Url, cols); // record.ID 放入第一列 // record.Cols 放入其他列(如果为keyid方式,key在这一群的第一列) } if (stop != null) stop.SetProgressValue(nStart + records.Length); } finally { listView.EndUpdate(); } if (nCount >= result.Value) break; if (records != null) { nStart += records.Length; } } catch (Exception ex) { /* strError = ConvertWebError(ex); return -1; * */ int nRet = ConvertWebError(ex, out strError); if (nRet == 0) return -1; // 2013/2/11 if (this.ErrorCode == ChannelErrorCode.QuotaExceeded) { if (nPerCount > 1 || nPerCount == -1) nPerCount = 1; // 修改为最小数量重做一次 else return -1; } goto REDO; } } this.ClearRedoCount(); if (stop != null) stop.HideProgress(); return 0; }