public string Get() { // RPC - use Thrift using (TTransport transport = new TSocket("192.168.0.92", 8885)) { using (TProtocol protocol = new TBinaryProtocol(transport)) { using (var serviceClient = new TestService.Client(protocol)) { transport.Open(); TrxnRecord record = new TrxnRecord { TrxnId = 10000001, TrxnName = "fxy", TrxnAmount = 12, TrxnType = "MM", Remark = "test rpc thrift" }; var result = serviceClient.Save(record); return(Convert.ToInt32(result) == 0 ? "Trxn Success" : "Trxn Failed"); } } } }
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(); }
public TrxnResult Save(TrxnRecord trxn) { #if !SILVERLIGHT send_Save(trxn); return recv_Save(); #else var asyncResult = Begin_Save(null, null, trxn); return End_Save(asyncResult); #endif }
public void send_Save(TrxnRecord trxn) #endif { oprot_.WriteMessageBegin(new TMessage("Save", TMessageType.Call, seqid_)); Save_args args = new Save_args(); args.Trxn = trxn; args.Write(oprot_); oprot_.WriteMessageEnd(); #if SILVERLIGHT return oprot_.Transport.BeginFlush(callback, state); #else oprot_.Transport.Flush(); #endif }
public void Read (TProtocol iprot) { iprot.IncrementRecursionDepth(); try { TField field; iprot.ReadStructBegin(); while (true) { field = iprot.ReadFieldBegin(); if (field.Type == TType.Stop) { break; } switch (field.ID) { case 1: if (field.Type == TType.Struct) { Trxn = new TrxnRecord(); Trxn.Read(iprot); } else { TProtocolUtil.Skip(iprot, field.Type); } break; default: TProtocolUtil.Skip(iprot, field.Type); break; } iprot.ReadFieldEnd(); } iprot.ReadStructEnd(); } finally { iprot.DecrementRecursionDepth(); } }
public TrxnResult Save(TrxnRecord trxn) { Console.WriteLine(JsonMapper.ToJson(trxn)); return(TrxnResult.SUCCESS); }
public IAsyncResult Begin_Save(AsyncCallback callback, object state, TrxnRecord trxn) { return send_Save(callback, state, trxn); }
public IAsyncResult send_Save(AsyncCallback callback, object state, TrxnRecord trxn)
public TrxnResult Save(TrxnRecord trxn) { Console.WriteLine("Log : TrxnName:{0}, TrxnAmount:{1}, Remark:{2}", trxn.TrxnName, trxn.TrxnAmount, trxn.Remark); return(TrxnResult.SUCCESS); }