Exemple #1
0
        private void InvokeClass()
        {
            Type t = null;

            #region 处理Ajax请求
            //从Url来源页找
            if (context.Request.UrlReferrer == null)
            {
                WriteError("Illegal request!");
            }
            else if (!IsExistsSafeKey() && WebHelper.IsCheckToken())// 仅检测需要登陆的页面
            {
                string path = context.Request.UrlReferrer.PathAndQuery;
                if (path == "/")
                {
                    path = "/index.html";
                }
                WriteError(path);//"Page timeout,please reflesh page!"
            }
            //AjaxController是由页面的后两个路径决定了。
            string[] items     = context.Request.UrlReferrer.LocalPath.TrimStart('/').Split('/');
            string   className = Path.GetFileNameWithoutExtension(items[items.Length - 1].ToLower());
            //从来源页获取className 可能是/aaa/bbb.shtml 先找aaa.bbb看看有木有,如果没有再找bbb
            if (items.Length > 1)
            {
                t = InvokeLogic.GetType(items[items.Length - 2].ToLower() + "." + className);
            }
            if (t == null)
            {
                t = InvokeLogic.GetDefaultType();
                if (t == null)
                {
                    WriteError("You need to create a controller for coding !");
                }
            }
            #endregion


            try
            {
                object o = Activator.CreateInstance(t);//实例化
                t.GetMethod("ProcessRequest").Invoke(o, new object[] { context });
            }
            catch (ThreadAbortException e)
            {
                //ASP.NET 的机制就是通过异常退出线程(不要觉的奇怪)
            }
            catch (Exception err)
            {
                WriteError(err.Message);
            }
        }
Exemple #2
0
 private void InvokeClass()
 {
     if (context.Request.Url.LocalPath.EndsWith("/ajax.html")) // 反射Url启动
     {
         string className = CommonHelper.Query <string>("sys_classname");
         if (string.IsNullOrEmpty(className))//看是否存在
         {
             //从Url来源页找
             if (context.Request.UrlReferrer == null)
             {
                 WriteError("非法请求!");
             }
             Type     t     = null;
             string[] items = context.Request.UrlReferrer.LocalPath.Split('/');
             className = Path.GetFileNameWithoutExtension(items[items.Length - 1].ToLower());
             //从来源页获取className 可能是/aaa/bbb.shtml 先找aaa.bbb看看有木有,如果没有再找bbb
             if (items.Length > 1)
             {
                 t = InvokeLogic.GetType(items[items.Length - 2].ToLower() + "." + className);
             }
             if (t == null)
             {
                 WriteError("找不到对应的请求逻辑!");
             }
             try
             {
                 object o = Activator.CreateInstance(t);//实例化
                 t.GetMethod("ProcessRequest").Invoke(o, new object[] { context });
             }
             catch (ThreadAbortException e)
             {
             }
             catch (Exception err)
             {
                 WriteError(err.Message);
             }
         }
     }
 }
        internal static IExcelConfig GetExcelConfigExtend()
        {
            if (isUseInterObj)
            {
                return(ExcelConfigExtend.Instance);
            }
            IExcelConfig config   = null;
            Assembly     assembly = InvokeLogic.GetAssembly();

            if (assembly != null)
            {
                object o = assembly.CreateInstance(InvokeLogic.GetClassFullName("Sys.ExcelConfigExtend"));
                if (o != null && o is IExcelConfig)
                {
                    config = o as IExcelConfig;
                }
            }
            if (config == null)
            {
                isUseInterObj = true;
                return(ExcelConfigExtend.Instance);
            }
            return(config);
        }
Exemple #4
0
        private void InvokeClass()
        {
            string localPath  = context.Request.Url.LocalPath;
            Type   t          = null;
            bool   needInvoke = false;

            if (localPath.EndsWith("/ajax.html")) // 反射Url启动
            {
                #region 处理Ajax请求
                //从Url来源页找
                if (context.Request.UrlReferrer == null)
                {
                    WriteError("Illegal request!");
                }
                else if (!IsExistsSafeKey())
                {
                    WriteError("Page timeout,please reflesh page!");
                }
                //AjaxController是由页面的后两个路径决定了。
                string[] items     = context.Request.UrlReferrer.LocalPath.Split('/');
                string   className = Path.GetFileNameWithoutExtension(items[items.Length - 1].ToLower());
                //从来源页获取className 可能是/aaa/bbb.shtml 先找aaa.bbb看看有木有,如果没有再找bbb
                if (items.Length > 1)
                {
                    t = InvokeLogic.GetType(items[items.Length - 2].ToLower() + "." + className, 0);
                }
                else
                {
                    t = InvokeLogic.GetDefaultType(0);
                }
                needInvoke = true;
                #endregion
            }
            else if (localPath.IndexOf(".") == -1) // 处理Mvc请求
            {
                needInvoke = true;
                string[] items     = localPath.Trim('/').Split('/');
                string   className = items[0];
                if (RouteConfig.RouteMode == 2)
                {
                    className = items.Length > 1 ? items[1] : "";
                }
                t = InvokeLogic.GetType(className, 1);
            }
            if (needInvoke)
            {
                if (t == null)
                {
                    WriteError("You need a controller for coding if you want to use Taurus.MVC! else go to <a href='/login.html'>login.html</a>");
                }
                try
                {
                    object o = Activator.CreateInstance(t);//实例化
                    t.GetMethod("ProcessRequest").Invoke(o, new object[] { context });
                }
                catch (ThreadAbortException e)
                {
                    //ASP.NET 的机制就是通过异常退出线程(不要觉的奇怪)
                }
                catch (Exception err)
                {
                    WriteError(err.Message);
                }
            }
        }