コード例 #1
0
ファイル: ValuesController.cs プロジェクト: Notheless/kpr
        public async Task <ActionResult <CommandRecord> > PostTodoItem(CommandRecord item)
        {
            _context.CommandRecords.Add(item);
            await _context.SaveChangesAsync();

            return(CreatedAtAction(nameof(GetCommandRecords), new { id = item.Id }, item));
        }
コード例 #2
0
        /// <summary>
        /// 获取给定条目的给定类型的命令
        /// </summary>
        /// <param name="commandType"></param>
        /// <param name="ontology"></param>
        /// <param name="n">条数</param>
        /// <param name="sortField"></param>
        /// <param name="sortOrder"></param>
        /// <returns>命令消息集合</returns>
        public IList <MessageEntity> GetTopNCommands(MessageTypeKind commandType, OntologyDescriptor ontology, int n, string sortField, string sortOrder)
        {
            if (ontology == null)
            {
                return(new List <MessageEntity>());
            }
            if (commandType == MessageTypeKind.Invalid || commandType == MessageTypeKind.AnyCommand)
            {
                return(new List <MessageEntity>());
            }
            var db  = this.GetCommandDb(ontology);
            var sql =
                @"select top " + n.ToString(CultureInfo.InvariantCulture) +
                " * from [" + GetTableName(commandType) + "] as c where lower(c.Ontology)=@Ontology order by c." + sortField + " " + sortOrder;
            var pOntology = CreateParameter(db, "Ontology", ontology.Ontology.Code.ToLower(), DbType.String);
            IList <MessageEntity> list = new List <MessageEntity>();

            using (var reader = db.ExecuteReader(sql, pOntology))
            {
                while (reader.Read())
                {
                    list.Add(CommandRecord.Create(ontology.Host, commandType, reader));
                }
                reader.Close();

                return(list);
            }
        }
コード例 #3
0
        private void dataWipeToolStripMenuItem_Click(object sender, EventArgs e)
        {
            if (MessageBox.Show("Are you sure, you want to delete all the data in the device?", "Confirm", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes)
            {
                CodeproofServiceClient cpservice = new CodeproofServiceClient();

                foreach (ListViewItem item in listView1.SelectedItems)
                {
                    Authenticate authObj        = (Authenticate)((object[])item.Tag)[0];
                    CPID         selectedDevice = (CPID)((object[])item.Tag)[1];

                    CommandRecord cmd = new CommandRecord();

                    cmd.Command = "datawipe";//do not change this

                    cmd.CommandName = "SDK data wipe cmd test";
                    cmd.Notes       = "SDK sample test command";

                    CommandRecord cmdupdated = cpservice.ExecuteCommand(authObj, selectedDevice, cmd);
                    MessageBox.Show(cmdupdated.Status);

                    break;
                }
            }
        }
コード例 #4
0
ファイル: PushMessageForm.cs プロジェクト: antonychrist/sdk
        private void button1_Click(object sender, EventArgs e)
        {
            if (textBox1.Text.Length == 0)
            {
                MessageBox.Show("Pleas enter a message");
                textBox1.Focus();
                return;
            }

            button1.Enabled = false;

            //send push message command

            CodeproofServiceClient cpservice = new CodeproofServiceClient();

            CommandRecord cmd = new CommandRecord();

            cmd.Command = "sendmessage";//do not change this

            cmd.CommandName = "SDK send message test";
            cmd.Param1      = textBox1.Text;
            cmd.Notes       = "SDK sample test command";

            CommandRecord cmdupdated = cpservice.ExecuteCommand(authObj, selectedDevice, cmd);

            MessageBox.Show(cmdupdated.Status);

            button1.Enabled = true;
            this.Close();
        }
        private async Task DoReadCommand()
        {
            SetStatusActive(true); // the false happens in the bluetooth status handler.
            ncommand++;
            try
            {
                var valueList = await bleDevice.ReadCommand();

                if (valueList == null)
                {
                    SetStatus($"Error: unable to read Command");
                    return;
                }

                var record = new CommandRecord();

                var Command = valueList.GetValue("Command");
                if (Command.CurrentType == BCBasic.BCValue.ValueType.IsDouble || Command.CurrentType == BCBasic.BCValue.ValueType.IsString)
                {
                    record.Command       = (double)Command.AsDouble;
                    Command_Command.Text = record.Command.ToString(); // "N0"); // either N or F3 based on DEC HEX FIXED. hex needs conversion to int first?
                }


                CommandRecordData.Add(record);
            }
            catch (Exception ex)
            {
                SetStatus($"Error: exception: {ex.Message}");
            }
        }
コード例 #6
0
ファイル: Program.cs プロジェクト: antonychrist/sdk
        public static void PushManagedAppConfig()
        {
            CommandRecord cmd = new CommandRecord();

            string configblob =
                "<dict>" +
                "<key>server</key>" +
                "<dict>" +
                "<key>DEV</key>" +
                "<string>dev-server </string>" +
                "<key> PRODUCTION </key>" +
                "<string>prod-server </string>" +
                "<key> STAGING </key>" +
                "<string>staging-server </string>" +
                "<key> TEST </key>" +
                "<string>test-server</string>" +
                "</dict>" +
                "</dict>";

            var    Blobbytes   = System.Text.Encoding.UTF8.GetBytes(configblob);
            string encodedBlob = System.Convert.ToBase64String(Blobbytes);

            cmd.Command     = "appconfig";
            cmd.CommandName = "managed app config";
            cmd.Param1      = BundleId;
            cmd.Param2      = encodedBlob;
            cmd.Notes       = "command generated by API";

            CommandRecord cmdupdated = cpservice.ExecuteCommandGroup(AuthObj, ManagedNode, ProductId, cmd);
        }
コード例 #7
0
        private HandledCommand ConvertFrom(CommandRecord record)
        {
            var message = default(IApplicationMessage);

            if (record.MessageTypeCode > 0)
            {
                var messageType = _typeCodeProvider.GetType <IApplicationMessage>(record.MessageTypeCode);
                message = _jsonSerializer.Deserialize(record.MessagePayload, messageType) as IApplicationMessage;
            }

            return(new HandledCommand(record.CommandId, record.AggregateRootId, message));
        }
コード例 #8
0
ファイル: MySqlCommandStore.cs プロジェクト: cole2295/enode
        private HandledCommand ConvertFrom(CommandRecord record)
        {
            var message = default(IApplicationMessage);

            if (!string.IsNullOrEmpty(record.MessageTypeName))
            {
                var messageType = _typeNameProvider.GetType(record.MessageTypeName);
                message = _jsonSerializer.Deserialize(record.MessagePayload, messageType) as IApplicationMessage;
            }

            return(new HandledCommand(record.CommandId, record.AggregateRootId, message));
        }
コード例 #9
0
        public MessageEntity GetCommand(MessageTypeKind commandType, OntologyDescriptor ontology, Guid id)
        {
            var db          = this.GetCommandDb(ontology);
            var queryString =
                @"select * from " + GetTableName(commandType) + " as a where a.Id=@Id";

            using (var reader = db.ExecuteReader(queryString, CreateParameter(db, "Id", id, DbType.Guid)))
            {
                if (reader.Read())
                {
                    return(CommandRecord.Create(ontology.Host, commandType, reader));
                }
            }

            return(null);
        }
コード例 #10
0
        public void It_can_serialize_and_deserialize_payload_with_private_readonly_fields()
        {
            var executeAfter      = DateTime.UtcNow;
            var fixture           = new Fixture();
            var encapsulatedValue = fixture.Create <string>();
            var enqueueDate       = fixture.Create <DateTime>();

            var payload = new TestCommand(new CommandArgument()
            {
                SomeValue = encapsulatedValue
            });

            var record = new CommandRecord(payload, enqueueDate, executeAfter);

            var deserializedPayload = (TestCommand)record.DeserializePayload();

            Assert.AreEqual(encapsulatedValue, ((CommandArgument)deserializedPayload.Argument).SomeValue);
        }
コード例 #11
0
        public IEnumerable <CommandEnvelope> Dequeue(int maxCount)
        {
            using (var session = _sessionFactory.OpenSession())
            {
                CommandRecord aliasCommandRecord = null;
                CommandProcessingResultRecord aliasCommandProcessing = null;
                var processedCommands =
                    QueryOver.Of(() => aliasCommandProcessing)
                    .Where(() => aliasCommandProcessing.Sequence == aliasCommandRecord.Sequence)
                    .Select(x => x.Sequence)
                    .DetachedCriteria;

                return(session.QueryOver(() => aliasCommandRecord)
                       .Where(Subqueries.NotExists(processedCommands))
                       .Take(maxCount)
                       .List <CommandRecord>()
                       .Select(x => new CommandEnvelope(x.Sequence, (Command)x.DeserializePayload()))
                       .ToList());
            }
        }
コード例 #12
0
        private void lockToolStripMenuItem_Click(object sender, EventArgs e)
        {
            CodeproofServiceClient cpservice = new CodeproofServiceClient();

            foreach (ListViewItem item in listView1.SelectedItems)
            {
                Authenticate authObj        = (Authenticate)((object[])item.Tag)[0];
                CPID         selectedDevice = (CPID)((object[])item.Tag)[1];

                CommandRecord cmd = new CommandRecord();

                cmd.Command = "screenlock";//do not change this

                cmd.CommandName = "SDK screen lock cmd test";
                cmd.Notes       = "SDK sample test command";

                CommandRecord cmdupdated = cpservice.ExecuteCommand(authObj, selectedDevice, cmd);
                MessageBox.Show(cmdupdated.Status);
                break;
            }
        }
コード例 #13
0
        protected override CommandDictionary <CommandCode> GetDictionary()
        {
            var d = new CommandDictionary <CommandCode>();

            Action <CommandCode, Predicate <int>, CodeAdder> add = (code, predicate, action) =>
                                                                   d[(byte)code] = new CommandRecord <CommandCode>(predicate, action((byte)code));

            // TODO: commands here
            add(CommandCode.CPU_Status, eq(4), sync(raw => new CPUStatusReply(raw[1], raw[2])));
            // strangely 4 bytes
            add(CommandCode.HVE, eq(4), sync(raw => new HighVoltagePermittedStatusReply(raw[2] == 0 ? true : false)));
            add(CommandCode.PRGE, eq(3), sync(raw => OperationBlockReply.Parse(raw[1])));
            add(CommandCode.TIC_Retransmit, moreeq(28), sync(raw => {
                var expression = new Regex(@"^=V902 ([0-7]);[0-7];[0-9]+;[0-9]+;[0-9]+;([0-4]);([0-4]);([0-4]);([0-9]+);[0-9]+\r$");
                Match match;
                var command = Encoding.ASCII.GetString(trim(raw).ToArray());
                match       = expression.Match(command);
                if (match.Success)
                {
                    GroupCollection groups = match.Groups;
                    var turbo  = groups[1].Value == "4";
                    var relay1 = groups[2].Value == "4";
                    var relay2 = groups[3].Value == "4";
                    var relay3 = groups[4].Value == "4";
                    int alert;
                    try {
                        alert = int.Parse(groups[5].Value);
                    } catch (FormatException) {
                        //error. wrong alert format.
                        alert = 0;
                    }
                    return(new TICStatusReply(turbo, relay1, relay2, relay3, alert));
                }
                else
                {
                    OnErrorCommand(raw, "Wrong TIC status");
                    return(null);
                }
            }));
            add(CommandCode.TIC_GetStatus, moreeq(21), sync(raw => {
                var expression = new Regex(@"^([0-7]);[0-7];[0-9]+;[0-9]+;[0-9]+;([0-4]);([0-4]);([0-4]);([0-9]+);[0-9]+$");
                Match match;
                var command = Encoding.ASCII.GetString(trim(raw).ToArray());
                match       = expression.Match(command);
                if (match.Success)
                {
                    GroupCollection groups = match.Groups;
                    var turbo  = groups[1].Value == "4";
                    var relay1 = groups[2].Value == "4";
                    var relay2 = groups[3].Value == "4";
                    var relay3 = groups[4].Value == "4";
                    int alert;
                    try {
                        alert = int.Parse(groups[5].Value);
                    } catch (FormatException) {
                        //error. wrong alert format.
                        alert = 0;
                    }
                    return(new VacuumStatusReply(turbo, relay1, relay2, relay3, alert));
                }
                else
                {
                    OnErrorCommand(raw, "Wrong TIC status");
                    return(null);
                }
            }));

            add(CommandCode.SEMV1, eq(3), sync(raw => new Valve1Reply(raw[1])));

            add(CommandCode.SEMV2, eq(3), sync(raw => new Valve2Reply(raw[1])));
            add(CommandCode.SEMV3, eq(3), sync(raw => new Valve3Reply(raw[1])));
            add(CommandCode.SPUMP, eq(3), sync(raw => new MicroPumpReply(raw[1])));

            add(CommandCode.SPI_PSIS_SetVoltage, eq(2), sync(raw => new IonSourceSetReply()));
            add(CommandCode.SPI_DPS_SetVoltage, eq(2), sync(raw => new DetectorSetReply()));
            add(CommandCode.SPI_PSInl_SetVoltage, eq(2), sync(raw => new InletSetReply()));
            add(CommandCode.SPI_PSIS_GetVoltage, eq(4), sync(raw => IonSourceGetReply.Parse(trim(raw))));
            add(CommandCode.SPI_DPS_GetVoltage, eq(4), sync(raw => DetectorGetReply.Parse(trim(raw))));
            add(CommandCode.SPI_PSInl_GetVoltage, eq(4), sync(raw => InletGetReply.Parse(trim(raw))));

            add(CommandCode.SPI_Scan_SetVoltage, eq(2), sync(raw => new ScanVoltageSetReply()));
            add(CommandCode.SPI_CP_SetVoltage, eq(2), sync(raw => new CapacitorVoltageSetReply()));

            add(CommandCode.SPI_GetAllVoltages, eq(29), sync(raw => new AllVoltagesReply(trim(raw))));

            add(CommandCode.RTC_StartMeasure, eq(3), sync(raw => new SendMeasureReply(raw[1])));
            add(CommandCode.RTC_DelayedStart, eq(3), sync(raw => new DelayedMeasureReply(raw[1])));
            add(CommandCode.RTC_ReceiveResults, eq(18), sync(raw => new CountsReply(trim(raw))));

            // BAD temporary solution
            ActionGenerator <ServicePacket <CommandCode> > service = gen => (code => (list => {
                switch (list[1])
                {
                case 1:
                case 10:
                    OnSyncErrorReceived(code, gen(list) as SyncError <CommandCode>);
                    break;

                case 20:
                case 21:
                case 22:
                case 23:
                    OnAsyncCommandReceived(code, gen(list) as Async <CommandCode>);
                    break;

                case 30:
                case 31:
                    OnAsyncErrorReceived(code, gen(list) as AsyncError <CommandCode>);
                    break;

                case 41:
                case 42:
                    OnAsyncErrorReceived(code, gen(list) as AsyncError <CommandCode>);
                    break;

                default:
                    break;
                }
            }));

            add(CommandCode.Service_Message, moreeq(3), service(raw => {
                byte code = raw[1];
                switch (code)
                {
                case 1:
                case 10:
                    return(new SyncErrorReply(code));

                case 20:
                case 21:
                case 22:
                    return(LAMEvent.Parse(code));

                case 23:
                    return(LAMEvent.Parse(code, raw[2]));

                case 30:
                case 31:
                    return(new LAMCriticalError(code));

                case 41:
                case 42:
                    return(new LAMInternalError(code));

                default:
                    return(null);
                }
            }));
            //add(CommandCode.Sync_Error, eq(4), syncerr(raw => new SyncErrorReply(raw[1])));

            //add(CommandCode.LAM_Event, eq(3), async(raw => new LAMEvent(raw[1])));

            //add(CommandCode.LAM_CriticalError, eq(3), asyncerr(raw => new LAMCriticalError(raw[1])));
            // TODO: check length!
            //add(CommandCode.LAM_InternalError, eq(3), asyncerr(raw => new LAMInternalError(raw[1])));

            return(d);
        }
コード例 #14
0
        public static void Enqueue(object command, ISession session, DateTime executeAfter)
        {
            var commandRecord = new CommandRecord(command, DateTime.UtcNow, executeAfter);

            session.Save(commandRecord);
        }
コード例 #15
0
        protected override CommandDictionary <CommandCode> GetDictionary()
        {
            var d = new CommandDictionary <CommandCode>();
            Action <CommandCode, Predicate <int>, CodeAdder> add = (code, predicate, action) =>
                                                                   d[(byte)code] = new CommandRecord <CommandCode>(predicate, action((byte)code));

            add(CommandCode.GetState, eq(3), sync(raw => new updateState(raw[1])));
            add(CommandCode.GetStatus, eq(29), sync(raw => new updateStatus(raw[1],
                                                                            raw[2],
                                                                            (ushort)((ushort)raw[3] + ((ushort)raw[4] << 8)),
                                                                            (ushort)((ushort)raw[5] + ((ushort)raw[6] << 8)),
                                                                            (ushort)((ushort)raw[7] + ((ushort)raw[8] << 8)),
                                                                            (ushort)((ushort)raw[9] + ((ushort)raw[10] << 8)),
                                                                            (ushort)((ushort)raw[11] + ((ushort)raw[12] << 8)),
                                                                            (ushort)((ushort)raw[13] + ((ushort)raw[14] << 8)),
                                                                            (ushort)((ushort)raw[15] + ((ushort)raw[16] << 8)),
                                                                            (ushort)((ushort)raw[17] + ((ushort)raw[18] << 8)),
                                                                            (ushort)((ushort)raw[19] + ((ushort)raw[20] << 8)),
                                                                            (ushort)((ushort)raw[21] + ((ushort)raw[22] << 8)),
                                                                            (ushort)((ushort)raw[23] + ((ushort)raw[24] << 8)),
                                                                            raw[25],
                                                                            (ushort)((ushort)raw[26] + ((ushort)raw[27] << 8)))));
            add(CommandCode.Shutdown, eq(2), sync(raw => new confirmShutdown()));
            add(CommandCode.Init, eq(2), sync(raw => new confirmInit()));
            add(CommandCode.SetHeatCurrent, eq(2), sync(raw => new confirmHCurrent()));
            add(CommandCode.SetEmissionCurrent, eq(2), sync(raw => new confirmECurrent()));
            add(CommandCode.SetIonizationVoltage, eq(2), sync(raw => new confirmIVoltage()));
            add(CommandCode.SetFocusVoltage1, eq(2), sync(raw => new confirmF1Voltage()));
            add(CommandCode.SetFocusVoltage2, eq(2), sync(raw => new confirmF2Voltage()));
            add(CommandCode.SetScanVoltage, eq(2), sync(raw => new confirmSVoltage()));
            add(CommandCode.SetCapacitorVoltage, eq(2), sync(raw => new confirmCP()));
            add(CommandCode.Measure, eq(2), sync(raw => new confirmMeasure()));
            add(CommandCode.GetCounts, eq(8), sync(raw => new updateCounts((uint)raw[1] + ((uint)raw[2] << 8) + ((uint)raw[3] << 16),
                                                                           (uint)raw[4] + ((uint)raw[5] << 8) + ((uint)raw[6] << 16))));
            add(CommandCode.heatCurrentEnable, eq(2), sync(raw => new confirmHECurrent()));
            add(CommandCode.EnableHighVoltage, eq(2), sync(raw => new confirmHighVoltage()));
            add(CommandCode.GetTurboPumpStatus, eq(17), sync(raw => new updateTurboPumpStatus((ushort)((ushort)raw[1] + ((ushort)raw[2] << 8)),
                                                                                              (ushort)((ushort)raw[3] + ((ushort)raw[4] << 8)),
                                                                                              (ushort)((ushort)raw[5] + ((ushort)raw[6] << 8)),
                                                                                              (ushort)((ushort)raw[7] + ((ushort)raw[8] << 8)),
                                                                                              (ushort)((ushort)raw[9] + ((ushort)raw[10] << 8)),
                                                                                              (ushort)((ushort)raw[11] + ((ushort)raw[12] << 8)),
                                                                                              raw[13],
                                                                                              raw[14],
                                                                                              raw[15])));
            add(CommandCode.SetForvacuumLevel, eq(2), sync(raw => new confirmForvacuumLevel()));

            add(CommandCode.InvalidCommand, moreeq(3), syncerr(raw => new logInvalidCommand(trim(raw))));
            add(CommandCode.InvalidChecksum, eq(2), syncerr(raw => new logInvalidChecksum()));
            add(CommandCode.InvalidPacket, eq(2), syncerr(raw => new logInvalidPacket()));
            add(CommandCode.InvalidLength, eq(2), syncerr(raw => new logInvalidLength()));
            add(CommandCode.InvalidData, eq(2), syncerr(raw => new logInvalidData()));
            add(CommandCode.InvalidState, eq(2), syncerr(raw => new logInvalidState()));

            add(CommandCode.InternalError, eq(3), asyncerr(raw => new logInternalError(raw[1])));
            add(CommandCode.InvalidSystemState, eq(2), asyncerr(raw => new logInvalidSystemState()));
            add(CommandCode.VacuumCrash, eq(3), asyncerr(raw => new logVacuumCrash(raw[1])));
            // see GetTurboPumpStatus!
            add(CommandCode.TurboPumpFailure, eq(17), asyncerr(raw => new logTurboPumpFailure(raw)));
            add(CommandCode.PowerFail, eq(2), asyncerr(raw => new logPowerFail()));
            add(CommandCode.InvalidVacuumState, eq(2), asyncerr(raw => new logInvalidVacuumState()));
            add(CommandCode.AdcPlaceIonSrc, moreeq(2), asyncerr(raw => new logAdcPlaceIonSrc(trim(raw))));
            add(CommandCode.AdcPlaceScanv, moreeq(2), asyncerr(raw => new logAdcPlaceScanv(trim(raw))));
            add(CommandCode.AdcPlaceControlm, moreeq(2), asyncerr(raw => new logAdcPlaceControlm(trim(raw))));

            add(CommandCode.Measured, eq(2), async(raw => new requestCounts()));
            add(CommandCode.VacuumReady, eq(2), async(raw => new confirmVacuumReady()));
            add(CommandCode.SystemShutdowned, eq(2), async(raw => new confirmShutdowned()));
            add(CommandCode.SystemReseted, eq(2), async(raw => new SystemReseted()));
            add(CommandCode.HighVoltageOff, eq(2), async(raw => new confirmHighVoltageOff()));
            add(CommandCode.HighVoltageOn, eq(2), async(raw => new confirmHighVoltageOn()));
            return(d);
        }
コード例 #16
0
ファイル: SqlServerCommandStore.cs プロジェクト: nicklv/enode
        private HandledCommand ConvertFrom(CommandRecord record)
        {
            var message = default(IApplicationMessage);

            if (record.MessageTypeCode > 0)
            {
                var messageType = _typeCodeProvider.GetType(record.MessageTypeCode);
                message = _jsonSerializer.Deserialize(record.Message, messageType) as IApplicationMessage;
            }

            return new HandledCommand(record.CommandId, record.AggregateRootId, message);
        }
コード例 #17
0
        private HandledCommand ConvertFrom(CommandRecord record)
        {
            var message = default(IApplicationMessage);

            if (!string.IsNullOrEmpty(record.MessageTypeName))
            {
                var messageType = _typeNameProvider.GetType(record.MessageTypeName);
                message = _jsonSerializer.Deserialize(record.MessagePayload, messageType) as IApplicationMessage;
            }

            return new HandledCommand(record.CommandId, record.AggregateRootId, message);
        }
コード例 #18
0
        /// <summary>
        /// 根据节点分页获取命令
        /// </summary>
        /// <typeparam name="T">命令类型参数</typeparam>
        /// <param name="commandType"></param>
        /// <param name="ontology">本体</param>
        /// <param name="catalogCode">目录码</param>
        /// <param name="actionCode">动作码,空值表示忽略本查询条件</param>
        /// <param name="nodeId">节点标识,空值表示忽略本查询条件</param>
        /// <param name="localEntityId">本地实体标识</param>
        /// <param name="pageIndex">页索引</param>
        /// <param name="pageSize">页尺寸</param>
        /// <param name="sortField">排序字段</param>
        /// <param name="sortOrder">排序方向</param>
        /// <param name="total">总记录数</param>
        /// <returns></returns>
        public IList <MessageEntity> GetPlistCommands(MessageTypeKind commandType,
                                                      OntologyDescriptor ontology, string catalogCode, string actionCode, Guid?nodeId, string localEntityId,
                                                      int pageIndex, int pageSize, string sortField, string sortOrder, out Int64 total)
        {
            var tableName   = GetTableName(commandType);
            var queryString =
                @"select top " + pageSize.ToString(CultureInfo.InvariantCulture) + " * from (SELECT ROW_NUMBER() OVER(ORDER BY " + sortField + " " + sortOrder + ") AS RowNumber,* from " + tableName +
                @" as a where a.Ontology=@Ontology {0}) b 
 where b.RowNumber>" + (pageSize * pageIndex).ToString(CultureInfo.InvariantCulture);
            var countQs =
                @"select count(Id) from " + tableName + @" as a 
where a.Ontology=@Ontology {0}";

            if (!string.IsNullOrEmpty(actionCode))
            {
                queryString = string.Format(queryString, " and a.Verb=@Verb {0}");
                countQs     = string.Format(countQs, " and a.Verb=@Verb {0}");
            }
            if (!string.IsNullOrEmpty(localEntityId))
            {
                queryString = string.Format(queryString, " and a.LocalEntityID=@LocalEntityId {0}");
                countQs     = string.Format(countQs, " and a.LocalEntityID=@LocalEntityId {0}");
            }
            if (!string.IsNullOrEmpty(catalogCode))
            {
                queryString = string.Format(queryString, " and a.CatalogCode like @CatalogCode {0}");
                countQs     = string.Format(countQs, " and a.CatalogCode like @CatalogCode {0}");
            }
            if (nodeId.HasValue)
            {
                queryString = string.Format(queryString, " and a.ClientID=@ClientId");
                countQs     = string.Format(countQs, " and a.ClientID=@ClientId");
            }
            else
            {
                queryString = string.Format(queryString, "");
                countQs     = string.Format(countQs, "");
            }
            var db    = this.GetCommandDb(ontology);
            var parms = new List <DbParameter> {
                CreateParameter(db, "Ontology", ontology.Ontology.Code, DbType.String)
            };

            if (!string.IsNullOrEmpty(actionCode))
            {
                parms.Add(CreateParameter(db, "Verb", actionCode, DbType.String));
            }
            if (nodeId.HasValue)
            {
                parms.Add(CreateParameter(db, "ClientId", nodeId.Value, DbType.Guid));
            }
            if (!string.IsNullOrEmpty(localEntityId))
            {
                parms.Add(CreateParameter(db, "LocalEntityId", localEntityId, DbType.String));
            }
            if (!string.IsNullOrEmpty(catalogCode))
            {
                parms.Add(CreateParameter(db, "CatalogCode", catalogCode + "%", DbType.String));
            }

            var pArray = parms.ToArray();
            IList <MessageEntity> list = new List <MessageEntity>();

            using (var reader = this.GetCommandDb(ontology).ExecuteReader(queryString, pArray))
            {
                while (reader.Read())
                {
                    list.Add(CommandRecord.Create(ontology.Host, commandType, reader));
                }
            }
            total = (int)this.GetCommandDb(ontology).ExecuteScalar(countQs, parms.Select(p => ((ICloneable)p).Clone()).Cast <DbParameter>().ToArray());

            return(list);
        }