LibraryServices.cs 5.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. using EMIS.DataLogic.Common.TeachingMaterial;
  6. using EMIS.ViewModel.TeachingMaterial;
  7. using EMIS.ViewModel;
  8. using Bowin.Common.Linq.Entity;
  9. using EMIS.DataLogic.Repositories;
  10. using EMIS.Entities;
  11. namespace EMIS.CommonLogic.TeachingMaterial
  12. {
  13. public class LibraryServices:BaseServices,ILibraryServices
  14. {
  15. #region --定义--
  16. public LibraryDAL LibraryDAL { get; set; }
  17. public LibraryRepository LibraryRepository { get; set; }
  18. public UserRepository UserRepository { get; set; }
  19. public CampusRepository CampusRepository { get; set; }
  20. #endregion
  21. #region 1.0 查询书库信息列表
  22. /// <summary>
  23. /// 获取书库信息列表
  24. /// </summary>
  25. /// <param name="exp"></param>
  26. /// <returns></returns>
  27. public IGridResultSet<LibraryView> GetLibraryViewGrid(ConfiguretView configuretView, int pageIndex, int pageSize)
  28. {
  29. var query = LibraryDAL.GetLibraryGridView(x => true);
  30. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  31. return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderByDescending(x => x.LibraryName).ToGridResultSet<LibraryView>(pageIndex, pageSize);
  32. return query.OrderByDescending(x => x.LibraryName).ToGridResultSet<LibraryView>(pageIndex, pageSize);
  33. }
  34. #endregion
  35. #region 2.0 编辑保存书库信息
  36. /// <summary>
  37. /// 编辑书库
  38. /// </summary>
  39. /// <param name="publisherView"></param>
  40. public void EditLibrary(LibraryView libraryView, Guid createUserID)
  41. {
  42. try
  43. {
  44. if (this.LibraryRepository.GetList(x => x.LibraryCode == libraryView.LibraryCode
  45. && x.LibraryID != libraryView.LibraryID).Count() > 0)
  46. {
  47. throw new Exception("书库编号已经存在,请重新输入!");
  48. }
  49. if (libraryView.LibraryID != null && libraryView.LibraryID != Guid.Empty)
  50. {
  51. CF_Library library = LibraryRepository.GetSingle(x => x.LibraryID == libraryView.LibraryID);
  52. library.LibraryName = libraryView.LibraryName;
  53. library.LibraryCode = libraryView.LibraryCode;
  54. library.ContectTelNumber = libraryView.ContectTelNumber;
  55. library.HeadPeople = libraryView.HeadPeople;
  56. library.CampusID = libraryView.CampusID.GetValueOrDefault();
  57. library.ModifyUserID = createUserID;
  58. library.ModifyTime = DateTime.Now;
  59. LibraryRepository.UnitOfWork.Update(library);
  60. LibraryRepository.UnitOfWork.Commit();
  61. }
  62. else
  63. {
  64. CF_Library publish = new CF_Library()
  65. {
  66. LibraryID = Guid.NewGuid(),
  67. CampusID = libraryView.CampusID.GetValueOrDefault(),
  68. ContectTelNumber = libraryView.ContectTelNumber,
  69. HeadPeople = libraryView.HeadPeople,
  70. LibraryCode = libraryView.LibraryCode,
  71. LibraryName = libraryView.LibraryName,
  72. Desc = libraryView.Desc,
  73. CreateTime = DateTime.Now,
  74. ModifyTime = DateTime.Now,
  75. CreateUserID = createUserID,
  76. ModifyUserID = createUserID
  77. };
  78. LibraryRepository.UnitOfWork.Add(publish);
  79. LibraryRepository.UnitOfWork.Commit();
  80. }
  81. }
  82. catch (Exception ex)
  83. {
  84. throw ex;
  85. }
  86. }
  87. #endregion
  88. #region 3.0 删除书库信息
  89. /// <summary>
  90. /// 删除书库信息
  91. /// </summary>
  92. /// <param name="publishID"></param>
  93. public void DeleteLibrary(List<Guid> libraryIDs)
  94. {
  95. try
  96. {
  97. LibraryRepository.UnitOfWork.Delete<CF_Library>(x => libraryIDs.Contains(x.LibraryID));
  98. }
  99. catch (Exception ex)
  100. {
  101. throw ex;
  102. }
  103. }
  104. #endregion
  105. #region 4.0 获取书库单位
  106. /// <summary>
  107. /// 获取书库单位
  108. /// </summary>
  109. /// <returns></returns>
  110. public LibraryView GetSingleLibrary(Guid libraryID)
  111. {
  112. return LibraryDAL.GetSingleLibrary(libraryID);
  113. }
  114. #endregion
  115. #region 5.0 获取书库信息列表导出
  116. /// <summary>
  117. /// 获取书库息列表导出
  118. /// </summary>
  119. /// <param name="exp"></param>
  120. /// <returns></returns>
  121. public IList<LibraryView> GetLibraryViewExcel(ConfiguretView configuretView)
  122. {
  123. var query = LibraryDAL.GetLibraryGridView(x => true);
  124. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  125. return query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue).OrderByDescending(x => x.LibraryName).ToList();
  126. return query.OrderByDescending(x => x.LibraryName).ToList();
  127. }
  128. #endregion
  129. #region 6.0 验证书库编号唯一
  130. public bool IsExistLibraryCode(string libraryCode)
  131. {
  132. bool IsExist = false;
  133. var libraryEnt = LibraryRepository.GetSingle(x => x.LibraryCode == libraryCode);
  134. if (libraryEnt != null)
  135. {
  136. IsExist = true;
  137. }
  138. return IsExist;
  139. }
  140. #endregion
  141. }
  142. }