Example #1
0
        // 修改集合中每个元素的 ElementSetName
        static void SetElementSetName(RecordCollection records,
                                      string strElementSetName)
        {
            if (records == null)
            {
                return;
            }

            foreach (DigitalPlatform.Z3950.Record record in records)
            {
                // 非诊断记录
                if (record.m_nDiagCondition == 0)
                {
                    record.m_strElementSetName = strElementSetName;
                }
            }
        }
Example #2
0
        // 获得记录
        // 确保一定可以获得nCount个
        // parameters:
        //		nStart	获取记录的开始位置(从0开始计数)
        //      nPreferedEachCount  推荐的每次条数。这涉及到响应的敏捷性。如果为-1或者0,表示最大
        public async Task <PresentResult> Present(
            string strResultSetName,
            int nStart,
            int nCount,
            int nPreferedEachCount,  // 推荐的每次条数。这涉及到响应的敏捷性
            string strElementSetName,
            string strPreferredRecordSyntax)
        {
            if (nCount == 0)
            {
                return new PresentResult {
                           Value = 0, ErrorInfo = "nCount 参数为 0,本次没有真正请求服务器获取记录"
                }
            }
            ;

            RecordCollection records = new RecordCollection();

            int nGeted = 0;

            for (; ;)
            {
                int nPerCount = 0;

                if (nPreferedEachCount == -1 || nPreferedEachCount == 0)
                {
                    nPerCount = nCount - nGeted;
                }
                else
                {
                    nPerCount = Math.Min(nPreferedEachCount, nCount - nGeted);
                }

                // this.Stop.SetMessage("正在获取命中结果 ( " + (nStart + nGeted + 1).ToString() + "-" + (nStart + nGeted + nPerCount).ToString() + " of " + this.ResultCount + " ) ...");

                // RecordCollection temprecords = null;
                PresentResult result = await OncePresent(
                    strResultSetName,
                    nStart + nGeted,
                    nPerCount,
                    strElementSetName,
                    strPreferredRecordSyntax);

                if (result.Value == -1)
                {
                    return(result);
                }
                if (result.Records == null)
                {
                    break;
                }


                nGeted += result.Records.Count;
                if (result.Records.Count > 0)
                {
                    records.AddRange(result.Records);
                }

                if (nGeted >= nCount || result.Records.Count == 0)
                {
                    break;
                }
            }

            return(new PresentResult {
                Records = records
            });
        }