Ejemplo n.º 1
0
        public string Invoke(Dictionary <string, string> input)
        {
            BaseAdapter adapter;
            string      rlt;

            try
            {
                if (input.ContainsKey(StorageCommand.COMMAND))
                {
                    var command = input[StorageCommand.COMMAND];
                    switch (command)
                    {
                    case StorageCommand.KVCOMMAND:
                        adapter = new KvStorageAdapter();
                        break;

                    default:
                        adapter = new ApiDocStorageAdapter();
                        break;
                    }
                    rlt = adapter.Invoke(input);
                }
                else
                {
                    return(FailMessage("未知指令,参考[Anno.Rpc.Storage.StorageCommand]下指令。"));
                }
            }
            catch (Exception ex)
            {
                return(FailMessage(ex.Message));
            }
            return(rlt);
        }
Ejemplo n.º 2
0
        public override Task <BrokerReply> Invoke(BrokerRequest request, ServerCallContext context)
        {
            return(Task.Run(() =>
            {
                BrokerReply reply = new BrokerReply();
                var input = new Dictionary <string, string>(request.Input);

                BaseAdapter adapter;
                string rlt;
                try
                {
                    if (input.ContainsKey(StorageCommand.COMMAND))
                    {
                        var command = input[StorageCommand.COMMAND];
                        switch (command)
                        {
                        case StorageCommand.KVCOMMAND:
                            adapter = new KvStorageAdapter();
                            break;

                        default:
                            adapter = new ApiDocStorageAdapter();
                            break;
                        }
                        rlt = adapter.Invoke(input);
                    }
                    else
                    {
                        rlt = FailMessage("未知指令,参考[Anno.Rpc.Storage.StorageCommand]下指令。");
                    }
                }
                catch (Exception ex)
                {
                    rlt = FailMessage(ex.Message);
                }
                reply.Reply = rlt;
                return reply;
            }));
        }