Beispiel #1
0
        protected ResponseResult <TReceiveType> PostJson <TReceiveType, TParameterType>(string remoteControllerName, string remoteActionName, TParameterType parameterInstance)
            where TReceiveType : class, new()
            where TParameterType : class, new()
        {
            if (string.IsNullOrEmpty(remoteControllerName))
            {
                throw new ArgumentNullException("remoteControllerName");
            }

            if (string.IsNullOrEmpty(remoteActionName))
            {
                throw new ArgumentNullException("remoteActionName");
            }

            var url        = bgApiServerUrl + remoteControllerName + "/" + remoteActionName;
            var parameters = ModelHelper.GetPropertyDictionary <TParameterType>(parameterInstance);

            if (parameters == null)
            {
                parameters = new Dictionary <string, string>();
            }

            return(RestSharpHelper.PostWithApplicationJson <ResponseResult <TReceiveType> >(
                       url, parameters, GetCertificationFilePath(), GetCertificationPwd()));
        }
Beispiel #2
0
        /// <summary>
        /// 访问远程服务器同名控制器的同名Action
        /// </summary>
        /// <typeparam name="TReceiveType"></typeparam>
        /// <param name="currentController"></param>
        /// <returns></returns>
        protected ResponseResult <TReceiveType> PostJsonWithSameControllerAction <TReceiveType>(Controller currentController)
            where TReceiveType : class, new()
        {
            var parameters = new Dictionary <string, string>();

            return(RestSharpHelper.PostWithApplicationJson <ResponseResult <TReceiveType> >(GetCurrentUrl(currentController), parameters, GetCertificationFilePath(), GetCertificationPwd()));
        }
Beispiel #3
0
        public PartialViewResult Menu()
        {
            using (var result = new ResponseResult <List <T_MENU> >())
            {
                //获取用户的角色信息
                var userId = GetLoginInfo().User.Id;
                //请求的参数
                var postParas = new Dictionary <string, string>()
                {
                    { "userId", userId.ToString() }
                };

                if (postParas.ContainsKey(DataKey.UserId) == false)
                {
                    postParas.Add(DataKey.UserId, GetLoginInfo().User.Id.ToString());
                }
                var reponseObj = RestSharpHelper.PostWithApplicationJson <ResponseResult <List <T_MENU> > >(GetCurrentUrl(this), postParas, GetCertificationFilePath(), GetCertificationPwd());
                //var menuString = HttpAsynchronousTool.CustomHttpWebRequestPost(GetCurrentUrl(this), postParas, GetCertificationFilePath(), GetCertificationPwd());
                if (reponseObj != null && reponseObj.IsSuccess)
                {
                    return(PartialView("MenuPartial", reponseObj.Entity));
                }

                return(PartialView("MenuPartial"));
            }
        }
Beispiel #4
0
        protected ResponseResult <TReceiveType> PostJsonWithSameControllerAction <TReceiveType, TParameterType>(Controller currentController, TParameterType parameterInstance)
            where TReceiveType : class, new()
            where TParameterType : class, new()
        {
            Dictionary <string, string> parameters = null;

            if (parameterInstance != null)
            {
                parameters = ModelHelper.GetPropertyDictionary <TParameterType>(parameterInstance);
            }

            if (parameters == null)
            {
                parameters = new Dictionary <string, string>();
            }

            if (!parameters.ContainsKey(DataKey.UserId))
            {
                parameters.Add(DataKey.UserId, GetLoginInfo().User.Id.ToString());
            }



            return(RestSharpHelper.PostWithApplicationJson <ResponseResult <TReceiveType> >(GetCurrentUrl(currentController), parameters, GetCertificationFilePath(), GetCertificationPwd()));
        }
Beispiel #5
0
        /// <summary>
        /// 子菜单列表显示
        /// </summary>
        /// <param name="input"></param>
        /// <returns></returns>
        public ActionResult GetChildrenMenu(MenuInput input)
        {
            //获取用户的角色信息
            var userId = GetLoginInfo().User.Id;
            //请求的参数
            var postParas = new Dictionary <string, string>()
            {
                { "userId", userId.ToString() }
            };

            postParas.Add("ParentId", input.ParentId.ToString());
            if (postParas.ContainsKey(DataKey.UserId) == false)
            {
                postParas.Add(DataKey.UserId, GetLoginInfo().User.Id.ToString());
            }
            var result  = RestSharpHelper.PostWithApplicationJson <ResponseResult <List <T_MENU> > >(GetCurrentUrl(this), postParas, GetCertificationFilePath(), GetCertificationPwd());
            var resultm = new { total = result.TotalNums, rows = result.Entity };

            return(Json(resultm, JsonRequestBehavior.AllowGet));
        }