Exemplo n.º 1
0
        public IList <User> FindAll()
        {
            HeaderContext headercontext = HeaderOperater.GetServiceWcfHeader(OperationContext.Current);
            ITransaction  t             = Cat.GetProducer().NewTransaction("Data", "call wcf");
            IMessageTree  tree          = Cat.GetManager().ThreadLocalMessageTree;

            tree.RootMessageId   = headercontext.RootID;
            tree.ParentMessageId = headercontext.CorrelationState;
            tree.MessageId       = headercontext.ParentID;

            List <User> list = new List <User>();

            for (int i = 0; i < 30; i++)
            {
                User obj = new User();
                obj.UserID   = i + 1;
                obj.UserName = "******" + (i + 1);

                list.Add(obj);
            }

            Cat.GetProducer().LogEvent("Data In.Server", "FindAll", "0", "Success");
            t.Status = "B";
            t.Complete();

            return(list);
        }
Exemplo n.º 2
0
        /// <summary>
        /// 调用方法前 输出参数值
        /// </summary>
        /// <param name="operationName"></param>
        /// <param name="inputs"></param>
        /// <returns></returns>
        public object BeforeCall(string operationName, object[] inputs)
        {
            String guid = Guid.NewGuid().ToString();

            try
            {
                if (WcfBeforeCallEvent != null)
                {
                    OperationContext context      = OperationContext.Current;
                    string           AbsolutePath = "";
                    if (context != null)
                    {
                        //获取传递的自定义消息头
                        HeaderContext headercontext = HeaderOperater.GetServiceWcfHeader(context);
                        string        wcfappname    = HeaderOperater.GetServiceWcfAppNameHeader(context);
                        wcfappname = wcfappname == null ? "" : wcfappname;
                        if (headercontext != null)
                        {
                            guid = headercontext.CorrelationState;
                        }

                        //获取客户端请求的路径
                        AbsolutePath = context.EndpointDispatcher.EndpointAddress.Uri.AbsolutePath;

                        //获取客户端ip和端口
                        MessageProperties             properties = context.IncomingMessageProperties;
                        RemoteEndpointMessageProperty endpoint   = properties[RemoteEndpointMessageProperty.Name] as RemoteEndpointMessageProperty;
                        string client_ip = endpoint.Address;
                        //int client_port = endpoint.Port;

                        if (!AbsolutePath.Contains("Com/FrameWork/Helper/Wcf"))
                        {
                            Hashtable ht = new Hashtable();
                            ht.Add("ip", client_ip + "_" + wcfappname);
                            ht.Add("url", AbsolutePath);
                            ht.Add("operatename", operationName);
                            //MonitorData.Instance.UpdateOperateNums(client_ip, AbsolutePath, operationName);
                            Thread th = new Thread(new ParameterizedThreadStart(Run));
                            th.Start(ht);
                        }
                    }
                    WcfBeforeCallEvent(operationName, inputs, AbsolutePath, guid);

                    #region
                    //Console.WriteLine("返回操作开始:" + AbsolutePath + "/" + operationName);
                    //Console.WriteLine("*************调用操作编号:" + guid.ToString() + "**************");
                    //for (int i = 0; i < inputs.Length; i++)
                    //{

                    //    Type T = inputs[i].GetType();
                    //    Console.WriteLine("操作参数" + i.ToString() + "  类型为:" + T.ToString());
                    //    Console.WriteLine("操作参数" + i.ToString() + "  ToString为:" + inputs[i].ToString());
                    //    Console.WriteLine("操作参数" + i.ToString() + "  属性:");
                    //    PropertyInfo[] PIs = T.GetProperties();
                    //    foreach (PropertyInfo PI in PIs)
                    //    {
                    //        Console.Write(PI.Name + ":");
                    //        Console.WriteLine(PI.GetValue(inputs[i], null));
                    //    }

                    //}
                    #endregion
                }
            }
            catch { }

            return(guid);
        }