Exemple #1
0
        public T Get <T>(string key)
        {
            Dictionary <string, string> input = new Dictionary <string, string>();

            input["KV"]        = "KV";
            input[KVCONST.Opt] = KVCONST.FindById;

            BrokerRequest request = new BrokerRequest();

            request.Input.Add(input);
            var rltStr = client.Invoke(request);
            var rlt    = Newtonsoft.Json.JsonConvert.DeserializeObject <AnnoDataResult <T> >(rltStr.Reply);

            return(rlt.Data);
        }
Exemple #2
0
        private AnnoKV GetAnnoKV(string key)
        {
            Dictionary <string, string> input = new Dictionary <string, string>();

            input[StorageCommand.COMMAND] = StorageCommand.KVCOMMAND;
            input[KVCONST.Opt]            = KVCONST.FindById;
            input[KVCONST.Id]             = key;
            BrokerRequest request = new BrokerRequest();

            request.Input.Add(input);
            var rltStr = client.Invoke(request);
            var rlt    = Newtonsoft.Json.JsonConvert.DeserializeObject <AnnoDataResult <AnnoKV> >(rltStr.Reply);

            if (rlt.Status == false)
            {
                throw new InvalidOperationException(rlt.Msg);
            }
            return(rlt.Data);
        }
Exemple #3
0
        public static string Invoke(Dictionary <string, string> input)
        {
            Channel channel = new Channel($"{SettingService.Local.IpAddress}:{SettingService.Local.Port}", ChannelCredentials.Insecure);

            BrokerCenter.BrokerCenterClient client = new BrokerCenter.BrokerCenterClient(channel);
            BrokerRequest request = new BrokerRequest();

            request.Input.Add(input);
            var rlt = client.Invoke(request);

            channel.ShutdownAsync();
            return(rlt.Reply);
        }