Ejemplo n.º 1
0
        public ActionResult FeedbackCreate(FormCollection fc)
        {
            var fTypeId = Eme.Utility.CommonHelper.To<int>(fc["FeedbackType"]);
            var fContent = fc["FeedbackContent"];
            var fAttName = fc["UploadFileName"];
            var fCode = fc["UploadFileCode"];
            var fExt = fc["UploadFileExt"];
            var fSize = fc["UploadFileSize"];

            var currUserId = LoginUserManager.CurrLoginUser.UserId;

            var feedback = new Feedback()
            {
                FeedbackTypeId = fTypeId,
                FContent = fContent,
                FeedbackUserId = currUserId,
                FeedbackStatusType = Utility.CommonHelper.To<int>(Enum.FeedbackStatusType.NoReply),
                Status = Utility.CommonHelper.To<int>(Enum.StatusType.Active),
                CreateBy = currUserId,
                CreateTime = DateTime.Now
            };

            FeedbackAttachment feedbackAttachment = null;
            if (!(string.IsNullOrEmpty(fAttName) || string.IsNullOrEmpty(fCode) || string.IsNullOrEmpty(fExt)))
            {
                feedbackAttachment = new FeedbackAttachment()
                {
                    FAttName = fAttName,
                    FileCode = fCode,
                    FileExt = fExt,
                    FileSize = Utility.CommonHelper.To<int>(fSize),
                    Status = Utility.CommonHelper.To<int>(Enum.StatusType.Active),
                    CreateBy = currUserId,
                    CreateTime = DateTime.Now
                };
            }

            FeedbackBLL.CreateFeedback(feedback, feedbackAttachment);
            return RedirectToAction("Index");
        }
Ejemplo n.º 2
0
        /// <summary>
        /// 作者:Vincen
        /// 时间:2014.01.02
        /// 描述:新增反馈信息
        /// </summary>
        /// <param name="feedback"></param>
        /// <param name="feedbackAttachment"></param>
        /// <returns></returns>
        public static bool CreateFeedback(Feedback feedback, FeedbackAttachment feedbackAttachment)
        {
            using (var tran = new TransactionScope())
            {
                using (var edb = new EmeEntities())
                {
                    try
                    {
                        feedback = new Feedback()
                        {
                            FeedbackTypeId = feedback.FeedbackTypeId,
                            FContent = feedback.FContent,
                            FeedbackUserId = feedback.FeedbackUserId,
                            FeedbackStatusType = feedback.FeedbackStatusType,
                            Status = ConvertEnum.StatusTypeForActive,
                            CreateBy = feedback.CreateBy,
                            CreateTime = DateTime.Now
                        };

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

                        if (feedbackAttachment != null)
                        {
                            feedbackAttachment = new FeedbackAttachment()
                            {
                                FeedbackId = feedbackAttachment.FeedbackId,
                                FAttName = feedbackAttachment.FAttName,
                                FileCode = feedbackAttachment.FileCode,
                                FileExt = feedbackAttachment.FileExt,
                                FileSize = feedbackAttachment.FileSize,
                                Status = ConvertEnum.StatusTypeForActive,
                                CreateBy = feedbackAttachment.CreateBy,
                                CreateTime = DateTime.Now
                            };

                            feedbackAttachment.FeedbackId = feedback.Id;
                            edb.Entry(feedbackAttachment).State = EntityState.Added;
                        }

                        var result = edb.SaveChanges() > 0;
                        tran.Complete();
                        if (result)
                        {
                            //EmeBLL.CreateMessageForMStudentFeedback(feedback.FeedbackUserId,feedback.feed)
                        }
                        return result;
                    }
                    catch (Exception e)
                    {
                        tran.Dispose();

                        // 异常日志消息队列
                        Common.MSMQ.QueueManager.AddExceptionLog(new ExceptionLogs()
                        {
                            ExceptionType = CommonHelper.To<int>(ExceptionType.Function),
                            Message = string.Format("FeedbackBLL-CreateFeedback:{0};{1};{2}", e.Message, e.InnerException.Message, e.HelpLink),
                            IsTreat = false,
                            CreateBy = feedback.CreateBy,
                            CreateTime = DateTime.Now
                        });

                        return false;
                    }
                }
            }
        }