/// <summary> /// 添加附件 /// </summary> /// <param name="applyAttachmentViews"></param> /// <returns></returns> public static bool AddApplyAttachmentView(List <ApplyAttachmentView> applyAttachmentViews, string operators) { using (DataAccess.DbOperator commad = Factory.CreateCommand()) { bool isSuccess = false; IApplyformRepository repository = Factory.CreateApplyformRepository(commad); try { repository.AddApplyAttachmentView(applyAttachmentViews); isSuccess = true; } catch (Exception ex) { LogService.SaveExceptionLog(ex); isSuccess = false; } //记录操作日志 ApplyAttachmentView apply = applyAttachmentViews.FirstOrDefault(); if (isSuccess && apply != null) { saveLog(OperationType.Insert, string.Format("添加:退票附件。申请单号:{0},附件Id:{1},源文件相对路径:{2},时间:{3},操作员:{4}", apply.ApplyformId, apply.Id, apply.FilePath, apply.Time, operators), OperatorRole.Platform, apply.ApplyformId.ToString(), operators); } return(isSuccess); } }
/// <summary> /// 删除附件 /// </summary> /// <param name="applyAttachmentId"></param> /// <returns></returns> public static bool DeleteApplyAttachmentView(Guid applyAttachmentId, string operators) { using (DataAccess.DbOperator commad = Factory.CreateCommand()) { //记录操作日志 ApplyAttachmentView apply = Service.ApplyformQueryService.QueryApplyAttachmentView(applyAttachmentId); bool isSuccess = false; IApplyformRepository repository = Factory.CreateApplyformRepository(commad); try { repository.DeleteApplyAttachmentView(applyAttachmentId); isSuccess = true; } catch (Exception ex) { LogService.SaveExceptionLog(ex); isSuccess = false; } if (isSuccess && apply != null) { saveLog(OperationType.Delete, string.Format("删除:退票附件。申请单号:{0},附件Id:{1},源文件相对路径:{2},时间:{3},操作员:{4}", apply.ApplyformId, apply.Id, apply.FilePath, apply.Time, operators), OperatorRole.Platform, apply.ApplyformId.ToString(), operators); } return(isSuccess); } }
public void OutPutApplyAttachment() { string applyAttachmentId = HttpContext.Current.Request.QueryString["ApplyAttachmentId"]; if (!string.IsNullOrEmpty(applyAttachmentId)) { Guid id = Guid.Parse(applyAttachmentId); ApplyAttachmentView apply = ApplyformQueryService.QueryApplyAttachmentView(id); if (apply != null) { HttpContext.Current.Response.BinaryWrite(apply.Thumbnail); } } }