Exemplo n.º 1
0
        /// <summary>
        /// 提交软件反馈
        /// </summary>
        /// <param name="ChangeAuth"></param>
        /// <returns></returns>
        public ActionResult SubmitFeedback(FeedbackOperateDTO dto)
        {
            bool             result         = true;
            ResultData <int> feedbackresult = new ResultData <int>();
            UserLoginDTO     user           = (UserLoginDTO)Session["UserLoginInfo"];

            dto.FeedbackDate  = DateTime.Now;
            dto.FeedbackStaus = 0;
            dto.UserID        = user.UserID;
            try
            {
                feedbackresult = SystemProvider.AddFeedback(dto);
                if (feedbackresult.SubmitResult)
                {
                    List <MasterData.DTO.Common.AdminDTO> lstadmin = UserApplyProvider.GetAdminInfo(new MasterData.DTO.Common.AdminSearchDTO {
                        RoleIdList = new List <int> {
                            99
                        }
                    });

                    EmailHelper.SendMessage("问题反馈", WebConfiger.ProblemFeedbackMessage, lstadmin.Select(g => g.Email).Distinct().ToList(), null, null);
                }
            }
            catch (Exception ex)
            {
                feedbackresult.SubmitResult = false;
                feedbackresult.Message      = ex.Message;
                result = false;
            }
            if (Request.Files.Count > 0 && result == true)
            {
                HttpPostedFileBase Filedata         = Request.Files[0];
                string             FileName         = Guid.NewGuid().ToString();                                            //保存的文件名
                string             FileExtenSrcName = Filedata.FileName.Substring(Filedata.FileName.LastIndexOf("\\") + 1); //原文件名带扩展名
                string             FileSrcName      = FileExtenSrcName.Substring(0, FileExtenSrcName.LastIndexOf("."));     //原文件名不带扩展名
                string             FilePath         = null;
                string             FileExtenName    = Path.GetExtension(Filedata.FileName);                                 // 文件扩展名

                string strSaveDir = this.Server.MapPath("~/Attachments/Feedback");                                          //存储目录
                if (!System.IO.Directory.Exists(strSaveDir))
                {
                    System.IO.Directory.CreateDirectory(strSaveDir);
                }
                FilePath = strSaveDir + "\\" + FileName;
                Filedata.SaveAs(FilePath);

                List <AttachFileOperateDTO> attachlist = new List <AttachFileOperateDTO>();
                AttachFileOperateDTO        attach     = new AttachFileOperateDTO();
                attach.BelongModulePrimaryKey  = feedbackresult.Object.ToString();
                attach.AttachFileID            = Guid.NewGuid();
                attach.AttachFileSrcName       = FileSrcName;
                attach.BelongModule            = 1;
                attach.AttachFileExtentionName = FileExtenName;
                attach.AttachFileName          = FileName;
                attach.CreateTime = DateTime.Now;
                attach.CreateUser = user.FullName;
                attachlist.Add(attach);
                ResultData <object> attachresult = new ResultData <object>();
                attachresult = HomeProvider.AddAttachFileList(attachlist);
                if (!attachresult.SubmitResult)
                {
                    result = false;
                }
            }

            return(Json(result));
        }