コード例 #1
0
 public ActionResult Index(int id)
 {
     gov_news newInfo = new gov_news();
     newInfo = _cnttDB.gov_news.Where(n => n.active_flg == true && n.id == id).FirstOrDefault();
     ViewData["new"] = newInfo;
     if(newInfo != null){
         ViewData["listNew"] = _cnttDB.gov_news.Where(n => n.active_flg == true && n.menu_id == newInfo.menu_id && n.id != id).OrderBy(n => n.entry_datetime).Skip(0).Take(7).ToList();
     }
     ViewData["lstComment"] = _cnttDB.gov_comments.Where(c => c.active_flg == true && c.news_id == id).OrderBy(c => c.entry_datetime).ToList();
     return View();
 }
コード例 #2
0
 public ActionResult Edit(gov_news item)
 {
     if (Session.getCurrentUser() == null)
         return Redirect("/admin/account/logon");
     if (!SercurityServices.HasPermission((int)TypeModule.MODULE_TINTUC, Session.getCurrentUser().username, TypeAudit.Edit))
     {
         return Redirect("/admin/error/error403");
     }
     gov_news newInfo = _cnttDB.gov_news.Find(item.id);
     newInfo.active_flg = item.active_flg;
     newInfo.avatar = item.avatar;
     newInfo.description = item.description;
     newInfo.is_shared = item.is_shared;
     newInfo.is_tinlq = item.is_tinlq;
     newInfo.is_comment = item.is_comment;
     newInfo.is_home = item.is_home;
     newInfo.menu_id = item.menu_id;
     newInfo.new_content = item.new_content;
     newInfo.new_source = item.new_source;
     newInfo.title = item.title;
     newInfo.type_id = item.type_id;
     newInfo.meta_desciption = item.meta_desciption;
     newInfo.meta_keyword = item.meta_keyword;
     newInfo.update_username = Session.getCurrentUser().username;
     newInfo.update_datetime = DateTime.Now;
     int rs = _cnttDB.SaveChanges();
     if (rs > 0)
     {
         var luceneNew = new LuceneSerives.LuceneNews();
         luceneNew.AddUpdateLuceneIndex(newInfo);
         if (rs > 0)
         {
             insertHistory(AccessType.chinhSuaTinTuc, Constant.CHINHSUA(Constant.ITEM_TINTUC, Constant.ID, item.id.ToString()));
             TempData["message"] = "Cập nhật thông tin thành công!";
         }
         else
         {
             TempData["err"] = "Cập nhật thông tin thất bại!";
         }
     }
     return Redirect("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");
 }