/// <summary> /// 保存实体数据(新增、修改) /// <param name="keyValue">主键</param> /// <summary> /// <returns></returns> public void SaveEntity(string keyValue, DTImgEntity entity) { try { if (!string.IsNullOrEmpty(keyValue)) { entity.Modify(keyValue); this.BaseRepository().Update(entity); } else { entity.Create(); this.BaseRepository().Insert(entity); } } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowServiceException(ex); } } }
/// <summary> /// 删除实体数据 /// <param name="keyValue">主键</param> /// <summary> /// <returns></returns> public void DeleteEntity(string keyValue) { try { DTImgEntity entity = GetEntity(keyValue); if (entity != null) { if (!string.IsNullOrEmpty(entity.F_FileName)) { string fileHeadImg = Config.GetValue("fileAppDTImg"); string fileImg = string.Format("{0}/{1}{2}", fileHeadImg, entity.F_Id, entity.F_FileName); if (DirFileHelper.IsExistFile(fileImg)) { System.IO.File.Delete(fileImg); } } } dTImgService.DeleteEntity(keyValue); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } }
/// <summary> /// 更新数据状态 /// </summary> /// <param name="keyValue">主键</param> /// <param name="state">状态1启用2禁用</param> public void UpdateState(string keyValue, int state) { DTImgEntity entity = new DTImgEntity(); entity.F_EnabledMark = state; SaveEntity(keyValue, entity); }
/// <summary> /// 获取图片 /// </summary> /// <param name="keyValue">主键</param> public void GetImg(string keyValue) { DTImgEntity entity = GetEntity(keyValue); string img = ""; if (entity != null) { if (!string.IsNullOrEmpty(entity.F_FileName)) { string fileHeadImg = Config.GetValue("fileAppDTImg"); string fileImg = string.Format("{0}/{1}{2}", fileHeadImg, entity.F_Id, entity.F_FileName); if (DirFileHelper.IsExistFile(fileImg)) { img = fileImg; FileDownHelper.DownLoadnew(img); return; } } } else { img = "/Content/images/add.jpg"; } if (string.IsNullOrEmpty(img)) { img = "/Content/images/add.jpg"; } FileDownHelper.DownLoad(img); }
/// <summary> /// 保存实体数据(新增、修改) /// <param name="keyValue">主键</param> /// <summary> /// <returns></returns> public void SaveEntity(string keyValue, DTImgEntity entity) { try { dTImgService.SaveEntity(keyValue, entity); } catch (Exception ex) { if (ex is ExceptionEx) { throw; } else { throw ExceptionEx.ThrowBusinessException(ex); } } }