Exemplo n.º 1
0
        /// <summary>将reques请求的参数封装到CorRefEntity对象中
        /// </summary>
        /// <param name="para"></param>
        /// <param name="request"></param>
        public static void FillCorRefEntity(RefRequestEntity para, HttpRequest request)
        {
            foreach (var key in request.Params.AllKeys)
            {
                para.Request.Add(key, request.Params[key]);

            }
        }
Exemplo n.º 2
0
        public RefRespondEntity Index4(RefRequestEntity param)
        {

             object AA = param.Request["A"];
             object BB = param.Request["B"];
             object CC = param.Request["C"];

            RefRespondEntity result = new RefRespondEntity(RespondType._String);
            result.ResultContext = View();
            object tt =   ViewBag.test;
            return result;
        }
Exemplo n.º 3
0
 public RefRespondEntity Index2(RefRequestEntity param)
 {
   var o1=  param.Request["qq"];
   var o2 = param.Request["addr"];
     RefRespondEntity result = new RefRespondEntity(RespondType._String);
     var M = new TestM(){A="aaa",B="gffff",C="fff"};
     M.A = HuberVariable.CurWebDir;
     ViewBag.abc = "ccc";
     ViewBag.test = "my test result";
     result.ResultContext = View("Index2", M);
     return result;
 }
Exemplo n.º 4
0
        /// <summary>
        /// 根据model设置传入参数
        /// </summary>
        /// <param name="routeValues"></param>
        /// <returns></returns>
        private static RefRequestEntity SetParamValue(object routeValues)
        {
            RefRequestEntity paras = new RefRequestEntity();

            Type t1 = routeValues.GetType();
            PropertyInfo[] pis = t1.GetProperties();
            foreach (PropertyInfo pi in pis)
            {
                paras.Request.Add(pi.Name, pi.GetValue(routeValues));

            }
            return paras;
        }
Exemplo n.º 5
0
        private static void Application_BeginRequest(object sender, EventArgs e)
        {

            HttpApplication application = sender as HttpApplication;
            HttpResponse respond = application.Response;
            HttpRequest request = application.Request;
            string url = request.Url.AbsolutePath.ToString();
            string _action = url.Substring(url.LastIndexOf("/") + 1);
            if (_action.IndexOf(".") < 0)//过滤非action请求
            {
                string controller = string.Empty;
                string action = string.Empty;
                // getUrlPathEntity(url, ref controller, ref action);

                Plugins plugin = GetPluginModel(url);
                if (plugin != null)
                {
                    controller = plugin.ControllerName;
                    action = plugin.ActionName;

                }


                if (controller != string.Empty && action != string.Empty)
                {

                    System.Type t = CurDomainAssembly.GetType(controller, false, true);
                    object dObj = Activator.CreateInstance(t);
                    System.Reflection.MethodInfo method = t.GetMethod(action);




                    RefRequestEntity paras = new RefRequestEntity();
                    //paras.CurPageRights = userRight;//设置本次请求的用户权限
                    #region 获取http参数
                    RequestHandle.FillCorRefEntity(paras, request);
                    #endregion
                    object result = method.Invoke(dObj, new object[] { paras });
                    RequestHandle.ResposeResult(respond, result);
                }
                else
                {
                    //respond.Write(FilterConfig.CODE404);
                }
            }
        }
Exemplo n.º 6
0
        // 请求拦截
        private void Application_BeginRequest(object sender, EventArgs e)
        {
            HttpApplication application = sender as HttpApplication;
            HttpResponse respond = application.Response;
            HttpRequest request = application.Request;
            string url = request.Url.AbsolutePath.ToString();
            //如果请求以“/plugins/”开头,表面我们需要对该请求做拦截处理了。
            if (url.ToLower().StartsWith("/plugins/"))
            {
                string action = url.Substring(url.LastIndexOf("/") + 1);
                //如果是非静态文件,即是action
                if (action.IndexOf(".") < 0)
                {
                    #region 匹配controller和action

                    var urlEntity = HuberPluginHandle.getUrlPathEntity(url.Substring(8), true);
                    #endregion
                    if (urlEntity != null && urlEntity.controller != null)
                    {
                        #region 获取路径中的插件名称等信息

                        #endregion
                        SandBoxDynamicLoader sandBox = HuberPluginHandle.getSandBox(urlEntity.pluginname, urlEntity.pluginversion);

                        if (sandBox != null)
                        {
                            List<RightEntity> userRight = new List<RightEntity>();
                            string uid = string.Empty;
                            int login = new UserBll().chekLogin(ref uid, false, userRight);
                            if (login == 2)//验证用户是否具有访问的权限
                            {
                                RefRequestEntity paras = new RefRequestEntity();
                                paras.PageRights = userRight;
                                paras.UserID = uid;
                                #region 获取http参数
                                RequestHandle.FillCorRefEntity(paras, request);
                                #endregion
                                //sandBox.InvokeMothod(urlEntity.controller, "InitChannel", paras)
                                var result = sandBox.InvokeMothod(urlEntity.controller, urlEntity.action, paras);
                                RequestHandle.ResposeResult(respond, result);

                            }
                            else if (login == 1)
                            {
                                RequestHandle.ResponseNoRight(request, respond);
                            }
                            else
                            {
                                RequestHandle.ResponseNoLogin(request, respond);
                            }

                        }
                    }
                    else
                    {
                        RequestHandle.ResponseNotfound(request, respond); ;
                    }

                    respond.End();
                }
            }
            else
            {
                if (!url.ToLower().Equals("/user/login"))
                {
                    string action = url.Substring(url.LastIndexOf("/") + 1);
                    if (action.IndexOf(".") < 0)
                    {
                        List<RightEntity> userRight = new List<RightEntity>();
                        string uid = string.Empty;
                        int login = new UserBll().chekLogin(ref uid, false, userRight);
                        if (login == 2)//验证用户是否具有访问的权限
                        {

                        }
                        else if (login == 1)
                        {
                            RequestHandle.ResponseNoRight(request, respond);
                        }
                        else
                        {
                            RequestHandle.ResponseNoLogin(request, respond);
                        }
                    }
                       
                }
            }

        }
Exemplo n.º 7
0
 public RefRespondEntity Index3(RefRequestEntity param)
 {
     RefRespondEntity result = new RefRespondEntity(RespondType._String);
     result.ResultContext = "我是INDEX3乱码";
     return result;
 }
Exemplo n.º 8
0
        //
        // GET: /Demo/

        public RefRespondEntity Index(RefRequestEntity param)
        {
            RefRespondEntity result = new RefRespondEntity(RespondType._Redirect);
            result.ResultContext = HuberVariable.CurWebUrl+ "/Demo/Index2";
            return result;
        }