/// <summary> /// 启动应用程序 /// </summary> protected void Application_Start() { AreaRegistration.RegisterAllAreas(); FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters); RouteConfig.RegisterRoutes(RouteTable.Routes); // 启动的时候清除全部缓存 ICache cache = CacheFactory.CaChe(); cache.RemoveAll(0); cache.RemoveAll(1); cache.RemoveAll(2); cache.RemoveAll(5); cache.RemoveAll(6); ; ModifyInMemory_Spire.ActivateMemoryPatching(); }
public virtual ActionResult FindByFileName(string name) { //获取指定的记录 //string condition = string.Format("FileName='{0}'", name); string condition = string.Format("1=1");//测试获取一个 var info = BLLFactory <FileUpload> .Instance.FindSingle(condition); if (info != null) { //判断是否存在PDF生成的图片文件, //生成的jpg文件名为附件的ID string pdfjpgPath = string.Format("/GenerateFiles/pdf/{0}.jpg", info.ID); string pdfjpg = Server.MapPath(pdfjpgPath); //PDF文件路径,相对目录即可 string pdfPath = @"/Content/Template/fapiao.pdf"; string pdfRealPath = Server.MapPath(pdfPath); //如果不存在,则生成,否则返回已生成的文件 if (!FileUtil.IsExistFile(pdfjpg)) { //破解 ModifyInMemory_Spire.ActivateMemoryPatching(); PdfDocument doc = new PdfDocument(pdfRealPath); var image = doc.SaveAsImage(0, Spire.Pdf.Graphics.PdfImageType.Bitmap, 300, 300); FileUtil.BytesToFile(ImageHelper.ImageToBytes(image), pdfjpg); } //存储一个路径 info.SavePath = pdfjpgPath;//修改使用这个属性返回使用 //序列号返回对象信息 string result = JsonConvert.SerializeObject(info, Formatting.Indented); return(Content(result)); } else { return(Content("")); } }