/// <inheritdoc cref="AbstractCommand.CreateQuery"/>
        public override ClientQuery CreateQuery()
        {
            ClientQuery result = base.CreateQuery();

            result.CommandCode = CommandCode.CorrectVirtualRecord;

            string database = Database ?? Connection.Database;

            if (string.IsNullOrEmpty(database))
            {
                Log.Error
                (
                    "GblVirtualCommand::CreateQuery: "
                    + "database not specified"
                );

                throw new IrbisException("database not specified");
            }
            result.AddAnsi(database);

            result.Add(Actualize);

            if (!string.IsNullOrEmpty(FileName))
            {
                result.AddAnsi(FileName);
            }
            else
            {
                string statements = GblUtility.EncodeStatements
                                    (
                    Statements.ThrowIfNull("Statements")
                                    );
                result.AddUtf8(statements);
            }

            result.Add(Record.ThrowIfNull("Record"));

            return(result);
        }
Esempio n. 2
0
        /// <inheritdoc cref="AbstractCommand.CreateQuery"/>
        public override ClientQuery CreateQuery()
        {
            ClientQuery result = base.CreateQuery();

            result.CommandCode = CommandCode.GlobalCorrection;

            string database = Database ?? Connection.Database;

            if (string.IsNullOrEmpty(database))
            {
                Log.Error
                (
                    "GblCommand::CreateQuery: "
                    + "database not specified"
                );

                throw new IrbisException("database not specified");
            }
            result.AddAnsi(database);

            result.Add(Actualize);

            if (!string.IsNullOrEmpty(FileName))
            {
                // @filename without extension
                result.AddAnsi(FileName);
            }
            else
            {
                string statements = GblUtility.EncodeStatements
                                    (
                    Statements.ThrowIfNull("Statements")
                                    );
                result.AddUtf8(statements);
            }

            string preparedSearch = IrbisSearchQuery.PrepareQuery
                                    (
                SearchExpression
                                    );

            result.AddUtf8(preparedSearch);

            result.Add(FirstRecord);
            result.Add(NumberOfRecords);

            result.Add(string.Empty);

            if (ReferenceEquals(MfnList, null))
            {
                // Seems doesn't work with 2015.1
                //result.Add(0);
                //result.Add(MinMfn);
                //result.Add(MaxMfn);

                int count = MaxMfn - MinMfn + 1;
                result.Add(count);
                for (int mfn = MinMfn; mfn < MaxMfn; mfn++)
                {
                    result.Add(mfn);
                }
            }
            else
            {
                if (MfnList.Length == 0)
                {
                    Log.Error
                    (
                        "GblCommand::CreateQuery: "
                        + "MfnList.Length="
                        + MfnList.Length
                    );

                    throw new IrbisException("MfnList.Length == 0");
                }
                result.Add(MfnList.Length);
                foreach (var mfn in MfnList)
                {
                    result.Add(mfn);
                }
            }

            if (!FormalControl)
            {
                result.Add("*");
            }

            if (!AutoIn)
            {
                result.Add("&");
            }

            return(result);
        }