コード例 #1
0
        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");
                    }
                }
            }
        }
コード例 #2
0
ファイル: Program.cs プロジェクト: Weidaicheng/ThriftDemo
        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();
        }
コード例 #3
0
    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
    }
コード例 #4
0
 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
 }
コード例 #5
0
 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();
   }
 }
コード例 #6
0
        public TrxnResult Save(TrxnRecord trxn)
        {
            Console.WriteLine(JsonMapper.ToJson(trxn));

            return(TrxnResult.SUCCESS);
        }
コード例 #7
0
 public IAsyncResult Begin_Save(AsyncCallback callback, object state, TrxnRecord trxn)
 {
   return send_Save(callback, state, trxn);
 }
コード例 #8
0
 public IAsyncResult send_Save(AsyncCallback callback, object state, TrxnRecord trxn)
コード例 #9
0
 public TrxnResult Save(TrxnRecord trxn)
 {
     Console.WriteLine("Log : TrxnName:{0}, TrxnAmount:{1}, Remark:{2}", trxn.TrxnName, trxn.TrxnAmount, trxn.Remark);
     return(TrxnResult.SUCCESS);
 }