Exemplo n.º 1
0
        public ActionResult Index(string keyWord, string type, string area, string org, int?page)
        {
            try
            {
                int typeID = type != null?Convert.ToInt32(type) : 0;

                int areaID = area != null?Convert.ToInt32(area) : 0;

                int orgID = org != null?Convert.ToInt32(org) : 0;

                keyWord = keyWord != null ? keyWord : "";
                CMS_Documents_DAO objDAO = new CMS_Documents_DAO();
                var data = objDAO.Search(keyWord, typeID, areaID, orgID);
                ViewBag.SearchString = keyWord;
                int pageSize   = 10;
                int pageNumber = (page ?? 1);
                return(View(data.ToPagedList(pageNumber, pageSize)));
            }
            catch (Exception ex)
            {
                SetAlert("Lỗi" + ex.Message.ToString(), "error");
                Logs.WriteLog(ex);
                return(View());
            }
        }
Exemplo n.º 2
0
 public ActionResult ThongKeVanBan(string keyWord, string type, string area, string org, int?page)
 {
     try
     {
         DT_WebGISEntities MVCContext = new DT_WebGISEntities();
         TempData["TypeOfDocumentID"] = MVCContext.CMS_TypeOfDocument.ToList();
         TempData.Keep("TypeOfDocumentID");
         TempData["AreaOfDocument"] = MVCContext.CMS_AreaOfDocument.ToList();
         TempData.Keep("AreaOfDocument");
         TempData["OrganizationID"] = MVCContext.CMS_Organization.ToList();
         TempData.Keep("OrganizationID");
         int typeID = Convert.ToInt32(type);
         int areaID = Convert.ToInt32(area);
         int orgID  = Convert.ToInt32(org);
         keyWord = keyWord != null ? keyWord : "";
         CMS_Documents_DAO objDAO = new CMS_Documents_DAO();
         var data = objDAO.Search(keyWord, typeID, areaID, orgID).Where(x => x.Publish == true);
         ViewBag.SearchString = keyWord;
         ViewBag.TYPE         = type;
         ViewBag.AREA         = area;
         ViewBag.ORG          = org;
         int pageSize   = 10;
         int pageNumber = (page ?? 1);
         return(View(data.ToPagedList(pageNumber, pageSize)));
     }
     catch (Exception ex)
     {
         SetAlert("Lỗi" + ex.Message.ToString(), "error");
         Logs.WriteLog(ex);
         return(View());
     }
 }
Exemplo n.º 3
0
 public void Cache_VanBan()
 {
     try
     {
         CMS_Documents_DAO objDAO   = new CMS_Documents_DAO();
         MemoryCache       objCache = MemoryCache.Default;
         List <CMS_Documents_LayTatCa_Result> lstNews = objDAO.Search("", 0, 0, 0).Where(s => s.Publish == true).ToList();
         objCache.Remove("VanBan");
         objCache.Add("VanBan", lstNews, DateTime.Now.AddDays(SoNgayCache));
     }
     catch (Exception ex)
     {
         Logs.WriteLog(ex);
     }
 }
Exemplo n.º 4
0
        public ActionResult export_excel(FormCollection fc)
        {
            try
            {
                DT_WebGISEntities MyContext = new DT_WebGISEntities();
                CMS_Documents_DAO objDAO    = new CMS_Documents_DAO();
                int          typeID         = fc["type_excel"].ToString() != "" ? Convert.ToInt32(fc["type_excel"].ToString()) : 0;
                int          areaID         = fc["area_excel"].ToString() != "" ? Convert.ToInt32(fc["area_excel"].ToString()) : 0;
                int          orgID          = fc["org_excel"].ToString() != "" ? Convert.ToInt32(fc["org_excel"].ToString()) : 0;
                string       keyWord        = fc["key_excel"].ToString();
                var          data           = objDAO.Search(keyWord, typeID, areaID, orgID).Where(x => x.Publish == true).ToList();
                MemoryStream stream         = new MemoryStream();

                using (SpreadsheetDocument spreadsheetDoc = SpreadsheetDocument.Create(stream, SpreadsheetDocumentType.Workbook))
                {
                    CWorkbook workbook  = new CWorkbook(spreadsheetDoc);
                    string    sheetName = "ThongKe";

                    CSheet sheetLH = createSheet(spreadsheetDoc, workbook, sheetName, data);

                    sheetLH._worksheetPart.Worksheet.Save();
                }
                string fileName    = "ThongKeVanBan.xlsx";
                var    contentType = "application/vnd.openxmlformats-officedocument.spreadsheetml.sheet";
                Response.Clear();
                Response.ContentType = contentType;
                string contentDisposition = "attachment; filename*=UTF-8''" + Uri.EscapeDataString(fileName);
                Response.AddHeader("content-disposition", contentDisposition);
                Response.AddHeader("Content-Length", stream.Length.ToString());
                Response.Cache.SetCacheability(HttpCacheability.NoCache);
                Response.BinaryWrite(stream.ToArray());
                Response.Flush();
                Response.SuppressContent = true;
                System.Web.HttpContext.Current.ApplicationInstance.CompleteRequest();
                return(View());
            }
            catch (Exception ex)
            {
                SetAlert("Lỗi" + ex.Message.ToString(), "error");
                Logs.WriteLog(ex);
                return(View());
            }
        }