// 从模拟keys中根据from获得对应的key static List <string> GetKeyByFrom(List <AccessKeyInfo> aKeyLine, string strFromName) { List <string> aResult = new List <string>(); for (int i = 0; i < aKeyLine.Count; i++) { AccessKeyInfo info = (AccessKeyInfo)aKeyLine[i]; if (info.FromName == strFromName) { aResult.Add(info.Key); } } return(aResult); }
// 模拟创建检索点 public long DoGetKeys( string strRecPath, string strXmlBody, string strLang, // string strStyle, DigitalPlatform.Stop stop, out List<AccessKeyInfo> aLine, out string strError) { strError = ""; aLine = null; if (strRecPath == "") { strError = "记录路径为空时无法模拟创建检索点"; return -1; } KeyInfo[] keys = null; int nStart = 0; int nPerCount = -1; int nCount = 0; aLine = new List<AccessKeyInfo>(); long lTotalCount = -1; for (; ; ) { DoIdle(); // 出让控制权,避免CPU资源耗费过度 if (stop != null) { if (stop.State != 0) { strError = "用户中断"; return -1; } } REDO: try { IAsyncResult soapresult = this.ws.BeginCreateKeys( strXmlBody, strRecPath, nStart, nPerCount, strLang, // strStyle, 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.EndCreateKeys( out keys, soapresult); if (result.Value == -1) { if (result.ErrorCode == ErrorCodeValue.NotLogin && this.Container != null) { // return: // -1 error // 0 login failed // 1 login succeed int nRet = this.UiLogin(strRecPath, out strError); if (nRet == -1 || nRet == 0) { return -1; } goto REDO; } ConvertErrorCode(result); strError = result.ErrorString; return -1; } else { Debug.Assert(keys != null, "WebService GetRecords() API record参数返回值不应为null"); lTotalCount = result.Value; } if (keys != null) { nStart += keys.Length; nCount += keys.Length; } // 做事 for (int i = 0; i < keys.Length; i++) { /* Application.DoEvents(); // 出让界面控制权 if (stop != null) { if (stop.State != 0) { strError = "用户中断"; return -1; } stop.SetMessage("正在装入 " + Convert.ToString(nStart+i)+" / " + ((lTotalCount == -1) ? "?" : Convert.ToString(lTotalCount)) ); } */ KeyInfo keyInfo = keys[i]; AccessKeyInfo info = new AccessKeyInfo(); info.FromValue = keyInfo.FromValue; info.ID = keyInfo.ID; info.Key = keyInfo.Key; info.KeyNoProcess = keyInfo.KeyNoProcess; info.Num = keyInfo.Num; info.FromName = keyInfo.FromName; aLine.Add(info); } if (nCount >= result.Value) break; } catch (Exception ex) { /* strError = ConvertWebError(ex); return -1; * */ int nRet = ConvertWebError(ex, out strError); if (nRet == 0) return -1; goto REDO; } } this.ClearRedoCount(); return 0; }