예제 #1
0
파일: Thrift.cs 프로젝트: bfyxzls/Lind.DDD
        public void ThrifTestMethod1()
        {
            //服务端:开始Thrift rpc服务
            new Thread(() =>
            {
                var processor1 = new HelloThrift.Processor(new HelloThriftHandler());
                TMultiplexedProcessor processor = new TMultiplexedProcessor();
                processor.RegisterProcessor("HelloThriftHandler", processor1);
                var serverTransport = new TServerSocket(9090);
                var server1         = new TThreadedServer(processor, serverTransport);
                Console.WriteLine("向客户端输出服务开启");
                server1.Serve();
            }).Start();

            //客户端:调用服务端的HelloThrift的HelloWorld方法
            TTransport           transport = new TSocket("localhost", 9090);
            TProtocol            protocol  = new TBinaryProtocol(transport);
            TMultiplexedProtocol mp1       = new TMultiplexedProtocol(protocol, "HelloThriftHandler");

            HelloThrift.Client client = new HelloThrift.Client(mp1);
            transport.Open();
            client.HelloWorld();
            client.adding(2, 3);
            Console.WriteLine(client.GetData(1));
            transport.Close();
        }
예제 #2
0
파일: Program.cs 프로젝트: dudyi/Thrift
        static void Main(string[] args)
        {
            TTransport transport = new TSocket("localhost", 10240);

            transport.Open();

            TProtocol protocol = new TBinaryProtocol(transport);

            SampleService.Client cli = new SampleService.Client(protocol);

            ServiceVersion ver = cli.GetVersion();

            System.Console.WriteLine("Remote Service Version: {0} - v{1}", ver.Name, ver.Version);

            //while (true) {
            var hellos = cli.SayHello("Thrift" + DateTime.Now.ToString());

            foreach (string item in hellos)
            {
                System.Console.WriteLine(item);
            }

            System.Threading.Thread.Sleep(1000);
            //}

            System.Console.ReadKey();
            transport.Close();
        }
예제 #3
0
        public void InsertData()
        {
            //实例化Socket连接
            //transport = new TSocket("2.5.172.38", 30001);
            var transport = new TSocket("hbaseclient1");
            //实例化一个协议对象
            TProtocol tProtocol = new TBinaryProtocol(transport);

            string logtablename = "logs";

            using (var client = new HBase.Thrift.Hbase.Client(tProtocol))
            {
                transport.Open();
                var boo = client.checkAndPut(Encoding.UTF8.GetBytes(logtablename), Encoding.UTF8.GetBytes("row1"), Encoding.UTF8.GetBytes("cjzf.vlogs:url"),
                                             null, new Mutation
                {
                    Column     = Encoding.UTF8.GetBytes("cjzf.vlogs:url"),
                    Value      = Encoding.UTF8.GetBytes("http://lulufaer.web2.nat123.net/cjzf/newsDetail.aspx?id=434494"),
                    IsDelete   = false,
                    WriteToWAL = true
                }, null);

                var rows = client.getRow(Encoding.UTF8.GetBytes(logtablename), Encoding.UTF8.GetBytes("row1"), null);
            }
        }
예제 #4
0
파일: HClient.cs 프로젝트: ahweb/CS4Hadoop
        public static void BatAddData()
        {
            var transport = new TBufferedTransport(new TSocket("master", 9090));


            transport.Open();


            var protocol = new TBinaryProtocol(transport);

            var client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);

            //client.createTable(Unitl.StrToBytes(tablename), new List<ColumnDescriptor> { new ColumnDescriptor { Name = Unitl.StrToBytes("zbw911"), InMemory = false } });

            var bytevalue = Unitl.StrToBytes(Longdata);

            for (var j = 0; j < 100000; j++)
            {
                //var j = 0;
                for (var i = 0; i < 1000; i++)
                {
                    client.mutateRow(Unitl.StrToBytes("1"), Unitl.StrToBytes("" + i + "___" + j), new List <Mutation> {
                        new Mutation {
                            Column = Unitl.StrToBytes("zbw911"), Value = bytevalue
                        }
                    });
                }

                Console.WriteLine(j + "批=" + 1000 * j);
            }


            transport.Close();
        }
예제 #5
0
        public static void Put <T>(string configname, string table, string family, string rowid, T obj, Func <T, IEnumerable <KeyValuePair <string, object> > > fun)
        {
            //实例化Socket连接
            //transport = new TSocket("2.5.172.38", 30001);
            var transport = new TSocket(configname);
            //实例化一个协议对象
            TProtocol tProtocol = new TBinaryProtocol(transport);

            byte[] tablenamebytes = Encoding.UTF8.GetBytes(table);
            byte[] familybytes    = Encoding.UTF8.GetBytes(family);
            byte[] rownamebytes   = Encoding.UTF8.GetBytes(rowid);
            using (var client = new HBase.Thrift2.THBaseService.Client(tProtocol))
            {
                transport.Open();

                try
                {
                    List <TColumnValue> columnvaluelist = new List <TColumnValue>();
                    foreach (var kv in fun(obj))
                    {
                        columnvaluelist.Add(new TColumnValue(familybytes, Encoding.UTF8.GetBytes(kv.Key),
                                                             Serializer.TSerializer.GetBytes(kv.Value)));
                    }

                    client.put(tablenamebytes, new HBase.Thrift2.TPut(rownamebytes, columnvaluelist));
                }
                finally
                {
                    transport.Close();
                }
            }
        }
        /// <summary>
        /// Operation the specified loginSite, imageUrl and image.
        /// </summary>
        /// <param name="loginSite">Login site.</param>
        /// <param name="imageUrl">Image URL.</param>
        /// <param name="image">Image.</param>
        public string Operation(string loginSite, string imageUrl = "", Image image = null)
        {
            string     result    = "";
            TTransport transport = new TSocket(_host, _port);

            try
            {
                TProtocol protocol            = new TBinaryProtocol(transport);
                ThriftOperation.Client client = new ThriftOperation.Client(protocol);
                transport.Open();
                OperationObj operationObj = new OperationObj()
                {
                    LoginSite = loginSite,
                    ImageUrl  = imageUrl,
                    //Image = ImageHelper.GetBytesByImage(image)
                };

                result = client.Operation(operationObj);
            }
            catch (Exception ex)
            {
                ILog logger = LogManager.GetLogger(typeof(ThriftHelper));
                logger.Error("Operation Not Found!" + Environment.NewLine + ex.ToString());
            }
            finally {
                transport.Close();
            }
            return(result);
        }
예제 #7
0
        public static MapD.Client get_client(string host_or_uri, int port, bool http)
        {
            THttpClient     httpTransport;
            TTransport      transport;
            TBinaryProtocol protocol;
            TJSONProtocol   jsonProtocol;

            MapD.Client client;

            try{
                if (http)
                {
                    Uri httpuri = new Uri(host_or_uri);
                    httpTransport = new THttpClient(httpuri);
                    jsonProtocol  = new TJSONProtocol(httpTransport);
                    client        = new MapD.Client(jsonProtocol);
                    httpTransport.Open();
                    return(client);
                }
                else
                {
                    transport = new TSocket(host_or_uri, port);
                    protocol  = new TBinaryProtocol(transport);
                    client    = new MapD.Client(protocol);
                    transport.Open();
                    return(client);
                }
            } catch (TException x) {
                Console.WriteLine(x.StackTrace);
            }
            return(null);
        }
예제 #8
0
파일: Program.cs 프로젝트: snowvil/Thrift
        static void Main(string[] args)
        {
            try
            {
                TTransport transport            = new TSocket("localhost", 9091);
                TProtocol  protocol             = new TBinaryProtocol(transport);
                HelloWorldService.Client client = new HelloWorldService.Client(protocol);

                transport.Open();
                try
                {
                    String recv = client.hello("C# Client Send Hello.");
                    Console.WriteLine(recv);

                    recv = client.hello("C# Client Send World.");
                    Console.WriteLine(recv);
                }
                finally
                {
                    transport.Close();
                }
            }
            catch (TApplicationException x)
            {
                Console.WriteLine(x.StackTrace);
            }
        }
예제 #9
0
        /**
         * Thrift入口函数:
         * service emsg_inf_push {
         *    string process(1:string licence,2:string sn,3:string content)
         *    string process_batch(1:string licence,2:string sn,3:list<string> contents)
         *}
         *
         * content样例:
         * {
         *          "envelope": {
         *              "id": "id",
         *              "type": 1,
         *              "from": "fromuser",
         *              "to": "touser",
         *              "ack": 1
         *          },
         *          "vsn": "0.0.1",
         *          "payload": {
         *              "attrs": {
         *                  "message_type": "contact",
         *                  "action": "reject",
         *                  "contact_icon": "头像",
         *                  "contact_nickname": "昵称",
         *                  "contact_id": "好友的用户id"
         *              }
         *          }
         *      }
         */
        private void button1_Click(object sender, EventArgs e)
        {
            TTransport transport = null;

            try
            {
                transport = new TSocket(host, port);
                TProtocol            protocol = new TBinaryProtocol(transport);
                emsg_inf_push.Client client   = new emsg_inf_push.Client(protocol);
                transport.Open();
                string content = createContent();
                var    req     = client.process(licence, sn, content);
                Console.WriteLine(string.Format("requst : {0}", req));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.StackTrace);
            }
            finally
            {
                if (null != transport)
                {
                    //close
                    transport.Close();
                }
            }
        }
예제 #10
0
        private static void Main(string[] args)
        {
            //using (TTransport transport = new TSocket("127.0.0.1", 8888))
            //using (TProtocol protocol = new TBinaryProtocol(transport))
            //using (var clientUser = new UserService.Client(protocol))
            //{
            //    transport.Open();
            //    User u = clientUser.Get(1);
            //    Console.WriteLine($"{u.Id},{u.Name}");
            //}

            using (TTransport transport = new TSocket("127.0.0.1", 8888))
                using (TProtocol protocol = new TBinaryProtocol(transport))
                    using (var protocolUserService = new TMultiplexedProtocol(protocol, "userService"))
                        using (var clientUser = new UserService.Client(protocolUserService))
                            using (var protocolCalcService = new TMultiplexedProtocol(protocol, "calcService"))
                                using (var clientCalc = new CalcService.Client(protocolCalcService))
                                {
                                    transport.Open();
                                    User u = clientUser.Get(1);
                                    Console.WriteLine($"{u.Id},{u.Name}");
                                    Console.WriteLine(clientCalc.Add(1, 2));
                                }

            Console.ReadKey();
        }
예제 #11
0
        protected override void Decode(IChannelHandlerContext context, IByteBuffer input, List <object> output)
        {
            int         messageBeginIndex = input.ReaderIndex;
            IByteBuffer messageBuffer     = null;

            try
            {
                using (TTransport transport = new TChannelBufferInputTransport(input))
                {
                    using (TBinaryProtocol protocol = new TBinaryProtocol(transport))
                    {
                        protocol.ReadMessageBegin();
                        TProtocolUtil.Skip(protocol, TType.Struct);
                        protocol.ReadMessageEnd();

                        messageBuffer = input.Slice(messageBeginIndex, input.ReaderIndex);
                    }
                }
            }
            catch (IndexOutOfRangeException)
            {
                input.SetReaderIndex(messageBeginIndex);
                return;
            }
            catch (Exception ex)
            {
                ex.ThrowIfNecessary();
                input.SetReaderIndex(messageBeginIndex);
                return;
            }

            output.Add(messageBuffer);
        }
예제 #12
0
        public string TestConnection(string IPAddress, int Port)
        {
            TTransport transport = null;

            try
            {
                //192.168.2.111:60010
                //实例化Socket连接
                transport = new TSocket(IPAddress, Port);
                //实例化一个协议对象
                TProtocol tProtocol = new TBinaryProtocol(transport);
                //实例化一个Hbase的Client对象
                var client = new Hbase.Client(tProtocol);
                //打开连接
                transport.Open();

                return("联接成功..");
            }
            catch (Exception ex)
            {
                return("联接失败.." + ":" + ex.ToString());
            }

            finally
            {
                if (transport != null)
                {
                    transport.Close();
                }
            }
        }
예제 #13
0
        public static void TestClient()
        {
            TTransport           transport = new TFramedTransport(new TSocket("localhost", 9090));
            TProtocol            protocol  = new TBinaryProtocol(transport);
            TMultiplexedProtocol mp        = new TMultiplexedProtocol(protocol, "search_service");

            SearchService.Client client = new SearchService.Client(mp);

            transport.Open();

            SearchRequest req = new SearchRequest();

            req.FileMask     = "*.bat";
            req.StartPath    = "c:\\";
            req.IgnoreErrors = true;
            var result = client.Search(req);

            Debug.WriteLine("P10");

            client.Delay1(2000);
            client.Delay2(1000);

            Task t1 = Task.Factory.StartNew(() => { Debug.WriteLine("T1:begin"); client.Delay1(2000); Debug.WriteLine("T1:end"); });
            Task t2 = Task.Factory.StartNew(() => { Debug.WriteLine("T2:begin"); client.Delay2(1000); Debug.WriteLine("T2:end"); });

            Debug.WriteLine("P20");

            t2.Wait();

            Debug.WriteLine("P30");

            t1.Wait();

            Debug.WriteLine("P40");
        }
예제 #14
0
        public static void t2()
        {
            var transport = new TBufferedTransport(new TSocket("hserver", 10000));
            var protocol  = new TBinaryProtocol(transport);
            var client    = new ThriftHive.Client(protocol);

            transport.Open();


            var database = new Database();

            database.Name        = "helloworldDB";
            database.Description = "测试用的第一个DB";

            var tables = client.get_all_tables("default");

            //var tables = client.get_all_databases();

            foreach (var table in tables)
            {
                System.Console.WriteLine(table);
            }



            transport.Close();
        }
예제 #15
0
        public static void query()
        {
            var transport = new TBufferedTransport(new TSocket("hserver", 10000));
            var protocol  = new TBinaryProtocol(transport);
            var client    = new ThriftHive.Client(protocol);

            transport.Open();

            //client.execute("CREATE TABLE r(a STRING, b INT, c DOUBLE)");
            //client.execute("LOAD TABLE LOCAL INPATH '/path' INTO TABLE r");
            client.execute("SELECT * FROM pokes where foo=180");
            while (true)
            {
                var row = client.fetchOne();
                if (string.IsNullOrEmpty(row))
                {
                    break;
                }
                System.Console.WriteLine(row);
            }
            client.execute("SELECT * FROM pokes");
            var all = client.fetchAll();

            System.Console.WriteLine(all);

            transport.Close();
        }
예제 #16
0
        static async Task Main(string[] args)
        {
            int port = 9090;

            string host = args.Length == 1 ? args[0] : "localhost";

            var ip        = IPAddress.Parse(host);
            var transport = new TBufferedClientTransport(new TSocketClientTransport(ip, port));
            var proto     = new TBinaryProtocol(transport);

            _hbase = new Hbase.Thrift.Hbase.Client(proto);

            try
            {
                await transport.OpenAsync();

                var names = await _hbase.getTableNamesAsync(CancellationToken.None);

                names.ForEach(msg => Console.WriteLine(Encoding.UTF8.GetString(msg)));

                await CreateTable();
                await Insert();
                await Get();

                transport.Close();
            }
            catch (Exception e)
            {
                Console.Error.Write(e.ToString());
            }
        }
        public EvernoteSyncServer()
        {
            TTransport userStoreTransport = new THttpClient(UserStoreUrl);
            TProtocol  userStoreProtocol  = new TBinaryProtocol(userStoreTransport);

            _userStore = new UserStore.Client(userStoreProtocol);
        }
예제 #18
0
        public void SerializeThriftCall(Action <BasicMathServer.Iface> action)
        {
            // Thrift protocol/transport stack
            var stm  = new MemoryStream();
            var trns = new TStreamTransport(null, stm);
            var prot = new TBinaryProtocol(trns);

            // serialize the call into a bunch of bytes
            var client = new BasicMathServer.Client(prot);

            if (action != null)
            {
                action(client);
            }
            else
            {
                throw new ArgumentException("action must not be null");
            }

            // make sure everything is written to the MemoryStream
            trns.Flush();

            // send the message
            var msg = new MathRequestCall()
            {
                rawBytes = stm.ToArray()
            };

            MQAdapter.Bus.Send(msg);
        }
예제 #19
0
    void 测试多个联接(int num)
    {
        TTransport transport = null;

        for (int i = 0; i < num; i++)
        {
            try
            {
                //192.168.2.111:60010
                //实例化Socket连接
                transport = new TSocket("192.168.2.111", 9090);
                //实例化一个协议对象
                TProtocol tProtocol = new TBinaryProtocol(transport);
                //实例化一个Hbase的Client对象
                var client = new Hbase.Client(tProtocol);
                //打开连接
                transport.Open();

                //添加到集合
                conns.Add(i, transport);
                //Label1.Text = "&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;&nbsp;联接成功..";
            }
            catch (Exception ex)
            {
                // Label1.Text = "联接失败..";
                //Label1.Text += ex;
            }

            finally
            {
                // if (transport != null) { transport.Close(); }
            }
        }
    }
예제 #20
0
        public ICassandraClient Make(Endpoint key)
        {
            if (key == null)
            {
                throw new ArgumentNullException("key");
            }

            var transport = new TSocket(key.Host, key.Port, timeout);
            var protocol  = new TBinaryProtocol(transport);

            Apache.Cassandra.Cassandra.Iface cassandra = null;
            cassandra = new Apache.Cassandra.Cassandra.Client(protocol);

            try
            {
                transport.Open();
            }
            catch (TTransportException e)
            {
                // Thrift exceptions aren't very good in reporting, so we have to catch the exception here and
                // add details to it.
                throw new Exception("Unable to open transport to " + key.ToString() + " , ", e);
            }

            return(new CassandraClient(cassandra, new KeyspaceFactory(monitor), key, pool));
        }
예제 #21
0
파일: HClient.cs 프로젝트: ahweb/CS4Hadoop
        public static void AddColumn()
        {
            var transport = new TBufferedTransport(new TSocket("master", 9090));


            transport.Open();


            var protocol = new TBinaryProtocol(transport);

            var client = new Apache.Hadoop.Hbase.Hbase.Client(protocol);


            //client.createTable(Unitl.StrToBytes("t"), new List<ColumnDescriptor> { new ColumnDescriptor { Name = Unitl.StrToBytes("default"), InMemory = false } });
            //client.createTable(Unitl.StrToBytes("thetable"), new List<ColumnDescriptor> { new ColumnDescriptor { Name = Unitl.StrToBytes("default"), InMemory = false } });

            for (var i = 0; i < 10; i++)
            {
                client.mutateRow(Unitl.StrToBytes("t"),

                                 Unitl.StrToBytes("key"),
                                 new List <Mutation> {
                    new Mutation {
                        Column = Unitl.StrToBytes("default:" + i), Value = Unitl.StrToBytes(System.DateTime.Now.ToString())
                    }
                });
            }
            transport.Close();
        }
예제 #22
0
        /// <summary>
        ///
        /// </summary>
        private void InitTransportAndClient()
        {
            var socket = new TSocket(Server.Host, Server.Port, Server.Timeout * 1000);

            switch (ConnectionType)
            {
            case ConnectionType.Simple:
                _transport = socket;
                break;

            case ConnectionType.Buffered:
                _transport = new TBufferedTransport(socket, BufferSize);
                break;

            case ConnectionType.Framed:
                _transport = new TFramedTransport(socket);
                break;

            default:
                goto case ConnectionType.Framed;
            }

            var protocol = new TBinaryProtocol(_transport);

            _client = new Cassandra.Client(protocol);
        }
예제 #23
0
        public MainPage(int observerServerPort, Client myClient)
        {
            this.myClient = myClient;
            InitializeComponent();
            this.observerServerPort = observerServerPort;
            Task.Run(() => checkForUpdate());


            TTransport transport = new TSocket("localhost", 9091);
            TProtocol  protocol  = new TBinaryProtocol(transport);

            transport.Open();

            TransformerService.Client client = new TransformerService.Client(protocol);
            List <MeciDTO>            dtos   = client.findAllMeci();

            meciuriData = retreive(dtos);
            transport.Close();

            MessageServer messageServer = new MessageServer(observerServerPort); // start mini-server as observer on the client

            PopulateMeciTable();
            this.locuriCBox.Text            = "0";
            this.listaMeciuri.FullRowSelect = true;
        }
예제 #24
0
        public static TProtocol CreateWriteProtocol(Stream inputStream, Stream outputStream)
        {
            var trans = new TStreamClientTransport(inputStream, outputStream);
            var proto = new TBinaryProtocol(trans);

            return(proto);
        }
예제 #25
0
        private static void t1(DateTime yesterday)
        {
            string viewTable  = "AdTxt" + yesterday.ToString("yyyy.MM.dd").Replace(".", "") + "View";
            string clickTable = "AdTxt" + yesterday.ToString("yyyy.MM.dd").Replace(".", "") + "View";

            StringBuilder sql = new StringBuilder();

            sql.Append("select '" + yesterday.ToString("yyyy-MM-dd hh:mm:ss.fffffff") + "' as ReportDate,vn.DealerId,vn.KeywordPId,");
            sql.Append("case when vn.num is null then 0L else  cn.num end  ViewNum,");
            sql.Append("case when cn.num is null then 0L else  cn.num end  clicknum,");
            sql.Append("case when vin.num is null then 0L else  vin.num end viewIpnum,");
            sql.Append("case when cin.num is null then 0L else  cin.num end  clickIpnum ");
            //sql.Append("unix_timestamp('" + DateTime.Now.ToShortDateString() + "') as createtime ");
            sql.Append("From (select a.VendorId as DealerId,v.KeywordPId,count(v.KeywordPId) Num  from " + viewTable + " v join temp_adtxt a on a.Id=v.AdTxtId inner join temp_Keyword_L1 k on k.Id=v.KeywordId group by a.VendorId ,v.KeywordPId) vn ");
            sql.Append("join (select a.VendorId as DealerId,v.KeywordPId,count(distinct v.Ip) Num  from " + viewTable + " v join temp_adtxt a on a.Id=v.AdTxtId join temp_Keyword_L1 k on k.Id=v.KeywordId group by a.VendorId ,v.KeywordPId) vin on vn.DealerId=vin.DealerId and vn.KeywordPId=vin.KeywordPId ");
            sql.Append("left outer join (select a.VendorId as DealerId,v.KeywordPId,count(v.KeywordPId) Num  from " + clickTable + " v join temp_adtxt a on a.Id=v.AdTxtId join temp_Keyword_L1 k on k.Id=v.KeywordId group by a.VendorId ,v.KeywordPId) cn on vn.DealerId=cn.DealerId and vn.KeywordPId=cn.KeywordPId ");
            sql.Append("left outer join (select a.VendorId as DealerId,v.KeywordPId,count(distinct v.Ip) Num  from " + clickTable + " v join temp_adtxt a on a.Id=v.AdTxtId join temp_Keyword_L1 k on k.Id=v.KeywordId group by a.VendorId ,v.KeywordPId) cin on vn.DealerId=cin.DealerId and vn.KeywordPId=cin.KeywordPId limit 1");
            int port      = 10000;
            var socket    = new TSocket("192.168.87.64", port);
            var transport = new TBufferedTransport(socket);
            var proto     = new TBinaryProtocol(transport);
            var client    = new ThriftHive.Client(proto);

            transport.Open();
            client.execute(sql.ToString());
            var rows2 = client.fetchAll();

            transport.Close();


            rows2.ForEach(Console.WriteLine);
        }
예제 #26
0
        public static TProtocol CreateReadProtocol(Stream inputStream)
        {
            var trans = new TStreamClientTransport(inputStream, null);
            var proto = new TBinaryProtocol(trans);

            return(proto);
        }
예제 #27
0
        public void CreateTableTest()
        {
            //实例化Socket连接
            //transport = new TSocket("2.5.172.38", 30001);
            var transport = new TSocket("hbaseclient1");
            //实例化一个协议对象
            TProtocol tProtocol = new TBinaryProtocol(transport);

            string logtablename = "logs";

            using (var client = new HBase.Thrift.Hbase.Client(tProtocol))
            {
                transport.Open();
                client.createTable(Encoding.UTF8.GetBytes(logtablename), new List <ColumnDescriptor>
                {
                    new ColumnDescriptor {
                        Name = Encoding.UTF8.GetBytes("cjzf.vlogs")
                    }
                });

                var tables = client.getTableNames();
                foreach (var tb in tables)
                {
                    var tbname = Encoding.UTF8.GetString(tb);
                }
            }
        }
예제 #28
0
        static void Main(string[] args)
        {
            Console.Write("输入发送订单:");
            Console.ReadLine();

            using (var transport = new TSocket("localhost", 8885))
            {
                using (var protocol = new TBinaryProtocol(transport))
                {
                    using (var client = new PaymentService.Client(protocol))
                    {
                        transport.Open();

                        var record = new TrxnRecord()
                        {
                            TrxnId     = 10000,
                            TrxnName   = "Premium payment",
                            TrxnAmount = 5000,
                            TrxnType   = "1",
                            Remark     = "remark"
                        };

                        var result = client.Save(record);
                        Console.WriteLine(result);
                    }
                }
            }

            Console.ReadKey();
        }
예제 #29
0
        public override void startConnector()
        {
            try {
                lock (this) {
                    this.transport = new TSocket(this.getHost(), this.getPort());
                    this.transport.Open();
                    this.transport.Timeout = 1000;
                    TProtocol protocol = new TBinaryProtocol(this.transport);
                    this.client = new ExternalCom.Client(protocol);
                    if (this.client != null)
                    {
                        setConnected(true);
                        //	Debug.Log ("Connected to " + this.getHost () + " - " + this.getPort ());

                        /*     extClientCheckConnectionThread = new Thread(new ThreadStart(ExternalClientConnectionCheckThread));
                         * extClientCheckConnectionThread.IsBackground = true;
                         * extClientCheckConnectionThread.Start();*/

                        if (extClientUpdateMessageThread == null)
                        {
                            extClientUpdateMessageThread = new Thread(new ThreadStart(ExternalClientUpdateMessageThread));
                            extClientUpdateMessageThread.IsBackground = true;
                            extClientUpdateMessageThread.Start();
                        }
                    }
                }
            } catch (Exception ex) {
                Console.Error.WriteLine("Exception " + ex.Message);
            }
        }
예제 #30
0
            public int Run()
            {
                int c = 0;

                try
                {
                    TTransport transport = new TSocket(Host, Port);
                    TProtocol  protocol  = new TBinaryProtocol(transport);
                    var        client    = new MultiplicationService.Client(protocol);

                    Console.WriteLine("Thrift client opening transport to {0} on port {1} ...", Host, Port);
                    transport.Open();


                    int a, b;
                    Console.Write("Enter 1st integer : ");
                    int.TryParse(Console.ReadLine(), out a);
                    Console.Write("Enter 2nd integer : ");
                    int.TryParse(Console.ReadLine(), out b);

                    c = client.multiply(a, b);

                    Console.WriteLine("{0} x {1} = {2}", a, b, c);
                    Console.WriteLine("Thrift client closing transport ...");
                    transport.Close();
                }
                catch (TApplicationException x)
                {
                    Console.WriteLine(x.StackTrace);
                }

                return(c);
            }
예제 #31
0
 public ExchangeServiceWrapper.Client GetClient(string uri,int timeout)
 {
     var transport = new THttpClient(new Uri(uri));
     if (timeout > 0) transport.ConnectTimeout = timeout;
     var protocol = new TBinaryProtocol(transport);
     return new ExchangeServiceWrapper.Client(protocol);
 }
예제 #32
0
 public DispatcherServiceWrapper.Client CreateDispatcherServiceClient(string uri, int timeout)
 {
     var transport = new THttpClient(new Uri(uri));
     var time = ConfigUtil.Instance.Timeout;
     if (time > 0)
     {
         transport.ConnectTimeout = time;
         transport.ReadTimeout = time;
     }
     var protocol = new TBinaryProtocol(transport);
     return new DispatcherServiceWrapper.Client(protocol);
 }