/// <summary> /// 作者:Vincen /// 时间:2014.04.30 /// 描述:创建消息 /// </summary> /// <param name="model"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static bool CreateMessage(MessageModel model, int loginUserId) { try { using (var tran = new TransactionScope()) { using (var edb = new EmeEntities()) { var msg = new Message() { MessageType = model.MessageType, Subject = model.Subject, MContent = model.MContent, Receivers = model.Receiver.Count, Openers = 0, Status = ConvertEnum.StatusTypeForActive, CreateBy = model.CreateBy, CreateTime = model.CreateTime }; edb.Entry(msg).State = EntityState.Added; edb.SaveChanges(); var receiver = from a in model.Receiver select new MessageReceiver() { MessageId = msg.Id, Receiver = a, IsRead = false, Status = ConvertEnum.StatusTypeForActive, CreateBy = model.CreateBy, CreateTime = model.CreateTime }; foreach (var messageReceiver in receiver) { edb.Entry(messageReceiver).State = EntityState.Added; } var result = edb.SaveChanges() > 0; tran.Complete(); return result; } } } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("EmeBLL-CreateMessage:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return false; } }
/// <summary> /// 作者:Raymond /// 日期:2014-4-22 /// 描述:新增中心产品 /// </summary> /// <param name="pBranch"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static bool AddProductBranch(ProductBranch pBranch, int loginUserId) { using (var edb = new EmeEntities()) { try { edb.Entry(pBranch).State = EntityState.Added; var result = edb.SaveChanges() > 0; return result; } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("ProductBLL-AddProductBranch:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:Vincen /// 时间:2014.04.01 /// 描述:创建课程 /// </summary> /// <param name="course"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static Course CreateCourse(Course course, int loginUserId) { using (var edb = new EmeEntities()) { try { edb.Entry(course).State = EntityState.Added; edb.SaveChanges(); return course; } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("CourseBLL-CreateCourse:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return null; } } }
/// <summary> /// 作者:Vincen /// 时间:2014.07.18 /// 描述:检查合同详情 /// </summary> /// <returns></returns> public static bool CheckContractDetail() { using (var edb = new EmeEntities()) { try { foreach (var detail in edb.ContractDetail.Where( p => p.Status == ConvertEnum.StatusTypeForActive && p.EndDate < DateTime.Now && p.ContractStatusType == ConvertEnum.ContractStatusTypeForExcute)) { // 更新结束的合同为结束状态 detail.ContractStatusType = ConvertEnum.ContractStatusTypeForOver; edb.Entry(detail).State = EntityState.Modified; } var result = edb.SaveChanges() > 0; return result; } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("StudentBLL-CheckContractDetail:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = null, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:Vincen /// 时间:2014.03.28 /// 描述:创建教室 /// </summary> /// <param name="model"></param> /// <param name="createBy"></param> /// <returns></returns> public static bool CreateClassroom(Classroom model, int createBy) { using (var edb = new EmeEntities()) { try { edb.Entry(model).State = EntityState.Added; var result = edb.SaveChanges() > 0; return result; } catch (Exception e) { Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Message), Message = string.Format("BranchBLL-CreateClassroom:{0};{1};{2}", e.Message, e.InnerException, e.HelpLink), IsTreat = false, UserHostAddress = WebHelper.GetCurrentIpAddress(), CreateBy = createBy, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:Raymond /// 日期:2014-6-27 /// 描述:新增报备 /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool CreateReferral(Referral model) { using (var edb = new EmeEntities()) { edb.Entry(model).State = EntityState.Added; return edb.SaveChanges() > 0; } }
/// <summary> /// 作者:Kylin /// 时间:2014.03.21 PM /// 描述:(学员)Follow Up (批量)发送 /// </summary> /// <param name="model"></param> /// <param name="followDetailLst"></param> /// <param name="followAttachmentLst"></param> /// <returns></returns> public static bool CreateFollow(Follow model, List<FollowDetail> followDetailLst, List<FollowAttachment> followAttachmentLst) { using (var edb = new EmeEntities()) { try { edb.Entry<Follow>(model).State = EntityState.Added; foreach (var item in followDetailLst) { item.FollowId = model.Id; edb.Entry<FollowDetail>(item).State = EntityState.Added; var student = edb.Student.SingleOrDefault(p => p.Id == item.StudentId); if (student != null) { var studentUserId = student.UserId; // 发送队列消息 //EmeBLL.CreateMessageForSFollowUp(studentUserId, model.CreateBy); var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "Follow Up 查看提醒", MContent = string.Format("您有SA新发送的FU,请注意查收;"), Receiver = new List<int>(), CreateBy = model.CreateBy, CreateTime = DateTime.Now }; msg.Receiver.Add(studentUserId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); } } foreach (var attachment in followAttachmentLst) { attachment.FollowId = model.Id; edb.Entry(attachment).State = EntityState.Added; } var result = edb.SaveChanges() > 0; return result; } catch (Exception ex) { Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Message), Message = string.Format("FollowBLL-CreateFollow:{0};{1};{2}", ex.Message, ex.InnerException, ex.HelpLink), IsTreat = false, CreateBy = model.CreateBy, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:Primo /// 时间:2014.07.02 /// 描述:创建课程附件 /// </summary> /// <param name="courseware"></param> /// <param name="coursewareDetail"></param> /// <returns></returns> public static bool CreateCourseware(Courseware courseware, CoursewareDetail coursewareDetail) { using (var tran = new TransactionScope()) { using (var edb = new EmeEntities()) { try { edb.Entry(courseware).State = EntityState.Added; edb.SaveChanges(); coursewareDetail.CoursewareId = courseware.Id; edb.Entry(coursewareDetail).State = EntityState.Added; var result = edb.SaveChanges() > 0; tran.Complete(); return result; } catch (Exception e) { tran.Dispose(); // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("CourseBLL-CreateCourseware:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = courseware.CreateBy, CreateTime = DateTime.Now }); return false; } } } }
/// <summary> /// 作者:Kylin /// 时间:2014.03.27 /// 描述:更新产品级别配置 /// </summary> /// <param name="model"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static bool UpdateProductLevelConfig(ProductLevelConfig model, int loginUserId) { using (var edb = new EmeEntities()) { try { var modelObj = edb.ProductLevelConfig.FirstOrDefault(a => a.Id == model.Id && a.Status == ConvertEnum.StatusTypeForActive); if (null == modelObj) return false; modelObj.Status = model.Status; modelObj.UpdateBy = model.UpdateBy; modelObj.UpdateTime = model.UpdateTime; modelObj.ProductLevelId = model.ProductLevelId; modelObj.IsOptional = model.IsOptional; modelObj.Optional = model.Optional; edb.Entry(modelObj).State = EntityState.Modified; var result = edb.SaveChanges() > 0; return result; } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("ProductBLL-UpdateProductLevelConfig:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:Raymond /// 日期:2014-3-5 /// 描述:更新产品级别,不含产品必修、选修信息 /// </summary> /// <param name="pLevel"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static bool UpdateProductLevel(ProductLevel pLevel, int loginUserId) { using (var edb = new EmeEntities()) { try { var pLevelObj = edb.ProductLevel.FirstOrDefault(p => p.Id == pLevel.Id); if (null == pLevelObj) return false; pLevelObj.CName = pLevel.CName; pLevelObj.EName = pLevel.EName; pLevelObj.SCode = pLevel.SCode; if (pLevel.OrderNum.HasValue) pLevelObj.OrderNum = pLevel.OrderNum.Value; pLevelObj.Description = pLevel.Description; pLevelObj.Remark = pLevel.Remark; pLevelObj.UpdateBy = pLevel.UpdateBy; pLevelObj.UpdateTime = pLevel.UpdateTime; edb.Entry(pLevelObj).State = EntityState.Modified; var result = edb.SaveChanges() > 0; return result; } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("ProductBLL-UpdateProductLevel:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:Raymond /// 日期:2014-3-5 /// 描述:新增课程级别 、明细 /// </summary> /// <param name="pLevel"></param> /// <param name="requiredCourse"></param> /// <param name="electiveCourse"></param> /// <param name="createBy"></param> /// <returns></returns> public static bool AddProductLevel(ProductLevel pLevel, string requiredCourse, string electiveCourse, int createBy) { using (var edb = new EmeEntities()) { try { edb.Entry(pLevel).State = EntityState.Added; var flag = edb.SaveChanges() > 0; if (flag) { var productLevelId = pLevel.Id; //处理必修课 if (requiredCourse.Length > 0) { var rList = requiredCourse.Split('&'); foreach (var item in rList) { var rListDetail = item.Split('^'); var pCourseTypeId = CommonHelper.To<int>(rListDetail[1]); var courses = CommonHelper.To<int>(rListDetail[2]); var students = CommonHelper.To<int>(rListDetail[3]); var pLevelCourseType = new ProductLevelCourseType() { ProductLevelId = productLevelId, ProductCourseTypeId = pCourseTypeId, SelectivityType = CommonHelper.To<int>(SelectivityType.Required), Courses = courses, Students = students, Status = CommonHelper.To<int>(StatusType.Active), CreateBy = createBy, CreateTime = DateTime.Now }; edb.Entry(pLevelCourseType).State = EntityState.Added; } } //处理选修课 if (electiveCourse.Length > 0) { var eList = electiveCourse.Split('&'); if (eList.Any()) { foreach (var item in eList) { var eListDetail = item.Split('^'); var pCourseTypeId = CommonHelper.To<int>(eListDetail[1]); var courses = CommonHelper.To<int>(eListDetail[2]); var students = CommonHelper.To<int>(eListDetail[3]); var pLevelCourseType = new ProductLevelCourseType() { ProductLevelId = productLevelId, ProductCourseTypeId = pCourseTypeId, SelectivityType = CommonHelper.To<int>(SelectivityType.Elective), Courses = courses, Students = students, Status = CommonHelper.To<int>(StatusType.Active), CreateBy = createBy, CreateTime = DateTime.Now }; edb.Entry(pLevelCourseType).State = EntityState.Added; } } } } return edb.SaveChanges() > 0; } catch { return false; } } }
/// <summary> /// 作者:Primo /// 日期:2014.06.24 /// 描述:新增夸产品课节 /// </summary> /// <param name="productLevelCourseTypeId"></param> /// <param name="list"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static bool CreateProductLevelCourseTypeForProductLevel(int productLevelCourseTypeId, List<ProductLevelCourseTypeForProductLevel> list, int loginUserId) { using (var edb = new EmeEntities()) { try { var result = false; var model = edb.ProductLevelCourseTypeForProductLevel.Where(p => p.ProductLevelCourseTypeId == productLevelCourseTypeId); foreach (var item in model) { edb.Entry(item).State = EntityState.Deleted; } foreach (var item in list) { edb.Entry(item).State = EntityState.Added; } result = edb.SaveChanges() > 0; return result; } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("ProductBLL-CreateProductLevelCourseTypeForProductLevel:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:Raymond /// 日期:2014-2-14 /// 描述:删除课程级别对应的课程类型 /// </summary> /// <param name="productLevelId"></param> /// <param name="editIds"></param> /// <param name="newIds"></param> /// <returns></returns> public bool DeleteProductLevelCourseTypes(int productLevelId, string editIds, string newIds) { using (var edb = new EmeEntities()) { var productLevelCourseTypeList = edb.ProductLevelCourseType.Where(p => p.ProductLevelId == productLevelId).ToList(); foreach (var item in productLevelCourseTypeList) { var IdKey = "," + item.ProductCourseTypeId.ToString() + ","; if (editIds.IndexOf(IdKey) < 0 && newIds.IndexOf(IdKey) < 0) { item.Status = ConvertEnum.StatusTypeForDelete; edb.Entry(item).State = EntityState.Modified; } } return edb.SaveChanges() > 0; } }
/// <summary> /// 作者:Kylin /// 时间:2014.03.27 /// 描述:撤销产品级别配置 /// </summary> /// <param name="model"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static bool CancelProductCourseTypeConfig(ProductCourseTypeConfig model, int loginUserId) { using (var edb = new EmeEntities()) { try { var modelObj = edb.ProductCourseTypeConfig.SingleOrDefault(p => p.Id == model.Id && p.Status == ConvertEnum.StatusTypeForActive); edb.Entry(modelObj).State = EntityState.Deleted; var result = edb.SaveChanges() > 0; return result; } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("ProductBLL-CancelProductCourseTypeConfig:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:Vincen /// 时间:2014.07.15 /// 描述:检查合同冻结详情 /// </summary> /// <returns></returns> public static bool CheckContractFrozenDetail() { try { using (var edb = new EmeEntities()) { using (var tran = new TransactionScope()) { foreach (var detail in edb.ContractFrozenDetail.Where( p => p.Status == ConvertEnum.StatusTypeForActive && p.EndDate < DateTime.Now)) { // 更新合同详情信息 var contractDetail = detail.ContractDetail; contractDetail.ContractStatusType = (contractDetail.EndDate < DateTime.Now) ? ConvertEnum.ContractStatusTypeForOver : ConvertEnum.ContractStatusTypeForExcute; edb.Entry(contractDetail).State = EntityState.Modified; // 更新冻结详情信息 ( 将处理完的数据设为无效 ) detail.UpdateTime = DateTime.Now; detail.Remark = "系统自动解冻"; detail.Status = ConvertEnum.StatusTypeForInactive; edb.Entry(detail).State = EntityState.Modified; } var result = edb.SaveChanges() > 0; tran.Complete(); return result; } } } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("StudentBLL-CheckContractFrozenDetail:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = null, CreateTime = DateTime.Now }); return false; } }
/// <summary> /// 作者:Raymond /// 日期:2014-7-22 /// 描述:根据合同对象新增、更新冻结记录 /// </summary> /// <param name="model"></param> /// <param name="beginDate"></param> /// <param name="endDate"></param> /// <param name="unDivestDate">解冻时间</param> /// <returns></returns> public static bool CreateOrUpdateContractFrozenDetail(Contract model, DateTime beginDate, DateTime endDate, DateTime? unDivestDate) { try { using (var edb = new EmeEntities()) { using (var tran = new TransactionScope()) { foreach (var detail in model.ContractDetail) { var frenzo = GetContractFrozenDeatailByContractDetailId(detail.Id); if (frenzo != null) { //修改 if (unDivestDate != null) frenzo.Status = ConvertEnum.StatusTypeForInactive; frenzo.UpdateBy = -1; frenzo.UpdateTime = unDivestDate; frenzo.BeginDate = beginDate; frenzo.EndDate = endDate; frenzo.Remark = "接口更新解冻"; edb.Entry(frenzo).State = EntityState.Modified; } else { //新增 frenzo = new ContractFrozenDetail() { ContractDetailId = detail.Id, BeginDate = beginDate, EndDate = endDate, Explain = "接口创建冻结", Remark = "接口创建冻结", Status = ConvertEnum.StatusTypeForActive, CreateBy = -1, CreateTime = DateTime.Now }; edb.Entry(frenzo).State = EntityState.Added; } } var result = edb.SaveChanges() > 0; tran.Complete(); return result; } } } catch (Exception ex) { Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("ContractFrozenDetail-Create:{0};{1};{2}", ex.Message, ex.InnerException.Message, ex.HelpLink), IsTreat = false, CreateBy = -1, CreateTime = DateTime.Now }); return false; } }
/// <summary> /// 作者:Primo /// 日期:2014.07.23 /// 描述:添加ContractTypeProductLevel /// </summary> /// <param name="model"></param> /// <returns></returns> public static bool CreateContractTypeProductLevel(ContractTypeProductLevel model) { using (var edb = new EmeEntities()) { using (var tran = new TransactionScope()) { try { //创建添加对象 var modelObj = new ContractTypeProductLevel() { BranchId = model.BranchId, ContractTypeId = model.ContractTypeId, ProductLevelId = model.ProductLevelId, MajorTotal = model.MajorTotal, ElectiveTotal = model.ElectiveTotal, Absence = model.Absence, Repair = model.Repair, IsSystem = false, Status = ConvertEnum.StatusTypeForActive, CreateBy = model.CreateBy, CreateTime = DateTime.Now }; edb.Entry(modelObj).State = EntityState.Added; var result = edb.SaveChanges() > 0; tran.Complete(); return result; } catch (Exception e) { tran.Dispose(); // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("StudentBLL-UpdateContractTypeProductLevel:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = model.UpdateBy, CreateTime = DateTime.Now }); return false; } } } }
/// <summary> /// 作者:Raymond /// 日期:2014-3-28 /// 描述:更改产品课节 /// </summary> /// <param name="pLevelCourseTypeCourse"></param> /// <returns></returns> public static bool UpdateProductLevelCourseTypeCourse(ProductLevelCourseTypeCourse pLevelCourseTypeCourse) { using (var edb = new EmeEntities()) { var model = edb.ProductLevelCourseTypeCourse.FirstOrDefault(p => p.Id == pLevelCourseTypeCourse.Id); if (null == model) return false; model.BranchId = pLevelCourseTypeCourse.BranchId; model.ProductLevelCourseTypeId = pLevelCourseTypeCourse.ProductLevelCourseTypeId; model.Coding = pLevelCourseTypeCourse.Coding; model.CourseId = pLevelCourseTypeCourse.CourseId; model.ClassHour = pLevelCourseTypeCourse.ClassHour; model.Stage = pLevelCourseTypeCourse.Stage; model.IsSystem = pLevelCourseTypeCourse.IsSystem; model.Status = pLevelCourseTypeCourse.Status; model.OrderNum = pLevelCourseTypeCourse.OrderNum; model.UpdateBy = pLevelCourseTypeCourse.UpdateBy; model.UpdateTime = pLevelCourseTypeCourse.UpdateTime; model.Remark = pLevelCourseTypeCourse.Remark; edb.Entry(model).State = EntityState.Modified; return edb.SaveChanges() > 0; } }
/// <summary> /// 作者:Primo /// 日期:2014.06.10 /// 描述:更改产品课节 /// </summary> /// <param name="pLevelCourseTypeCourse"></param> /// <param name="course"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static bool UpdateProductLevelCourseTypeCourseAndCourse(ProductLevelCourseTypeCourse pLevelCourseTypeCourse, Course course, int loginUserId) { using (var edb = new EmeEntities()) { try { var courseObj = edb.Course.FirstOrDefault(p => p.Id == course.Id); if (null != courseObj) { courseObj.CName = course.CName; courseObj.EName = course.EName; courseObj.ClassTime = course.ClassTime; courseObj.Description = course.Description; courseObj.StudyTypeId = course.StudyTypeId; courseObj.UpdateBy = course.UpdateBy; courseObj.UpdateTime = course.UpdateTime; edb.Entry(courseObj).State = EntityState.Modified; } var pLevelCourseTypeCourseObj = edb.ProductLevelCourseTypeCourse.FirstOrDefault(p => p.Id == pLevelCourseTypeCourse.Id); if (null != pLevelCourseTypeCourseObj) { pLevelCourseTypeCourseObj.ClassHour = pLevelCourseTypeCourse.ClassHour; pLevelCourseTypeCourseObj.Stage = pLevelCourseTypeCourse.Stage; pLevelCourseTypeCourseObj.Coding = pLevelCourseTypeCourse.Coding; pLevelCourseTypeCourseObj.OrderNum = pLevelCourseTypeCourse.OrderNum; pLevelCourseTypeCourseObj.UpdateBy = pLevelCourseTypeCourse.UpdateBy; pLevelCourseTypeCourseObj.UpdateTime = pLevelCourseTypeCourse.UpdateTime; edb.Entry(pLevelCourseTypeCourseObj).State = EntityState.Modified; } return edb.SaveChanges() > 0; } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("ProductBLL-UpdateProductLevelCourseTypeCourseAndCourse:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:Kylin /// 时间:2014.03.27 /// 描述:添加产品级别配置 /// </summary> /// <param name="model"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static ProductLevelConfig CreateProductLevelConfig(ProductLevelConfig model, int loginUserId) { using (var edb = new EmeEntities()) { try { if (!edb.ProductLevelConfig.Any(p => p.BranchId == model.BranchId && p.ProductLevelId == model.ProductLevelId && p.Status == ConvertEnum.StatusTypeForActive)) { var result = edb.ProductLevelConfig.Add(model); edb.SaveChanges(); return result; } else { return null; } } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("ProductBLL-AddProductLevelConfig:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return null; } } }
/// <summary> /// 作者:Primo /// 时间:2014.06.25 /// 描述:重置产品类型配置 /// </summary> /// <param name="productCourseTypeConfigId"></param> /// <param name="productCourseTypeId"></param> /// <param name="branchId"></param> /// <param name="userId"></param> /// <returns></returns> public static bool ResetProductCourseTypeConfig(int productCourseTypeConfigId, int productCourseTypeId, int branchId, int userId) { using (var edb = new EmeEntities()) { try { var result = false; //获取级别所属的原产品中心 var resetModelObjBranchId = edb.Product.Where(p => p.ProductCourseType.Any(a => a.Id == productCourseTypeId && p.Id == a.ProductId && a.Status == ConvertEnum.StatusTypeForActive) && p.Status == ConvertEnum.StatusTypeForActive).Select(s => s.BranchId).FirstOrDefault(); //获取该中心,该级别的复制对象 var resetModelObj = edb.ProductCourseTypeConfig.FirstOrDefault(p => p.ProductCourseTypeId == productCourseTypeId && p.BranchId == resetModelObjBranchId && p.Status == ConvertEnum.StatusTypeForActive); if (null != resetModelObj) { if (productCourseTypeConfigId > 0) { //获取需要重置的对象 var modelObj = edb.ProductCourseTypeConfig.FirstOrDefault(p => p.Id == productCourseTypeConfigId); if (null != modelObj) { modelObj.ProductCourseTypeId = productCourseTypeId; modelObj.BranchId = branchId; modelObj.IsBook = resetModelObj.IsBook; modelObj.MaxBookNum = resetModelObj.MaxBookNum; modelObj.IsRepeatBook = resetModelObj.IsRepeatBook; modelObj.BookLimitType = resetModelObj.BookLimitType; modelObj.BookTime = resetModelObj.BookTime; modelObj.BookTimeType = resetModelObj.BookTimeType; modelObj.PlusBookTime = resetModelObj.PlusBookTime; modelObj.PlusBookTimeType = resetModelObj.PlusBookTimeType; modelObj.UnBookTime = resetModelObj.UnBookTime; modelObj.UnBookTimeType = resetModelObj.UnBookTimeType; modelObj.IsAutoPass = resetModelObj.IsAutoPass; modelObj.IsScore = resetModelObj.IsScore; modelObj.PassScore = resetModelObj.PassScore; modelObj.IsRate = resetModelObj.IsRate; modelObj.IsFT = resetModelObj.IsFT; modelObj.IsLT = resetModelObj.IsLT; modelObj.IsSA = resetModelObj.IsSA; modelObj.Status = ConvertEnum.StatusTypeForActive; modelObj.UpdateBy = userId; modelObj.UpdateTime = DateTime.Now; modelObj.CreateBy = userId; modelObj.CreateTime = DateTime.Now; edb.Entry(modelObj).State = EntityState.Modified; result = edb.SaveChanges() > 0; } } else { var productCourseTypeConfig = new ProductCourseTypeConfig() { ProductCourseTypeId = productCourseTypeId, BranchId = branchId, IsBook = resetModelObj.IsBook, MaxBookNum = resetModelObj.MaxBookNum, IsRepeatBook = resetModelObj.IsRepeatBook, BookLimitType = resetModelObj.BookLimitType, BookTime = resetModelObj.BookTime, BookTimeType = resetModelObj.BookTimeType, PlusBookTime = resetModelObj.PlusBookTime, PlusBookTimeType = resetModelObj.PlusBookTimeType, UnBookTime = resetModelObj.UnBookTime, UnBookTimeType = resetModelObj.UnBookTimeType, IsAutoPass = resetModelObj.IsAutoPass, IsScore = resetModelObj.IsScore, PassScore = resetModelObj.PassScore, IsRate = resetModelObj.IsRate, IsFT = resetModelObj.IsFT, IsLT = resetModelObj.IsLT, IsSA = resetModelObj.IsSA, Status = ConvertEnum.StatusTypeForActive, UpdateBy = userId, UpdateTime = DateTime.Now, CreateBy = userId, CreateTime = DateTime.Now }; edb.Entry(productCourseTypeConfig).State = EntityState.Added; result = edb.SaveChanges() > 0; } } return result; } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("ProductBLL-ResetProductLevelConfig:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = userId, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:Primo /// 日期:2014.06.24 /// 描述:新增产品课节 /// </summary> /// <param name="pLevelCourseTypeCourse"></param> /// <param name="course"></param> /// <returns></returns> public static bool CreateProductLevelCourseTypeCourse(ProductLevelCourseTypeCourse pLevelCourseTypeCourse, Course course, int loginUserId) { using (var edb = new EmeEntities()) { using (var tran = new TransactionScope()) { try { var result = false; var modelCourse = edb.Course.FirstOrDefault(p => p.CName == course.CName && p.Status == ConvertEnum.StatusTypeForActive); var courseId = 0; edb.Entry(course).State = EntityState.Added; result = edb.SaveChanges() > 0; courseId = course.Id; pLevelCourseTypeCourse.CourseId = courseId; edb.Entry(pLevelCourseTypeCourse).State = EntityState.Added; result = edb.SaveChanges() > 0; tran.Complete(); return result; } catch (Exception e) { tran.Dispose(); // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("ProductBLL-CreateProductLevelCourseTypeCourse:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return false; } } } }
/// <summary> /// 作者:Primo /// 时间:2014.05.19 /// 描述:创建课程类型和课程级别的关联 /// </summary> /// <param name="productLevelId"></param> /// <param name="oldList"></param> /// <param name="newList"></param> /// <param name="newPLCTList"></param> /// <returns></returns> public static bool CreateProductLevelCourseType(int productLevelId, string[] oldList, string[] newList, List<ProductLevelCourseType> newPLCTList, int loginUserId) { using (var edb = new EmeEntities()) { var result = true; try { foreach (var oIdAndType in oldList) { if (!newList.Contains(oIdAndType) && oIdAndType != "") { var idAndType = oIdAndType.Split('-'); //需要删除 var productCourseTypeId = CommonHelper.To<int>(idAndType[0]); var selectivityType = CommonHelper.To<int>(idAndType[1]); var obj = edb.ProductLevelCourseType.FirstOrDefault( p => p.ProductLevelId == productLevelId && p.ProductCourseTypeId == productCourseTypeId && p.SelectivityType == selectivityType && p.Status == ConvertEnum.StatusTypeForActive); if (obj != null) { obj.Status = ConvertEnum.StatusTypeForDelete; edb.Entry(obj).State = EntityState.Modified; } } } if (newPLCTList.Count > 0) { foreach (var nPLCT in newPLCTList) { edb.Entry(nPLCT).State = EntityState.Added; } } result = edb.SaveChanges() > 0; return result; } catch (Exception ex) { Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Message), Message = string.Format("ProductBLL-CreateProductLevelCourseType:{0};{1};{2}", ex.Message, ex.InnerException, ex.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:Primo /// 时间:2014.06.20 /// 描述:重置产品级别配置 /// </summary> /// <param name="productLevelConfigId"></param> /// <param name="productLevelId"></param> /// <param name="branchId"></param> /// <param name="userId"></param> /// <returns></returns> public static bool ResetProductLevelConfig(int productLevelConfigId, int productLevelId, int branchId, int userId) { using (var edb = new EmeEntities()) { try { var result = false; //获取级别所属的原产品中心 var resetModelObjBranchId = edb.Product.Where(p => p.ProductLevel.Any(a => a.Id == productLevelId && p.Id == a.ProductId && a.Status == ConvertEnum.StatusTypeForActive) && p.Status == ConvertEnum.StatusTypeForActive).Select(s => s.BranchId).FirstOrDefault(); //获取该中心,该级别的复制对象 var resetModelObj = edb.ProductLevelConfig.FirstOrDefault(p => p.ProductLevelId == productLevelId && p.BranchId == resetModelObjBranchId && p.Status == ConvertEnum.StatusTypeForActive); if (resetModelObj != null) { if (resetModelObjBranchId > 0) { //获取需要重置的对象 var modelObj = edb.ProductLevelConfig.FirstOrDefault(p => p.Id == productLevelConfigId); if (null != modelObj) { modelObj.IsOptional = resetModelObj.IsOptional; modelObj.Optional = resetModelObj.Optional; edb.Entry(modelObj).State = EntityState.Modified; result = edb.SaveChanges() > 0; } } else { var productLevelConfig = new ProductLevelConfig() { BranchId = branchId, ProductLevelId = productLevelId, IsOptional = resetModelObj.IsOptional, Optional = resetModelObj.Optional, Status = ConvertEnum.StatusTypeForActive, CreateTime = DateTime.Now, UpdateTime = DateTime.Now }; edb.Entry(productLevelConfig).State = EntityState.Added; result = edb.SaveChanges() > 0; } } return result; } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("ProductBLL-ResetProductLevelConfig:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = userId, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:Primo /// 日期:2015.03.06 /// 描述:如果是存在,则修改,不存在则添加 /// </summary> /// <param name="plctff"></param> /// <returns></returns> public static bool CreateProductLevelCourseTypeForForbidden(ProductLevelCourseTypeForForbidden plctff) { var edb = new EmeEntities(); try { var result = false; //根据条件获取ProductLevelCourseTypeForForbidden var model = edb.ProductLevelCourseTypeForForbidden.SingleOrDefault(a => a.ProductLevelId == plctff.ProductLevelId && a.ProductLevelCourseTypeId == plctff.ProductLevelCourseTypeId && a.BranchId == plctff.BranchId && a.Status == ConvertEnum.StatusTypeForActive); if (model != null)//不等于空的时候则更新 { model.ProductLevelId = plctff.ProductLevelId; model.ProductLevelCourseTypeId = plctff.ProductLevelCourseTypeId; model.BranchId = plctff.BranchId; model.IsForbidden = plctff.IsForbidden; model.CreateBy = plctff.CreateBy; model.CreateTime = plctff.CreateTime; model.UpdateBy = plctff.UpdateBy; model.UpdateTime = plctff.UpdateTime; model.Status = plctff.Status; edb.Entry(model).State = EntityState.Modified; } else//等于空的时候则添加 { edb.Entry(plctff).State = EntityState.Added; } result = edb.SaveChanges() > 0; return result; } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("ProductBLL-CreateProductLevelCourseTypeForForbidden:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = plctff.UpdateBy, CreateTime = DateTime.Now }); return false; } }
/// <summary> /// 作者:Raymond /// 时间:2013-11-27 /// 描述:修改产品基本信息 /// </summary> /// <param name="product"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static bool UpdateProduct(Product product, int loginUserId) { using (var edb = new EmeEntities()) { try { var productObj = edb.Product.FirstOrDefault(p => p.Id == product.Id); if (productObj == null) return false; productObj.CName = product.CName; productObj.EName = product.EName; productObj.SCode = product.SCode; productObj.Levels = product.Levels; productObj.Online = product.Online; productObj.Offline = product.Offline; productObj.Description = product.Description; productObj.UpdateBy = product.UpdateBy; productObj.UpdateTime = product.UpdateTime; productObj.IsVip = product.IsVip; edb.Entry(productObj).State = EntityState.Modified; var result = edb.SaveChanges() > 0; return result; } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("ProductBLL-UpdateProduct:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:Raymond /// 时间:2013-11-28 /// 描述:通过Id,逻辑删除产品相关信息,更改Status的状态为Delete /// </summary> /// <param name="productId"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static bool DeleteProductById(int productId, int loginUserId) { using (var edb = new EmeEntities()) { var product = edb.Product.FirstOrDefault(p => p.Id == productId); try { if (product != null) { foreach (var pLevel in product.ProductLevel) { pLevel.Status = ConvertEnum.StatusTypeForDelete; edb.Entry(pLevel).State = EntityState.Modified; } foreach (var pNode in product.ProductNode) { pNode.Status = ConvertEnum.StatusTypeForDelete; edb.Entry(pNode).State = EntityState.Modified; } foreach (var pCourseType in product.ProductCourseType) { pCourseType.Status = ConvertEnum.StatusTypeForDelete; edb.Entry(pCourseType).State = EntityState.Modified; } product.Status = ConvertEnum.StatusTypeForDelete; } var result = edb.SaveChanges() > 0; return result; } catch (Exception ex) { Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Message), Message = string.Format("ProductBLL-DeleteProductById:{0};{1};{2}", ex.Message, ex.InnerException, ex.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:Raymond /// 日期:2014-2-13 /// 描述:更新产品课程类型 /// </summary> /// <param name="courseType"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static bool UpdateProductCourseType(ProductCourseType courseType, int loginUserId) { using (var edb = new EmeEntities()) { try { var productCourseType = edb.ProductCourseType.FirstOrDefault(p => p.Id == courseType.Id); if (productCourseType == null) return false; productCourseType.CName = courseType.CName; productCourseType.EName = courseType.EName; productCourseType.SCode = courseType.SCode; productCourseType.Coding = courseType.Coding; productCourseType.OrderNum = courseType.OrderNum; productCourseType.Description = courseType.Description; productCourseType.UpdateBy = courseType.UpdateBy; productCourseType.UpdateTime = courseType.UpdateTime; productCourseType.Remark = courseType.Remark; edb.Entry(productCourseType).State = EntityState.Modified; var result = edb.SaveChanges() > 0; return result; } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("ProductBLL-UpdateProductCourseType:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:Raymond /// 日期:2014-3-28 /// 描述:逻辑删除产品课节 /// </summary> /// <param name="pLevelCourseTypeCourseId"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static bool DeleteProductLevelCourseTypeCourseById(int pLevelCourseTypeCourseId, int loginUserId) { using (var edb = new EmeEntities()) { try { var pLevelCourseTypeCourse = edb.ProductLevelCourseTypeCourse.FirstOrDefault(p => p.Id == pLevelCourseTypeCourseId && p.Status == ConvertEnum.StatusTypeForActive); if (null == pLevelCourseTypeCourse) return false; var course = edb.Course.FirstOrDefault(p => p.Id == pLevelCourseTypeCourse.CourseId && p.Status == ConvertEnum.StatusTypeForActive); pLevelCourseTypeCourse.Status = ConvertEnum.StatusTypeForDelete; if (course != null) { course.Status = ConvertEnum.StatusTypeForDelete; edb.Entry(course).State = EntityState.Modified; } edb.Entry(pLevelCourseTypeCourse).State = EntityState.Modified; var result = edb.SaveChanges() > 0; return result; } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("ProductBLL-DeleteProductLevelCourseTypeCourseById:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return false; } } }
/// <summary> /// 作者:Kylin /// 时间:2014.03.27 /// 描述:更新产品级别配置 /// </summary> /// <param name="model"></param> /// <param name="loginUserId"></param> /// <returns></returns> public static bool UpdateProductCourseTypeConfig(ProductCourseTypeConfig model, int loginUserId) { using (var edb = new EmeEntities()) { try { var modelObj = edb.ProductCourseTypeConfig.SingleOrDefault(p => p.Id == model.Id && p.Status == ConvertEnum.StatusTypeForActive); if (modelObj == null) return false; modelObj.IsBook = model.IsBook; modelObj.MaxBookNum = model.MaxBookNum; modelObj.IsRepeatBook = model.IsRepeatBook; modelObj.BookLimitType = model.BookLimitType; modelObj.BookTime = model.BookTime; modelObj.BookTimeType = model.BookTimeType; modelObj.PlusBookTime = model.PlusBookTime; modelObj.PlusBookTimeType = model.PlusBookTimeType; modelObj.UnBookTime = model.UnBookTime; modelObj.UnBookTimeType = model.UnBookTimeType; modelObj.IsAutoPass = model.IsAutoPass; modelObj.IsScore = model.IsScore; modelObj.PassScore = model.PassScore; modelObj.IsRate = model.IsRate; modelObj.ProductCourseTypeId = model.ProductCourseTypeId; modelObj.BranchId = model.BranchId; modelObj.IsFT = model.IsFT; modelObj.IsLT = model.IsLT; modelObj.IsSA = model.IsSA; modelObj.UpdateBy = model.UpdateBy; modelObj.UpdateTime = model.UpdateTime; edb.Entry(modelObj).State = EntityState.Modified; var result = edb.SaveChanges() > 0; return result; } catch (Exception e) { // 异常日志消息队列 Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs() { ExceptionType = CommonHelper.To<int>(ExceptionType.Function), Message = string.Format("ProductBLL-UpdateProductCourseTypeConfig:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink), IsTreat = false, CreateBy = loginUserId, CreateTime = DateTime.Now }); return false; } } }