Exemplo n.º 1
0
        /// <summary>
        /// beta
        /// 2015.09.28
        /// 教师对学员课程评语写入消息盒子
        /// </summary>
        /// <param name="bookRecordId"></param>
        /// <param name="createBy"></param>
        /// <param name="userId"></param>
        public static void CreateMessageForCourseRate(int bookRecordId, int createBy,string mContent)
        {
            try
            {
                using (var tran = new TransactionScope())
                {
                    using (var edb = new EmeEntities())
                    {
                        var bookRecord = edb.BookRecord.Single(p => p.Id == bookRecordId);
                        var teacherInfo = UserBLL.GetUserInfoByUserId(createBy);
                        var courseName = bookRecord.ArrangeCourse.ProductLevelCourseTypeCourse.Course.CName;
                        var beginTime = bookRecord.ArrangeCourse.BeginTime.ToString("yyyy-MM-dd HH:mm");
                        var userinfo = UserBLL.GetUserInfoByStudentId(bookRecord.StudentId);
                        var msg = new Message()
                        {
                            MessageType = CommonHelper.To<int>(MessageType.System),
                            Subject = "教师评分",
                            MContent = string.Format("教师【{0}】对你的课程:【{1}】的评语:{2};", teacherInfo.CName, courseName,mContent),
                            Receivers = 1,
                            Openers = 0,
                            Status = ConvertEnum.StatusTypeForActive,
                            CreateBy = createBy,
                            CreateTime = DateTime.Now
                        };

                        edb.Entry(msg).State = EntityState.Added;
                        edb.SaveChanges();

                        var receiver = new MessageReceiver()
                        {
                            MessageId = msg.Id,
                            Receiver = userinfo.UserId,
                            IsRead = false,
                            Status = ConvertEnum.StatusTypeForActive,
                            CreateBy = createBy,
                            CreateTime = DateTime.Now
                        };

                        edb.Entry(receiver).State = EntityState.Added;

                        var result = edb.SaveChanges() > 0;

                        tran.Complete();
                    }
                }
            }
            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 = createBy,
                    CreateTime = DateTime.Now
                });
            }
        }
Exemplo n.º 2
0
        /// <summary>
        /// 作者:beta
        /// 时间:2014.12.04
        /// 描述:创建站内消息(排队预订成功发是消息给学员SA \ CC)
        /// </summary>
        /// <param name="bookRecordId"></param>
        /// <param name="createBy"></param>
        /// <param name="bookStudentId"></param>
        public static void CreateMessageForQueueBooking(int bookRecordId, string mobile, int? createBy, int bookStudentId)
        {
            try
            {
                using (var tran = new TransactionScope())
                {
                    using (var edb = new EmeEntities())
                    {
                        var bookRecord = edb.BookRecord.Single(p => p.Id == bookRecordId);
                        var studentInfo = UserBLL.GetUserInfoByStudentId(bookStudentId);
                        var courseName = bookRecord.ArrangeCourse.ProductLevelCourseTypeCourse.Course.CName;
                        var beginTime = bookRecord.ArrangeCourse.BeginTime.ToString("yyyy-MM-dd HH:mm");
                        var msg = new Message()
                        {
                            MessageType = CommonHelper.To<int>(MessageType.System),
                            Subject = "排队订课提醒",
                            MContent = string.Format("您的学员【{0}】电话:【{1}】{2} 通过排队预订了{3}课程,请与学员确认是否收到短信来中心上课!;", studentInfo.CName, mobile, beginTime, courseName),
                            Receivers = 1,
                            Openers = 0,
                            Status = ConvertEnum.StatusTypeForActive,
                            CreateBy = createBy,
                            CreateTime = DateTime.Now
                        };

                        edb.Entry(msg).State = EntityState.Added;
                        edb.SaveChanges();

                        var receiver = new MessageReceiver()
                                       {
                                           MessageId = msg.Id,
                                           Receiver = createBy.Value,
                                           IsRead = false,
                                           Status = ConvertEnum.StatusTypeForActive,
                                           CreateBy = createBy,
                                           CreateTime = DateTime.Now
                                       };

                        edb.Entry(receiver).State = EntityState.Added;

                        var result = edb.SaveChanges() > 0;

                        tran.Complete();
                    }
                }
            }
            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 = createBy,
                    CreateTime = DateTime.Now
                });
            }
        }
Exemplo n.º 3
0
        /// <summary>
        /// 作者:Primo
        /// 时间:2015.04.28
        /// 描述:投诉回复提醒
        /// </summary>
        /// <param name="userId"></param>
        /// <param name="subject"></param>
        /// <param name="mContent"></param>
        /// <param name="createBy"></param>
        public static void CreateMessageForComplainReply(int userId, string subject, string mContent, int? createBy)
        {
            try
            {
                using (var tran = new TransactionScope())
                {
                    using (var edb = new EmeEntities())
                    {
                        var msg = new Message()
                        {
                            MessageType = CommonHelper.To<int>(MessageType.System),
                            Subject = subject,
                            MContent = mContent,
                            Receivers = 1,
                            Openers = 0,
                            Status = ConvertEnum.StatusTypeForActive,
                            CreateBy = createBy,
                            CreateTime = DateTime.Now
                        };

                        edb.Entry(msg).State = EntityState.Added;
                        var result = edb.SaveChanges() > 0;

                        if (result)
                        {
                            var receiver = new MessageReceiver()
                            {
                                MessageId = msg.Id,
                                Receiver = userId,
                                IsRead = false,
                                Status = ConvertEnum.StatusTypeForActive,
                                CreateBy = createBy,
                                CreateTime = DateTime.Now
                            };

                            edb.Entry(receiver).State = EntityState.Added;

                            result = edb.SaveChanges() > 0;
                        }

                        if (result)
                            tran.Complete();
                        else
                            tran.Dispose();
                    }
                }
            }
            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 = createBy,
                    CreateTime = DateTime.Now
                });
            }
        }