You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

FileFolderService.cs 4.2 KiB

4 years ago
123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125
  1. using Learun.Application.OA.File.FileInfo;
  2. using Learun.DataBase.Repository;
  3. using Learun.Util;
  4. using System;
  5. using System.Collections.Generic;
  6. using System.Linq;
  7. namespace Learun.Application.OA.File.FileFolder
  8. {
  9. /// <summary>
  10. /// 版 本 Learun-ADMS-Ultimate V7.0.0 数字化智慧校园
  11. /// Copyright (c) 2013-2017
  12. /// 创建人:陈彬彬
  13. /// 日 期:2018.06.20
  14. /// 描 述:文件管理
  15. /// </summary>
  16. public class FileFolderService : RepositoryFactory
  17. {
  18. #region 获取数据
  19. /// <summary>
  20. /// 文件夹列表
  21. /// </summary>
  22. /// <param name="userId">用户Id</param>
  23. /// <returns></returns>
  24. public IEnumerable<FileFolderEntity> GetList(string userId)
  25. {
  26. var expression = LinqExtensions.True<FileFolderEntity>();
  27. expression = expression.And(t => t.F_CreateUserId == userId);
  28. return this.BaseRepository().IQueryable(expression).ToList();
  29. }
  30. /// <summary>
  31. /// 文件夹实体
  32. /// </summary>
  33. /// <param name="keyValue">主键值</param>
  34. /// <returns></returns>
  35. public FileFolderEntity GetEntity(string keyValue)
  36. {
  37. return this.BaseRepository().FindEntity<FileFolderEntity>(keyValue);
  38. }
  39. #endregion
  40. #region 提交数据
  41. /// <summary>
  42. /// 还原文件夹
  43. /// </summary>
  44. /// <param name="keyValue">主键</param>
  45. public void RestoreFile(string keyValue)
  46. {
  47. FileFolderEntity fileFolderEntity = new FileFolderEntity();
  48. fileFolderEntity.Modify(keyValue);
  49. fileFolderEntity.F_DeleteMark = 0;
  50. this.BaseRepository().Update(fileFolderEntity);
  51. }
  52. /// <summary>
  53. /// 删除文件夹
  54. /// </summary>
  55. /// <param name="keyValue">主键</param>
  56. public void RemoveForm(string keyValue)
  57. {
  58. FileFolderEntity fileFolderEntity = new FileFolderEntity();
  59. fileFolderEntity.Modify(keyValue);
  60. fileFolderEntity.F_DeleteMark = 1;
  61. this.BaseRepository().Update(fileFolderEntity);
  62. }
  63. /// <summary>
  64. /// 彻底删除文件夹
  65. /// </summary>
  66. /// <param name="keyValue">主键</param>
  67. public void ThoroughRemoveForm(string keyValue)
  68. {
  69. this.BaseRepository().Delete<FileFolderEntity>(t => t.F_FolderId == keyValue);
  70. }
  71. /// <summary>
  72. /// 清空回收站
  73. /// </summary>
  74. public void EmptyRecycledForm()
  75. {
  76. var db = this.BaseRepository().BeginTrans();
  77. try
  78. {
  79. db.Delete<FileFolderEntity>(t => t.F_DeleteMark == 1);
  80. db.Delete<FileInfoEntity>(t => t.F_DeleteMark == 1);
  81. db.Commit();
  82. }
  83. catch (Exception ex)
  84. {
  85. db.Rollback();
  86. throw ExceptionEx.ThrowServiceException(ex);
  87. }
  88. }
  89. /// <summary>
  90. /// 保存文件夹表单(新增、修改)
  91. /// </summary>
  92. /// <param name="keyValue">主键值</param>
  93. /// <param name="fileFolderEntity">文件夹实体</param>
  94. /// <returns></returns>
  95. public void SaveForm(string keyValue, FileFolderEntity fileFolderEntity)
  96. {
  97. if (!string.IsNullOrEmpty(keyValue))
  98. {
  99. fileFolderEntity.Modify(keyValue);
  100. this.BaseRepository().Update(fileFolderEntity);
  101. }
  102. else
  103. {
  104. fileFolderEntity.Create();
  105. this.BaseRepository().Insert(fileFolderEntity);
  106. }
  107. }
  108. /// <summary>
  109. /// 共享文件夹
  110. /// </summary>
  111. /// <param name="keyValue">主键</param>
  112. /// <param name="IsShare">是否共享:1-共享 0取消共享</param>
  113. public void ShareFolder(string keyValue, int IsShare)
  114. {
  115. FileFolderEntity fileFolderEntity = new FileFolderEntity();
  116. fileFolderEntity.F_FolderId = keyValue;
  117. fileFolderEntity.F_IsShare = IsShare;
  118. fileFolderEntity.F_ShareTime = DateTime.Now;
  119. this.BaseRepository().Update(fileFolderEntity);
  120. }
  121. #endregion
  122. }
  123. }