123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797798799800801802803804805806807808809810811812813814815816817818819820821822823824825826827828829830831832833834835836837838839840841842843844845846847848849850851852853854855856857858859 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Linq.Expressions;
- using System.Text;
- using System.Text.RegularExpressions;
- using System.Transactions;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using Bowin.Common.Utility;
- using EMIS.Entities;
- using EMIS.Utility;
- using EMIS.ViewModel;
- using EMIS.ViewModel.CacheManage;
- using EMIS.ViewModel.UniversityManage.ClassroomManage;
- using EMIS.DataLogic.UniversityManage.ClassroomManage;
- namespace EMIS.CommonLogic.UniversityManage.ClassroomManage
- {
- public class BuildingsInfoServices : BaseServices, IBuildingsInfoServices
- {
- public BuildingsInfoDAL BuildingsInfoDAL { get; set; }
-
-
-
-
-
-
-
-
-
-
-
- public IGridResultSet<BuildingsInfoView> GetBuildingsInfoViewGrid(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? buildingsTypeID, int? isSpecial, int pageIndex, int pageSize)
- {
- Expression<Func<CF_BuildingsInfo, bool>> expBuildingsInfo = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (campusID.HasValue)
- {
-
- expBuildingsInfo = expBuildingsInfo.And(x => x.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
-
- expBuildingsInfo = expBuildingsInfo.And(x => x.CollegeID == collegeID);
- }
- if (buildingsTypeID.HasValue)
- {
-
- expBuildingsInfo = expBuildingsInfo.And(x => x.BuildingsTypeID == buildingsTypeID);
- }
- if (isSpecial.HasValue)
- {
-
- if (isSpecial.Value == (int)CF_GeneralPurpose.IsYes)
- {
- expBuildingsInfo = expBuildingsInfo.And(x => x.IsSpecial == true);
- }
- if (isSpecial.Value == (int)CF_GeneralPurpose.IsNo)
- {
- expBuildingsInfo = expBuildingsInfo.And(x => x.IsSpecial != true);
- }
- }
- var query = BuildingsInfoDAL.GetBuildingsInfoViewQueryable(expBuildingsInfo);
-
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCampus(query).OrderBy(x => x.CampusCode.Length).ThenBy(x => x.CampusCode).ThenBy(x => x.Code.Length)
- .ThenBy(x => x.Code).ThenBy(x => x.BuildingsTypeID).ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode).ToGridResultSet<BuildingsInfoView>(pageIndex, pageSize);
- }
-
-
-
-
-
-
-
-
-
- public IList<BuildingsInfoView> GetBuildingsInfoViewList(ConfiguretView configuretView, Guid? campusID, Guid? collegeID, int? buildingsTypeID, int? isSpecial)
- {
- Expression<Func<CF_BuildingsInfo, bool>> expBuildingsInfo = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- if (campusID.HasValue)
- {
-
- expBuildingsInfo = expBuildingsInfo.And(x => x.CampusID == campusID);
- }
- if (collegeID.HasValue)
- {
-
- expBuildingsInfo = expBuildingsInfo.And(x => x.CollegeID == collegeID);
- }
- if (buildingsTypeID.HasValue)
- {
-
- expBuildingsInfo = expBuildingsInfo.And(x => x.BuildingsTypeID == buildingsTypeID);
- }
- if (isSpecial.HasValue)
- {
-
- if (isSpecial.Value == (int)CF_GeneralPurpose.IsYes)
- {
- expBuildingsInfo = expBuildingsInfo.And(x => x.IsSpecial == true);
- }
- if (isSpecial.Value == (int)CF_GeneralPurpose.IsNo)
- {
- expBuildingsInfo = expBuildingsInfo.And(x => x.IsSpecial != true);
- }
- }
- var query = BuildingsInfoDAL.GetBuildingsInfoViewQueryable(expBuildingsInfo);
-
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return this.GetQueryByDataRangeByCampus(query).OrderBy(x => x.CampusCode.Length).ThenBy(x => x.CampusCode).ThenBy(x => x.Code.Length)
- .ThenBy(x => x.Code).ThenBy(x => x.BuildingsTypeID).ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode).ToList();
- }
-
-
-
-
-
- public CF_BuildingsInfo GetBuildingsInfo(Guid? buildingsInfoID)
- {
- try
- {
- var query = BuildingsInfoDAL.BuildingsInfoRepository.GetList(x => x.BuildingsInfoID == buildingsInfoID).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
-
-
-
-
- public BuildingsInfoView GetBuildingsInfoView(Guid? buildingsInfoID)
- {
- try
- {
- var query = BuildingsInfoDAL.GetBuildingsInfoViewQueryable(x => x.BuildingsInfoID == buildingsInfoID).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
-
-
-
- public void BuildingsInfoEdit(BuildingsInfoView buildingsInfoView)
- {
- try
- {
-
- var buildingsInfoVerify = BuildingsInfoDAL.BuildingsInfoRepository.GetList(x => x.BuildingsInfoID != buildingsInfoView.BuildingsInfoID && x.Code == buildingsInfoView.Code).FirstOrDefault();
- if (buildingsInfoVerify == null)
- {
-
- if (buildingsInfoView.BuildingsInfoID != Guid.Empty)
- {
- var buildingsInfo = BuildingsInfoDAL.BuildingsInfoRepository.GetList(x => x.BuildingsInfoID == buildingsInfoView.BuildingsInfoID).SingleOrDefault();
- if (buildingsInfo == null)
- {
- throw new Exception("数据有误,请核查");
- }
- else
- {
-
- buildingsInfo.Code = buildingsInfoView.Code.Trim();
- buildingsInfo.Name = buildingsInfoView.Name;
- buildingsInfo.CampusID = buildingsInfoView.CampusID;
- buildingsInfo.CollegeID = buildingsInfoView.CollegeID;
- buildingsInfo.BuildingsTypeID = buildingsInfoView.BuildingsTypeID;
- buildingsInfo.BuildingsStatusID = buildingsInfoView.BuildingsStatusID;
- buildingsInfo.BuildingsLevel = buildingsInfoView.BuildingsLevel;
- buildingsInfo.BuildingsArea = buildingsInfoView.BuildingsArea;
- buildingsInfo.UseArea = buildingsInfoView.UseArea;
- buildingsInfo.Position = buildingsInfoView.Position;
- buildingsInfo.IsSpecial = buildingsInfoView.IsSpecial;
- buildingsInfo.Remark = buildingsInfoView.Remark;
- SetModifyStatus(buildingsInfo);
- }
- }
- else
- {
-
- CF_BuildingsInfo buildingsInfo = new CF_BuildingsInfo();
- buildingsInfo.BuildingsInfoID = Guid.NewGuid();
- buildingsInfo.Code = buildingsInfoView.Code.Trim();
- buildingsInfo.Name = buildingsInfoView.Name;
- buildingsInfo.CampusID = buildingsInfoView.CampusID;
- buildingsInfo.CollegeID = buildingsInfoView.CollegeID;
- buildingsInfo.BuildingsTypeID = buildingsInfoView.BuildingsTypeID;
- buildingsInfo.BuildingsStatusID = buildingsInfoView.BuildingsStatusID;
- buildingsInfo.BuildingsLevel = buildingsInfoView.BuildingsLevel;
- buildingsInfo.BuildingsArea = buildingsInfoView.BuildingsArea;
- buildingsInfo.UseArea = buildingsInfoView.UseArea;
- buildingsInfo.Position = buildingsInfoView.Position;
- buildingsInfo.IsSpecial = buildingsInfoView.IsSpecial;
- buildingsInfo.Remark = buildingsInfoView.Remark;
- SetNewStatus(buildingsInfo);
- UnitOfWork.Add(buildingsInfo);
- }
- }
- else
- {
- throw new Exception("已存在相同的建筑编号,请核查");
- }
-
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
-
-
-
-
-
- public bool BuildingsInfoDelete(List<Guid?> buildingsInfoIDList)
- {
- try
- {
- UnitOfWork.Delete<CF_BuildingsInfo>(x => buildingsInfoIDList.Contains(x.BuildingsInfoID));
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- public IGridResultSet<ClassroomView> GetClassroomViewGrid(ConfiguretView configuretView, Guid? buildingsInfoID, string classroomName, int? classroomTypeID, Guid? collegeID, int? isConcurrentUse, int? isReserve, int? isAvailable, int pageIndex, int pageSize)
- {
- Expression<Func<CF_BuildingsInfo, bool>> expBuildingsInfo = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expBuildingsInfo = expBuildingsInfo.And(x => x.BuildingsInfoID == buildingsInfoID);
- var query = BuildingsInfoDAL.GetClassroomViewQueryable(expBuildingsInfo);
- if (!string.IsNullOrEmpty(classroomName) && classroomName != "-1")
- {
-
- query = query.Where(x => x.Name == classroomName);
- }
- if (classroomTypeID.HasValue)
- {
-
- query = query.Where(x => x.CF_ClassroomType.Select(w => w.ClassroomType).Contains(classroomTypeID));
- }
- if (collegeID.HasValue)
- {
-
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (isConcurrentUse.HasValue)
- {
-
- if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsYes)
- {
- query = query.Where(x => x.IsConcurrentUse == true);
- }
- if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsNo)
- {
- query = query.Where(x => x.IsConcurrentUse != true);
- }
- }
- if (isReserve.HasValue)
- {
-
- if (isReserve.Value == (int)CF_GeneralPurpose.IsYes)
- {
- query = query.Where(x => x.IsReserve == true);
- }
- if (isReserve.Value == (int)CF_GeneralPurpose.IsNo)
- {
- query = query.Where(x => x.IsReserve != true);
- }
- }
- if (isAvailable.HasValue)
- {
-
- if (isAvailable.Value == (int)CF_GeneralPurpose.IsYes)
- {
- query = query.Where(x => x.IsAvailable == true);
- }
- if (isAvailable.Value == (int)CF_GeneralPurpose.IsNo)
- {
- query = query.Where(x => x.IsAvailable != true);
- }
- }
-
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.BuildingsInfoCode.Length).ThenBy(x => x.BuildingsInfoCode).ThenBy(x => x.Code.Length).ThenBy(x => x.Code)
- .ThenBy(x => x.RoomUseID).ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode).ToGridResultSet<ClassroomView>(pageIndex, pageSize);
- }
-
-
-
-
-
-
-
-
-
-
-
-
- public IList<ClassroomView> GetClassroomViewList(ConfiguretView configuretView, Guid? buildingsInfoID, string classroomName,
- int? classroomTypeID, Guid? collegeID, int? isConcurrentUse, int? isReserve, int? isAvailable)
- {
- Expression<Func<CF_BuildingsInfo, bool>> expBuildingsInfo = (x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- expBuildingsInfo = expBuildingsInfo.And(x => x.BuildingsInfoID == buildingsInfoID);
- var query = BuildingsInfoDAL.GetClassroomViewQueryable(expBuildingsInfo);
- if (!string.IsNullOrEmpty(classroomName) && classroomName != "-1")
- {
-
- query = query.Where(x => x.Name == classroomName);
- }
- if (classroomTypeID.HasValue)
- {
-
- query = query.Where(x => x.CF_ClassroomType.Select(w => w.ClassroomType).Contains(classroomTypeID));
- }
- if (collegeID.HasValue)
- {
-
- query = query.Where(x => x.CollegeID == collegeID);
- }
- if (isConcurrentUse.HasValue)
- {
-
- if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsYes)
- {
- query = query.Where(x => x.IsConcurrentUse == true);
- }
- if (isConcurrentUse.Value == (int)CF_GeneralPurpose.IsNo)
- {
- query = query.Where(x => x.IsConcurrentUse != true);
- }
- }
- if (isReserve.HasValue)
- {
-
- if (isReserve.Value == (int)CF_GeneralPurpose.IsYes)
- {
- query = query.Where(x => x.IsReserve == true);
- }
- if (isReserve.Value == (int)CF_GeneralPurpose.IsNo)
- {
- query = query.Where(x => x.IsReserve != true);
- }
- }
- if (isAvailable.HasValue)
- {
-
- if (isAvailable.Value == (int)CF_GeneralPurpose.IsYes)
- {
- query = query.Where(x => x.IsAvailable == true);
- }
- if (isAvailable.Value == (int)CF_GeneralPurpose.IsNo)
- {
- query = query.Where(x => x.IsAvailable != true);
- }
- }
-
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.BuildingsInfoCode.Length).ThenBy(x => x.BuildingsInfoCode).ThenBy(x => x.Code.Length).ThenBy(x => x.Code)
- .ThenBy(x => x.RoomUseID).ThenBy(x => x.CollegeCode.Length).ThenBy(x => x.CollegeCode).ToList();
- }
-
-
-
-
-
-
-
-
-
- public void BuildingsInfoImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount, out List<BuildingsInfoView> errdataList, out int? errCount, string sourcePhysicalPath)
- {
- try
- {
- StringBuilder errorMsg = new StringBuilder();
- List<BuildingsInfoView> errList = new List<BuildingsInfoView>();
- cellheader.Remove("ErrorMessage");
- List<BuildingsInfoView> enlist = NpoiExcelHelper.ExcelToEntityList<BuildingsInfoView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
- cellheader.Add("ErrorMessage", "未导入原因");
-
- if (enlist.Count() <= 0)
- {
- throw new Exception("Excel文件数据为空,请检查。");
- }
- Regex reg = null;
-
- inCount = 0;
- upCount = 0;
- errCount = 0;
- string errorMsgStr = "";
- List<CF_BuildingsInfo> newBuildingsInfoInList = new List<CF_BuildingsInfo>();
- List<CF_BuildingsInfo> newBuildingsInfoUpList = new List<CF_BuildingsInfo>();
-
-
- var campusList = BuildingsInfoDAL.CampusRepository.GetList(x => true).ToList();
-
- var campusNoList = enlist.Where(x => !string.IsNullOrEmpty(x.CampusCode)).Select(x => x.CampusCode).ToList();
-
- var newCampusList = campusList.Where(x => campusNoList.Contains(x.No)).ToList();
-
- var collegeList = BuildingsInfoDAL.CollegeRepository.GetList(x => true, x => x.CF_Campus).ToList();
-
- var collegeNoList = enlist.Where(x => !string.IsNullOrEmpty(x.CollegeCode)).Select(x => x.CollegeCode).ToList();
-
- var newCollegeList = collegeList.Where(x => collegeNoList.Contains(x.No)).ToList();
-
- var buildingsTypeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_BuildingsType).ToList();
-
- var buildingsStatusList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_BuildingsStatus).ToList();
-
- var generalPurposeList = IdNameExt.GetDictionaryItem(DictionaryItem.CF_GeneralPurpose).ToList();
-
- var buildingsInfoList = BuildingsInfoDAL.BuildingsInfoRepository.GetList(x => true).ToList();
-
- var buildingsInfoCodeList = enlist.Where(x => !string.IsNullOrEmpty(x.Code)).Select(x => x.Code).ToList();
-
- var newBuildingsInfoList = buildingsInfoList.Where(x => buildingsInfoCodeList.Contains(x.Code)).ToList();
-
- for (int i = 0; i < enlist.Count; i++)
- {
- BuildingsInfoView en = enlist[i];
- CF_BuildingsInfo newBuildingsInfo = new CF_BuildingsInfo();
-
- if (string.IsNullOrWhiteSpace(en.Code))
- {
- errCount++;
- errorMsgStr = "建筑编号不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- reg = new Regex(@"^[0-9a-zA-Z\s?]+$");
- if (!reg.IsMatch(en.Code.Trim()))
- {
- errCount++;
- errorMsgStr = "建筑编号格式不正确,请检查(数字或英文字母)";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
-
- newBuildingsInfo.Code = en.Code.Trim();
- }
- }
-
- if (string.IsNullOrWhiteSpace(en.Name))
- {
- errCount++;
- errorMsgStr = "建筑名称不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
-
- newBuildingsInfo.Name = en.Name.Trim();
- }
-
- if (string.IsNullOrWhiteSpace(en.CampusCode))
- {
- errCount++;
- errorMsgStr = RSL.Get("CampusCode") + "不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- reg = new Regex(@"^[0-9a-zA-Z\s?]+$");
- if (!reg.IsMatch(en.CampusCode.Trim()))
- {
- errCount++;
- errorMsgStr = RSL.Get("CampusCode") + "格式不正确,请检查(数字或英文字母)";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var campus = newCampusList.Where(x => x.No == en.CampusCode.Trim()).SingleOrDefault();
- if (campus == null)
- {
- errCount++;
- errorMsgStr = RSL.Get("CampusCode") + "不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
-
- newBuildingsInfo.CampusID = campus.CampusID;
- }
- }
- }
-
- if (string.IsNullOrWhiteSpace(en.CollegeCode))
- {
-
- }
- else
- {
- reg = new Regex(@"^[0-9a-zA-Z\s?]+$");
- if (!reg.IsMatch(en.CollegeCode.Trim()))
- {
- errCount++;
- errorMsgStr = RSL.Get("CollegeCode") + "格式不正确,请检查(数字或英文字母)";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var college = newCollegeList.Where(x => x.No == en.CollegeCode.Trim()).SingleOrDefault();
- if (college == null)
- {
- errCount++;
- errorMsgStr = RSL.Get("CollegeCode") + "不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
-
- newBuildingsInfo.CollegeID = college.CollegeID;
- }
- }
- }
-
- if (string.IsNullOrWhiteSpace(en.BuildingsTypeStr))
- {
- errCount++;
- errorMsgStr = "建筑类型不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var buildingsType = buildingsTypeList.Where(x => x.Name == en.BuildingsTypeStr.Trim()).SingleOrDefault();
- if (buildingsType == null)
- {
- errCount++;
- errorMsgStr = "建筑类型不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
-
- newBuildingsInfo.BuildingsTypeID = buildingsType.Value;
- }
- }
-
- if (string.IsNullOrWhiteSpace(en.BuildingsStatusStr))
- {
- errCount++;
- errorMsgStr = "建筑状况不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var buildingsStatus = buildingsStatusList.Where(x => x.Name == en.BuildingsStatusStr.Trim()).SingleOrDefault();
- if (buildingsStatus == null)
- {
- errCount++;
- errorMsgStr = "建筑状况不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
-
- newBuildingsInfo.BuildingsStatusID = buildingsStatus.Value;
- }
- }
-
- if (string.IsNullOrWhiteSpace(en.BuildingsLevelStr))
- {
-
- }
- else
- {
- reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$");
- if (!reg.IsMatch(en.BuildingsLevelStr.Trim()))
- {
- errCount++;
- errorMsgStr = "建筑层数格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
-
- newBuildingsInfo.BuildingsLevel = Convert.ToDecimal(en.BuildingsLevelStr.Trim());
- }
- }
-
- if (string.IsNullOrWhiteSpace(en.BuildingsAreaStr))
- {
-
- }
- else
- {
- reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$");
- if (!reg.IsMatch(en.BuildingsAreaStr.Trim()))
- {
- errCount++;
- errorMsgStr = "建筑面积格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
-
- newBuildingsInfo.BuildingsArea = Convert.ToDecimal(en.BuildingsAreaStr.Trim());
- }
- }
-
- if (string.IsNullOrWhiteSpace(en.UseAreaStr))
- {
-
- }
- else
- {
- reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$");
- if (!reg.IsMatch(en.UseAreaStr.Trim()))
- {
- errCount++;
- errorMsgStr = "使用面积格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
-
- newBuildingsInfo.UseArea = Convert.ToDecimal(en.UseAreaStr.Trim());
- }
- }
-
- if (string.IsNullOrWhiteSpace(en.Position))
- {
-
- }
- else
- {
- newBuildingsInfo.Position = en.Position;
- }
-
- if (string.IsNullOrWhiteSpace(en.IsSpecialStr))
- {
- errCount++;
- errorMsgStr = "是否可用不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var generalPurpose = generalPurposeList.Where(x => x.Name == en.IsSpecialStr.Trim()).SingleOrDefault();
- if (generalPurpose == null)
- {
- errCount++;
- errorMsgStr = "是否可用不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
-
- newBuildingsInfo.IsSpecial = generalPurpose.Value == (int)CF_GeneralPurpose.IsYes ? true : false;
- }
- }
-
- if (string.IsNullOrWhiteSpace(en.Remark))
- {
-
- }
- else
- {
- newBuildingsInfo.Remark = en.Remark;
- }
-
-
-
-
-
-
-
-
-
-
-
- var buildingsInfoVerify = newBuildingsInfoList.Where(x => x.Code == newBuildingsInfo.Code).SingleOrDefault();
- if (buildingsInfoVerify == null)
- {
-
- if (!newBuildingsInfoInList.Any(x => x.Code == newBuildingsInfo.Code))
- {
- newBuildingsInfo.BuildingsInfoID = Guid.NewGuid();
- SetNewStatus(newBuildingsInfo);
- newBuildingsInfoInList.Add(newBuildingsInfo);
- inCount++;
- }
- else
- {
-
-
- inCount++;
- }
- }
- else
- {
-
- buildingsInfoVerify.Name = newBuildingsInfo.Name;
- buildingsInfoVerify.CampusID = newBuildingsInfo.CampusID;
- buildingsInfoVerify.CollegeID = newBuildingsInfo.CollegeID;
- buildingsInfoVerify.BuildingsTypeID = newBuildingsInfo.BuildingsTypeID;
- buildingsInfoVerify.BuildingsStatusID = newBuildingsInfo.BuildingsStatusID;
- buildingsInfoVerify.BuildingsLevel = newBuildingsInfo.BuildingsLevel;
- buildingsInfoVerify.BuildingsArea = newBuildingsInfo.BuildingsArea;
- buildingsInfoVerify.UseArea = newBuildingsInfo.UseArea;
- buildingsInfoVerify.Position = newBuildingsInfo.Position;
- buildingsInfoVerify.IsSpecial = newBuildingsInfo.IsSpecial;
- buildingsInfoVerify.Remark = newBuildingsInfo.Remark;
- SetModifyStatus(buildingsInfoVerify);
- newBuildingsInfoUpList.Add(buildingsInfoVerify);
- upCount++;
- }
- }
- using (TransactionScope ts = new TransactionScope())
- {
- UnitOfWork.BulkInsert(newBuildingsInfoInList);
-
- if (newBuildingsInfoUpList != null && newBuildingsInfoUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(newBuildingsInfoUpList);
- }
- ts.Complete();
- }
- errdataList = errList.Distinct().ToList();
- }
- catch (Exception)
- {
-
- throw;
- }
- }
- }
- }
|