コード例 #1
0
ファイル: FollowBLL.cs プロジェクト: kylin589/EmePro
        /// <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;
                }
            }
        }
コード例 #2
0
ファイル: FollowBLL.cs プロジェクト: kylin589/EmePro
        /// <summary>
        /// 作者:Kylin
        /// 时间:2014.03.21 PM
        /// 描述:关闭(启用)Follow回复
        /// </summary>
        /// <param name="follow"></param>
        /// <param name="loginUserId"></param>
        /// <returns></returns>
        public static bool UpdateFollow(Follow follow, int loginUserId)
        {
            using (var edb = new EmeEntities())
            {
                try
                {
                    var followModel = edb.Follow.SingleOrDefault(p => p.Id == follow.Id && p.Status == ConvertEnum.StatusTypeForActive);

                    if (followModel != null)
                    {
                        followModel.Subject = follow.Subject;
                        followModel.FContent = follow.FContent;
                        followModel.IsRate = follow.IsRate;
                        followModel.IsReply = follow.IsReply;
                        followModel.UpdateBy = follow.UpdateBy;
                        followModel.UpdateTime = follow.UpdateTime;

                        edb.Entry(followModel).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("FollowBLL-UpdateFollow:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                        IsTreat = false,
                        CreateBy = loginUserId,
                        CreateTime = DateTime.Now
                    });

                    return false;
                }
            }
        }