/// <summary> /// 构造一个服务调用上下文 /// </summary> /// <param name="transaction">是否开启事务</param> /// <param name="logtrack">是否开启日志跟踪</param> public SoaServiceCallContext(bool transaction, bool logtrack) { this.Transaction = transaction; this.LogTrack = logtrack; //设置一个服务调用上下文的访问点,便于被感知 SoaServiceCallContext.context = this; }
static void Main(string[] args) { ServiceProxy proxy = new ServiceProxy(); using (SoaServiceCallContext soaContext = new SoaServiceCallContext(true, true)) { soaContext.BeginRecordLogTrackEvent += SoaContext_BeginRecordLogTrackEvent; soaContext.TransactionEndEvent += SoaContext_TransactionEndEvent; proxy.SetTicketPrice("29339", 300); proxy.UpdateTicketCache("29339", 350); } }