Exemple #1
0
        public void PreProcess(Microsoft.Practices.Unity.InterceptionExtension.IMethodInvocation input)
        {
            ViewData   = (input.Target as WebHttpController).ViewData;
            _oleDb     = (input.Target as WebHttpController).oleDb;
            _container = (input.Target as WebHttpController).GetUnityContainer();
            _cache     = (input.Target as WebHttpController).GetCache();

            sessionData = (input.Target as WebHttpController).sessionData;
            PutOutData  = (input.Target as WebHttpController).PutOutData;
            ParamsData  = (input.Target as WebHttpController).ParamsData;
            FormData    = (input.Target as WebHttpController).FormData;
            ClearKey    = (input.Target as WebHttpController).ClearKey;
            LoadViewData();

            string filepath = GetFilePath();

            //FileInfo fileinfo = new FileInfo(AppGlobal.AppRootPath+filepath);
            //if (fileinfo.Exists == false)
            //    throw new Exception(fileinfo.Name + "文件不存在!");
            //string html = File.ReadAllText(fileinfo.FullName);
            //RazorEngine.Razor.Compile(html, filepath);
            if (ViewData.ContainsKey("Razor_Include") == false)
            {
                ViewData.Add("Razor_Include", filepath);
            }
            else
            {
                string paths = ViewData["Razor_Include"].ToString();
                ViewData["Razor_Include"] = paths + "|" + filepath;
            }
        }
Exemple #2
0
        public void PreProcess(Microsoft.Practices.Unity.InterceptionExtension.IMethodInvocation input)
        {
            ViewData   = (input.Target as WebHttpController).ViewData;
            _oleDb     = (input.Target as WebHttpController).oleDb;
            _container = (input.Target as WebHttpController).GetUnityContainer();
            _cache     = (input.Target as WebHttpController).GetCache();

            sessionData = (input.Target as WebHttpController).sessionData;
            PutOutData  = (input.Target as WebHttpController).PutOutData;
            ParamsData  = (input.Target as WebHttpController).ParamsData;
            FormData    = (input.Target as WebHttpController).FormData;
            ClearKey    = (input.Target as WebHttpController).ClearKey;
            LoadViewData();
        }
        public void PreProcess(Microsoft.Practices.Unity.InterceptionExtension.IMethodInvocation input)
        {
            List <AbstractDatabase> _RdbList = ((IbindDb)input.Target).GetMoreDb();
            AbstractDatabase        Rdb      = ((IbindDb)input.Target).GetDb();

            if (_RdbList == null)
            {
                Rdb.BeginTransaction();
            }
            else
            {
                foreach (AbstractDatabase db in _RdbList)
                {
                    db.BeginTransaction();
                }
            }
        }
        public override Exception HandlerException(Microsoft.Practices.Unity.InterceptionExtension.IMethodInvocation input, Exception exception)
        {
            if (exception is WebFaultException <ExceptionDetail> )
            {
                string note = FormmatException(exception.StackTrace, exception.Message);
                ExceptionLog.Write(note);
                throw exception;
            }
            if (!(exception is GenericException))
            {
                exception = new GenericException(exception);
                string notepad = FormmatException(exception.StackTrace, exception.Message);
                ExceptionLog.Write(notepad);
            }
            ExceptionDetail detail = new ExceptionDetail(exception);

            var result = new WebFaultException <ExceptionDetail>(detail, HttpStatusCode.BadRequest);

            throw result;
        }
        public void PostProcess(Microsoft.Practices.Unity.InterceptionExtension.IMethodInvocation input, Microsoft.Practices.Unity.InterceptionExtension.IMethodReturn result)
        {
            List <AbstractDatabase> _RdbList = ((IbindDb)input.Target).GetMoreDb();
            AbstractDatabase        Rdb      = ((IbindDb)input.Target).GetDb();

            if (_RdbList == null)
            {
                if (result.Exception == null)
                {
                    Rdb.CommitTransaction();
                }
                else
                {
                    Rdb.RollbackTransaction();
                }
            }
            else
            {
                List <AbstractDatabase> RdbList = new List <AbstractDatabase>();
                foreach (AbstractDatabase db in _RdbList)
                {
                    RdbList.Add(db);
                }
                RdbList.Reverse();//反序

                if (result.Exception == null)
                {
                    foreach (AbstractDatabase db in RdbList)
                    {
                        db.CommitTransaction();
                    }
                }
                else
                {
                    foreach (AbstractDatabase db in RdbList)
                    {
                        db.RollbackTransaction();
                    }
                }
            }
        }
Exemple #6
0
        public override Exception HandlerException(Microsoft.Practices.Unity.InterceptionExtension.IMethodInvocation input, Exception exception)
        {
            //if (exception is GenericException)
            //    exception = exception;

            if (exception is WebFaultException <ExceptionDetail> )
            {
                throw exception;
            }

            if (!(exception is GenericException))
            {
                exception = new GenericException(exception);
            }

            ExceptionDetail detail = new ExceptionDetail(exception);


            var result = new WebFaultException <ExceptionDetail>(detail, HttpStatusCode.BadRequest);

            throw result;
        }
Exemple #7
0
        public override Microsoft.Practices.Unity.InterceptionExtension.IMethodReturn Invoke(Microsoft.Practices.Unity.InterceptionExtension.IMethodInvocation input, Microsoft.Practices.Unity.InterceptionExtension.GetNextInterceptionBehaviorDelegate getNext)
        {
            //方法执行前
            var methodReturn = getNext().Invoke(input, getNext);

            //方法执行后
            if (methodReturn.Exception != null)
            {
                //这里显示打印异常信息
            }
            return(methodReturn);
        }
 public override Exception OnException(Microsoft.Practices.Unity.InterceptionExtension.IMethodInvocation input, Exception ex)
 {
     throw ex;
 }
 public override void OnRelease(Microsoft.Practices.Unity.InterceptionExtension.IMethodInvocation input)
 {
     Console.WriteLine("OnRelease");
 }
Exemple #10
0
 public UnityMethodInvocationParameter(IMethodInvocation invocation, int parameterIndex)
 {
     _invocation     = invocation;
     _parameterIndex = parameterIndex;
 }
Exemple #11
0
 public void PostProcess(Microsoft.Practices.Unity.InterceptionExtension.IMethodInvocation input, Microsoft.Practices.Unity.InterceptionExtension.IMethodReturn result)
 {
     //throw new NotImplementedException();
 }
Exemple #12
0
 public override void AfterCall(Microsoft.Practices.Unity.InterceptionExtension.IMethodInvocation input)
 {
     Console.WriteLine("AfterMethod");
 }
Exemple #13
0
 /// <summary>
 /// 后处理
 /// </summary>
 /// <param name="input"></param>
 /// <param name="result"></param>
 public void PostProcess(Microsoft.Practices.Unity.InterceptionExtension.IMethodInvocation input, Microsoft.Practices.Unity.InterceptionExtension.IMethodReturn result)
 {
     LogHelper.EndTrace(trace);
 }
Exemple #14
0
 /// <summary>
 /// 前处理
 /// </summary>
 /// <param name="input"></param>
 public void PreProcess(Microsoft.Practices.Unity.InterceptionExtension.IMethodInvocation input)
 {
     trace = LogHelper.StartTrace();
 }