예제 #1
0
파일: UserBll.cs 프로젝트: cashcat/wcf-2
        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);
        }
예제 #2
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();
            }
        }
예제 #3
0
	void Awake() {
		curState = null;
		Menu = new MenuContext( this );
		Character = new CharacterContext( this );
		Map = new MapContext( this );
		EnterName = new EnterNameContext( this );
		MatchScore = new MatchScore( this );
		Header = new HeaderContext( this );
	}
예제 #4
0
        public HeaderContext header()
        {
            HeaderContext _localctx = new HeaderContext(_ctx, State);

            EnterRule(_localctx, 8, RULE_header);
            try {
                EnterOuterAlt(_localctx, 1);
                {
                    State = 42; Match(DIGIT);
                    State = 43; Match(NEWLINE);
                }
            }
            catch (RecognitionException re) {
                _localctx.exception = re;
                _errHandler.ReportError(this, re);
                _errHandler.Recover(this, re);
            }
            finally {
                ExitRule();
            }
            return(_localctx);
        }
예제 #5
0
    public HeaderContext header()
    {
        HeaderContext _localctx = new HeaderContext(Context, State);

        EnterRule(_localctx, 8, RULE_header);
        try {
            EnterOuterAlt(_localctx, 1);
            {
                State = 49; Match(HeaderOpenTag);
                State = 50; headerContent();
                State = 51; Match(HeaderCloseTag);
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            ErrorHandler.ReportError(this, re);
            ErrorHandler.Recover(this, re);
        }
        finally {
            ExitRule();
        }
        return(_localctx);
    }
예제 #6
0
    public HeaderContext header()
    {
        HeaderContext _localctx = new HeaderContext(Context, State);

        EnterRule(_localctx, 2, RULE_header);
        int _la;

        try {
            EnterOuterAlt(_localctx, 1);
            {
                {
                    State = 38; _localctx.x = x_field();
                    _localctx.referenceNumber = _localctx.x.referenceNumber;
                }
                {
                    State           = 41; _localctx.t = t_field();
                    _localctx.title = _localctx.t.title;
                }
                State = 49;
                ErrorHandler.Sync(this);
                _la = TokenStream.La(1);
                while ((((_la) & ~0x3f) == 0 && ((1L << _la) & ((1L << MField) | (1L << QField) | (1L << LFieldHeader))) != 0))
                {
                    {
                        State = 47;
                        switch (TokenStream.La(1))
                        {
                        case MField:
                        {
                            State = 44; _localctx.m = m_field();
                        }
                        break;

                        case LFieldHeader:
                        {
                            State = 45; _localctx.l = l_field();
                        }
                        break;

                        case QField:
                        {
                            State = 46; _localctx.q = q_field();
                        }
                        break;

                        default:
                            throw new NoViableAltException(this);
                        }
                    }
                    State = 51;
                    ErrorHandler.Sync(this);
                    _la = TokenStream.La(1);
                }
                {
                    State = 52; _localctx.k = k_field();

                    _localctx.tonality = Tonality.parse(_localctx.k.tonality_str);
                    noteParser.setTonality(_localctx.tonality);
                }
            }
        }
        catch (RecognitionException re) {
            _localctx.exception = re;
            ErrorHandler.ReportError(this, re);
            ErrorHandler.Recover(this, re);
        }
        finally {
            ExitRule();
        }
        return(_localctx);
    }
예제 #7
0
 public HeaderManager(HeaderContext context)
 {
     _context = context;
 }
예제 #8
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);
        }
예제 #9
0
 public HomeController(HeaderContext context)
 {
     this.Context = context;
 }
	public HeaderContext header() {
		HeaderContext _localctx = new HeaderContext(Context, State);
		EnterRule(_localctx, 4, RULE_header);
		int _la;
		try {
			State = 39;
			switch (TokenStream.La(1)) {
			case T__1:
				EnterOuterAlt(_localctx, 1);
				{
				State = 26; Match(T__1);
				State = 27; expression();
				}
				break;
			case T__6:
			case T__7:
			case ID:
				EnterOuterAlt(_localctx, 2);
				{
				State = 28; expression();
				State = 33;
				ErrorHandler.Sync(this);
				_la = TokenStream.La(1);
				while (_la==T__2) {
					{
					{
					State = 29; Match(T__2);
					State = 30; expression();
					}
					}
					State = 35;
					ErrorHandler.Sync(this);
					_la = TokenStream.La(1);
				}
				State = 36; Match(T__1);
				State = 37; expression();
				}
				break;
			default:
				throw new NoViableAltException(this);
			}
		}
		catch (RecognitionException re) {
			_localctx.exception = re;
			ErrorHandler.ReportError(this, re);
			ErrorHandler.Recover(this, re);
		}
		finally {
			ExitRule();
		}
		return _localctx;
	}