public JsonResult AddExhibitionAreaForDemonstateFarm(FarmAreaInput input)
        {
            CheckPermission();
            using (var result = new ResponseResult <object>())
            {
                //判断数据库中是否已有该区
                var existSameArea = _farmAreaService.Count(m => m.FarmId == input.FarmId && m.Name == input.Name) > 0;
                if (existSameArea)
                {
                    throw new CustomException("已有相同的区存在!");
                }

                var farmArea = new T_FARM_AREA
                {
                    FarmId          = input.FarmId,
                    Name            = input.Name,
                    IsFarmMachinery = input.IsMachineryArea,
                    CreateTime      = DateTime.Now
                };

                _farmAreaService.Insert(farmArea);
                farmArea.Url = "/Articles/article_farm_area_" + farmArea.Id + ".html";
                _farmAreaService.Update(farmArea);
                result.Entity  = farmArea.Id;
                result.Message = "农场展区添加成功!";
                return(new JsonResultEx(result));
            }
        }
        public ActionResult AddExhibitionAreaForDemonstateFarm(FarmAreaInput input)
        {
            CheckPermission(GetLoginInfo().User.Id, CurrentUrl);
            if (CheckInputWhenReturnActionResult() == false)
            {
                return(View(input));
            }

            var parameters = ModelHelper.GetPropertyDictionary <FarmAreaInput>(input);

            var responseResult = PostStandardWithSameControllerAction <object>(this, parameters);

            if (responseResult.IsSuccess)
            {
                TempData["Message"] = "添加成功!";

                //静态化处理
                string content         = System.IO.File.ReadAllText(Server.MapPath("~/Templates/FarmAreaDetail.html"));
                var    articleHtmlPath = Server.MapPath("~/Articles/");
                if (!Directory.Exists(articleHtmlPath))
                {
                    Directory.CreateDirectory(articleHtmlPath);
                }

                string htmlResult = content.Replace("@PageTitle", input.Name)
                                    .Replace("@Title", input.Name)
                                    .Replace("@CreateTime", DateTime.Now.ToString("yyyy.MM.dd"))
                                    .Replace("@Content", input.Content);

                System.IO.File.WriteAllText(articleHtmlPath + "article_farm_area_" + responseResult.Entity + ".html", htmlResult, Encoding.UTF8);

                return(View(input));
            }
            else
            {
                TempData["Error"] = responseResult.Message;
                return(View(input));
            }
        }