コード例 #1
0
        public ActionResult SentMail()
        {
            String smtpUsername = "******";
            String smtpPassword = "******";
            String smtpHost = "smtp.gmail.com";
            int smtpPost = 25;

            String emailTo = "*****@*****.**";
            String subject = "Thông tin đăng ký cựu sinh viên của bạn đã được duyệt";
            String body = "<p><strong>Website Khoa công nghệ thông tin thông báo:</strong> Thông tin cựu sinh viên của bạn đã được duyệt.</p>";
            body += "<p><strong><a href='fit.nuce.edu.vn' target='_blank'>BẤM ĐÂY</a><strong> để xem thông tin cựu sinh viên của bạn</p>";
            body += "<p>Mọi ý kiến thắc xin gửi về: <a href='mailto:[email protected]' target='_blank'>[email protected]</a></p>";
            body += "<p></p>";
            EmailServices services = new EmailServices();
            bool rs = services.Send(smtpUsername, smtpPassword, smtpHost, smtpPost, emailTo, subject, body);
            if (rs)
                ViewData["message"] = "Thanh cong";
            else
                ViewData["message"] = "That bai";
            return View();
        }
コード例 #2
0
        public ActionResult ChangeState(CommentViewhelper commentViewhelper)
        {
            if (Session.getCurrentUser() == null)
                return Redirect("/admin/account/logon");
            if (!SercurityServices.HasPermission((int)TypeModule.MODULE_TINTUC, Session.getCurrentUser().username, TypeAudit.ManagerComment))
            {
                return Redirect("/admin/error/error403");
            }
            if (commentViewhelper.CheckID != null && commentViewhelper.CheckID.Length > 0) {
                //get email pass
                String smtpUsername = "";
                String smtpPassword = "";
                List<gov_system_config> lstSystem = _cnttDB.gov_system_config.ToList();
                foreach (var item in lstSystem)
                {
                    if (item.key_config.Equals(Constant.CONFIG_KEY_EMAIL))
                    {
                        smtpUsername = item.value_config;
                    }
                    if (item.key_config.Equals(Constant.CONFIG_KEY_PASS))
                    {
                        smtpPassword = item.value_config;
                    }
                }
                String content = "";
                Boolean state;
                foreach (var id in commentViewhelper.CheckID) {
                    gov_comments commentInfo = _cnttDB.gov_comments.Find(id);
                    state = commentInfo.active_flg;
                    commentInfo.active_flg = commentViewhelper.ChangeState;
                    int rs = _cnttDB.SaveChanges();
                    if (rs > 0) {
                        if (state == false && Convert.ToBoolean(commentViewhelper.ChangeState))
                        {

                            String smtpHost = "smtp.gmail.com";
                            int smtpPost = 25;
                            String emailTo = commentInfo.email;
                            String subject = "Bình luận của bạn " + commentInfo.full_name + " đã được duyệt";
                            String body = "<p><strong>Website Khoa Công Nghệ Thông Tin - ĐHXD thông báo:</strong> Bình luận của bạn đã được duyệt.</p>";
                            body += "<p><strong><a href='http://fit.nuce.edu.vn" + Utils.getLinkDefault(commentInfo.news_id, TypeLink.tintuc) + "' target='_blank'>BẤM ĐÂY</a><strong> để xem thông tin bình luận của bạn</p>";
                            body += "<p>Mọi ý kiến thắc xin gửi về: <a href='mailto:" + smtpUsername + "' target='_blank'>" + smtpUsername + "</a></p>";
                            body += "<p><strong style='font-style: italic;'>Xin cảm ơn!</strong></p>";
                            body += "<p></p>";
                            EmailServices services = new EmailServices();
                            services.Send(smtpUsername, smtpPassword, smtpHost, smtpPost, emailTo, subject, body);
                        }
                        content += Constant.CHUYEN_TRANG_THAI(Constant.ITEM_BINHLUAN, id.ToString(), state.ToString(), commentViewhelper.ChangeState.ToString());
                        content += ".<br/>";
                    }
                }
                if (!content.Equals(""))
                {
                    insertHistory(AccessType.chuyenTrangThaiBinhLuan, content);
                    TempData["message"] = Constant.CHANGE_STATE_SUCCESSFULL;
                }
            }
            saveData(commentViewhelper);
            return View("Index");
        }
コード例 #3
0
 public ActionResult SaveRegist(gov_news item){
     if (Session.getCurrentUser() == null)
         return Redirect("/admin/account/logon");
     if (!SercurityServices.HasPermission((int)TypeModule.MODULE_TINTUC, Session.getCurrentUser().username, TypeAudit.Addnew))
     {
         return Redirect("/admin/error/error403");
     }
     item.update_username = Session.getCurrentUser().username;
     item.update_datetime = DateTime.Now;
     item.entry_username = Session.getCurrentUser().username;
     item.entry_datetime = DateTime.Now;
     item.total_view = 0;
     item = _cnttDB.gov_news.Add(item);
     int rs = _cnttDB.SaveChanges();
     if (rs > 0) {
         var luceneNew = new LuceneSerives.LuceneNews();
         luceneNew.AddUpdateLuceneIndex(item);
         if (rs > 0)
         {
             insertHistory(AccessType.themMoiTinTuc, Constant.THEM(Constant.ITEM_TINTUC, Constant.ID, item.id.ToString()));
             //SEND MAIL
             //get email pass
             String smtpUsername = "";
             String smtpPassword = "";
             List<gov_system_config> lstSystem = _cnttDB.gov_system_config.ToList();
             foreach (var item1 in lstSystem)
             {
                 if (item1.key_config.Equals(Constant.CONFIG_KEY_EMAIL))
                 {
                     smtpUsername = item1.value_config;
                 }
                 if (item1.key_config.Equals(Constant.CONFIG_KEY_PASS))
                 {
                     smtpPassword = item1.value_config;
                 }
             }
             var lstUser = _cnttDB.gov_user.Where(u => u.active_flg == true).ToList();
             foreach (var user in lstUser)
             {
                 var c = SercurityServices.HasPermission((int)TypeModule.MODULE_TINTUC, user.username, TypeAudit.ManagerStudent);
                 if (SercurityServices.HasPermission((int)TypeModule.MODULE_TINTUC, user.username, TypeAudit.ManagerStudent))
                 {
                     try
                     {
                         if (!String.IsNullOrWhiteSpace(user.email))
                         {
                             String menuName = "";
                             var menuInfo = _cnttDB.gov_menu.Find(item.menu_id);
                             if (menuInfo != null)
                                 menuName = menuInfo.title;
                             String smtpHost = "smtp.gmail.com";
                             int smtpPost = 587;
                             String emailTo = user.email;
                             String subject = "[Fwd: Fit.nuce.edu.vn] Bài viết mới trên fit.nuce.edu.vn";
                             String body = "<p><strong>Website Khoa công nghệ thông tin thông báo:</strong></p>";
                             body += "<p><strong>" + item.entry_username + "</strong> vừa thêm mới bài viết có tiêu đề: <strong>" + item.title + "</strong>; vào danh mục: <strong>" + menuName + "</strong> lúc: <strong>" + DateTime.Now.ToString("HH:mm dd/MM/yyyy") + "</strong>.";
                             body += "<p>Chi tiết về bài viết: </p>";
                             body += "<div style='padding:0;min-height:100%;width:100%'>";
                             body += "<table style='width:600px;' cellspacing='10' cellpadding=''>";
                             body += "<tbody>";
                             body += "<tr>";
                             body += "<td style='padding:30px;font-size:13px;margin:0;border-radius:0px 0px 4px 4px;border:1px solid rgba(218,218,215,0.6);border-bottom:4px solid rgba(218,218,215,0.6)' colspan='2'>";
                             body += "<h3 style='font-size:17px;font-weight:bold'><span style='color:#003c95'>" + item.title + "</h3></span>";
                             body += "<h4 style='margin-bottom : 10px;'><p>" + item.description + "</p></h4>";
                             body += item.new_content.Replace("src=\"/Upload/", "src=\"http:fit.nuce.edu.vn/Upload/");
                             body += "</td>";
                             body += "</tr>";
                             body += "</tbody></table>";
                             body += "</div>";
                             body += "<p>Mọi ý kiến thắc xin gửi về: <a href='mailto:" + smtpUsername + "' target='_blank'>" + smtpUsername + "</a></p>";
                             body += "<p><strong style='font-style: italic;'>Xin cảm ơn!</strong></p>";
                             body += "<p></p>";
                             EmailServices services = new EmailServices();
                             var a = services.Send(smtpUsername, smtpPassword, smtpHost, smtpPost, emailTo, subject, body);
                             var b = a;
                         }
                     }
                     catch (Exception ex)
                     {
                         throw ex;
                     }
                 }
             }
             TempData["message"] = "Thêm mới thông tin thành công!";
         }
         else
         {
             TempData["err"] = "Thêm mới thông tin thất bại!";
         }
     }
     return Redirect("Index");
 }
コード例 #4
0
        public ActionResult changeActive(int[] ids, String changeActive)
        {
            if (Session.getCurrentUser() == null)
                return Redirect("/admin/account/logon");
            if (!SercurityServices.HasPermission((int)TypeModule.MODULE_CUUSINHVIEN, Session.getCurrentUser().username, TypeAudit.ManagerNotebook))
            {
                return Redirect("/admin/error/error403");
            }
            if (ids != null)
            {
                //get email pass
                String smtpUsername = "";
                String smtpPassword = "";
                List<gov_system_config> lstSystem = _cnttDB.gov_system_config.ToList();
                foreach (var item in lstSystem)
                {
                    if (item.key_config.Equals(Constant.CONFIG_KEY_EMAIL))
                    {
                        smtpUsername = item.value_config;
                    }
                    if (item.key_config.Equals(Constant.CONFIG_KEY_PASS))
                    {
                        smtpPassword = item.value_config;
                    }
                }
                String content = "";
                Boolean state;
                foreach (int id in ids)
                {
                    gov_notebook item = _cnttDB.gov_notebook.Find(id);
                    if (item != null)
                    {
                        state = item.active_flg;
                        item.active_flg = Convert.ToBoolean(changeActive);
                        int rs = _cnttDB.SaveChanges();
                        if (rs > 0)
                        {
                            if (state == false && Convert.ToBoolean(changeActive))
                            {

                                String smtpHost = "smtp.gmail.com";
                                int smtpPost = 587;
                                String emailTo = item.email;
                                String subject = "Thông tin đăng ký lưu bút ra trường của bạn đã được duyệt";
                                String body = "<p><strong>Website Khoa công nghệ thông tin thông báo:</strong> Thông tin lưu bút ra trường của bạn đã được duyệt.</p>";
                                body += "<p><strong><a href='fit.nuce.edu.vn/cuu-sinh-vien/luu-but-ra-truong' target='_blank'>BẤM ĐÂY</a></strong> để xem danh sách lưu bút ra trường của website</p>";
                                body += "<p>Mọi ý kiến thắc xin gửi về: <a href='mailto:" + smtpUsername + "' target='_blank'>" + smtpUsername + "</a></p>";
                                body += "<p><strong style='font-style: italic;'>Xin cảm ơn!</strong></p>";
                                body += "<p></p>";
                                EmailServices services = new EmailServices();
                                services.Send(smtpUsername, smtpPassword, smtpHost, smtpPost, emailTo, subject, body);
                            }
                            content += Constant.CHUYEN_TRANG_THAI(Constant.ITEM_LUUBUTRATRUONG, id.ToString(), state.ToString(), changeActive);
                            content += ".<br/>";
                        }
                    }
                }
                if (!content.Equals(""))
                {
                    insertHistory(AccessType.chuyenTrangThaiLuuBut, content);
                    TempData["message"] = Constant.CHANGE_STATE_SUCCESSFULL;
                }
            }
            return Redirect("Index");
        }
コード例 #5
0
 public ActionResult ReturnCode(String email)
 {
     var studentInfo = _cnttDB.gov_person.Where(p => p.email.ToUpper().Equals(email.ToUpper())).FirstOrDefault();
     if (studentInfo != null)
     {
         //get email pass
         String smtpUsername = "";
         String smtpPassword = "";
         List<gov_system_config> lstSystem = _cnttDB.gov_system_config.ToList();
         foreach (var item in lstSystem)
         {
             if (item.key_config.Equals(Constant.CONFIG_KEY_EMAIL))
             {
                 smtpUsername = item.value_config;
             }
             if (item.key_config.Equals(Constant.CONFIG_KEY_PASS))
             {
                 smtpPassword = item.value_config;
             }
         }
         String smtpHost = "smtp.gmail.com";
         int smtpPost = 587;
         String emailTo = email;
         String subject = "Lấy lại mật mã cựu sinh viên";
         String body = "<p><strong>Mật mã</strong> dùng để thay đổi thông tin cựu sinh viên của bạn là: <strong>" + studentInfo.code + "</strong>.</p>";
         body += "<p>Mọi ý kiến thắc xin gửi về: <a href='mailto:" + smtpUsername + "' target='_blank'>" + smtpUsername + "</a></p>";
         body += "<p><strong style='font-style: italic;'>Xin cảm ơn!</strong></p>";
         body += "<p></p>";
         EmailServices services = new EmailServices();
         services.Send(smtpUsername, smtpPassword, smtpHost, smtpPost, emailTo, subject, body);
         ViewData["message"] = "Mật mã đã được gửi về mail của bạn. Vui lòng kiểm tra lại và tiếp tục truy cập vào hệ thống!";
     }
     else
     {
         ViewData["err"] = "Email nhập vào không tồn tại trong hệ thống. Vui lòng kiểm tra lại!";
         return View("LostCode");
     }
     
     return View("ConfirmCode");
 }
コード例 #6
0
        public ActionResult changeActive(int[] ids, String changeActive) {
            if (Session.getCurrentUser() == null)
                return Redirect("/admin/account/logon");
            if (!SercurityServices.HasPermission((int)TypeModule.MODULE_CUUSINHVIEN, Session.getCurrentUser().username, TypeAudit.ManagerStudent))
            {
                return Redirect("/admin/error/error403");
            }
            if (ids != null) {

                //get email pass
                String smtpUsername = "";
                String smtpPassword = "";
                List<gov_system_config> lstSystem = _cnttDB.gov_system_config.ToList();
                foreach (var item in lstSystem) {
                    if (item.key_config.Equals(Constant.CONFIG_KEY_EMAIL)){
                        smtpUsername = item.value_config;
                    }
                    if (item.key_config.Equals(Constant.CONFIG_KEY_PASS))
                    {
                        smtpPassword = item.value_config;
                    }
                }
                String content = "";
                Boolean state;
                foreach (int id in ids) {
                    gov_person item = _cnttDB.gov_person.Find(id);
                    if (item != null) {
                        state = item.active_flg;
                        item.active_flg = Convert.ToBoolean(changeActive);
                        int rs = _cnttDB.SaveChanges();
                        if (rs > 0)
                        {
                            if (state == false && Convert.ToBoolean(changeActive))
                            {
                                
                                String smtpHost = "smtp.gmail.com";
                                int smtpPost = 587;
                                String emailTo = item.email;
                                String subject = "Thông tin đăng ký cựu sinh viên của bạn đã được duyệt";
                                String body = "<p><strong>Website Khoa công nghệ thông tin thông báo:</strong> Thông tin cựu sinh viên của bạn đã được duyệt.</p>";
                                body += "<p><strong>Mật mã</strong> dùng để phục vụ thay đổi thông tin của bạn sau này là: <strong>" + item.code + "</strong></p>";
                                body += "<p><strong style='font-style: italic;'>Bạn có thể tiếp tục với các lựa chọn sau:</strong></p>";
                                body += "<p>- <strong><a href='fit.nuce.edu.vn/cuu-sinh-vien/cuu-sinh-vien-tieu-bieu/thay-doi-mat-ma' target='_blank'>BẤM ĐÂY</a></strong> để thay đổi mật mã của bạn</p>";
                                body += "<p>- <strong><a href='fit.nuce.edu.vn/cuu-sinh-vien/cuu-sinh-vien-tieu-bieu' target='_blank'>BẤM ĐÂY</a></strong> để xem danh sách cựu sinh viên</p>";
                                body += "<p>- Xem thông tin cựu sinh viên của bạn <strong><a href='fit.nuce.edu.vn/cuu-sinh-vien/cuu-sinh-vien-tieu-bieu/"  + Utils.ConvertToUnSign(item.full_name) + "-" + item.id + "' target='_blank'>Xem chi tiết</a></strong> </p>";
                                body += "<p>Mọi ý kiến thắc xin gửi về: <a href='mailto:" + smtpUsername + "' target='_blank'>" + smtpUsername + "</a></p>";
                                body += "<p><strong style='font-style: italic;'>Xin cảm ơn!</strong></p>";
                                body += "<p></p>";
                                EmailServices services = new EmailServices();
                                services.Send(smtpUsername, smtpPassword, smtpHost, smtpPost, emailTo, subject, body);
                            }

                            content += Constant.CHUYEN_TRANG_THAI(Constant.ITEM_CUUSINHVIEN, id.ToString(), state.ToString(), changeActive);
                            content += ".<br/>";
                        }
                    }
                }
                if (!content.Equals(""))
                {
                    insertHistory(AccessType.chuyenTrangThaiCuuSinhVien, content);
                    TempData["message"] = Constant.CHANGE_STATE_SUCCESSFULL;
                }
            }
            return Redirect("Index");
        }