Пример #1
0
        public static MarcRecord ParseResponseForReadRecord
        (
            [NotNull] ServerResponse response,
            [NotNull] MarcRecord record
        )
        {
            Sure.NotNull(response, "response");
            Sure.NotNull(record, "record");

            try
            {
                record.Fields.BeginUpdate();

                ParseMfnStatusVersion
                (
                    response.RequireUtfString(),
                    response.RequireUtfString(),
                    record
                );

                string line;
                while (true)
                {
                    line = response.GetUtfString();
                    if (string.IsNullOrEmpty(line))
                    {
                        break;
                    }
                    if (line == "#")
                    {
                        break;
                    }
                    RecordField field = ParseLine(line);
                    if (field.Tag > 0)
                    {
                        record.Fields.Add(field);
                    }
                }
                if (line == "#")
                {
                    int returnCode = response.RequireInt32();
                    if (returnCode >= 0)
                    {
                        line = response.RequireUtfString();
                        line = IrbisText.IrbisToWindows(line);
                        record.Description = line;
                    }
                }
            }
            finally
            {
                record.Fields.EndUpdate();
                record.Modified = false;
            }

            return(record);
        }
Пример #2
0
        public static MarcRecord ParseResponseForWriteRecords
        (
            [NotNull] ServerResponse response,
            [NotNull] MarcRecord record
        )
        {
            Sure.NotNull(response, "response");
            Sure.NotNull(record, "record");

            try
            {
                record.Fields.BeginUpdate();
                record.Fields.Clear();

                string   whole = response.RequireUtfString();
                string[] split = whole.Split('\x1E');

                ParseMfnStatusVersion
                (
                    split[0],
                    split[1],
                    record
                );

                for (int i = 2; i < split.Length; i++)
                {
                    string      line  = split[i];
                    RecordField field = ParseLine(line);
                    if (field.Tag > 0)
                    {
                        record.Fields.Add(field);
                    }
                }
            }
            finally
            {
                record.Fields.EndUpdate();
                record.Modified = false;
            }

            return(record);
        }
Пример #3
0
        /// <inheritdoc cref="AbstractCommand.Execute"/>
        public override ServerResponse Execute
        (
            ClientQuery query
        )
        {
            Sure.NotNull(query, "query");

            ServerResponse response = base.Execute(query);

            CheckResponse(response);

            string line = response.RequireUtfString();

            Result = Record.ThrowIfNull().Clone();
            ProtocolText.ParseResponseForGblFormat
            (
                line,
                Result
            );

            return(response);
        }