Exemple #1
0
        public JsonResult GetAreaChild(string ParentAId)
        {
            var postParas = new Dictionary <string, string>();

            postParas.Add("ParentAId", ParentAId);
            //证书的路径
            var certification = GetCertificationFilePath();
            //证书的密码
            var certificationPwd = GetCertificationPwd();

            if (postParas.ContainsKey(DataKey.UserId) == false)
            {
                postParas.Add(DataKey.UserId, GetLoginInfo().User.Id.ToString());
            }
            var responseResult = RestSharpHelper.PostWithStandard <ResponseResult <List <AreaViewModel> > >(GetCurrentUrl(this), postParas, GetCertificationFilePath(), GetCertificationPwd());

            if (responseResult != null && responseResult.IsSuccess)
            {
                return(new JsonResultEx(responseResult));
            }
            else
            {
                return(new JsonResultEx(new List <AreaViewModel>()));
            }
        }
        protected ResponseResult <TReceiveType> PostStandardWithSameControllerAction <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.PostWithStandard <ResponseResult <TReceiveType> >(
                       url, parameters, GetCertificationFilePath(), GetCertificationPwd()));
        }
Exemple #3
0
        protected ResponseResult <TReceiveType> PostStandardWithControllerAction <TReceiveType>(string remoteControllerName, string remoteActionName, Dictionary <string, string> parameters)
            where TReceiveType : class, new()
        {
            if (string.IsNullOrEmpty(remoteControllerName))
            {
                throw new ArgumentNullException("remoteControllerName");
            }

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

            var url = bgApiServerUrl + remoteControllerName + "/" + remoteActionName;

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

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

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

            return(RestSharpHelper.PostWithStandard <ResponseResult <TReceiveType> >(GetCurrentUrl(currentController), parameters, GetCertificationFilePath(), GetCertificationPwd()));
        }
Exemple #5
0
        protected ResponseResult <TReceiveType> PostStandardWithSameControllerAction <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.PostWithStandard <ResponseResult <TReceiveType> >(GetCurrentUrl(currentController), parameters, GetCertificationFilePath(), GetCertificationPwd()));
        }
        public ActionResult List(int pageIndex = 1, int pageSize = 10)
        {
            WhereModel wheremodel;
            Dictionary <string, string> postParas;

            GetSearchParameters(pageIndex, pageSize, out wheremodel, out postParas);
            var responseObj = RestSharpHelper.PostWithStandard <ResponseResult <UserModelWithNoPager> >(GetCurrentUrl(this), postParas, GetCertificationFilePath(), GetCertificationPwd());

            if (responseObj != null)
            {
                if (responseObj.IsSuccess)
                {
                    var usermodel = new UserModel();
                    usermodel.Pager                = new PagedList <string>(new string[0], responseObj.PageIndex, responseObj.PageSize, (int)responseObj.TotalNums);
                    usermodel.PendingAuditList     = responseObj.Entity.PendingAuditList;
                    usermodel.Wheremodel           = wheremodel;
                    ViewBag.IsSuperOrAdministrator = GetLoginInfo().IsSuperOrAdministrator;
                    return(View(usermodel));
                }
                else
                {
                    ThrowException(responseObj.State.Id, responseObj.Message);
                }
            }
            return(View());
        }
Exemple #7
0
        public ActionResult ApproveForOperator(long verificationId, Dictionary <int, int> demandLevelInfoList)
        {
            var auditUser = GetLoginInfo();

            if (auditUser == null)
            {
                return(null);
            }
            long auditUserId = GetLoginInfo().User.Id;

            var postParas = new Dictionary <string, string>()
            {
                { "verificationId", verificationId.ToString() },
                { "UserId", auditUserId.ToString() }
            };

            for (int i = 0; i < demandLevelInfoList.Count; i++)
            {
                var keyValuePair = demandLevelInfoList.ElementAt(i);
                postParas.Add("demandLevelInfoList[" + i + "].Key", keyValuePair.Key.ToString());
                postParas.Add("demandLevelInfoList[" + i + "].Value", keyValuePair.Value.ToString());
            }

            //证书的路径
            var certification = GetCertificationFilePath();
            //证书的密码
            var certificationPwd = GetCertificationPwd();

            if (postParas.ContainsKey(DataKey.UserId) == false)
            {
                postParas.Add(DataKey.UserId, GetLoginInfo().User.Id.ToString());
            }
            var responseResult = RestSharpHelper.PostWithStandard <ResponseResult <RoleStateViewModel> >(GetPostUrl("ApproveForOperator"), postParas, GetCertificationFilePath(), GetCertificationPwd());

            if (responseResult == null)
            {
                return(RedirectToAction("List"));
            }
            if (!responseResult.IsSuccess)
            {
                TempData["Error"] = responseResult.Message;
                return(RedirectToAction("Detail", new { verificationId, roleId = RoleType.Farmer }));
            }
            else
            {
                TempData["Message"] = responseResult.Message;
            }
            return(RedirectToAction("List"));
        }
Exemple #8
0
        /// <summary>
        /// 访问远程服务器同名控制器的同名Action
        /// </summary>
        /// <typeparam name="TReceiveType"></typeparam>
        /// <typeparam name="TParameterType"></typeparam>
        /// <param name="currentController"></param>
        /// <param name="parameters"></param>
        /// <returns></returns>
        protected ResponseResult <TReceiveType> PostStandardWithSameControllerAction <TReceiveType>(Controller currentController, Dictionary <string, string> parameters)
            where TReceiveType : class, new()
        {
            if (parameters == null)
            {
                parameters = new Dictionary <string, string>();
            }
            var currentUrl = "/" + (currentController.RouteData.Values["controller"].ToString() + "/" + currentController.RouteData.Values["action"]).ToLower();

            if (!parameters.ContainsKey(DataKey.UserId) && currentUrl != "/account/login")
            {
                parameters.Add(DataKey.UserId, GetLoginInfo().User.Id.ToString());
            }
            return(RestSharpHelper.PostWithStandard <ResponseResult <TReceiveType> >(GetCurrentUrl(currentController), parameters, GetCertificationFilePath(), GetCertificationPwd()));
        }
Exemple #9
0
        public JsonResult CarouselPictures(CarouselPictureSearchInput input)
        {
            var responseResult = RestSharpHelper.PostWithStandard <ResponseResult <List <CarouselPictureOutput> > >(GetCurrentUrl(this), GetPostParameters(), GetCertificationFilePath(), GetCertificationPwd());

            if (responseResult.IsSuccess)
            {
                if (responseResult.IsSuccess && responseResult.Entity != null)
                {
                    var articBasePath = ConfigHelper.GetAppSetting(DataKey.ArticleStaticPageBasePath);
                    foreach (var article in responseResult.Entity)
                    {
                        article.ArticleUrl = articBasePath + article.ArticleUrl;
                    }
                }
            }
            return(new JsonResultEx(responseResult));
        }
Exemple #10
0
        public JsonResult ArticleList(ArticleListSearchInput input)
        {
            var responseResult = RestSharpHelper.PostWithStandard <ResponseResult <List <ArticleListSearchOutput> > >(GetCurrentUrl(this), GetPostParameters(), GetCertificationFilePath(), GetCertificationPwd());

            if (responseResult.IsSuccess && responseResult.Entity != null)
            {
                var articleBaseHost = ConfigHelper.GetAppSetting(DataKey.ArticleStaticPageBasePath);
                foreach (var article in responseResult.Entity)
                {
                    article.Url = articleBaseHost + article.Url;
                    if (!(article.PictureUrl.IndexOf(Request.Url.Authority) > -1))
                    {
                        article.PictureUrl = "";
                    }
                }
            }
            return(new JsonResultEx(responseResult));
        }
Exemple #11
0
        public ActionResult Reject(long verificationId, RoleType roleType)
        {
            var auditUser = GetLoginInfo();

            if (auditUser == null)
            {
                return(null);
            }
            long auditUserId = auditUser.User.Id;
            var  postParas   = new Dictionary <string, string>()
            {
                { "verificationId", verificationId.ToString() },
                { "roleType", roleType.ToString() },
                { "UserId", auditUserId.ToString() }
            };

            //证书的路径
            var certification = GetCertificationFilePath();
            //证书的密码
            var certificationPwd = GetCertificationPwd();

            if (postParas.ContainsKey(DataKey.UserId) == false)
            {
                postParas.Add(DataKey.UserId, GetLoginInfo().User.Id.ToString());
            }
            var responseResult = RestSharpHelper.PostWithStandard <ResponseResult <RoleStateViewModel> >(GetCurrentUrl(this), postParas, GetCertificationFilePath(), GetCertificationPwd());

            if (responseResult != null && responseResult.IsSuccess)
            {
                TempData["Message"] = responseResult.Message;
                return(RedirectToAction("List"));
            }
            else
            {
                TempData["Error"] = responseResult.Message;
                return(RedirectToAction("Detail", new { responseResult.Entity.verificationId, roleId = (RoleType)responseResult.Entity.roleId }));
            }
        }
Exemple #12
0
        public ActionResult ApproveForFarmer(long verificationId, byte star = 1)
        {
            var auditUser = GetLoginInfo();

            if (auditUser == null)
            {
                return(null);
            }
            long auditUserId = auditUser.User.Id;
            var  postParas   = new Dictionary <string, string>()
            {
                { "verificationId", verificationId.ToString() },
                { "star", star.ToString() },
                { "UserId", auditUserId.ToString() }
            };

            if (postParas.ContainsKey(DataKey.UserId) == false)
            {
                postParas.Add(DataKey.UserId, GetLoginInfo().User.Id.ToString());
            }
            var responseResult = RestSharpHelper.PostWithStandard <ResponseResult <RoleStateViewModel> >(GetPostUrl("ApproveForFarmer"), postParas, GetCertificationFilePath(), GetCertificationPwd());

            if (responseResult == null)
            {
                return(RedirectToAction("List"));
            }
            if (!responseResult.IsSuccess)
            {
                TempData["Error"] = responseResult.Message;
                return(RedirectToAction("Detail", new { verificationId, roleId = RoleType.Farmer }));
            }
            else
            {
                TempData["Message"] = responseResult.Message;
            }
            return(RedirectToAction("List"));
        }
Exemple #13
0
        public ActionResult Detail(int verificationId, RoleType roleId)
        {
            var userId = GetLoginInfo().User.Id;

            var    roleType     = (RoleType)roleId;
            string viewName     = string.Empty;
            string remoteApiUrl = PageConfig.GetRemoteApiUrl();//获取APP接口服务的地址

            var postParas = new Dictionary <string, string>()
            {
                { "UserId", userId.ToString() },
                { "verificationId", verificationId.ToString() },
                { "roleId", roleType.ToString() },
                { "remoteApiUrl", remoteApiUrl }
            };

            object viewModel = null;

            if (postParas.ContainsKey(DataKey.UserId) == false)
            {
                postParas.Add(DataKey.UserId, GetLoginInfo().User.Id.ToString());
            }

            switch (roleType)
            {
            case RoleType.Farmer:
                viewName = "Farmer_Detail";
                var responseResult = RestSharpHelper.PostWithStandard <ResponseResult <FarmerVerificationInfoViewModel> >(GetCurrentUrl(this), postParas, GetCertificationFilePath(), GetCertificationPwd());
                if (responseResult != null && responseResult.IsSuccess)
                {
                    viewModel = responseResult.Entity;
                }
                else
                {
                    ThrowException(responseResult.State.Id, responseResult.Message);
                }
                break;

            case RoleType.MachineryOperator:
                viewName = "Machinery_Operator_Detail";
                var machineOperatorVerificationInfo = RestSharpHelper.PostWithStandard <ResponseResult <MachineOperatorVerificationInfoViewModel> >(GetCurrentUrl(this), postParas, GetCertificationFilePath(), GetCertificationPwd());
                if (machineOperatorVerificationInfo != null && machineOperatorVerificationInfo.IsSuccess)
                {
                    viewModel = machineOperatorVerificationInfo.Entity;
                }
                else
                {
                    ThrowException(machineOperatorVerificationInfo.State.Id, machineOperatorVerificationInfo.Message);
                }
                break;

            case RoleType.Business:
                viewName = "Business_Detail";
                var businessVerificationInfo = RestSharpHelper.PostWithStandard <ResponseResult <BusinessVerificationInfoViewModel> >(GetCurrentUrl(this), postParas, GetCertificationFilePath(), GetCertificationPwd());
                if (businessVerificationInfo != null && businessVerificationInfo.IsSuccess)
                {
                    viewModel = businessVerificationInfo.Entity;
                }
                else
                {
                    ThrowException(businessVerificationInfo.State.Id, businessVerificationInfo.Message);
                }
                break;

            case RoleType.SuperAdmin:
            case RoleType.Admin:
            case RoleType.Dealer:
            case RoleType.Unknown:
            default:
                return(null);
            }

            return(View(viewName, viewModel));
        }
Exemple #14
0
        public ActionResult List(WhereModel model, int pageIndex = 1, int pageSize = 10)
        {
            var userId     = GetLoginInfo().User.Id;
            var wheremodel = new WhereModel()
            {
                RoleId      = Convert.ToInt32(string.IsNullOrEmpty(Request["RoleId"]) ? "0" : Request["RoleId"]),
                Province    = string.IsNullOrEmpty(Request["Province"]) ? "0" : Request["Province"],
                City        = string.IsNullOrEmpty(Request["City"]) ? "0" : Request["City"],
                Region      = string.IsNullOrEmpty(Request["Region"]) ? "0" : Request["Region"],
                PhoneNumber = string.IsNullOrEmpty(Request["PhoneNumber"]) ? "" : Request["PhoneNumber"].ToString(),
            };

            var str_startTime = Request["StartTime"];
            var str_endTime   = Request["EndTime"];

            if (!string.IsNullOrEmpty(str_startTime))
            {
                str_startTime = str_startTime.Replace("年", "-").Replace("月", "-").Replace("日", "");
            }
            if (!string.IsNullOrEmpty(str_endTime))
            {
                str_endTime = str_endTime.Replace("年", "-").Replace("月", "-").Replace("日", "");
            }

            DateTime dt_now    = DateTime.Now;
            DateTime startTime = dt_now;
            DateTime endTime   = dt_now;

            if (string.IsNullOrEmpty(str_startTime))
            {
                startTime = dt_now.AddMonths(-3);
            }
            else
            {
                startTime = DateTime.Parse(str_startTime);
            }

            if (string.IsNullOrEmpty(str_endTime))
            {
                endTime = dt_now;
            }
            else
            {
                endTime = DateTime.Parse(str_endTime);
            }


            wheremodel.StartTime = startTime;
            wheremodel.EndTime   = new DateTime(endTime.Year,
                                                endTime.Month,
                                                endTime.Day,
                                                23,
                                                59,
                                                59);

            var postParas = new Dictionary <string, string>()
            {
                { "UserId", userId.ToString() },
                { "pageIndex", pageIndex.ToString() },
                { "pageSize", pageSize.ToString() },
                { "RoleId", wheremodel.RoleId.ToString() },
                { "Province", wheremodel.Province },
                { "City", wheremodel.City.ToString() },
                { "Region", wheremodel.Region.ToString() },
                { "PhoneNumber", wheremodel.PhoneNumber.ToString() },
                { "StartTime", wheremodel.StartTime.ToString() },
                { "EndTime", wheremodel.EndTime.ToString() }
            };


            //证书的路径
            var certification = GetCertificationFilePath();
            //证书的密码
            var certificationPwd = GetCertificationPwd();

            if (postParas.ContainsKey(DataKey.UserId) == false)
            {
                postParas.Add(DataKey.UserId, GetLoginInfo().User.Id.ToString());
            }
            var responseResult = RestSharpHelper.PostWithStandard <ResponseResult <RoleVerificationViewModelWithoutPager> >(GetPostUrl("Search"), postParas, GetCertificationFilePath(), GetCertificationPwd());

            if (responseResult != null && responseResult.IsSuccess)
            {
                var roleVerification = new RoleVerificationViewModel();
                roleVerification.Pager            = new PagedList <string>(new string[0], responseResult.PageIndex, responseResult.PageSize, (int)responseResult.TotalNums);
                roleVerification.PendingAuditList = responseResult.Entity.PendingAuditList;
                roleVerification.Wheremodel       = wheremodel;
                return(View("List", roleVerification));
            }
            return(View());
        }
Exemple #15
0
        public JsonResult Article_Statistics(long ArticleId)
        {
            var responseResult = RestSharpHelper.PostWithStandard <ResponseResult <object> >(GetCurrentUrl(this), GetPostParameters(), GetCertificationFilePath(), GetCertificationPwd());

            return(new JsonResultEx(responseResult));
        }
Exemple #16
0
        public JsonResult NavMenu()
        {
            var responseResult = RestSharpHelper.PostWithStandard <ResponseResult <List <NavigateMenuItemOutput> > >(GetCurrentUrl(this), null, GetCertificationFilePath(), GetCertificationPwd());

            return(new JsonResultEx(responseResult));
        }