Пример #1
0
        /// <summary>
        /// 下载日志文件
        /// </summary>
        /// <param name="type"></param>
        /// <param name="file"></param>
        /// <returns></returns>
        public ActionResult DownLoad(string type = "", string file = "")
        {
            if (!RegLogFile.IsMatch(file.Trim()))
            {
                return(RedirectToAction("NotFound", "Home", new { sgs = "fileInfoError", url = Request.Url.AbsoluteUri, Area = "" }));
            }
            string rootPath  = "~/System/Log";
            string directory = string.Empty;

            switch (type)
            {
            case "0":    // info
                directory = "Info";
                break;

            case "1":    // error
                directory = "Error";
                break;

            default:
                return(RedirectToAction("NotFound", "Home", new { sgs = "logFileNotFound", url = Request.Url.AbsoluteUri, Area = "" }));
            }
            string filePath = Server.MapPath(string.Format("{0}/{1}/{2}", rootPath, directory, file));

            if (!FileCommon.Exists(filePath))
            {
                return(RedirectToAction("NotFound", "Home", new { sgs = "logFileNotFound2", url = Request.Url.AbsoluteUri, Area = "" }));
            }
            // 拼接出 Said-Error-20170121.txt 这样的格式
            return(File(filePath, "text/plain", string.Format("Said-{0}Log-{1}", directory, file)));
        }
Пример #2
0
        public JsonResult AddClassify(string name, string imgName)
        {
            if (string.IsNullOrWhiteSpace(imgName) || !FileCommon.Exists(Server.MapPath(ICONPATH) + imgName))
            {
                return(ResponseResult(2, "上传的Icon不正确"));
            }
            if (string.IsNullOrWhiteSpace(name))
            {
                return(ResponseResult(1, "分类名称不正确"));
            }
            //TODO 检测特殊字符,例如.,啊之类的


            name = HttpUtility.UrlDecode(name).Trim();
            if (classifyApplication.FindByName(name) != null)
            {
                return(ResponseResult(4, "该分类已经存在!"));
            }
            Classify model = new Classify
            {
                CCount        = 0,
                CIcon         = imgName,
                CLastBlogId   = string.Empty,
                CLastBlogName = string.Empty,
                ClassifyId    = Guid.NewGuid().ToString().Replace("-", ""),
                CName         = name,
                Date          = DateTime.Now,
                IsDel         = 0
            };

            classifyApplication.Add(model);
            return(classifyApplication.Commit() ?
                   ResponseResult(model.ClassifyId) :
                   ResponseResult(3, "服务器删除异常"));
        }
Пример #3
0
        /// <summary>
        /// 编辑分类
        /// </summary>
        /// <param name="name">分类名</param>
        /// <param name="imgName">分类Icon</param>
        /// <param name="id">分类Icon</param>
        /// <returns></returns>
        public JsonResult EditClassify(string name, string imgName, string id)
        {
            if (string.IsNullOrWhiteSpace(name))
            {
                return(ResponseResult(1, "分类名称不正确"));
            }
            if (string.IsNullOrWhiteSpace(imgName) || !FileCommon.Exists(Server.MapPath(ICONPATH) + imgName))
            {
                return(ResponseResult(2, "上传的Icon不正确"));
            }
            if (string.IsNullOrWhiteSpace(id))
            {
                return(ResponseResult(3, "分类信息不正确"));
            }
            //TODO 检测特殊字符,例如.,啊之类的
            name    = HttpUtility.UrlDecode(name).Trim();
            imgName = imgName.Trim();
            Classify model = classifyApplication.FindById(id);

            if (model == null)
            {
                return(ResponseResult(4, "没有找到该分类信息"));
            }
            if (model.CIcon == imgName.Trim() && model.CName == name.Trim())//没有改动直接编辑成功
            {
                ResponseResult();
            }

            //验证
            Classify oldModel = classifyApplication.FindByName(name);

            //找到分类名称已经存在的model
            if (oldModel != null && oldModel.ClassifyId != model.ClassifyId)
            {
                return(ResponseResult(6, "该分类已经存在"));
            }
            model.CIcon = imgName;
            model.CName = name;
            classifyApplication.Update(model);
            return(classifyApplication.Commit() ?
                   ResponseResult() :
                   ResponseResult(5, "服务器编辑异常"));
        }