Beispiel #1
0
        protected void Page_Load(object sender, EventArgs e)
        {
            if (!IsPostBack)
            {
                string filename = Server.MapPath("~/config/catclient.xml");
                Cat.Initialize(filename);
                ITransaction t = Cat.GetProducer().NewTransaction("URL", "demo.aspx");
                IMessageTree tree = Cat.GetManager().ThreadLocalMessageTree;

                //创建传递的上下文信息
                HeaderContext context = new HeaderContext();
                context.AppName = "";
                context.CorrelationState = tree.MessageId;
                context.RootID = tree.RootMessageId == null ? tree.MessageId : tree.RootMessageId;
                context.ParentID = Cat.GetManager().CreateMessageId();
                context.Ip = "";
                HeaderOperater.SetClientWcfHeader(context);
                Cat.GetProducer().LogEvent("URL", "Call", "0", "Call Start...");
                Cat.GetProducer().LogEvent("RemoteCall", "PigeonRequest", "0", context.ParentID);

                IUserBll bll = WcfClient.GetProxy<IUserBll>();
                IList<User> list = bll.FindAll();

                Cat.GetProducer().LogEvent("URL", "Call", "0", "Call End...");

                //注:上下文信息必须在创建后清除
                HeaderOperater.ClearClientWcfHeader();
                t.Status = "A";
                t.Complete();

                this.GridView1.DataSource = list;
                this.GridView1.DataBind();
            }
        }
Beispiel #2
0
 /// <summary>
 /// 创建客户端消息头
 /// </summary>
 public static void SetClientWcfHeader(HeaderContext context)
 {
     if (context == null)
     {
         CallContext.LogicalSetData("msgheader", null);
         return;
     }
     MessageHeader msgheader = System.ServiceModel.Channels.MessageHeader.CreateHeader("HeaderContext", "session", context);
     //MessageHeader msgheader = MessageHeader.CreateHeader("HeaderContext", "session", context);
     CallContext.LogicalSetData("msgheader", msgheader);
 }
Beispiel #3
0
        /// <summary>
        /// 创建客户端消息头
        /// </summary>
        public static void SetClientWcfHeader(HeaderContext context)
        {
            if (context == null)
            {
                CallContext.LogicalSetData("msgheader", null);
                return;
            }
            MessageHeader msgheader = System.ServiceModel.Channels.MessageHeader.CreateHeader("HeaderContext", "session", context);

            //MessageHeader msgheader = MessageHeader.CreateHeader("HeaderContext", "session", context);
            CallContext.LogicalSetData("msgheader", msgheader);
        }