123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735736737738739740741742743744745746747748749750751752753754755756757758759760761762763764765766767768769770771772773774775776777778779780781782783784785786787788789790791792793794795796797 |
- using System;
- using System.Collections.Generic;
- using System.Linq;
- using System.Text;
- using EMIS.DataLogic.Common.Specialtymanage;
- using EMIS.Entities;
- using Bowin.Common.Linq;
- using Bowin.Common.Linq.Entity;
- using EMIS.ViewModel.Specialtymanage;
- using EMIS.ViewModel;
- using System.Text.RegularExpressions;
- using Bowin.Common.Utility;
- using EMIS.ViewModel.Cache;
- using EMIS.Utility;
- using System.Linq.Expressions;
- namespace EMIS.CommonLogic.Specialtymanage
- {
- public class SpecialtyServices : BaseServices, ISpecialtyServices
- {
- public SpecialtyDAL SpecialtyDAL { get; set; }
- /// <summary>
- /// 查询对应的专业信息View
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="scienceclassID"></param>
- /// <param name="propertyID"></param>
- /// <param name="recordStatus"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<SpecialtyView> GetSpecialtyViewGrid(ConfiguretView configuretView, int? standardID, int? educationID,
- int? learningformID, string learnSystem, int? scienceclassID, int? propertyID, int? recordStatus, int pageIndex, int pageSize)
- {
- //专业信息
- Expression<Func<CF_Specialty, bool>> expSpecialty = (x => true);
- if (standardID.HasValue)
- {
- //专业ID(Value)
- expSpecialty = expSpecialty.And(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- //培养层次
- expSpecialty = expSpecialty.And(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- //学习形式
- expSpecialty = expSpecialty.And(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- //学制
- var LearnSystems = Convert.ToDecimal(learnSystem);
- expSpecialty = expSpecialty.And(x => x.LearnSystem == LearnSystems);
- }
- if (scienceclassID.HasValue)
- {
- //专业科类
- expSpecialty = expSpecialty.And(x => x.ScienceclassID == scienceclassID);
- }
- if (propertyID.HasValue)
- {
- //专业属性
- expSpecialty = expSpecialty.And(x => x.PropertyID == propertyID);
- }
- if (recordStatus.HasValue)
- {
- //启用状态
- if (recordStatus.Value == (int)SYS_STATUS.USABLE)
- {
- expSpecialty = expSpecialty.And(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- }
- if (recordStatus.Value == (int)SYS_STATUS.UNUSABLE)
- {
- expSpecialty = expSpecialty.And(x => x.RecordStatus <= (int)SYS_STATUS.UNUSABLE);
- }
- }
- var query = SpecialtyDAL.GetSpecialtyViewQueryable(expSpecialty);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- //暂时不考虑
- //string conditionValue = string.Empty;
- //Regex rg = new Regex(@"^[0-9]*$");
- //if (rg.IsMatch(configuretView.ConditionValue))
- //{
- // conditionValue = Convert.ToInt32(configuretView.ConditionValue).ToString();
- //}
- //else
- //{
- // conditionValue = configuretView.ConditionValue;
- //}
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.StandardName).ThenBy(x => x.EducationID)
- .ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
- .ToGridResultSet<SpecialtyView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的专业信息List
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="standardID"></param>
- /// <param name="educationID"></param>
- /// <param name="learningformID"></param>
- /// <param name="learnSystem"></param>
- /// <param name="scienceclassID"></param>
- /// <param name="propertyID"></param>
- /// <param name="recordStatus"></param>
- /// <returns></returns>
- public IList<SpecialtyView> GetSpecialtyViewList(ConfiguretView configuretView, int? standardID, int? educationID,
- int? learningformID, string learnSystem, int? scienceclassID, int? propertyID, int? recordStatus)
- {
- //专业信息
- Expression<Func<CF_Specialty, bool>> expSpecialty = (x => true);
- if (standardID.HasValue)
- {
- //专业ID(Value)
- expSpecialty = expSpecialty.And(x => x.StandardID == standardID);
- }
- if (educationID.HasValue)
- {
- //培养层次
- expSpecialty = expSpecialty.And(x => x.EducationID == educationID);
- }
- if (learningformID.HasValue)
- {
- //学习形式
- expSpecialty = expSpecialty.And(x => x.LearningformID == learningformID);
- }
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "-1")
- {
- //学制
- var LearnSystems = Convert.ToDecimal(learnSystem);
- expSpecialty = expSpecialty.And(x => x.LearnSystem == LearnSystems);
- }
- if (scienceclassID.HasValue)
- {
- //专业科类
- expSpecialty = expSpecialty.And(x => x.ScienceclassID == scienceclassID);
- }
- if (propertyID.HasValue)
- {
- //专业属性
- expSpecialty = expSpecialty.And(x => x.PropertyID == propertyID);
- }
- if (recordStatus.HasValue)
- {
- //启用状态
- if (recordStatus.Value == (int)SYS_STATUS.USABLE)
- {
- expSpecialty = expSpecialty.And(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- }
- if (recordStatus.Value == (int)SYS_STATUS.UNUSABLE)
- {
- expSpecialty = expSpecialty.And(x => x.RecordStatus <= (int)SYS_STATUS.UNUSABLE);
- }
- }
- var query = SpecialtyDAL.GetSpecialtyViewQueryable(expSpecialty);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- //暂时不考虑
- //string conditionValue = string.Empty;
- //Regex rg = new Regex(@"^[0-9]*$");
- //if (rg.IsMatch(configuretView.ConditionValue))
- //{
- // conditionValue = Convert.ToInt32(configuretView.ConditionValue).ToString();
- //}
- //else
- //{
- // conditionValue = configuretView.ConditionValue;
- //}
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.StandardName).ThenBy(x => x.EducationID)
- .ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
- .ToList();
- }
- /// <summary>
- /// 查询对应的专业信息(字典)
- /// </summary>
- /// <param name="standardID"></param>
- /// <param name="standardName"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<Sys_DictionaryItem> GetStandardView(int? standardID, string standardName, int pageIndex, int pageSize)
- {
- var query = SpecialtyDAL.DictionaryItemRepository
- .GetList(x => x.DictionaryCode == EMIS.ViewModel.DictionaryItem.CF_Standard.ToString());
- if (standardID.HasValue)
- {
- //专业ID(Value)
- query = query.Where(x => x.Value == standardID);
- }
- if (!string.IsNullOrEmpty(standardName) && standardName != "-1")
- {
- //专业名称
- query = query.Where(x => x.Name == standardName);
- }
- return query.OrderBy(x => x.Name)
- .ToGridResultSet<Sys_DictionaryItem>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询专业信息中学制信息SpecialtyView
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="learnSystem"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<SpecialtyView> GetLearnSystemViewList(ConfiguretView configuretView, string learnSystem, int pageIndex, int pageSize)
- {
- var query = SpecialtyDAL.GetLearnSystemQueryable(x => true);
- if (!string.IsNullOrEmpty(learnSystem) && learnSystem != "")
- {
- var LearnSystems = Convert.ToDecimal(learnSystem);
- query = query.Where(x => x.LearnSystem == LearnSystems);
- }
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- var learn = Convert.ToDecimal(configuretView.ConditionValue);
- query = query.Where(x => x.LearnSystem == learn);
- }
- return query.OrderBy(x => x.LearnSystem)
- .ToGridResultSet<SpecialtyView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 查询对应的专业信息(只查询启用状态的信息)
- /// </summary>
- /// <param name="configuretView"></param>
- /// <param name="pageIndex"></param>
- /// <param name="pageSize"></param>
- /// <returns></returns>
- public IGridResultSet<SpecialtyView> GetSpecialtyIDViewList(ConfiguretView configuretView, int pageIndex, int pageSize)
- {
- var query = SpecialtyDAL.GetSpecialtyViewQueryable(x => x.RecordStatus > (int)SYS_STATUS.UNUSABLE);
- //查询条件
- if (!string.IsNullOrEmpty(configuretView.ConditionValue))
- {
- query = query.DynamicWhere(configuretView.Attribute, configuretView.Condition, configuretView.ConditionValue.Trim());
- }
- return query.OrderBy(x => x.StandardName).ThenBy(x => x.EducationID)
- .ThenBy(x => x.LearningformID).ThenBy(x => x.LearnSystem)
- .ToGridResultSet<SpecialtyView>(pageIndex, pageSize);
- }
- /// <summary>
- /// 根据专业信息ID查询对应的专业信息CF_Specialty
- /// </summary>
- /// <param name="specialtyID"></param>
- /// <returns></returns>
- public CF_Specialty GetSpecialtyInfo(Guid? specialtyID)
- {
- try
- {
- var query = SpecialtyDAL.SpecialtyRepository
- .GetList(x => x.SpecialtyID == specialtyID).SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 根据专业信息ID查询对应的专业信息SpecialtyView
- /// </summary>
- /// <param name="specialtyID"></param>
- /// <returns></returns>
- public SpecialtyView GetSpecialtyView(Guid? specialtyID)
- {
- try
- {
- var query = SpecialtyDAL.GetSpecialtyViewQueryable(x => x.SpecialtyID == specialtyID)
- .SingleOrDefault();
- return query;
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 编辑(新增、修改,业务主键:专业ID、培养层次、学习形式、学制)
- /// </summary>
- /// <param name="specialtyView"></param>
- public void SpecialtyEdit(SpecialtyView specialtyView)
- {
- try
- {
- //查询数据库进行验证
- var specialtyVerification = SpecialtyDAL.SpecialtyRepository
- .GetList(x => x.SpecialtyID != specialtyView.SpecialtyID
- && x.StandardID == specialtyView.StandardID
- && x.EducationID == specialtyView.EducationID
- && x.LearningformID == specialtyView.LearningformID
- && x.LearnSystem == specialtyView.LearnSystem
- ).SingleOrDefault();
- if (specialtyVerification == null)
- {
- //数据有误验证
- if (specialtyView.SpecialtyID != Guid.Empty)
- {
- var specialty = SpecialtyDAL.SpecialtyRepository
- .GetList(x => x.SpecialtyID == specialtyView.SpecialtyID)
- .SingleOrDefault();
- if (specialty == null)
- {
- throw new Exception("数据有误,请核查");
- }
- else
- {
- //表示修改
- specialty.StandardID = specialtyView.StandardID;
- specialty.EducationID = specialtyView.EducationID;
- specialty.LearningformID = specialtyView.LearningformID;
- specialty.LearnSystem = specialtyView.LearnSystem;
- specialty.ScienceclassID = specialtyView.ScienceclassID;
- specialty.PropertyID = specialtyView.PropertyID;
- specialty.StandardTitle = specialtyView.StandardTitle;
- specialty.StandardLevel = specialtyView.StandardLevel;
- specialty.Remark = specialtyView.Remark;
- specialty.RecordStatus = specialtyView.RecordStatus;
- SetModifyStatus(specialty);
- }
- }
- else
- {
- //表示新增
- CF_Specialty specialty = new CF_Specialty();
- specialty.SpecialtyID = Guid.NewGuid();
- specialty.StandardID = specialtyView.StandardID;
- specialty.EducationID = specialtyView.EducationID;
- specialty.LearningformID = specialtyView.LearningformID;
- specialty.LearnSystem = specialtyView.LearnSystem;
- specialty.ScienceclassID = specialtyView.ScienceclassID;
- specialty.PropertyID = specialtyView.PropertyID;
- specialty.StandardTitle = specialtyView.StandardTitle;
- specialty.StandardLevel = specialtyView.StandardLevel;
- specialty.Remark = specialtyView.Remark;
- SetNewStatus(specialty, specialtyView.RecordStatus.Value);
- UnitOfWork.Add(specialty);
- }
- }
- else
- {
- throw new Exception("已存在相同的专业信息(专业ID、" + RSL.Get("EducationID") + "、学习形式、学制唯一),请核查");
- }
- //事务提交
- UnitOfWork.Commit();
- }
- catch (Exception ex)
- {
- throw new Exception(ex.Message);
- }
- }
- /// <summary>
- /// 删除
- /// </summary>
- /// <param name="specialtyIDList"></param>
- /// <returns></returns>
- public bool SpecialtyDelete(List<Guid?> specialtyIDList)
- {
- try
- {
- UnitOfWork.Delete<CF_Specialty>(x => specialtyIDList.Contains(x.SpecialtyID));
- UnitOfWork.Commit();
- return true;
- }
- catch (Exception)
- {
- throw;
- }
- }
- /// <summary>
- /// Excel导入
- /// </summary>
- /// <param name="cellheader"></param>
- /// <param name="inCount"></param>
- /// <param name="upCount"></param>
- /// <param name="errdataList"></param>
- /// <param name="errCount"></param>
- /// <param name="sourcePhysicalPath"></param>
- public void SpecialtyImport(Dictionary<string, string> cellheader, out int? inCount, out int? upCount,
- out List<SpecialtyView> errdataList, out int? errCount, string sourcePhysicalPath)
- {
- try
- {
- StringBuilder errorMsg = new StringBuilder(); // 错误信息
- List<SpecialtyView> errList = new List<SpecialtyView>();
- // 1.1解析文件,存放到一个List集合里
- cellheader.Remove("ErrorMessage");//移除“未导入原因”列(ErrorMessage)
- List<SpecialtyView> enlist = NpoiExcelHelper.ExcelToEntityList<SpecialtyView>(cellheader, sourcePhysicalPath, out errorMsg, out errList);
- cellheader.Add("ErrorMessage", "未导入原因");
- //对List集合进行有效性校验
- if (enlist.Count() <= 0)
- {
- throw new Exception("Excel文件数据为空,请检查。");
- }
- Regex reg = new Regex(@"^[0-9]+([.]{1}[0-9]+){0,1}$"); //学制字段正则表达式()
- inCount = 0; //导入个数
- upCount = 0; //更新个数
- errCount = 0; //失败个数
- string errorMsgStr = ""; //错误信息
- List<CF_Specialty> specialtyInList = new List<CF_Specialty>(); //专业信息insert实体List
- List<CF_Specialty> specialtyUpList = new List<CF_Specialty>(); //专业信息update实体List
- //循环检测数据列,对各数据列进行验证(必填、字典项验证、数据格式等)
- for (int i = 0; i < enlist.Count; i++)
- {
- SpecialtyView en = enlist[i]; //Excel表数据视图
- CF_Specialty specialty = new CF_Specialty(); //专业信息实体
- //专业代码
- if (string.IsNullOrEmpty(en.StandardCode))
- {
- errCount++;
- errorMsgStr = "专业代码不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- if (!IdNameExt.GetDictionaryItem(DictionaryItem.CF_Standard.ToString())
- .Any(x => x.Code == en.StandardCode.Trim()))
- {
- errCount++;
- errorMsgStr = "专业代码不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //专业代码
- }
- }
- //专业名称
- if (string.IsNullOrEmpty(en.StandardName))
- {
- errCount++;
- errorMsgStr = "专业名称不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- if (!IdNameExt.GetDictionaryItem(DictionaryItem.CF_Standard.ToString())
- .Any(x => x.Name == en.StandardName.Trim()))
- {
- errCount++;
- errorMsgStr = "专业名称不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- //专业名称
- }
- }
- //专业代码与专业名称查询专业ID(Value)
- if (string.IsNullOrEmpty(en.StandardCode) || string.IsNullOrEmpty(en.StandardName))
- {
- errCount++;
- errorMsgStr = "专业代码或专业名称不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- var standard = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Standard.ToString())
- .Where(x => x.Code == en.StandardCode.Trim() && x.Name == en.StandardName.Trim())
- .SingleOrDefault();
- if (standard == null)
- {
- errCount++;
- errorMsgStr = "专业代码与专业名称对应的元素值不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- specialty.StandardID = standard.Value;
- }
- }
- //培养层次(所修学历)
- if (string.IsNullOrEmpty(en.EducationStr))
- {
- errCount++;
- errorMsgStr = RSL.Get("EducationID") + "不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- if (!IdNameExt.GetDictionaryItem(DictionaryItem.CF_Education.ToString())
- .Any(x => x.Name == en.EducationStr.Trim()))
- {
- errCount++;
- errorMsgStr = RSL.Get("EducationID") + "不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- specialty.EducationID = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Education.ToString())
- .Where(x => x.Name == en.EducationStr.Trim()).FirstOrDefault().Value;
- }
- }
- //学习形式
- if (string.IsNullOrEmpty(en.LearningformStr))
- {
- errCount++;
- errorMsgStr = "学习形式不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- if (!IdNameExt.GetDictionaryItem(DictionaryItem.CF_Learningform.ToString())
- .Any(x => x.Name == en.LearningformStr.Trim()))
- {
- errCount++;
- errorMsgStr = "学习形式不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- specialty.LearningformID = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Learningform.ToString())
- .Where(x => x.Name == en.LearningformStr.Trim()).FirstOrDefault().Value;
- }
- }
- //学制
- if (string.IsNullOrEmpty(en.LearnSystemStr))
- {
- errCount++;
- errorMsgStr = "学制不能为空";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- if (!reg.IsMatch(en.LearnSystemStr))
- {
- errCount++;
- errorMsgStr = "学制格式不正确,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- specialty.LearnSystem = Convert.ToDecimal(en.LearnSystemStr);
- }
- }
- //专业科类
- if (!string.IsNullOrEmpty(en.ScienceclassStr))
- {
- if (!IdNameExt.GetDictionaryItem(DictionaryItem.CF_Scienceclass.ToString())
- .Any(x => x.Name == en.ScienceclassStr.Trim()))
- {
- errCount++;
- errorMsgStr = "专业科类不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- specialty.ScienceclassID = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Scienceclass.ToString())
- .Where(x => x.Name == en.ScienceclassStr.Trim()).FirstOrDefault().Value;
- }
- }
- //专业属性
- if (!string.IsNullOrEmpty(en.PropertyStr))
- {
- if (!IdNameExt.GetDictionaryItem(DictionaryItem.CF_Property.ToString())
- .Any(x => x.Name == en.PropertyStr.Trim()))
- {
- errCount++;
- errorMsgStr = "专业属性不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- specialty.PropertyID = IdNameExt.GetDictionaryItem(DictionaryItem.CF_Property.ToString())
- .Where(x => x.Name == en.PropertyStr.Trim()).FirstOrDefault().Value;
- }
- }
- //专业称号
- if (!string.IsNullOrEmpty(en.StandardTitleStr))
- {
- if (!IdNameExt.GetDictionaryItem(DictionaryItem.CF_StandardTitle.ToString())
- .Any(x => x.Name == en.StandardTitleStr.Trim()))
- {
- errCount++;
- errorMsgStr = "专业称号不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- specialty.StandardTitle = IdNameExt.GetDictionaryItem(DictionaryItem.CF_StandardTitle.ToString())
- .Where(x => x.Name == en.StandardTitleStr.Trim()).FirstOrDefault().Value;
- }
- }
- //称号级别
- if (!string.IsNullOrEmpty(en.StandardLevelStr))
- {
- if (!IdNameExt.GetDictionaryItem(DictionaryItem.CF_StandardLevel.ToString())
- .Any(x => x.Name == en.StandardLevelStr.Trim()))
- {
- errCount++;
- errorMsgStr = "称号级别不存在,请检查";
- en.ErrorMessage = errorMsgStr;
- errList.Add(en);
- errorMsg.AppendLine(errorMsgStr);
- continue;
- }
- else
- {
- specialty.StandardLevel = IdNameExt.GetDictionaryItem(DictionaryItem.CF_StandardLevel.ToString())
- .Where(x => x.Name == en.StandardLevelStr.Trim()).FirstOrDefault().Value;
- }
- }
- //备注
- specialty.Remark = en.Remark;
- ////Excel表重复性验证(注:当数据表中没有此记录,但是Excel中有重复数据时的去掉)
- //for (int j = i + 1; j < enlist.Count; j++)
- //{
- // SpecialtyView enA = enlist[j];
- // //根据Excel表中的业务主键进行去重(专业代码、专业名称、培养层次(所修学历)、学习形式、学制唯一)
- // if (en.InitStandardCode == enA.InitStandardCode && en.StandardName == enA.StandardName && en.LearnSystemStr == enA.LearnSystemStr
- // && en.EducationStr == enA.EducationStr && en.LearningformStr == enA.LearningformStr)
- // {
- // //用于标识Excel表中的重复记录(由于是批量进行插入数据表)
- // }
- //}
- //数据表重复性验证(专业ID(Value)、培养层次(所修学历)、学习形式、学制唯一)
- var specialtyEnetey = SpecialtyDAL.SpecialtyRepository
- .GetList(x => x.StandardID == specialty.StandardID
- && x.EducationID == specialty.EducationID
- && x.LearningformID == specialty.LearningformID
- && x.LearnSystem == specialty.LearnSystem)
- .SingleOrDefault();
- if (specialtyEnetey == null)
- {
- //新增
- if (!specialtyInList.Any(x => x.StandardID == specialty.StandardID
- && x.EducationID == specialty.EducationID
- && x.LearningformID == specialty.LearningformID
- && x.LearnSystem == specialty.LearnSystem))
- {
- specialty.SpecialtyID = Guid.NewGuid();
- SetNewStatus(specialty, (int)SYS_STATUS.USABLE); //默认启用状态
- specialtyInList.Add(specialty);
- inCount++;
- }
- else
- {
- //Excel表重复性验证
- //(注:当数据表中没有此记录,但是Excel中有重复数据,可在此处进行抛出到失败数据文件中,目前暂不考虑)
- inCount++;
- }
- }
- else
- {
- //更新(Excel有重复时,以最后一条记录的更新为准)
- specialtyEnetey.ScienceclassID = specialty.ScienceclassID;
- specialtyEnetey.PropertyID = specialty.PropertyID;
- specialtyEnetey.StandardTitle = specialty.StandardTitle;
- specialtyEnetey.StandardLevel = specialty.StandardLevel;
- specialtyEnetey.Remark = specialty.Remark;
- SetModifyStatus(specialtyEnetey);
- specialtyUpList.Add(specialtyEnetey);
- upCount++;
- }
- }
- UnitOfWork.BulkInsert(specialtyInList); //批量插入
- //批量统一提交更新
- if (specialtyUpList != null && specialtyUpList.Count() > 0)
- {
- UnitOfWork.BatchUpdate(specialtyUpList); //批量更新
- }
- errdataList = errList.Distinct().ToList(); //错误列表List
- }
- catch (Exception ex)
- {
- //目前会出现,由于错误信息字符太长,无法抛出弹出框的问题
- throw new Exception(ex.Message);
- }
- }
- }
- }
|