/// <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> /// 作者: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> /// 作者:Kylin /// 时间:2014.05.27 /// 描述:生日提醒 /// </summary> /// <param name="userId"></param> /// <param name="userName"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForSBirthday(int userId, string userName, int createBy) { var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "生日提醒", MContent = string.Format("Happy Birthday to you! {0}!美联英语", userName), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(userId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); }
/// <summary> /// 作者:Kylin /// 时间:2014.05.27 /// 描述:学员生日提醒 /// </summary> /// <param name="userId"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForSBirthday(int userId, int createBy) { var Db = new EmeEntities(); var currentDateTime = DateTime.Now; var executeContranctStatusType = CommonHelper.To<int>(ContractStatusType.Excute); var saStudentList = Db.Student.Where(p => p.SA == userId && p.Status == ConvertEnum.StatusTypeForActive //SA 's Student List && p.User.UserInfo.Any(info => info.Birthday != null && info.Birthday.Value.Month.Equals(currentDateTime.Month)) && p.Contract.Any(c => c.ContractDetail.Any(d => d.ContractStatusType == executeContranctStatusType))); var userName = string.Empty; foreach (var info in saStudentList.Select(student => student.User.UserInfo).SelectMany(userInfo => userInfo)) { userName += string.Format("学员{0} {1},生日{2}", info.EName, info.CName, info.Birthday); userName += ","; } var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "学员生日提醒", MContent = string.Format("您的{0};", userName), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(userId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); }
/// <summary> /// 作者:Kylin /// 时间:2014.05.27 /// 描述:学习计划提醒 /// </summary> /// <param name="userId"></param> /// <param name="planTypeId"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForSStudyPlan(int userId, int planTypeId, int createBy) { var Db = new EmeEntities(); var planExested = Db.FollowDetail.Any( p => p.Student.UserId == userId && p.Status == ConvertEnum.StatusTypeForActive && p.Follow.FollowTypeId == planTypeId && !(p.IsRead.HasValue && p.IsRead.Value)); if (planExested) { var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "学习计划提醒", MContent = string.Format("您的SA有新的学习计划发给您,请注意查收;"), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(userId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); } }
/// <summary> /// 作者:Kylin /// 时间:2014.05.28 /// 描述:管理端培训提醒 /// </summary> /// <param name="trainRecordId"></param> /// <param name="userId"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForMTrain(int trainRecordId, int userId, int? createBy) { var Db = new EmeEntities(); var train = Db.TrainRecord.SingleOrDefault(p => p.Id == trainRecordId && p.Status == ConvertEnum.StatusTypeForActive); if (train != null && train.TrainSchedule != null) { var trainSchedule = train.TrainSchedule; var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "培训提醒", MContent = string.Format("您预定的培训{0}的培训,请按时参加;", trainSchedule.BeginTime.ToString("yyyy-MM-dd HH:mm")), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(userId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); } }
/// <summary> /// 作者:Kylin /// 时间:2014.05.27 /// 描述:长时间未上课提醒(学员订课提醒) /// </summary> /// <param name="branchId"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForSLongTime(int branchId, int createBy) { var Db = new EmeEntities(); var currentDateTime = DateTime.Now; var currentStartMonth = currentDateTime.AddDays(1 - currentDateTime.Day); //本月月初 var currentEndMonth = currentStartMonth.AddMonths(1).AddDays(-1); //本月月末 var userStudentType = CommonHelper.To<int>(UserType.Student); var contractStatusType = CommonHelper.To<int>(ContractStatusType.Excute); //中心学员列表 var branchStudentUsers = UserBLL.GetBranchUserList(branchId); foreach (var branchStudentUser in branchStudentUsers) { var user = branchStudentUser; var bookrecords = Db.BookRecord.Where( p => p.Student.UserId == user.UserId && p.Status == ConvertEnum.StatusTypeForActive); var maxBookedTime = bookrecords.Max(m => m.BookTime.Value); //最后订课时间 var bookedMonthSpan = Math.Floor((currentEndMonth - maxBookedTime).TotalDays / 30); if (bookedMonthSpan > 1) { var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "长时间未上课提醒", MContent = string.Format("您已经超过{0}个月未订任何课程;", bookedMonthSpan), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(branchStudentUser.UserId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); } } }
/// <summary> /// 作者:Vincen /// 时间:2014.05.27 /// 描述:创建站内消息(学员上课提醒) /// </summary> /// <param name="bookRecordId"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForSOfflinePending(int bookRecordId, int? createBy) { var Db = new EmeEntities(); var bookRecord = Db.BookRecord.Single(p => p.Id == bookRecordId); var courseName = bookRecord.ArrangeCourse.ProductLevelCourseTypeCourse.Course.CName; var beginDate = bookRecord.ArrangeCourse.BeginTime.ToString("yyyy-MM-dd"); var branchName = bookRecord.ArrangeCourse.Branch.CName; var classRoom = bookRecord.ArrangeCourse.Classroom.ClassroomName; var beginTime = bookRecord.ArrangeCourse.BeginTime.ToString("HH:mm"); var receiver = bookRecord.Student.UserId; var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "上课提醒", MContent = string.Format("您预订的{0}课程,将于{1}在{2}中心{3}教室,{4}开始,请按时出席;", courseName, beginDate, branchName, classRoom, beginTime), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(receiver); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); }
/// <summary> /// 作者:Kylin /// 时间:2014.05.28 /// 描述:新学员(OC)提醒 /// </summary> /// <param name="userId"></param> /// <param name="studentEName"></param> /// <param name="studenCName"></param> /// <param name="beginTime"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForMoc(int userId, string studentEName, string studenCName, string beginTime, int? createBy) { var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "新学员(OC)提醒", MContent = string.Format("您有新的学员{0} {1},将于{2}参加OC课程;", studentEName, studenCName, beginTime), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(userId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); }
/// <summary> /// 作者:Kylin /// 时间:2014.05.27 /// 描述:Follow Up 查看提醒 (OK) /// </summary> /// <param name="userId"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForSFollowUp(int userId, int? createBy) { var Db = new EmeEntities(); var noNewFollowTotal = Db.FollowDetail.Count(p => p.Student.UserId == userId && p.Status == ConvertEnum.StatusTypeForActive && (!p.IsRead.Value)); var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "Follow Up 查看提醒", MContent = string.Format("您有SA新发送的{0}条FU,请注意查收;", noNewFollowTotal), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(userId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); }
/// <summary> /// 作者:Kylin /// 时间:2014.05.28 /// 描述:F/U回复提醒 /// </summary> /// <param name="userId"></param> /// <param name="studentName"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForMFollowUp(int userId, string studentName, int? createBy) { var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "F/U回复提醒", MContent = string.Format("您的F/U,学员{0}已有回复,请注意查收;", studentName), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(userId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); }
/// <summary> /// 作者:Kylin /// 时间:2014.05.28 /// 描述:学员升级提醒 /// </summary> /// <param name="userId"></param> /// <param name="levelName"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForMLevel(int userId, string levelName, int? createBy) { var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "学员升级提醒", MContent = string.Format("恭喜!您的学员成功升级到{0}级!", levelName), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(userId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); }
/// <summary> /// 作者:Kylin /// 时间:2014.05.28 /// 描述:合同变更学员提醒 /// </summary> /// <param name="userId"></param> /// <param name="userName"></param> /// <param name="contractStatus"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForMContract(int userId, string userName, ContractStatusType contractStatus, int? createBy) { var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "新学员(OC)提醒", MContent = string.Format("您的学员{0}合同已{1};", userName, BaseEnum.EmeEnum<ContractStatusType>.GetEnameByValue(contractStatus)), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(userId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); }
/// <summary> /// 作者:Kylin /// 时间:2014.05.28 /// 描述:老师上课提醒(老师端提醒) /// </summary> /// <param name="branchId"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForTPending(int branchId, int? createBy) { var Db = new EmeEntities(); //中心学员 var branchUserList = UserBLL.GetBranchUserList(branchId); foreach (var userBranch in branchUserList) { var classTotal = Db.ArrangeCourse.Count(p => p.TeachRecord.Any(t => t.Teacher.UserId == userBranch.UserId && t.Status == ConvertEnum.StatusTypeForActive) && p.BeginTime.Date == DateTime.Now.Date //当天 && p.OpenTime.HasValue && p.CurrentBookNum > 0 && p.Status == ConvertEnum.StatusTypeForActive); var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "上课提醒", MContent = string.Format("You have {0} classes today on the schedule;", classTotal), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(userBranch.UserId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); } }
/// <summary> /// 作者:Primo /// 时间:2015.04.28 /// 描述:投诉回复提醒 /// </summary> /// <param name="userId"></param> /// <param name="customerName"></param> /// <param name="customerTel"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForComplainReply(int userId, int? createBy) { var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "投诉回复提醒", MContent = "您好!您在2015月6日发布的“投诉建议”已回复。<a href=/Complain>>>点击查看。</a>", Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(userId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); }
/// <summary> /// 作者:Vincen /// 时间:2014.05.27 /// 描述:创建站内消息(学员订课提醒)(OK) /// </summary> /// <param name="bookRecordId"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForSBooking(int bookRecordId, int? createBy) { var Db = new EmeEntities(); var bookRecord = Db.BookRecord.Single(p => p.Id == bookRecordId); var courseName = bookRecord.ArrangeCourse.ProductLevelCourseTypeCourse.Course.CName; var beginTime = bookRecord.ArrangeCourse.BeginTime.ToString("yyyy-MM-dd HH:mm"); var receiver = bookRecord.Student.UserId; var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "订课提醒", MContent = string.Format("您{0}预订的{1}课程,已成功预订;", beginTime, courseName), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(receiver); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); }
/// <summary> /// 作者:Kylin /// 时间:2014.05.28 /// 描述:报备提醒 /// </summary> /// <param name="userId"></param> /// <param name="customerName"></param> /// <param name="customerTel"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForMReferral(int userId, string customerName, string customerTel, int? createBy) { var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "报备提醒", MContent = string.Format("您的{0}客户,电话:{1},已经成功报备;", customerName, customerTel), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(userId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); }
/// <summary> /// 作者:Kylin /// 时间:2014.05.27 /// 描述:投诉回复提醒 (OK) /// </summary> /// <param name="feedbackId"></param> /// <param name="userId"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForSFeedbackReply(int feedbackId, int userId, int? createBy) { var Db = new EmeEntities(); var feedback = Db.Feedback.SingleOrDefault(p => p.Id == feedbackId && p.Status == ConvertEnum.StatusTypeForActive); if (feedback == null) { return; } var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "反馈回复提醒", MContent = string.Format("您的意见已回复,请前往信息中心查看;"), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(userId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); }
/// <summary> /// 作者:Kylin /// 时间:2014.05.28 /// 描述:静态学员提醒 /// </summary> /// <param name="userId"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForMStaticStudent(int userId, int? createBy) { var Db = new EmeEntities(); var currentDateTime = DateTime.Now; var targetMonthDay = currentDateTime.AddDays(1 - currentDateTime.Day).AddDays(5); //本月 5day var executeContranctStatusType = CommonHelper.To<int>(ContractStatusType.Excute); //SA 's Student List var saStudentList = Db.Student.Where(p => p.SA == userId && p.Status == ConvertEnum.StatusTypeForActive && p.Contract.Any( c => c.ContractDetail.Any( d => d.ContractStatusType == executeContranctStatusType ))).ToList(); var message = string.Empty; foreach (var studentGroup in saStudentList) { var studentLastBookTime = studentGroup.BookRecord.OrderByDescending(p => p.BookTime).Select(p => p.BookTime != null ? p.BookTime.Value : new DateTime()).ToList(); var monthSpan = Math.Floor((studentLastBookTime[0] - targetMonthDay).TotalDays / 30); if ((studentLastBookTime[0] - targetMonthDay).TotalDays / 30 > 1) { message += string.Format("学员{0}", studentGroup.User.UserInfo.Aggregate(message, (current, info) => current + string.Format("{0} {1}", info.EName, info.CName))); message += string.Format("已有{0}个月", monthSpan); message += ", "; } } if (!string.IsNullOrEmpty(message)) { var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "静态学员提醒", MContent = string.Format("您的{0}没有预定课程没有预定课程;", message), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(userId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); } }
/// <summary> /// 作者:Kylin /// 时间:2014.05.27 /// 描述:升级提醒 /// </summary> /// <param name="userId"></param> /// <param name="productLevelId"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForSLevel(int userId, int productLevelId, int createBy) { var Db = new EmeEntities(); var productLevel = Db.ProductLevel.SingleOrDefault(p => p.Id == productLevelId); if (productLevel == null) { return; } var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "升级提醒", MContent = string.Format("恭喜您!您已经成功得升级为{0}级别!", productLevel.EName), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(userId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); }
/// <summary> /// 作者:Kylin /// 时间:2014.05.27 /// 描述:创建站内消息(中心放课信息提醒) /// </summary> /// <param name="branchId"></param> /// <param name="branchName"></param> /// <param name="isOnline"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForSOpening(int branchId, string branchName, bool isOnline, int? createBy) { var Db = new EmeEntities(); var currentDateTime = DateTime.Now; var currentDayOfWeek = CommonHelper.To<int>(currentDateTime.DayOfWeek); var nextweekStartTime = currentDateTime.AddDays(1 - ((currentDayOfWeek == 0) ? 7 : currentDayOfWeek)).AddDays(7); //下周周一 var isOpenCourses = Db.ArrangeCourse.Any(p => p.OpenTime.HasValue && p.BranchId == branchId && p.Status == ConvertEnum.StatusTypeForActive); var conExcute = CommonHelper.To<int>(ContractStatusType.Excute); if (!isOpenCourses) { return; } var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "中心开始放课提醒", MContent = string.Format("{0}{1}下周课程已放课,请前往订课中心预订;", branchName, isOnline ? "网课" : ""), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; //取得执行学员列表 var students = Db.Student.Where(p => p.User.UserBranch.Any(b => b.BranchId == branchId) && p.Contract.Any(t => t.ContractDetail.Any(d => d.ContractStatusType == conExcute && d.Status == ConvertEnum.StatusTypeForActive) && t.Status == ConvertEnum.StatusTypeForActive) && p.Status == ConvertEnum.StatusTypeForActive); foreach (var msgr in students) { msg.Receiver.Add(msgr.UserId); } // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); }
/// <summary> /// 作者:Kylin /// 时间:2014.05.27 /// 描述:NoShow 提醒 (OK) /// </summary> /// <param name="userId"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForSNoShow(int userId, int? createBy) { var Db = new EmeEntities(); var noshowType = CommonHelper.To<int>(AttendStatusType.Absent); var arrangeCourseNoShow = Db.ContractLevel.Where(p => p.Status == ConvertEnum.StatusTypeForActive && p.IsCurrent && p.ContractDetail.Contract.Student.UserId == userId); foreach (var contractLevel in arrangeCourseNoShow) { var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "NoShow 提醒", MContent = string.Format("您缺席了{0}的{1}课程,请联系SA说明原因;", contractLevel.ProductLevel.EName, contractLevel.Absence), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(userId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); } }
/// <summary> /// 作者:Kylin /// 时间:2014.05.28 /// 描述:学员投诉提醒(OK) /// </summary> /// <param name="userId"></param> /// <param name="feedbackTime"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForMStudentFeedback(int userId, string feedbackTime, int? createBy) { var Db = new EmeEntities(); var student = Db.Student.FirstOrDefault(p => p.UserId == userId && p.Status == ConvertEnum.StatusTypeForActive && (p.SA != null || p.CC != null)); if (null != student) { var uinfo = Db.UserInfo.FirstOrDefault(p => p.UserId == userId && p.Status == ConvertEnum.StatusTypeForActive); if (null != uinfo) { var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "学员投诉提醒", MContent = string.Format("您的学员{0},于{1}发起了投诉;", string.Format("{0}{1}", uinfo.CName, uinfo.EName), feedbackTime), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; if (student.SA != null) { msg.Receiver.Add(student.SA.Value); } if (student.CC != null) { msg.Receiver.Add(student.CC.Value); } // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); } } }
/// <summary> /// 作者:Vincen /// 时间:2014.05.27 /// 描述:创建站内消息(学员上网课提醒) /// </summary> /// <param name="bookRecordId"></param> /// <param name="meetingUrl"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForSOnlinePending(int bookRecordId, string meetingUrl, int? createBy) { var Db = new EmeEntities(); var bookRecord = Db.BookRecord.Single(p => p.Id == bookRecordId); var courseName = bookRecord.ArrangeCourse.ProductLevelCourseTypeCourse.Course.CName; var beginTime = bookRecord.ArrangeCourse.BeginTime.ToString("yyyy-MM-dd HH:mm"); var receiver = bookRecord.Student.UserId; var attendUserName = string.Empty; foreach (var uinfo in bookRecord.User.UserInfo) { attendUserName = string.Format("{0}", uinfo.EName); } var courseSpan = bookRecord.ArrangeCourse.EndTime.Subtract(bookRecord.ArrangeCourse.BeginTime).TotalMinutes; const EnterClassroomType enterType = EnterClassroomType.Create; var urlParam = string.Format("type:\"{0}\",platformType:\"{1}\",systemType:\"{2}\",businessType:\"{3}\",arrangeCourseId:\"{4}\",startTime:\"{5}\",courseTime:\"{6}\",courseNo:\"{7}\",courseName:\"{8}\",loginName:\"{9}\",userType:\"{10}\"" , enterType, MeetingPlatformType.Gensee, SystemType.Eme, BusinessType.Online, bookRecord.ArrangeCourseId, bookRecord.ArrangeCourse.BeginTime.ToString("yyyy-MM-dd HH:mm:ss"), courseSpan, bookRecord.ArrangeCourse.ProductLevelCourseTypeCourse.Course.Id, courseName, attendUserName, MeetingAttendType.Attendee); urlParam = "{" + urlParam + "}"; var onlineUrl = string.Format("{0}/Home?p={1}", meetingUrl, urlParam); var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "上课提醒", MContent = string.Format("您预订的网络课程{0},将在{1}开始,请提前10分钟登录链接 <a href='{2}' target='_blank'>{2}</a>;", courseName, beginTime, onlineUrl), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(receiver); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); }
/// <summary> /// 作者:Kylin /// 时间:2014.05.27 /// 描述:长时间未反馈提醒(学员反馈提醒) /// </summary> /// <param name="branchId"></param> /// <param name="createBy"></param> /// <returns></returns> public static void CreateMessageForSRate(int branchId, int createBy) { var Db = new EmeEntities(); //中心学员列表 var branchStudentUsers = UserBLL.GetBranchUserList(branchId); foreach (var branchStudentUser in branchStudentUsers) { var noRateTotal = Db.BookRecord.Count(p => p.Status == ConvertEnum.StatusTypeForActive && !p.IsUnBook && p.Student.UserId == branchStudentUser.UserId && p.ArrangeCourse.CourseRate.Any(r => !r.StudentIsRate && p.Status == ConvertEnum.StatusTypeForActive)); var msg = new MessageModel() { MessageType = CommonHelper.To<int>(MessageType.System), Subject = "长时间未反馈提醒", MContent = string.Format("您有{0}份课程反馈需要完成,感谢您的支持;", noRateTotal), Receiver = new List<int>(), CreateBy = createBy, CreateTime = DateTime.Now }; msg.Receiver.Add(branchStudentUser.UserId); // 将消息加入队列 Common.MSMQ.QueueManager.AddSystemMessage(msg); } }