/// <summary> /// 修改图片,根据config的参数值确定对应的配置文件 /// </summary> /// <param name="fileData"></param> /// <returns></returns> public string UpdateImage() { var userModel = AllServices.UserService.GetUserBySession(); int intDpiID = Request["dpi"].ToInt32(); string strkey = Request["key"].ToStr(); string strTag = Request["tag"].ToStr(); string strSize = Request["size"].ToStr(); string strSysID = Request["sysID"].ToStr(); int intUID = Request["uid"].ToInt32(); if (strkey != this.strKEY) { return(new CommonResult("上传文件失败,key值对应不上").ToJson()); } string strConfig = Request["config"].ToStr("ImageUploadBaseConfig"); DataModel dataModel = new DataModel(); dataModel.Add("UID", intUID); dataModel.Add("DpiID", intDpiID); dataModel.Add("Size", strSize); CommonResult commonResult = new CommonResult(); HttpPostedFileBase postFile = Request.Files[0]; var configInstance = ConfigHelper.GetConfig <Foundation.SiteConfig.Models.ImageUploadBaseConfig>(strConfig); commonResult = AllServices.ImageUploadService.ImageHandler(postFile, configInstance, userModel.UserName, dataModel, ActionType.Modify); //修改文件 if (commonResult.code < 1) { return(commonResult.ToJson()); } if (string.IsNullOrEmpty(strSysID)) { return(new CommonResult("请选择所属系统").ToJson()); } int[] intSysIDs = ArrayHelper.ToIntArray(strSysID); CommonResult commonResult1 = AddDocumentFolder(intSysIDs, (int)commonResult.data); CommonResult commonResult2 = UpdateTag(strTag, intUID); if (commonResult1.code < 1) { commonResult = new CommonResult("文件修改成功,标签修改失败"); } else if (commonResult2.code < 1) { commonResult = new CommonResult("文件修改成功,所属系统修改失败"); } else if (commonResult1.code < 1 && commonResult2.code < 1) { commonResult = new CommonResult("文件修改成功,标签修改失败,所属修改失败"); } return(commonResult.ToJson()); //上传成功返回图片信息 //var res = AllServices.ImageUploadService.ImageHandler(fileData, AllConfigServices.NewsImageUploadConfig); }
/// <summary> /// 修改图片信息 /// </summary> /// <param name="fileData"></param> /// <returns></returns> public string UpdateImageInfo() { var userModel = AllServices.UserService.GetUserBySession(); int intDpiID = Request["dpi"].ToInt32(); string strTag = Request["tag"].ToStr(); string strSize = Request["size"].ToStr(); string strSysID = Request["sysID"].ToStr(); string strName = Request["name"].ToStr(); string strPath = Request["path"].ToStr(); string strType = Request["type"].ToStr(); int intUID = Request["uid"].ToInt32(); string strConfig = Request["config"].ToStr("ImageUploadBaseConfig"); DataModel dataModel = new DataModel(); dataModel.Add("UID", intUID); dataModel.Add("DpiID", intDpiID); dataModel.Add("Size", strSize); CommonResult commonResult; var configInstance = ConfigHelper.GetConfig <Foundation.SiteConfig.Models.ImageUploadBaseConfig>(strConfig); if (!FileHelper.RenameFile(PathHelper.GetMapPath(strPath), strName + strType)) { commonResult = new CommonResult("重命名失败,修改终止,请联系管理员"); return(commonResult.ToJson()); } //更新图片信息记录 Document documentModel = new Document(); documentModel.UID = dataModel["UID"].ToInt(); documentModel.DocumentName = strName; documentModel.DocumentPath = string.Format("{0}/{1}", configInstance.SavePath, strName + strType); documentModel.PictureSize = dataModel["Size"].ToStr(); documentModel.PictureResolution = dataModel["DpiID"].ToInt() == 0 ? "96dpi" : "72dpi"; documentModel.Editor = userModel.UserName; documentModel.EditTime = DateTime.Now; documentModel.State = Convert.ToInt32(ItemState.Enable); commonResult = AllServices.DocumentService.Update(documentModel); if (commonResult.code < 1) { return(commonResult.ToJson()); } if (string.IsNullOrEmpty(strSysID)) { return(new CommonResult("请选择所属系统").ToJson()); } int[] intSysIDs = ArrayHelper.ToIntArray(strSysID); CommonResult commonResult1 = AddDocumentFolder(intSysIDs, intUID); CommonResult commonResult2 = UpdateTag(strTag, intUID); if (commonResult1.code < 1) { commonResult = new CommonResult("文件修改成功,标签修改失败"); } else if (commonResult2.code < 1) { commonResult = new CommonResult("文件修改成功,所属系统修改失败"); } else if (commonResult1.code < 1 && commonResult2.code < 1) { commonResult = new CommonResult("文件修改成功,标签修改失败,所属修改失败"); } return(commonResult.ToJson()); }