コード例 #1
0
        /// <summary>
        /// 前置拦截
        /// </summary>
        /// <param name="invocation">IInvocation</param>
        /// <param name="args">参数</param>
        protected override void PreProceed(IInvocation invocation, params object[] args)
        {
            //日志判断
            if (IsOperateLog)
            {
                ZhuJi.Log.IDAL.ILogging log = new ZhuJi.Log.NHibernateDAL.Logging();
                log.WriteEntry(string.Format("{0} {1}.{2}", "PreProceed", invocation.Method.DeclaringType, invocation.Method.Name));
            }

            //权限判断类
            if (IsPermission)
            {
                ZhuJi.UUMS.IDAL.IPermissionByMethods permission = new ZhuJi.UUMS.NHibernateDAL.PermissionByMethods();
                string className  = invocation.Method.DeclaringType.ToString();
                string methodName = invocation.Method.Name;
                if (permission.CheckClassMethod(className, methodName, GlobalHelper.RolesId))
                {
                    base.PreProceed(invocation, args);
                }
                else
                {
                    throw new Exception("您没有相应权限!");
                }
            }
            else
            {
                base.PreProceed(invocation, args);
            }
        }
コード例 #2
0
 /// <summary>
 /// 后置拦截
 /// </summary>
 /// <param name="invocation">IInvocation</param>
 /// <param name="returnValue">方法</param>
 /// <param name="arguments">参数</param>
 protected override void PostProceed(IInvocation invocation, ref object returnValue, params object[] arguments)
 {
     //日志判断
     if (IsOperateLog)
     {
         ZhuJi.Log.IDAL.ILogging log = new ZhuJi.Log.NHibernateDAL.Logging();
         log.WriteEntry(string.Format("{0} {1}.{2}", "PostProceed", invocation.Method.DeclaringType, invocation.Method.Name));
     }
     base.PostProceed(invocation, ref returnValue, arguments);
 }
コード例 #3
0
        /// <summary>
        /// 显示消息提示对话框,并进行页面后退
        /// </summary>
        /// <param name="ex">错误信息</param>
        public void ShowMessage(Exception ex)
        {
            ZhuJi.Log.IDAL.ILogging logging = new ZhuJi.Log.NHibernateDAL.Logging();
            logging.WriteException(ex);

            StringBuilder Builder = new StringBuilder();

            Builder.Append("<script language=\"javascript\" defer>");
            Builder.AppendFormat("alert(\"{0}\");", ex.Message.Replace("\r", "").Replace("\n", "\\r\\n"));
            Builder.Append("history.go(-1);");
            Builder.Append("</script>");
            ClientScriptManager cs = this.Page.ClientScript;

            cs.RegisterStartupScript(this.Page.GetType(), "message", Builder.ToString());
        }
コード例 #4
0
        /// <summary>
        /// 拦截
        /// </summary>
        /// <param name="invocation">IInvocation</param>
        /// <param name="args">参数</param>
        /// <returns></returns>
        public override object Intercept(IInvocation invocation, params object[] args)
        {
            try
            {
                PreProceed(invocation, args);

                object ret;
                //事务判断
                if (IsTransaction)
                {
                    using (TransactionScope ts = new TransactionScope())
                    {
                        try
                        {
                            ret = invocation.Proceed(args);
                            ts.Complete();
                        }
                        catch (Exception ex)
                        {
                            throw (ex);
                        }
                    }
                }
                else
                {
                    ret = invocation.Proceed(args);
                }

                PostProceed(invocation, ref ret, args);
                return(ret);
            }
            catch (Exception ex)
            {
                //日志判断
                if (IsErrorLog)
                {
                    ZhuJi.Log.IDAL.ILogging log = new ZhuJi.Log.NHibernateDAL.Logging();
                    log.WriteException(ex);
                }
                throw ex;
            }
        }
コード例 #5
0
        /// <summary>
        /// ��ʾ��Ϣ��ʾ�Ի��򣬲�����ҳ�����
        /// </summary>
        /// <param name="ex">������Ϣ</param>
        public void ShowMessage(Exception ex)
        {
            ZhuJi.Log.IDAL.ILogging logging = new ZhuJi.Log.NHibernateDAL.Logging();
            logging.WriteException(ex);

            StringBuilder Builder = new StringBuilder();
            Builder.Append("<script language=\"javascript\" defer>");
            Builder.AppendFormat("alert(\"{0}\");", ex.Message.Replace("\r", "").Replace("\n", "\\r\\n"));
            Builder.Append("history.go(-1);");
            Builder.Append("</script>");
            ClientScriptManager cs = this.Page.ClientScript;
            cs.RegisterStartupScript(this.Page.GetType(), "message", Builder.ToString());
        }
コード例 #6
0
        /// <summary>
        /// ����
        /// </summary>
        /// <param name="invocation">IInvocation</param>
        /// <param name="args">����</param>
        /// <returns></returns>
        public override object Intercept(IInvocation invocation, params object[] args)
        {
            try
            {
                PreProceed(invocation, args);

                object ret;
                //�����ж�
                if (IsTransaction)
                {
                    using (TransactionScope ts = new TransactionScope())
                    {
                        try
                        {
                            ret = invocation.Proceed(args);
                            ts.Complete();
                        }
                        catch (Exception ex)
                        {
                            throw (ex);
                        }
                    }
                }
                else
                {
                    ret = invocation.Proceed(args);
                }

                PostProceed(invocation, ref ret, args);
                return ret;
            }
            catch (Exception ex)
            {
                //��־�ж�
                if (IsErrorLog)
                {
                    ZhuJi.Log.IDAL.ILogging log = new ZhuJi.Log.NHibernateDAL.Logging();
                    log.WriteException(ex);
                }
                throw ex;
            }
        }
コード例 #7
0
        /// <summary>
        /// ǰ������
        /// </summary>
        /// <param name="invocation">IInvocation</param>
        /// <param name="args">����</param>
        protected override void PreProceed(IInvocation invocation, params object[] args)
        {
            //��־�ж�
            if (IsOperateLog)
            {
                ZhuJi.Log.IDAL.ILogging log = new ZhuJi.Log.NHibernateDAL.Logging();
                log.WriteEntry(string.Format("{0} {1}.{2}", "PreProceed", invocation.Method.DeclaringType, invocation.Method.Name));
            }

            //Ȩ���ж���
            if (IsPermission)
            {
                ZhuJi.UUMS.IDAL.IPermissionByMethods permission = new ZhuJi.UUMS.NHibernateDAL.PermissionByMethods();
                string className = invocation.Method.DeclaringType.ToString();
                string methodName = invocation.Method.Name;
                if (permission.CheckClassMethod(className, methodName, GlobalHelper.RolesId))
                {
                    base.PreProceed(invocation, args);
                }
                else
                {
                    throw new Exception("��û����ӦȨ�ޣ�");
                }
            }
            else
            {
                base.PreProceed(invocation, args);
            }
        }
コード例 #8
0
 /// <summary>
 /// ��������
 /// </summary>
 /// <param name="invocation">IInvocation</param>
 /// <param name="returnValue">����</param>
 /// <param name="arguments">����</param>
 protected override void PostProceed(IInvocation invocation, ref object returnValue, params object[] arguments)
 {
     //��־�ж�
     if (IsOperateLog)
     {
         ZhuJi.Log.IDAL.ILogging log = new ZhuJi.Log.NHibernateDAL.Logging();
         log.WriteEntry(string.Format("{0} {1}.{2}", "PostProceed", invocation.Method.DeclaringType, invocation.Method.Name));
     }
     base.PostProceed(invocation, ref returnValue, arguments);
 }