public List <ResponseVillagePic> Post(VillagePic request) { return(Manager.GetAllVillagePics(request)); }
/// <summary> /// 保存形势图路径等等 /// </summary> /// <param name="request"></param> /// <returns></returns> public bool SaveVillagePic(SaveVillagePic request) { using (var db = DbFactory.Open()) { if (string.IsNullOrEmpty(request.adcd)) { throw new Exception("行政区划编码不能为空"); } if (string.IsNullOrEmpty(request.filePath)) { throw new Exception("文件路径不能为空"); } if (request.Year == 0) { throw new Exception("年份异常"); } var log = new operateLog(); log.userName = RealName; log.operateTime = DateTime.Now; var logList = new List <operateLog>(); var list = GetVillagePicAdcd(new GetVillagePicAdcd() { adcd = request.adcd, year = request.Year, type = 1 }).rows; if (list.Count == 1) { log.operateMsg = "更新" + ZZTXManager.GetADCDInfoByADCD(request.adcd).adnm + "的防汛防台形势图"; logList.Add(log); #region 日志 StringBuilder sb = new StringBuilder(); sb.Append("在栏目{组织责任/行政村防汛防台形势图}下,更新了形势图{" + ZZTXManager.GetADCDInfoByADCD(request.adcd).adnm + "}"); _ILogHelper.WriteLog(sb.ToString(), OperationTypeEnums.更新); #endregion var _AuditNums = 0; if (AuditNums != null) { _AuditNums = AuditNums.Value + 1; } return(db.UpdateOnly( new VillagePic() { path = request.filePath, operateLog = JsonTools.ObjectToJson(logList), AuditNums = _AuditNums }, onlyFields: x => new { x.path, x.operateLog }, where : x => x.Id == list[0].Id) == 1); } else { var newInfo = new VillagePic2(); string[] arryFiles; string picNames = ""; if (request.filePath.Contains("|")) { arryFiles = request.filePath.Split('|'); foreach (var item in arryFiles) { JObject jo = (JObject)JsonConvert.DeserializeObject(item); picNames += Path.GetFileName(jo["fileSrc"].ToString().Replace("/", @"\")) + ","; } picNames = picNames.Substring(0, picNames.Length - 1); } else { JObject jo = (JObject)JsonConvert.DeserializeObject(request.filePath); picNames = Path.GetFileName(jo["fileSrc"].ToString().Replace("/", @"\")); } newInfo.Adcd = request.adcd; newInfo.Year = request.Year; newInfo.PicName = picNames; newInfo.CreatTime = DateTime.Now; newInfo.id = Guid.NewGuid().ToString(); var info = new VillagePic(); info.adcd = request.adcd; info.Year = request.Year; info.path = request.filePath; info.CreatTime = DateTime.Now; //写入更新记录 if (AuditNums != null) { info.AuditNums = AuditNums.Value + 1; newInfo.AuditNums = AuditNums.Value + 1; } else { newInfo.AuditNums = 0; } log.operateMsg = "新增" + ZZTXManager.GetADCDInfoByADCD(request.adcd).adnm + "的防汛防台形势图"; logList.Add(log); info.operateLog = JsonTools.ObjectToJson(logList); newInfo.operateLog = JsonTools.ObjectToJson(logList); #region 日志 StringBuilder sb = new StringBuilder(); sb.Append("在栏目{组织责任/行政村防汛防台形势图}下,新增了{" + ZZTXManager.GetADCDInfoByADCD(request.adcd).adnm + "}形势图"); _ILogHelper.WriteLog(sb.ToString(), OperationTypeEnums.新增); #endregion long a = db.Insert(info); string insertsql = "INSERT INTO VillagePic2(id, Adcd, PicName, isDelete, Year, operateLog, CreatTime, AuditNums) VALUES('" + newInfo.id + "','" + newInfo.Adcd + "', '" + newInfo.PicName + "', '" + newInfo.isDelete + "', '" + newInfo.Year + "', '" + newInfo.operateLog + "', '" + newInfo.CreatTime + "', '" + newInfo.AuditNums + "')"; long b = db.ExecuteSql(insertsql); return(b == 1); //return db.Insert(info) == 1; } } }
/// <summary> /// 保存形势图路径等等 /// </summary> /// <param name="request"></param> /// <returns></returns> public bool SaveVillagePic(SaveVillagePic request) { using (var db = DbFactory.Open()) { if (string.IsNullOrEmpty(request.adcd)) { throw new Exception("行政区划编码不能为空"); } if (string.IsNullOrEmpty(request.filePath)) { throw new Exception("文件路径不能为空"); } if (request.Year == 0) { throw new Exception("年份异常"); } var log = new operateLog(); log.userName = RealName; log.operateTime = DateTime.Now; var logList = new List <operateLog>(); var list = GetVillagePicAdcd(new GetVillagePicAdcd() { adcd = request.adcd, year = request.Year, type = 1 }).rows; if (list.Count == 1) { log.operateMsg = "更新" + ZZTXManager.GetADCDInfoByADCD(request.adcd).adnm + "的防汛防台形势图"; logList.Add(log); #region 日志 StringBuilder sb = new StringBuilder(); sb.Append("在栏目{组织责任/行政村防汛防台形势图}下,更新了形势图{" + ZZTXManager.GetADCDInfoByADCD(request.adcd).adnm + "}"); _ILogHelper.WriteLog(sb.ToString(), OperationTypeEnums.更新); #endregion var _AuditNums = 0; if (AuditNums != null) { _AuditNums = AuditNums.Value + 1; } return(db.UpdateOnly( new VillagePic() { path = request.filePath, operateLog = JsonTools.ObjectToJson(logList), AuditNums = _AuditNums }, onlyFields: x => new { x.path, x.operateLog }, where : x => x.Id == list[0].Id) == 1); } else { var info = new VillagePic(); info.adcd = request.adcd; info.Year = request.Year; info.path = request.filePath; info.CreatTime = DateTime.Now; //写入更新记录 if (AuditNums != null) { info.AuditNums = AuditNums.Value + 1; } log.operateMsg = "新增" + ZZTXManager.GetADCDInfoByADCD(request.adcd).adnm + "的防汛防台形势图"; logList.Add(log); info.operateLog = JsonTools.ObjectToJson(logList); #region 日志 StringBuilder sb = new StringBuilder(); sb.Append("在栏目{组织责任/行政村防汛防台形势图}下,新增了{" + ZZTXManager.GetADCDInfoByADCD(request.adcd).adnm + "}形势图"); _ILogHelper.WriteLog(sb.ToString(), OperationTypeEnums.新增); #endregion return(db.Insert(info) == 1); } } }