ClassroomServices.cs 56 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859860861862863864865866867868869870871872873874875876877878879880881882883884885886887888889890891892893894895896897898899900901902903904905906907908909910911912913914915916917918919920921922923924925926927928929930931932933934935936937938939940941942943944945946947948949950951952953954955956957958959960961962963964965966967968969970971972973974975976977978979980981982983984985986987988989990991992993994995996997998999100010011002100310041005100610071008100910101011101210131014101510161017101810191020102110221023102410251026102710281029103010311032103310341035103610371038103910401041104210431044104510461047104810491050105110521053105410551056105710581059106010611062106310641065106610671068106910701071107210731074107510761077107810791080108110821083108410851086108710881089109010911092109310941095109610971098109911001101110211031104110511061107110811091110111111121113111411151116111711181119112011211122112311241125112611271128112911301131113211331134113511361137113811391140114111421143114411451146114711481149115011511152115311541155115611571158115911601161116211631164116511661167116811691170117111721173
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Linq.Expressions;
  5. using System.Text;
  6. using System.Text.RegularExpressions;
  7. using System.Transactions;
  8. using Bowin.Common.Linq;
  9. using Bowin.Common.Linq.Entity;
  10. using Bowin.Common.Utility;
  11. using EMIS.Entities;
  12. using EMIS.Utility;
  13. using EMIS.ViewModel;
  14. using EMIS.ViewModel.CacheManage;
  15. using EMIS.ViewModel.UniversityManage.ClassroomManage;
  16. using EMIS.DataLogic.UniversityManage.ClassroomManage;
  17. namespace EMIS.CommonLogic.UniversityManage.ClassroomManage
  18. {
  19. public class ClassroomServices : BaseServices, IClassroomServices
  20. {
  21. public ClassroomDAL ClassroomDAL { get; set; }
  22. /// <summary>
  23. /// 查询对应的教室信息View
  24. /// </summary>
  25. /// <param name="configuretView"></param>
  26. /// <param name="campusID"></param>
  27. /// <param name="buildingsInfoID"></param>
  28. /// <param name="classroomName"></param>
  29. /// <param name="classroomTypeID"></param>
  30. /// <param name="collegeID"></param>
  31. /// <param name="isConcurrentUse"></param>
  32. /// <param name="isReserve"></param>
  33. /// <param name="isAvailable"></param>
  34. /// <param name="pageIndex"></param>
  35. /// <param name="pageSize"></param>
  36. /// <returns></returns>
  37. public IGridResultSet<ClassroomView> GetClassroomViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? buildingsInfoID, string classroomName, int? classroomTypeID,
  38. Guid? collegeID, int? isConcurrentUse, int? isReserve, int? isAvailable, int pageIndex, int pageSize)
  39. {
  40. Expression<Func<CF_Classroom, bool>> expClassroom = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  41. if (buildingsInfoID.HasValue)
  42. {
  43. //建筑信息
  44. expClassroom = expClassroom.And(x => x.BuildingsInfoID == buildingsInfoID);
  45. }
  46. if (!string.IsNullOrEmpty(classroomName) && classroomName != "-1")
  47. {
  48. //教室名称
  49. expClassroom = expClassroom.And(x => x.Name == classroomName);
  50. }
  51. if (classroomTypeID.HasValue)
  52. {
  53. //教室类型(模糊查询)
  54. expClassroom = expClassroom.And(x => x.CF_ClassroomType.Select(w => w.ClassroomType).Contains(classroomTypeID));
  55. }
  56. if (collegeID.HasValue)
  57. {
  58. //院系所
  59. expClassroom = expClassroom.And(x => x.CollegeID == collegeID);
  60. }
  61. if (isConcurrentUse.HasValue)
  62. {
  63. //可否多班教学
  64. if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsYes)
  65. {
  66. expClassroom = expClassroom.And(x => x.IsConcurrentUse == true);
  67. }
  68. if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsNo)
  69. {
  70. expClassroom = expClassroom.And(x => x.IsConcurrentUse != true);
  71. }
  72. }
  73. if (isAvailable.HasValue)
  74. {
  75. //是否可用
  76. if (isAvailable.Value == (int)CF_GeneralPurpose.IsYes)
  77. {
  78. expClassroom = expClassroom.And(x => x.IsAvailable == true);
  79. }
  80. if (isAvailable.Value == (int)CF_GeneralPurpose.IsNo)
  81. {
  82. expClassroom = expClassroom.And(x => x.IsAvailable != true);
  83. }
  84. }
  85. var query = ClassroomDAL.GetClassroomViewQueryable(expClassroom);
  86. if (campusID.HasValue)
  87. {
  88. //校区
  89. query = query.Where(x => x.CampusID == campusID);
  90. }
  91. if (isReserve.HasValue)
  92. {
  93. //是否预留(排课用)
  94. if (isReserve.Value == (int)CF_GeneralPurpose.IsYes)
  95. {
  96. query = query.Where(x => x.IsReserve == true);
  97. }
  98. if (isReserve.Value == (int)CF_GeneralPurpose.IsNo)
  99. {
  100. query = query.Where(x => x.IsReserve != true);
  101. }
  102. }
  103. //查询条件
  104. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  105. {
  106. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  107. }
  108. return this.GetQueryByDataRangeByCampus(query).OrderBy(x => x.CampusCode.Length).ThenBy(x => x.CampusCode)
  109. .ThenBy(x => x.BuildingsInfoCode.Length).ThenBy(x => x.BuildingsInfoCode).ThenBy(x => x.Code.Length)
  110. .ThenBy(x => x.Code).ThenBy(x => x.RoomUseID).ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode).ToGridResultSet<ClassroomView>(pageIndex, pageSize);
  111. }
  112. /// <summary>
  113. /// 查询对应的教室信息List
  114. /// </summary>
  115. /// <param name="configuretView"></param>
  116. /// <param name="campusID"></param>
  117. /// <param name="buildingsInfoID"></param>
  118. /// <param name="classroomName"></param>
  119. /// <param name="classroomTypeID"></param>
  120. /// <param name="collegeID"></param>
  121. /// <param name="isConcurrentUse"></param>
  122. /// <param name="isReserve"></param>
  123. /// <param name="isAvailable"></param>
  124. /// <returns></returns>
  125. public IList<ClassroomView> GetClassroomViewList(ConfiguretView configuretView, Guid? campusID, Guid? buildingsInfoID, string classroomName, int? classroomTypeID,
  126. Guid? collegeID, int? isConcurrentUse, int? isReserve, int? isAvailable)
  127. {
  128. Expression<Func<CF_Classroom, bool>> expClassroom = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  129. if (buildingsInfoID.HasValue)
  130. {
  131. //建筑信息
  132. expClassroom = expClassroom.And(x => x.BuildingsInfoID == buildingsInfoID);
  133. }
  134. if (!string.IsNullOrEmpty(classroomName) && classroomName != "-1")
  135. {
  136. //教室名称
  137. expClassroom = expClassroom.And(x => x.Name == classroomName);
  138. }
  139. if (classroomTypeID.HasValue)
  140. {
  141. //教室类型(模糊查询)
  142. expClassroom = expClassroom.And(x => x.CF_ClassroomType.Select(w => w.ClassroomType).Contains(classroomTypeID));
  143. }
  144. if (collegeID.HasValue)
  145. {
  146. //院系所
  147. expClassroom = expClassroom.And(x => x.CollegeID == collegeID);
  148. }
  149. if (isConcurrentUse.HasValue)
  150. {
  151. //可否多班教学
  152. if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsYes)
  153. {
  154. expClassroom = expClassroom.And(x => x.IsConcurrentUse == true);
  155. }
  156. if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsNo)
  157. {
  158. expClassroom = expClassroom.And(x => x.IsConcurrentUse != true);
  159. }
  160. }
  161. if (isAvailable.HasValue)
  162. {
  163. //是否可用
  164. if (isAvailable.Value == (int)CF_GeneralPurpose.IsYes)
  165. {
  166. expClassroom = expClassroom.And(x => x.IsAvailable == true);
  167. }
  168. if (isAvailable.Value == (int)CF_GeneralPurpose.IsNo)
  169. {
  170. expClassroom = expClassroom.And(x => x.IsAvailable != true);
  171. }
  172. }
  173. var query = ClassroomDAL.GetClassroomViewQueryable(expClassroom);
  174. if (campusID.HasValue)
  175. {
  176. //校区
  177. query = query.Where(x => x.CampusID == campusID);
  178. }
  179. if (isReserve.HasValue)
  180. {
  181. //是否预留(排课用)
  182. if (isReserve.Value == (int)CF_GeneralPurpose.IsYes)
  183. {
  184. query = query.Where(x => x.IsReserve == true);
  185. }
  186. if (isReserve.Value == (int)CF_GeneralPurpose.IsNo)
  187. {
  188. query = query.Where(x => x.IsReserve != true);
  189. }
  190. }
  191. //查询条件
  192. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  193. {
  194. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  195. }
  196. return this.GetQueryByDataRangeByCampus(query).OrderBy(x => x.CampusCode.Length).ThenBy(x => x.CampusCode)
  197. .ThenBy(x => x.BuildingsInfoCode.Length).ThenBy(x => x.BuildingsInfoCode).ThenBy(x => x.Code.Length)
  198. .ThenBy(x => x.Code).ThenBy(x => x.RoomUseID).ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode).ToList();
  199. }
  200. /// <summary>
  201. /// 查询对应的教室信息CF_Classroom
  202. /// </summary>
  203. /// <param name="classroomID"></param>
  204. /// <returns></returns>
  205. public CF_Classroom GetClassroomInfo(Guid? classroomID)
  206. {
  207. try
  208. {
  209. var query = ClassroomDAL.ClassroomRepository.GetList(x => x.ClassroomID == classroomID).SingleOrDefault();
  210. return query;
  211. }
  212. catch (Exception ex)
  213. {
  214. throw new Exception(ex.Message);
  215. }
  216. }
  217. /// <summary>
  218. /// 查询对应的教室信息ClassroomView
  219. /// </summary>
  220. /// <param name="classroomID"></param>
  221. /// <returns></returns>
  222. public ClassroomView GetClassroomView(Guid? classroomID)
  223. {
  224. try
  225. {
  226. var query = ClassroomDAL.GetClassroomViewQueryable(x => x.ClassroomID == classroomID).SingleOrDefault();
  227. return query;
  228. }
  229. catch (Exception ex)
  230. {
  231. throw new Exception(ex.Message);
  232. }
  233. }
  234. /// <summary>
  235. /// 编辑(新增、修改,业务主键:教室编号唯一)
  236. /// </summary>
  237. /// <param name="classroomView"></param>
  238. public void ClassroomEdit(ClassroomView classroomView)
  239. {
  240. try
  241. {
  242. //查询数据库进行验证
  243. var classroomVerify = ClassroomDAL.ClassroomRepository.GetList(x => x.ClassroomID != classroomView.ClassroomID && x.Code == classroomView.Code).FirstOrDefault();
  244. if (classroomVerify == null)
  245. {
  246. //数据有误验证
  247. if (classroomView.ClassroomID != null && classroomView.ClassroomID != Guid.Empty)
  248. {
  249. var classroom = ClassroomDAL.ClassroomRepository.GetList(x => x.ClassroomID == classroomView.ClassroomID, x => x.CF_ClassroomType).SingleOrDefault();
  250. if (classroom == null)
  251. {
  252. throw new Exception("数据有误,请核查");
  253. }
  254. else
  255. {
  256. //表示修改
  257. classroom.Code = classroomView.Code.Trim();
  258. classroom.Name = classroomView.Name.Trim();
  259. classroom.BuildingsInfoID = classroomView.BuildingsInfoID;
  260. classroom.CollegeID = classroomView.CollegeID;
  261. classroom.LayoutTypeID = classroomView.LayoutTypeID;
  262. classroom.RoomUseID = classroomView.RoomUseID;
  263. classroom.FloorLevel = classroomView.FloorLevel;
  264. classroom.Acreage = classroomView.Acreage;
  265. classroom.RowCout = classroomView.RowCout;
  266. classroom.ColumnCount = classroomView.ColumnCount;
  267. classroom.Totalseating = classroomView.Totalseating;
  268. classroom.Effectiveseating = classroomView.Effectiveseating;
  269. classroom.Examinationseating = classroomView.Examinationseating;
  270. classroom.IsWrittenExam = classroomView.IsWrittenExam;
  271. classroom.IsMachinetest = classroomView.IsMachinetest;
  272. classroom.IsConcurrentUse = classroomView.IsConcurrentUse;
  273. classroom.IsAvailable = classroomView.IsAvailable;
  274. classroom.Remark = classroomView.Remark;
  275. SetModifyStatus(classroom);
  276. //教室类型
  277. if (classroomView.ClassroomTypeIDList != null && classroomView.ClassroomTypeIDList.Count() > 0)
  278. {
  279. UnitOfWork.Delete<EMIS.Entities.CF_ClassroomType>(x => x.ClassroomID == classroom.ClassroomID);
  280. foreach (var classroomTypeID in classroomView.ClassroomTypeIDList)
  281. {
  282. EMIS.Entities.CF_ClassroomType classroomModeType = new EMIS.Entities.CF_ClassroomType();
  283. classroomModeType.ClassroomTypeID = Guid.NewGuid();
  284. classroomModeType.ClassroomID = classroom.ClassroomID;
  285. classroomModeType.ClassroomType = classroomTypeID;
  286. SetNewStatus(classroomModeType);
  287. UnitOfWork.Add(classroomModeType);
  288. }
  289. }
  290. }
  291. }
  292. else
  293. {
  294. //表示新增
  295. CF_Classroom classroom = new CF_Classroom();
  296. classroom.ClassroomID = Guid.NewGuid();
  297. classroom.Code = classroomView.Code.Trim();
  298. classroom.Name = classroomView.Name.Trim();
  299. classroom.BuildingsInfoID = classroomView.BuildingsInfoID;
  300. classroom.CollegeID = classroomView.CollegeID;
  301. classroom.LayoutTypeID = classroomView.LayoutTypeID;
  302. classroom.RoomUseID = classroomView.RoomUseID;
  303. classroom.FloorLevel = classroomView.FloorLevel;
  304. classroom.Acreage = classroomView.Acreage;
  305. classroom.RowCout = classroomView.RowCout;
  306. classroom.ColumnCount = classroomView.ColumnCount;
  307. classroom.Totalseating = classroomView.Totalseating;
  308. classroom.Effectiveseating = classroomView.Effectiveseating;
  309. classroom.Examinationseating = classroomView.Examinationseating;
  310. classroom.IsWrittenExam = classroomView.IsWrittenExam;
  311. classroom.IsMachinetest = classroomView.IsMachinetest;
  312. classroom.IsConcurrentUse = classroomView.IsConcurrentUse;
  313. classroom.IsAvailable = classroomView.IsAvailable;
  314. classroom.Remark = classroomView.Remark;
  315. SetNewStatus(classroom);
  316. UnitOfWork.Add(classroom);
  317. //教室类型
  318. if (classroomView.ClassroomTypeIDList != null && classroomView.ClassroomTypeIDList.Count() > 0)
  319. {
  320. //UnitOfWork.Delete<EMIS.Entities.CF_ClassroomType>(x => x.ClassroomID == classroom.ClassroomID);
  321. foreach (var classroomTypeID in classroomView.ClassroomTypeIDList)
  322. {
  323. EMIS.Entities.CF_ClassroomType classroomModeType = new EMIS.Entities.CF_ClassroomType();
  324. classroomModeType.ClassroomTypeID = Guid.NewGuid();
  325. classroomModeType.ClassroomID = classroom.ClassroomID;
  326. classroomModeType.ClassroomType = classroomTypeID;
  327. SetNewStatus(classroomModeType);
  328. UnitOfWork.Add(classroomModeType);
  329. }
  330. }
  331. }
  332. }
  333. else
  334. {
  335. throw new Exception("已存在相同的教室编号,请核查");
  336. }
  337. //事务提交
  338. UnitOfWork.Commit();
  339. }
  340. catch (Exception ex)
  341. {
  342. throw new Exception(ex.Message);
  343. }
  344. }
  345. /// <summary>
  346. /// 增加对应的教室类型(根据教室信息ID、教室类型List)
  347. /// </summary>
  348. /// <param name="classroomID"></param>
  349. /// <param name="list"></param>
  350. /// <returns></returns>
  351. public bool ClassroomModeTypeAdd(Guid? classroomID, List<int> list)
  352. {
  353. try
  354. {
  355. if (list != null && list.Count() > 0)
  356. {
  357. UnitOfWork.Delete<EMIS.Entities.CF_ClassroomType>(x => x.ClassroomID == classroomID);
  358. foreach (var value in list)
  359. {
  360. EMIS.Entities.CF_ClassroomType classroomModeType = new EMIS.Entities.CF_ClassroomType();
  361. classroomModeType.ClassroomTypeID = Guid.NewGuid();
  362. classroomModeType.ClassroomID = classroomID;
  363. classroomModeType.ClassroomType = value;
  364. SetNewStatus(classroomModeType);
  365. UnitOfWork.Add(classroomModeType);
  366. }
  367. UnitOfWork.Commit();
  368. return true;
  369. }
  370. return false;
  371. }
  372. catch (Exception ex)
  373. {
  374. throw new Exception(ex.Message);
  375. }
  376. }
  377. /// <summary>
  378. /// 删除
  379. /// </summary>
  380. /// <param name="classroomIDList"></param>
  381. /// <returns></returns>
  382. public bool ClassroomDelete(List<Guid?> classroomIDList)
  383. {
  384. try
  385. {
  386. using (TransactionScope ts = new TransactionScope())
  387. {
  388. UnitOfWork.Delete<EMIS.Entities.CF_ClassroomType>(x => classroomIDList.Contains(x.ClassroomID));
  389. UnitOfWork.Delete<CF_Classroom>(x => classroomIDList.Contains(x.ClassroomID));
  390. ts.Complete();
  391. return true;
  392. }
  393. }
  394. catch (Exception)
  395. {
  396. throw;
  397. }
  398. }
  399. /// <summary>
  400. /// 根据教室信息ID查询对应的教室类型List
  401. /// </summary>
  402. /// <param name="classroomID"></param>
  403. /// <returns></returns>
  404. public List<int> GetClassroomTypeList(Guid? classroomID)
  405. {
  406. var query = ClassroomDAL.GetClassroomModeTypeQueryble(classroomID);
  407. return query.OrderBy(x => x).ToList();
  408. }
  409. /// <summary>
  410. /// 查询教室信息对应的排课分配院系所信息ClassroomView(无数据范围)
  411. /// </summary>
  412. /// <param name="configuretView"></param>
  413. /// <param name="classroomID"></param>
  414. /// <param name="campusID"></param>
  415. /// <param name="collegeID"></param>
  416. /// <param name="unitCategoryID"></param>
  417. /// <param name="pageIndex"></param>
  418. /// <param name="pageSize"></param>
  419. /// <returns></returns>
  420. public IGridResultSet<ClassroomView> GetClassroomCollegeViewGrid(ConfiguretView configuretView, Guid? classroomID, Guid? campusID, Guid? collegeID, int? unitCategoryID, int pageIndex, int pageSize)
  421. {
  422. Expression<Func<CF_Classroom, bool>> expClassroom = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  423. expClassroom = expClassroom.And(x => x.ClassroomID == classroomID);
  424. var query = ClassroomDAL.GetClassroomCollegeViewQueryable(expClassroom);
  425. if (campusID.HasValue)
  426. {
  427. query = query.Where(x => x.CollegeCampusID == campusID);
  428. }
  429. if (collegeID.HasValue)
  430. {
  431. query = query.Where(x => x.CollegeID == collegeID);
  432. }
  433. if (unitCategoryID.HasValue)
  434. {
  435. query = query.Where(x => x.UnitCategoryID == unitCategoryID);
  436. }
  437. //查询条件
  438. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  439. {
  440. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  441. }
  442. return query.OrderBy(x => x.Code.Length).ThenBy(x => x.Code).ThenBy(x => x.RoomUseID).ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  443. .OrderBy(x => x.CollegeCampusCode.Length).ThenBy(x => x.CollegeCampusCode).ToGridResultSet<ClassroomView>(pageIndex, pageSize);
  444. }
  445. /// <summary>
  446. /// 查询教室信息对应的排课分配院系所信息List(无数据范围)
  447. /// </summary>
  448. /// <param name="configuretView"></param>
  449. /// <param name="classroomID"></param>
  450. /// <param name="campusID"></param>
  451. /// <param name="collegeID"></param>
  452. /// <param name="unitCategoryID"></param>
  453. /// <returns></returns>
  454. public IList<ClassroomView> GetClassroomCollegeViewList(ConfiguretView configuretView, Guid? classroomID, Guid? campusID, Guid? collegeID, int? unitCategoryID)
  455. {
  456. Expression<Func<CF_Classroom, bool>> expClassroom = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
  457. expClassroom = expClassroom.And(x => x.ClassroomID == classroomID);
  458. var query = ClassroomDAL.GetClassroomCollegeViewQueryable(expClassroom);
  459. if (campusID.HasValue)
  460. {
  461. query = query.Where(x => x.CollegeCampusID == campusID);
  462. }
  463. if (collegeID.HasValue)
  464. {
  465. query = query.Where(x => x.CollegeID == collegeID);
  466. }
  467. if (unitCategoryID.HasValue)
  468. {
  469. query = query.Where(x => x.UnitCategoryID == unitCategoryID);
  470. }
  471. //查询条件
  472. if (!string.IsNullOrEmpty(configuretView.ConditionValue))
  473. {
  474. query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
  475. }
  476. return query.OrderBy(x => x.Code.Length).ThenBy(x => x.Code).ThenBy(x => x.RoomUseID).ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode)
  477. .OrderBy(x => x.CollegeCampusCode.Length).ThenBy(x => x.CollegeCampusCode).ToList();
  478. }
  479. /// <summary>
  480. /// Excel教室信息导入
  481. /// </summary>
  482. /// <param name="cellheader"></param>
  483. /// <param name="inCount"></param>
  484. /// <param name="upCount"></param>
  485. /// <param name="errdataList"></param>
  486. /// <param name="errCount"></param>
  487. /// <param name="sourcePhysicalPath"></param>
  488. public void ClassroomImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount, out List<ClassroomView> errdataList, out int? errCount, string sourcePhysicalPath)
  489. {
  490. try
  491. {
  492. StringBuilder errorMsg = new StringBuilder();
  493. List<ClassroomView> errList = new List<ClassroomView>();
  494. // 1.1解析文件,存放到一个List集合里
  495. cellheader.Remove("ErrorMessage");
  496. List<ClassroomView> enlist = NpoiExcelHelper.ExcelToEntityList<ClassroomView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
  497. cellheader.Add("ErrorMessage", "未导入原因");
  498. //对List集合进行有效性校验
  499. if (enlist.Count() <= 0)
  500. {
  501. throw new Exception("Excel文件数据为空,请检查。");
  502. }
  503. Regex reg = null; //正则表达式
  504. //DateTime result; //用于返回判断日期字段格式
  505. bool isClassroomTypePass = true; //教室类型判断标识
  506. inCount = 0; //导入个数
  507. upCount = 0; //更新个数
  508. errCount = 0; //失败个数
  509. string errorMsgStr = ""; //错误信息
  510. List<CF_Classroom> newClassroomInList = new List<CF_Classroom>();
  511. List<CF_Classroom> newClassroomUpList = new List<CF_Classroom>();
  512. List<EMIS.Entities.CF_ClassroomType> newClassroomTypeInList = new List<Entities.CF_ClassroomType>();
  513. List<Guid?> classroomCTDelList = new List<Guid?>();
  514. //将循环中相关数据库查询统一查询出来进行匹配(尽量避免在循环中进行数据库查询)
  515. //建筑信息
  516. var buildingsInfoList = ClassroomDAL.BuildingsInfoRepository.GetList(x => true).ToList();
  517. //建筑编号
  518. var buildingsInfoCodeList = enlist.Where(x => !string.IsNullOrEmpty(x.BuildingsInfoCode)).Select(x => x.BuildingsInfoCode).ToList();
  519. //对比后的newBuildingsInfoList
  520. var newBuildingsInfoList = buildingsInfoList.Where(x => buildingsInfoCodeList.Contains(x.Code)).ToList();
  521. //院系所信息
  522. var collegeList = ClassroomDAL.CollegeRepository.GetList(x => true, x => x.CF_Campus).ToList();
  523. //院系所代码
  524. var collegeNoList = enlist.Where(x => !string.IsNullOrEmpty(x.CollegeCode)).Select(x => x.CollegeCode).ToList();
  525. //对比后的newCollegeList
  526. var newCollegeList = collegeList.Where(x => collegeNoList.Contains(x.No)).ToList();
  527. //房间用途
  528. var roomUseList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_RoomUse).ToList();
  529. //教室类型
  530. var classroomTypeDicList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_ClassroomType).ToList();
  531. //是否启用
  532. var generalPurposeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_GeneralPurpose).ToList();
  533. //教室信息
  534. var classroomList = ClassroomDAL.ClassroomRepository.GetList(x => true).ToList();
  535. //教室编号
  536. var classroomCodeList = enlist.Where(x => !string.IsNullOrEmpty(x.Code)).Select(x => x.Code).ToList();
  537. //对比后的newClassroomList(暂时只对比教室编号)
  538. var newClassroomList = classroomList.Where(x => classroomCodeList.Contains(x.Code)).ToList();
  539. //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
  540. for (int i = 0; i < enlist.Count; i++)
  541. {
  542. ClassroomView en = enlist[i]; //Excel表数据视图
  543. CF_Classroom newClassroom = new CF_Classroom();
  544. List<int> newClassroomTypeIDList = new List<int>();
  545. //教室编号
  546. if (string.IsNullOrWhiteSpace(en.Code))
  547. {
  548. errCount++;
  549. errorMsgStr = "教室编号不能为空";
  550. en.ErrorMessage = errorMsgStr;
  551. errList.Add(en);
  552. errorMsg.AppendLine(errorMsgStr);
  553. continue;
  554. }
  555. else
  556. {
  557. //教室编号
  558. newClassroom.Code = en.Code.Trim();
  559. }
  560. //教室名称
  561. if (string.IsNullOrWhiteSpace(en.Name))
  562. {
  563. errCount++;
  564. errorMsgStr = "教室名称不能为空";
  565. en.ErrorMessage = errorMsgStr;
  566. errList.Add(en);
  567. errorMsg.AppendLine(errorMsgStr);
  568. continue;
  569. }
  570. else
  571. {
  572. //教室名称
  573. newClassroom.Name = en.Name.Trim();
  574. }
  575. //建筑编号
  576. if (string.IsNullOrWhiteSpace(en.BuildingsInfoCode))
  577. {
  578. errCount++;
  579. errorMsgStr = "建筑编号不能为空";
  580. en.ErrorMessage = errorMsgStr;
  581. errList.Add(en);
  582. errorMsg.AppendLine(errorMsgStr);
  583. continue;
  584. }
  585. else
  586. {
  587. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
  588. if (!reg.IsMatch(en.BuildingsInfoCode.Trim()))
  589. {
  590. errCount++;
  591. errorMsgStr = "建筑编号格式不正确,请检查(数字或英文字母)";
  592. en.ErrorMessage = errorMsgStr;
  593. errList.Add(en);
  594. errorMsg.AppendLine(errorMsgStr);
  595. continue;
  596. }
  597. else
  598. {
  599. var buildingsInfo = newBuildingsInfoList.Where(x => x.Code == en.BuildingsInfoCode.Trim()).SingleOrDefault();
  600. if (buildingsInfo == null)
  601. {
  602. errCount++;
  603. errorMsgStr = "建筑编号不存在,请检查";
  604. en.ErrorMessage = errorMsgStr;
  605. errList.Add(en);
  606. errorMsg.AppendLine(errorMsgStr);
  607. continue;
  608. }
  609. else
  610. {
  611. //建筑信息ID
  612. newClassroom.BuildingsInfoID = buildingsInfo.BuildingsInfoID;
  613. //建筑信息对应的校区
  614. en.CampusID = buildingsInfo.CampusID;
  615. }
  616. }
  617. }
  618. //院系所代码
  619. if (string.IsNullOrWhiteSpace(en.CollegeCode))
  620. {
  621. //不考虑
  622. }
  623. else
  624. {
  625. reg = new Regex(@"^[0-9a-zA-Z\s?]+$"); //正则表达式(请输入数字或英文字母)
  626. if (!reg.IsMatch(en.CollegeCode.Trim()))
  627. {
  628. errCount++;
  629. errorMsgStr = RSL.Get("CollegeCode") + "格式不正确,请检查(数字或英文字母)";
  630. en.ErrorMessage = errorMsgStr;
  631. errList.Add(en);
  632. errorMsg.AppendLine(errorMsgStr);
  633. continue;
  634. }
  635. else
  636. {
  637. var college = newCollegeList.Where(x => x.No == en.CollegeCode.Trim()).SingleOrDefault();
  638. if (college == null)
  639. {
  640. errCount++;
  641. errorMsgStr = RSL.Get("CollegeCode") + "不存在,请检查";
  642. en.ErrorMessage = errorMsgStr;
  643. errList.Add(en);
  644. errorMsg.AppendLine(errorMsgStr);
  645. continue;
  646. }
  647. else
  648. {
  649. ////判断院系所对应的校区与建筑信息对应的校区(暂不考虑)
  650. //if (college.CampusID == en.CampusID)
  651. //{
  652. // //院系所信息ID
  653. // newClassroom.CollegeID = college.CollegeID;
  654. //}
  655. //else
  656. //{
  657. // errCount++;
  658. // errorMsgStr = "建筑信息中对应的" + RSL.Get("CampusCode")
  659. // + "与" + RSL.Get("CollegeCode") + "对应关系不存在,请检查";
  660. // en.ErrorMessage = errorMsgStr;
  661. // errList.Add(en);
  662. // errorMsg.AppendLine(errorMsgStr);
  663. // continue;
  664. //}
  665. //院系所信息ID
  666. newClassroom.CollegeID = college.CollegeID;
  667. }
  668. }
  669. }
  670. //教室类型
  671. if (string.IsNullOrWhiteSpace(en.ClassroomTypeIDListStr))
  672. {
  673. errCount++;
  674. errorMsgStr = "教室类型不能为空(存在多个教室类型时,可用顿号隔开)";
  675. en.ErrorMessage = errorMsgStr;
  676. errList.Add(en);
  677. errorMsg.AppendLine(errorMsgStr);
  678. continue;
  679. }
  680. else
  681. {
  682. //教室类型可为多个(可用顿号隔开)
  683. List<string> list = en.ClassroomTypeIDListStr.Split('、').Where(x => !string.IsNullOrEmpty(x)).Select(x => x.Trim()).Distinct().ToList();
  684. foreach (var item in list)
  685. {
  686. var classroomTypeDic = classroomTypeDicList.Where(x => x.Name == item.Trim()).SingleOrDefault();
  687. if (classroomTypeDic == null)
  688. {
  689. errCount++;
  690. errorMsgStr = "教室类型(" + item.Trim() + ")不存在,请检查(存在多个教室类型时,可用顿号隔开)";
  691. en.ErrorMessage = errorMsgStr;
  692. errList.Add(en);
  693. errorMsg.AppendLine(errorMsgStr);
  694. isClassroomTypePass = false;
  695. break;
  696. }
  697. }
  698. if (isClassroomTypePass)
  699. {
  700. newClassroomTypeIDList = classroomTypeDicList.Where(x => list.Contains(x.Name)).Select(x => x.Value.Value).ToList();
  701. }
  702. else
  703. {
  704. isClassroomTypePass = true;
  705. continue;
  706. }
  707. }
  708. //布局类型(暂不考虑)
  709. //房间用途
  710. if (string.IsNullOrWhiteSpace(en.RoomUseStr))
  711. {
  712. //不考虑
  713. }
  714. else
  715. {
  716. var roomUse = roomUseList.Where(x => x.Name == en.RoomUseStr.Trim()).SingleOrDefault();
  717. if (roomUse == null)
  718. {
  719. errCount++;
  720. errorMsgStr = "房间用途不存在,请检查";
  721. en.ErrorMessage = errorMsgStr;
  722. errList.Add(en);
  723. errorMsg.AppendLine(errorMsgStr);
  724. continue;
  725. }
  726. else
  727. {
  728. //房间用途
  729. newClassroom.RoomUseID = roomUse.Value;
  730. }
  731. }
  732. //所在楼层
  733. if (string.IsNullOrWhiteSpace(en.FloorLevelStr))
  734. {
  735. //不考虑
  736. }
  737. else
  738. {
  739. reg = new Regex(@"^-?\d+$"); //正则表达式(整数)
  740. if (!reg.IsMatch(en.FloorLevelStr.Trim()))
  741. {
  742. errCount++;
  743. errorMsgStr = "所在楼层格式不正确,请检查(请输入整数)";
  744. en.ErrorMessage = errorMsgStr;
  745. errList.Add(en);
  746. errorMsg.AppendLine(errorMsgStr);
  747. continue;
  748. }
  749. else
  750. {
  751. //所在楼层
  752. newClassroom.FloorLevel = Convert.ToInt32(en.FloorLevelStr.Trim());
  753. }
  754. }
  755. //面积
  756. if (string.IsNullOrWhiteSpace(en.AcreageStr))
  757. {
  758. //不考虑
  759. }
  760. else
  761. {
  762. reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$"); //正则表达式()
  763. if (!reg.IsMatch(en.AcreageStr.Trim()))
  764. {
  765. errCount++;
  766. errorMsgStr = "面积格式不正确,请检查(请输入数字)";
  767. en.ErrorMessage = errorMsgStr;
  768. errList.Add(en);
  769. errorMsg.AppendLine(errorMsgStr);
  770. continue;
  771. }
  772. else
  773. {
  774. //面积
  775. newClassroom.Acreage = Convert.ToDecimal(en.AcreageStr.Trim());
  776. }
  777. }
  778. //行数
  779. if (string.IsNullOrWhiteSpace(en.RowCoutStr))
  780. {
  781. //不考虑
  782. }
  783. else
  784. {
  785. reg = new Regex(@"^\d+$"); //正则表达式(非负整数)
  786. if (!reg.IsMatch(en.RowCoutStr.Trim()))
  787. {
  788. errCount++;
  789. errorMsgStr = "行数格式不正确,请检查(请输入非负整数)";
  790. en.ErrorMessage = errorMsgStr;
  791. errList.Add(en);
  792. errorMsg.AppendLine(errorMsgStr);
  793. continue;
  794. }
  795. else
  796. {
  797. //行数
  798. newClassroom.RowCout = Convert.ToInt32(en.RowCoutStr.Trim());
  799. }
  800. }
  801. //列数
  802. if (string.IsNullOrWhiteSpace(en.ColumnCountStr))
  803. {
  804. //不考虑
  805. }
  806. else
  807. {
  808. reg = new Regex(@"^\d+$"); //正则表达式(非负整数)
  809. if (!reg.IsMatch(en.ColumnCountStr.Trim()))
  810. {
  811. errCount++;
  812. errorMsgStr = "列数格式不正确,请检查(请输入负零整数)";
  813. en.ErrorMessage = errorMsgStr;
  814. errList.Add(en);
  815. errorMsg.AppendLine(errorMsgStr);
  816. continue;
  817. }
  818. else
  819. {
  820. //列数
  821. newClassroom.ColumnCount = Convert.ToInt32(en.ColumnCountStr.Trim());
  822. }
  823. }
  824. //总座位数
  825. if (string.IsNullOrWhiteSpace(en.TotalseatingStr))
  826. {
  827. //不考虑
  828. }
  829. else
  830. {
  831. reg = new Regex(@"^\d+$"); //正则表达式(非负整数)
  832. if (!reg.IsMatch(en.TotalseatingStr.Trim()))
  833. {
  834. errCount++;
  835. errorMsgStr = "总座位数格式不正确,请检查(请输入非负整数)";
  836. en.ErrorMessage = errorMsgStr;
  837. errList.Add(en);
  838. errorMsg.AppendLine(errorMsgStr);
  839. continue;
  840. }
  841. else
  842. {
  843. //总座位数
  844. newClassroom.Totalseating = Convert.ToInt32(en.TotalseatingStr.Trim());
  845. }
  846. }
  847. //有效座位数
  848. if (string.IsNullOrWhiteSpace(en.EffectiveseatingStr))
  849. {
  850. //不考虑
  851. }
  852. else
  853. {
  854. reg = new Regex(@"^\d+$"); //正则表达式(非负整数)
  855. if (!reg.IsMatch(en.EffectiveseatingStr.Trim()))
  856. {
  857. errCount++;
  858. errorMsgStr = "有效座位数格式不正确,请检查(请输入非负整数)";
  859. en.ErrorMessage = errorMsgStr;
  860. errList.Add(en);
  861. errorMsg.AppendLine(errorMsgStr);
  862. continue;
  863. }
  864. else
  865. {
  866. //有效座位数
  867. newClassroom.Effectiveseating = Convert.ToInt32(en.EffectiveseatingStr.Trim());
  868. //座位判断
  869. if (newClassroom.Totalseating != null)
  870. {
  871. if (newClassroom.Effectiveseating.Value > newClassroom.Totalseating.Value)
  872. {
  873. errCount++;
  874. errorMsgStr = "有效座位数不能大于总座位数,请检查";
  875. en.ErrorMessage = errorMsgStr;
  876. errList.Add(en);
  877. errorMsg.AppendLine(errorMsgStr);
  878. continue;
  879. }
  880. }
  881. }
  882. }
  883. //考试座位数
  884. if (string.IsNullOrWhiteSpace(en.ExaminationseatingStr))
  885. {
  886. //不考虑
  887. }
  888. else
  889. {
  890. reg = new Regex(@"^\d+$"); //正则表达式(非负整数)
  891. if (!reg.IsMatch(en.ExaminationseatingStr.Trim()))
  892. {
  893. errCount++;
  894. errorMsgStr = "考试座位数格式不正确,请检查(请输入非负整数)";
  895. en.ErrorMessage = errorMsgStr;
  896. errList.Add(en);
  897. errorMsg.AppendLine(errorMsgStr);
  898. continue;
  899. }
  900. else
  901. {
  902. //考试座位数
  903. newClassroom.Examinationseating = Convert.ToInt32(en.ExaminationseatingStr.Trim());
  904. //座位判断
  905. if (newClassroom.Totalseating != null)
  906. {
  907. if (newClassroom.Examinationseating.Value > newClassroom.Totalseating.Value)
  908. {
  909. errCount++;
  910. errorMsgStr = "考试座位数不能大于总座位数,请检查";
  911. en.ErrorMessage = errorMsgStr;
  912. errList.Add(en);
  913. errorMsg.AppendLine(errorMsgStr);
  914. continue;
  915. }
  916. }
  917. }
  918. }
  919. //可否笔试
  920. if (string.IsNullOrWhiteSpace(en.IsWrittenExamStr))
  921. {
  922. //可否笔试(默认为否)
  923. newClassroom.IsWrittenExam = false;
  924. }
  925. else
  926. {
  927. var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsWrittenExamStr.Trim()).SingleOrDefault();
  928. if (generalPurpose == null)
  929. {
  930. errCount++;
  931. errorMsgStr = "可否笔试不存在,请检查";
  932. en.ErrorMessage = errorMsgStr;
  933. errList.Add(en);
  934. errorMsg.AppendLine(errorMsgStr);
  935. continue;
  936. }
  937. else
  938. {
  939. //可否笔试
  940. newClassroom.IsWrittenExam = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  941. }
  942. }
  943. //可否机试
  944. if (string.IsNullOrWhiteSpace(en.IsMachinetestStr))
  945. {
  946. //可否机试(默认为否)
  947. newClassroom.IsMachinetest = false;
  948. }
  949. else
  950. {
  951. var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsMachinetestStr.Trim()).SingleOrDefault();
  952. if (generalPurpose == null)
  953. {
  954. errCount++;
  955. errorMsgStr = "可否机试不存在,请检查";
  956. en.ErrorMessage = errorMsgStr;
  957. errList.Add(en);
  958. errorMsg.AppendLine(errorMsgStr);
  959. continue;
  960. }
  961. else
  962. {
  963. //可否机试
  964. newClassroom.IsMachinetest = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  965. }
  966. }
  967. //可否多班教学
  968. if (string.IsNullOrWhiteSpace(en.IsConcurrentUseStr))
  969. {
  970. //可否多班教学(默认为否)
  971. newClassroom.IsConcurrentUse = false;
  972. }
  973. else
  974. {
  975. var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsConcurrentUseStr.Trim()).SingleOrDefault();
  976. if (generalPurpose == null)
  977. {
  978. errCount++;
  979. errorMsgStr = "可否多班教学不存在,请检查";
  980. en.ErrorMessage = errorMsgStr;
  981. errList.Add(en);
  982. errorMsg.AppendLine(errorMsgStr);
  983. continue;
  984. }
  985. else
  986. {
  987. //可否多班教学
  988. newClassroom.IsConcurrentUse = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  989. }
  990. }
  991. //是否可用
  992. if (string.IsNullOrWhiteSpace(en.IsAvailableStr))
  993. {
  994. errCount++;
  995. errorMsgStr = "是否可用不能为空";
  996. en.ErrorMessage = errorMsgStr;
  997. errList.Add(en);
  998. errorMsg.AppendLine(errorMsgStr);
  999. continue;
  1000. }
  1001. else
  1002. {
  1003. var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsAvailableStr.Trim()).SingleOrDefault();
  1004. if (generalPurpose == null)
  1005. {
  1006. errCount++;
  1007. errorMsgStr = "是否可用不存在,请检查";
  1008. en.ErrorMessage = errorMsgStr;
  1009. errList.Add(en);
  1010. errorMsg.AppendLine(errorMsgStr);
  1011. continue;
  1012. }
  1013. else
  1014. {
  1015. //是否可用
  1016. newClassroom.IsAvailable = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
  1017. }
  1018. }
  1019. //备注
  1020. if (string.IsNullOrWhiteSpace(en.Remark))
  1021. {
  1022. //不考虑
  1023. }
  1024. else
  1025. {
  1026. newClassroom.Remark = en.Remark;
  1027. }
  1028. ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉)
  1029. //for (int j = i + 1; j < enlist.Count; j++)
  1030. //{
  1031. // NewClassroomView enA = enlist[j];
  1032. // //根据Excel表中的业务主键进行去重(教室编号唯一)
  1033. // if (en.No == enA.No && en.Name == enA.Name)
  1034. // {
  1035. // //用于标识Excel表中的重复记录(由于是批量进行插入数据表)
  1036. // }
  1037. //}
  1038. //数据表重复性验证(教室编号唯一)
  1039. var classroomVerify = newClassroomList.Where(x => x.Code == newClassroom.Code).SingleOrDefault();
  1040. if (classroomVerify == null)
  1041. {
  1042. //新增
  1043. if (!newClassroomInList.Any(x => x.Code == newClassroom.Code))
  1044. {
  1045. newClassroom.ClassroomID = Guid.NewGuid();
  1046. SetNewStatus(newClassroom);
  1047. newClassroomInList.Add(newClassroom);
  1048. //教室类型
  1049. if (newClassroomTypeIDList != null && newClassroomTypeIDList.Count() > 0)
  1050. {
  1051. foreach (var value in newClassroomTypeIDList)
  1052. {
  1053. EMIS.Entities.CF_ClassroomType classroomModeType = new EMIS.Entities.CF_ClassroomType();
  1054. classroomModeType.ClassroomTypeID = Guid.NewGuid();
  1055. classroomModeType.ClassroomID = newClassroom.ClassroomID;
  1056. classroomModeType.ClassroomType = value;
  1057. SetNewStatus(classroomModeType);
  1058. newClassroomTypeInList.Add(classroomModeType);
  1059. }
  1060. }
  1061. inCount++;
  1062. }
  1063. else
  1064. {
  1065. //Excel表重复性验证
  1066. //(注:当数据表中没有此记录,但是Excel中有重复数据,可在此处进行抛出到失败数据文件中,目前暂不考虑)
  1067. inCount++;
  1068. }
  1069. }
  1070. else
  1071. {
  1072. //更新(Excel有重复时,以最后一条记录的更新为准)
  1073. classroomVerify.Name = newClassroom.Name;
  1074. classroomVerify.BuildingsInfoID = newClassroom.BuildingsInfoID;
  1075. classroomVerify.CollegeID = newClassroom.CollegeID;
  1076. classroomVerify.LayoutTypeID = newClassroom.LayoutTypeID;
  1077. classroomVerify.RoomUseID = newClassroom.RoomUseID;
  1078. classroomVerify.FloorLevel = newClassroom.FloorLevel;
  1079. classroomVerify.Acreage = newClassroom.Acreage;
  1080. classroomVerify.RowCout = newClassroom.RowCout;
  1081. classroomVerify.ColumnCount = newClassroom.ColumnCount;
  1082. classroomVerify.Totalseating = newClassroom.Totalseating;
  1083. classroomVerify.Effectiveseating = newClassroom.Effectiveseating;
  1084. classroomVerify.Examinationseating = newClassroom.Examinationseating;
  1085. classroomVerify.IsWrittenExam = newClassroom.IsWrittenExam;
  1086. classroomVerify.IsMachinetest = newClassroom.IsMachinetest;
  1087. classroomVerify.IsConcurrentUse = newClassroom.IsConcurrentUse;
  1088. classroomVerify.IsAvailable = newClassroom.IsAvailable;
  1089. classroomVerify.Remark = newClassroom.Remark;
  1090. SetModifyStatus(classroomVerify);
  1091. newClassroomUpList.Add(classroomVerify);
  1092. //教室类型
  1093. if (newClassroomTypeIDList != null && newClassroomTypeIDList.Count() > 0)
  1094. {
  1095. if (newClassroomTypeInList.Any(x => x.ClassroomID == classroomVerify.ClassroomID))
  1096. {
  1097. newClassroomTypeInList.RemoveAll(x => x.ClassroomID == classroomVerify.ClassroomID);
  1098. }
  1099. classroomCTDelList.Add(classroomVerify.ClassroomID);
  1100. foreach (var value in newClassroomTypeIDList)
  1101. {
  1102. EMIS.Entities.CF_ClassroomType classroomModeType = new EMIS.Entities.CF_ClassroomType();
  1103. classroomModeType.ClassroomTypeID = Guid.NewGuid();
  1104. classroomModeType.ClassroomID = classroomVerify.ClassroomID;
  1105. classroomModeType.ClassroomType = value;
  1106. SetNewStatus(classroomModeType);
  1107. newClassroomTypeInList.Add(classroomModeType);
  1108. }
  1109. }
  1110. else
  1111. {
  1112. classroomCTDelList.Add(classroomVerify.ClassroomID);
  1113. }
  1114. upCount++;
  1115. }
  1116. }
  1117. using (TransactionScope ts = new TransactionScope())
  1118. {
  1119. //删除
  1120. UnitOfWork.Delete<EMIS.Entities.CF_ClassroomType>(x => classroomCTDelList.Contains(x.ClassroomID));
  1121. //批量插入
  1122. UnitOfWork.BulkInsert(newClassroomInList);
  1123. UnitOfWork.BulkInsert<EMIS.Entities.CF_ClassroomType>(newClassroomTypeInList);
  1124. //批量统一提交更新
  1125. if (newClassroomUpList != null && newClassroomUpList.Count() > 0)
  1126. {
  1127. UnitOfWork.BatchUpdate(newClassroomUpList);
  1128. }
  1129. ts.Complete();
  1130. }
  1131. errdataList = errList.Distinct().ToList(); //错误列表List
  1132. }
  1133. catch (Exception)
  1134. {
  1135. //目前会出现,由于错误信息字符太长,无法抛出弹出框的问题
  1136. throw;
  1137. }
  1138. }
  1139. }
  1140. }