Exemplo n.º 1
0
        /// <summary>
        /// 导出收藏夹
        /// </summary>
        /// <returns></returns>
        public ActionResult ExportBookmarks()
        {
            string             templ = FileHelper.GetFileContent(Server.MapPath("~/Templete/bookmarks-template.html"), Encoding.GetEncoding("utf-8"));
            IList <UrlsEntity> list  = urlsRepository.FindAll().ToList();

            if (list == null)
            {
                list = new List <UrlsEntity>();
            }
            foreach (UrlsEntity entity in list)
            {
                entity.IconName = ImgHelper.ToBase64(Server.MapPath(GetIconUrl(entity.IconName)));
            }
            string      content  = Razor.Parse <IList <UrlsEntity> >(templ, list);
            string      fileName = "bookmarks-" + DateTimeHelper.GetDateFormat(FormatHelper.Date) + ".html";
            WebDownload download = new WebDownload(fileName);

            download.DownloadContent(content);
            return(View());
        }