/// <summary>
        /// Begin NH transaction and also records the method name being called.
        /// </summary>
        /// <param name="instanceContext"></param>
        /// <param name="channel"></param>
        /// <param name="message"></param>
        /// <returns></returns>
        object ICallContextInitializer.BeforeInvoke(
			System.ServiceModel.InstanceContext instanceContext,
			System.ServiceModel.IClientChannel channel,
			System.ServiceModel.Channels.Message message)
        {
            if (instanceContext.GetServiceInstance() is ServiceBase)
            {
                try
                {
                    //try to catch the client request whether we should bypass the 2nd level cache.
                    if (OperationContext.Current.IncomingMessageHeaders.FindHeader("token", "ns") >= 0)
                    {
                        _isChange = true;
                        bool? bypass2ndLevelCache = OperationContext.Current.IncomingMessageHeaders.GetHeader<bool>("token", "ns");
                        if (bypass2ndLevelCache.HasValue && bypass2ndLevelCache.Value)
                        {
                            NHibernateSessionManager.Instance.EnforceRefreshData();
                        }
                    }

                }
                catch(Exception ex)
                {
                    //just ignore and we'll use the default 2nd level cache setting
                }
                //NHibernateSessionManager.Instance.IsTransactionRequired = true;
            }
            return null;
        }
Example #2
0
        public object AfterReceiveRequest(ref System.ServiceModel.Channels.Message request,
            System.ServiceModel.IClientChannel channel, System.ServiceModel.InstanceContext instanceContext)
        {
            //权限认证
            //if (ContextSession.ContainsKey(OperationContext.Current.SessionId))
            //{

            //}
            //else if()
            //{
            //    throw new FaultException("权限认证失败");
            //}
            string session = channel.SessionId;
            Mobao.M.Utility.LogHelper.Instance.Info(session + "--" );
            Stopwatch sw = new System.Diagnostics.Stopwatch();
            sw.Start();
            string serviceName = instanceContext.GetServiceInstance().GetType().ToString();
            Mobao.M.Utility.LogHelper.Instance.Info(serviceName + "服务接收请求,开始处理");
            return new Tuple<Stopwatch, string>(sw, serviceName);
        }