public ActionResult Register(RegisterDto UserInfo)
        {
            //int pageSize = Convert.ToInt32(ConfigHelp.GetConfigValue("pageSize"));
            try
            {
                if (ModelState.IsValid == false)
                {
                    ModelState.AddModelError("", "实体验证不合法");

                    List <RoomDto> list = new List <RoomDto>();
                    list = roomService.GetAll();
                    SelectList selList = new SelectList(list, "ID", "Name");
                    ViewData["Position"] = selList;

                    return(View(UserInfo)); //数据验证不通过后,重新跳到新增页面。
                }

                bool InsertCount = registerService.InsertInfo(UserInfo);
                /// <summary>
                /// 发送邮件
                /// </summary>
                /// <param name="title">邮件主题</param>
                /// <param name="email">要发送对象的邮箱</param>
                /// <param name="content">邮件内容</param>
                /// <returns></returns>
                if (InsertCount)
                {
                    string senderServerIp  = ConfigHelp.GetConfigValue("smtptype");                                             //使用163代理邮箱服务器(也可是使用qq的代理邮箱服务器,但需要与具体邮箱对相应)
                    string toMailAddress   = ConfigHelp.GetConfigValue("admin");                                                //要发送对象的邮箱
                    string fromMailAddress = ConfigHelp.GetConfigValue("useraddress");                                          //你的邮箱
                    string subjectInfo     = "学生注册审核通知";                                                                        //主题
                    string bodyInfo        = "<html>" + "名为 " + UserInfo.Real_Name + " 的学生提交了注册申请,请前往“用户管理”界面进行审核" + "</html>"; //以Html格式发送的邮件
                    string mailUsername    = ConfigHelp.GetConfigValue("user");                                                 //登录邮箱的用户名
                    string mailPassword    = ConfigHelp.GetConfigValue("pass");                                                 //对应的登录邮箱的第三方密码(你的邮箱不论是163还是qq邮箱,都需要自行开通stmp服务)
                    string mailPort        = "25";                                                                              //发送邮箱的端口号
                    //string attachPath = "E:\\123123.txt; E:\\haha.pdf";

                    //创建发送邮箱的对象
                    Email myEmail = new Email(senderServerIp, toMailAddress, fromMailAddress, subjectInfo, bodyInfo, mailUsername, mailPassword, mailPort, true, false);

                    //添加附件
                    //email.AddAttachments(attachPath);
                    //string message;
                    if (myEmail.Send())
                    {
                        return(Content("<script>alert('已将审核邮件发送给管理员,请耐心等待');window.location.href='Register';</script>"));
                    }
                    else
                    {
                        return(Content("<script>alert('邮件发送失败')window.location.href='Register';</script>"));
                    }
                }
            }
            catch
            {
            }
            return(View());
        }
예제 #2
0
        public JsonResult GetSumPer(string nickTime, int curPage, int id)
        {
            long recordCount          = 0;
            int  pageSize             = Convert.ToInt32(ConfigHelp.GetConfigValue("pageSize"));
            List <SumBaseDto> sumList = SumService.GetSumPer(nickTime, curPage, pageSize, id, out recordCount);
            string            jsonStr = JsonConvert.SerializeObject(new { recordCount = recordCount, pageSize = pageSize, lists = sumList });

            return(Json(jsonStr));
        }
        public JsonResult GetLeaveList(string nickName, string nickTime, int curPage, string RoomID)  //获取分页列表
        {
            List <UserBaseDto> UserList = userService.GetAll();
            long recordCount            = 0;

            int pageSize = Convert.ToInt32(ConfigHelp.GetConfigValue("pageSize"));
            List <LeaveBaseDto> LeaveList = leaveService.GetLeaveList(nickName.Trim(), nickTime, curPage, pageSize, RoomID, out recordCount);

            foreach (var item in LeaveList)
            {
                foreach (var item1 in UserList)
                {
                    if (item1.ID == item.User_ID)
                    {
                        item.Real_Name = item1.Real_Name;
                    }
                }
            }
            string jsonStr = JsonConvert.SerializeObject(new { recordCount = recordCount, pageSize = pageSize, lists = LeaveList });

            return(Json(jsonStr));
        }
        public JsonResult GetEquipList(string nickName, int curPage)  //获取分页列表
        {
            List <LABMANAGE.Service.Equip.Dto.EUserBaseDto> UserList = userService.GetAll();
            int  pageSize    = Convert.ToInt32(ConfigHelp.GetConfigValue("pageSize"));
            long recordCount = 0;
            List <EquipBaseDto> EquipList = null;

            EquipList = equipService.GetEquipList(nickName.Trim(), curPage, pageSize, out recordCount);

            foreach (var item in EquipList)
            {
                foreach (var item1 in UserList)
                {
                    if (item1.ID == item.User_ID)
                    {
                        item.Real_Name = item1.Real_Name;
                    }
                }
            }
            string jsonStr = JsonConvert.SerializeObject(new { recordCount = recordCount, pageSize = pageSize, lists = EquipList });

            return(Json(jsonStr));
        }
        public ContentResult UserCheck(int userId, string email) //用户审核,用于审核刚注册的用户
        {
            try
            {
                bool success = UserManService.UserCheck(userId);
                if (success)
                {
                    string senderServerIp  = ConfigHelp.GetConfigValue("smtptype");    //使用163代理邮箱服务器(也可是使用qq的代理邮箱服务器,但需要与具体邮箱对相应)
                    string toMailAddress   = email;                                    //要发送对象的邮箱
                    string fromMailAddress = ConfigHelp.GetConfigValue("useraddress"); //你的邮箱
                    string subjectInfo     = "审核通过消息";                                 //主题
                    string bodyInfo        = "<p>" + "注册已通过审核,请前往“登陆”页面进行登陆" + "</p>"; //以Html格式发送的邮件
                    string mailUsername    = ConfigHelp.GetConfigValue("user");        //登录邮箱的用户名
                    string mailPassword    = ConfigHelp.GetConfigValue("pass");        //对应的登录邮箱的第三方密码(你的邮箱不论是163还是qq邮箱,都需要自行开通stmp服务)
                    string mailPort        = "25";                                     //发送邮箱的端口号
                    //string attachPath = "E:\\123123.txt; E:\\haha.pdf";

                    //创建发送邮箱的对象
                    Email myEmail = new Email(senderServerIp, toMailAddress, fromMailAddress, subjectInfo, bodyInfo, mailUsername, mailPassword, mailPort, true, false);

                    if (myEmail.Send())
                    {
                        return(Content("true"));
                    }
                    else
                    {
                        return(Content("false"));
                    }
                }
                else
                {
                    return(Content("false"));
                }
            }
            catch { return(Content("false")); }
        }
        public ActionResult Index(EquipBaseDto equipBaseDto)
        {
            string VerfiyEmail            = null;
            List <EUserBaseDto> UserModel = userService.GetAll();

            TempData["peoplelist"] = UserModel;
            int id = 0;

            try
            {
                id = Convert.ToInt32(@LoginBase.ID);
            }
            catch { return(Content("<script>alert('尚未登录');window.location.href='../Login';</script>")); }
            equipBaseDto.User_ID = id;
            try
            {
                int Valid = Convert.ToInt32(Request.Form["valid"]);
                foreach (var item in UserModel)
                {
                    if (item.ID == Valid)
                    {
                        equipBaseDto.Verify_ID = item.ID;
                        VerfiyEmail            = item.Email;
                    }
                }
            }
            catch { return(Content("<script>alert('该审核用户不存在');window.location.href='Index';</script>")); }
            if (VerfiyEmail == null)
            {
                return(Content("<script>alert('审核用户不存在!');window.location.href='AskEquip?id=" + id + "&flag=false';</script>"));
            }
            System.DateTime NowTime = System.DateTime.Now;
            equipBaseDto.Time      = NowTime;
            equipBaseDto.Pass      = 0;
            equipBaseDto.IsExamine = 0;
            try
            {
                if (equipService.InsertInfo(equipBaseDto))
                {
                    string senderServerIp  = ConfigHelp.GetConfigValue("smtptype");    //使用163代理邮箱服务器(也可是使用qq的代理邮箱服务器,但需要与具体邮箱对相应)
                    string toMailAddress   = VerfiyEmail;                              //要发送对象的邮箱
                    string fromMailAddress = ConfigHelp.GetConfigValue("useraddress"); //你的邮箱
                    string subjectInfo     = "设备申请";                                   //主题
                    string bodyInfo        = "<p>" + "有新的设备申请,请前往“设备管理”进行审核" + "</p>"; //以Html格式发送的邮件
                    string mailUsername    = ConfigHelp.GetConfigValue("user");        //登录邮箱的用户名
                    string mailPassword    = ConfigHelp.GetConfigValue("pass");        //对应的登录邮箱的第三方密码(你的邮箱不论是163还是qq邮箱,都需要自行开通stmp服务)
                    string mailPort        = "25";                                     //发送邮箱的端口号
                    //创建发送邮箱的对象
                    Email myEmail = new Email(senderServerIp, toMailAddress, fromMailAddress, subjectInfo, bodyInfo, mailUsername, mailPassword, mailPort, true, false);

                    //添加附件
                    //email.AddAttachments(attachPath);
                    //string message;
                    if (myEmail.Send())
                    {
                        return(RedirectPermanent("/Equip/AskEquip?id=" + Convert.ToInt32(LoginBase.ID) + "&flag=true"));
                    }
                    else
                    {
                        return(Content("<script>alert('邮件发送失败');</script>"));
                    }
                }
            }
            catch { }


            return(RedirectPermanent("/Equip/AskEquip?id=" + Convert.ToInt32(LoginBase.ID) + "&flag=true"));
        }
        public ActionResult Index(LeaveBaseDto leaveBaseDto)
        {
            string             VerfiyEmail = null;
            List <UserBaseDto> UserModel   = userService.GetAll();

            TempData["peoplelist"] = UserModel;
            int id = 0;

            try
            {
                id = Convert.ToInt32(@LoginBase.ID);
            }
            catch { return(Content("<script>alert('尚未登录');window.location.href='../Login';</script>")); }
            leaveBaseDto.User_ID = id;

            try
            {
                int Valid = Convert.ToInt32(Request.Form["valid"]);

                foreach (var item in UserModel)
                {
                    if (item.ID == Valid)
                    {
                        leaveBaseDto.Verify_ID = item.ID;
                        VerfiyEmail            = item.Email;
                    }
                }
            }
            catch { return(Content("<script>alert('请选择正确的审核用户!');window.location.href='Index';</script>")); }
            if (VerfiyEmail == null)
            {
                return(Content("<script>alert('审核用户不存在!');window.location.href='AskLeave?id=" + id + "&flag=false';</script>"));
            }


            string Time = Request.Form["time"];
            string StartTime, EndTime;

            StartTime = EndTime = null;
            if (Time != null)
            {
                StartTime = Time.Split('-')[0].Trim().ToString();
                EndTime   = Time.Split('-')[1].Trim().ToString();
                leaveBaseDto.Start_Time = Convert.ToDateTime(StartTime);
                leaveBaseDto.End_Time   = Convert.ToDateTime(EndTime);
            }
            System.DateTime NowTime = System.DateTime.Now;
            leaveBaseDto.Time      = NowTime;
            leaveBaseDto.Pass      = 0;
            leaveBaseDto.IsExamine = 0;

            try
            {
                if (leaveService.InsertInfo(leaveBaseDto))
                {
                    string senderServerIp  = ConfigHelp.GetConfigValue("smtptype");    //使用163代理邮箱服务器(也可是使用qq的代理邮箱服务器,但需要与具体邮箱对相应)
                    string toMailAddress   = VerfiyEmail;                              //要发送对象的邮箱
                    string fromMailAddress = ConfigHelp.GetConfigValue("useraddress"); //你的邮箱
                    string subjectInfo     = "请假申请";                                   //主题
                    string bodyInfo        = "<p>" + "有学生请假,请前往“请假管理”进行审核" + "</p>";   //以Html格式发送的邮件
                    string mailUsername    = ConfigHelp.GetConfigValue("user");        //登录邮箱的用户名
                    string mailPassword    = ConfigHelp.GetConfigValue("pass");        //对应的登录邮箱的第三方密码(你的邮箱不论是163还是qq邮箱,都需要自行开通stmp服务)
                    string mailPort        = "25";                                     //发送邮箱的端口号
                    //创建发送邮箱的对象
                    Email myEmail = new Email(senderServerIp, toMailAddress, fromMailAddress, subjectInfo, bodyInfo, mailUsername, mailPassword, mailPort, true, false);

                    //添加附件
                    //email.AddAttachments(attachPath);
                    //string message;
                    if (myEmail.Send())
                    {
                        return(RedirectPermanent("/Leave/AskLeave?id=" + Convert.ToInt32(LoginBase.ID) + "&flag=true"));
                    }
                    else
                    {
                        //return Content("<script>alert('邮件发送失败')window.location.href='Index';</script>");
                    }
                }
            }
            catch { }
            return(RedirectPermanent("/Leave/AskLeave?id=" + Convert.ToInt32(LoginBase.ID) + "&flag=true"));
        }