public void ActionAdd(ModISPModel model) { if (model.RecordID > 0) { entity = ModISPService.Instance.GetByID(model.RecordID); // khoi tao gia tri mac dinh khi update entity.Updated = DateTime.Now; } else { entity = new ModISPEntity(); // khoi tao gia tri mac dinh khi insert entity.Activity = CPViewPage.UserPermissions.Approve; entity.Order = GetMaxOrder(model); } ViewBag.Data = entity; ViewBag.Model = model; }
//public void ExportToPDF(ModIncidentModel model) //{ // RenderView("Index"); // //lấy danh sách thuật ngữ // var listEntity = ModIncidentService.Instance.CreateQuery() // //.Where(o => o.Activity == true) // .ToList(); // //khai báo tập hợp bản ghi excel // List<List<object>> list = new List<List<object>>(); // //khai báo 1 dòng excel // List<object> _list = null; // string cityname = ""; // for (int i = 0; listEntity != null && listEntity.Count > 0 && i < listEntity.Count; i++) // { // _list = new List<object>(); // //add 1 dòng excel // // _list.Add(i + 1); // _list.Add(listEntity[i].Name); // _list.Add(cityname); // _list.Add(listEntity[i].Published); // list.Add(_list); // } // //ghi exel // string temp_file = CPViewPage.Server.MapPath("~/Data/upload/files/Excel/DanhSachSuCo_" + // string.Format("{0:dd_MM_yyyy}", DateTime.Now) + ".xls"); // string filePath = CPViewPage.Server.MapPath("~/TTPortal/Templates/DanhSachSuCo.xlsx"); // CPViewPage.Response.ContentType = "application/pdf"; // CPViewPage.Response.AddHeader("content-disposition", "attachment;filename=DataTable.pdf"); // CPViewPage.Response.Cache.SetCacheability(HttpCacheability.NoCache); // StringWriter sw = new StringWriter(); // HtmlTextWriter hw = new HtmlTextWriter(sw); // GridView1.RenderControl(hw); // StringReader sr = new StringReader(sw.ToString()); // Document pdfDoc = new Document(PageSize.A4, 10f, 10f, 10f, 0f); // HTMLWorker htmlparser = new HTMLWorker(pdfDoc); // PdfWriter.GetInstance(pdfDoc, Response.OutputStream); // pdfDoc.Open(); // htmlparser.Parse(sr); // pdfDoc.Close(); // CPViewPage.Response.Write(pdfDoc); // CPViewPage.Response.End(); //} public void ActionSendMail(EmailEntity emailEntity) { // Lay danh sach su co ModIncidentEntity suCoParent = ModIncidentService.Instance.CreateQuery().Where(o => o.ID == emailEntity.RecordID).ToSingle(); List <ModIncidentEntity> suCos = null; WebMenuEntity menuIncident = null; string sSuCo = string.Empty, isp = string.Empty, ip = string.Empty; string s2 = string.Empty, s3 = string.Empty, s4 = string.Empty, sName = string.Empty; //{2}: (giả mạo (phishing), nhiễm mã độc (malware), (thay đổi giao diện) Deface ) //{3}: , và các cố {2} // {4}: {2} + {3} if (suCoParent != null) { suCos = ModIncidentService.Instance.CreateQuery().Where(o => o.Resolve == false && o.ParentID == suCoParent.ID).ToList(); sSuCo += "<b><span>" + suCoParent.Path + "</span></b>"; isp = suCoParent.ISP; ip = suCoParent.IP; } if (suCos != null && suCos.Count > 0) { int countSuCo = suCos.Count; for (int i = 0; i < countSuCo; i++) { menuIncident = WebMenuService.Instance.CreateQuery().Where(o => o.Activity == true && o.Type == "Incident" && o.ID == suCos[i].MenuID).ToSingle(); if (menuIncident != null) { sName = menuIncident.Code == "Phishing" ? "giả mạo (Phishing)" : menuIncident.Code == "Malware" ? "nhiễm mã độc(Malware)" : "thay đổi giao diện (Deface)"; if (i == 0) { s2 = sName; } else { s3 += sName; if (i < countSuCo - 1) { s3 += ", "; } } } sSuCo += "<br /> " + suCos[i].Path + "<br />"; } } sSuCo += ip; // Lay template ModEmailTemplateEntity emailTemp = ModEmailTemplateService.Instance.CreateQuery().Where(o => o.Activity == true && o.Code == "Type1").ToSingle(); // Lay email gui di theo ISP ModISPEntity ispEntity = ModISPService.Instance.CreateQuery().Where(o => o.Activity == true && o.Name == isp).ToSingle(); if (emailTemp != null) { if (ispEntity != null) { emailEntity.To = ispEntity.Email; } emailEntity.Cc = "*****@*****.**"; emailEntity.Subject = string.Format(emailTemp.Subject, isp); emailEntity.Body = string.Format(emailTemp.Content, isp, sSuCo, s2, (!string.IsNullOrEmpty(s3) ? ", và các sự cố " + s3 : ""), s2 + (!string.IsNullOrEmpty(s3) ? ", " + s3 : "")); } ViewBag.Data = emailEntity; }