Ejemplo n.º 1
0
        private void _FetchRemaining
        (
            ServerResponse mainResponse,
            int expected
        )
        {
            if (ReferenceEquals(Found, null))
            {
                return;
            }

            if (!_subCommand && expected > IrbisConstants.MaxPostings)
            {
                int firstRecord = FirstRecord + Found.Count;

                while (firstRecord < expected)
                {
                    SearchCommand subCommand = Clone();
                    subCommand.FirstRecord     = firstRecord;
                    subCommand.NumberOfRecords =
                        Math.Min
                        (
                            expected - firstRecord + 1,
                            IrbisConstants.MaxPostings
                        );
                    subCommand._subCommand = true;

                    ClientQuery    clientQuery = subCommand.CreateQuery();
                    ServerResponse subResponse = subCommand
                                                 .Execute(clientQuery);
                    subCommand.CheckResponse(subResponse);

                    List <FoundItem> found = subCommand.Found
                                             .ThrowIfNull("Found");
                    int count = found.Count;
                    Found.ThrowIfNull().AddRange(found);

                    Debug.Assert
                    (
                        count != 0,
                        "Found.Count == 0 in SubCommand"
                    );

                    firstRecord += count;
                }
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Execute the command.
        /// </summary>
        public override ServerResponse Execute
        (
            ClientQuery clientQuery
        )
        {
            ServerResponse result = base.Execute(clientQuery);

            if (result.ReturnCode == 0)
            {
                if (UseReadInsteadOfFormat)
                {
                    int[] mfns = FoundItem.ConvertToMfn
                                 (
                        Found.ThrowIfNull("Found")
                                 );
                    Records = Connection.ReadRecords
                              (
                        Database ?? Connection.Database,
                        mfns
                              );
                }
                else
                {
                    Records = Found
                              .ThrowIfNull("Found")

#if !WINMOBILE && !PocketPC
                              .AsParallel()
                              .AsOrdered()
#endif

                              .Select
                              (
                        item => _ConvertRecord(item)
                              )
                              .ToArray();
                }
            }

            return(result);
        }