string _imgpath1 = WebConfigurationManager.AppSettings["IMGPATH1"].ToString();

 string outputPath = Server.MapPath(Request.ApplicationPath + "/output");
string file = Guid.NewGuid().ToString() + ".pdf";
string desFile = Path.Combine(outputPath, file); string relativepath = "output/" + file; //转义
//System.Text.Encoding gb2312 = System.Text.Encoding.GetEncoding("gb2312");
//string encodeFilePath = _imgpath1 + HttpUtility.UrlEncode(_imgpath2 + genre, gb2312).Replace("%2f", "/").Replace("%5c", "/").Replace("+", "%20"); private void DownloadFile(string userName, string password, string ftpSourceFilePath, string localDestinationFilePath)
{
int bytesRead = ;
byte[] buffer = new byte[]; FtpWebRequest request = CreateFtpWebRequest(ftpSourceFilePath, userName, password, true);
request.Method = WebRequestMethods.Ftp.DownloadFile; Stream reader = request.GetResponse().GetResponseStream();
FileStream fileStream = new FileStream(localDestinationFilePath, FileMode.Create); while (true)
{
bytesRead = reader.Read(buffer, , buffer.Length); if (bytesRead == )
break; fileStream.Write(buffer, , bytesRead);
}
fileStream.Close();
}
private FtpWebRequest CreateFtpWebRequest(string ftpDirectoryPath, string userName, string password, bool keepAlive = false)
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(new Uri(ftpDirectoryPath)); //Set proxy to null. Under current configuration if this option is not set then the proxy that is used will get an html response from the web content gateway (firewall monitoring system)
request.Proxy = null; request.UsePassive = true;
request.UseBinary = true;
request.KeepAlive = keepAlive; request.Credentials = new NetworkCredential(userName, password); return request;
} try
{
string template = Server.MapPath(Request.ApplicationPath + "/reporttemplate/国有土地使用证.mrt");
string outputPath = Server.MapPath(Request.ApplicationPath + "/output");
//删除过期的临时PDF文件
List<FileInfo> toDeleteFiles = new List<FileInfo>();
Directory.GetFiles(outputPath, "*.pdf").ToList().ForEach(i => {
if ((new FileInfo(i)).CreationTime < DateTime.Now)
toDeleteFiles.Add(new FileInfo(i));
});
Task task = new Task(() =>
{
for (int i = toDeleteFiles.Count - ; i >= ; i--)
{ toDeleteFiles[i].Delete(); }
});
task.Start(); StiReport report = new StiReport();
report.Load(template);
report.RegBusinessObject("land", "cer", cer);
report.Compile();
report.Render(true);
string file = Guid.NewGuid().ToString() + ".pdf";
string relativepath = "/output/" + file;
string fullpath = Path.Combine(outputPath, file);
report.ExportDocument(StiExportFormat.Pdf, fullpath); return View(new PdfEntity() { Filename = fullpath, RelativeFilename = relativepath });
}
catch (Exception ex)
{
return View("Error", new HandleErrorInfo(ex, "CerController转换为PDF文件时发生异常", "Index"));
}
@model LandRegQueryWeb.Models.PdfEntity
@{
Layout = null;
} <html>
<body style="background-color: rgb(38,38,38); height: 100%; width: 100%; overflow: hidden; margin: 0"> <embed width="100%" height="100%"
name="plugin" id="plugin"
src="@Model.Filename#toolbar=0&navpanes=0&scrollbar=0"
type="application/pdf" internalinstanceid="" title=""> </body>
</html>

backup1的更多相关文章

  1. backup1:开始数据库备份

    数据库备份分为数据文件备份和日志文件备份,数据文件的备份分为:完整备份和差异备份.在SQL Server 2012中,能够将数据分布式备份到不同的存储设备上,一般情况,只将数据备份到一个备份文件(.b ...

  2. 工行ICBC_WAPB_B2C支付接口

    一. 前期准备 手机银行(WAP)B2C在线支付接口说明V1.0.0.6.doc 手机银行移动生活商户及门户网站js接口API.doc 支付组件ICBCEBankUtil.dll和infosecapi ...

  3. ngx_http_upstream_module模块.md

    ngx_http_upstream_module ngx_http_upstream_module模块用于定义可由proxy_pass,fastcgi_pass,uwsgi_pass,scgi_pas ...

  4. Linux下部署docker记录(1)-Volume使用

    之前部署了Linux下部署docker记录(0)-基础环境安装,接下来看看Docker Volume的使用. Docker volume使用1)一个数据卷是一个特别指定的目录,该目录利用容器的UFS文 ...

  5. Linux下不同服务器间数据传输--转载

    因为工作原因,需要经常在不同的服务器见进行文件传输,特别是大文件的传输,因此对linux下不同服务器间数据传输命令和工具进行了研究和总结.主要是rcp,scp,rsync,ftp,sftp,lftp, ...

  6. Linux下不同服务器间数据传输

    因为工作原因,需要经常在不同的服务器见进行文件传输,特别是大文件的传输,因此对linux下不同服务器间数据传输命令和工具进行了研究和总结.主要是rcp,scp,rsync,ftp,sftp,lftp, ...

  7. RMAN备份与恢复之初入茅庐

    理解数据库备份 所谓备份实际上是把数据库复制到转储设备的过程. 从备份方式来看数据库备份分为物理备份和逻辑备份,物理备份是把构成数据库的所有文件拷贝到指定的位置的过程,而逻辑备份只是利用SQL语言从数 ...

  8. nginx的反向代理和负载均衡的一个总结

    之前一直觉的nginx的反向代理和负载均衡很厉害的样子,最近有机会接触了一下公司的这方面的技术,发现技术就是一张窗户纸呀,捅破了啥都明白了! 接下来先看一下nginx的反向代理: 简单的来说就是ngi ...

  9. linux下不同服务器间数据传输(rcp,scp,rsync,ftp,sftp,lftp,wget,curl)(zz)

    linux下不同服务器间数据传输(rcp,scp,rsync,ftp,sftp,lftp,wget,curl) 分类: linux2011-10-10 13:21 8773人阅读 评论(1) 收藏 举 ...

随机推荐

  1. MFC双缓冲绘图(2015.09.24)

    问题引入: 最近在尝试编写贪吃蛇游戏时遇到这么一个问题:当系统以较快频率向窗口发送WM_PAINT消息时,调用OnPaint()函数在窗口中绘制图形就会发生闪烁现象. 问题分析: 当我们把绘图过程放在 ...

  2. chosen组件实现下拉框

    chosen组件用于增强原生的select控件,使之有更好的用户体验.官方demo https://harvesthq.github.io/chosen/ 目前项目中碰到的使用,比如一个页面中有两个不 ...

  3. Servlet页面登录的数据库验证程序(二)

    这个程序在原来的程序基础上加入了密码验证. 一.增加一个error.jsp页面,用于跳转出现用户名和密码错误显示信息. <%@ page language="java" im ...

  4. 使用dispatch_semaphore_t实现event的基本功能

    在Windows平台下, 对线程的同步控制,可以有Critical Section,Mutex,Semaphore,Event 等方式. 在IOS平台,使用GCD进行简单的多线程编程时,可以使用dis ...

  5. openjudge 螺旋加密

    /*======================================================================== 25:螺旋加密 总时间限制: 1000ms 内存限 ...

  6. TensorFlow官方文档中文版

    github地址: https://github.com/jikexueyuanwiki/tensorflow-zh

  7. [转]编译安装libevent,memcache,以及php的memcached扩展

    一 安装libevent 1.去官网http://libevent.org/ 下载最新源码,我用的是libevent-2.0.20-stable.tar.gz 2.解压到/usr/src目录 ,执行命 ...

  8. Android线程间通信更新UI的方法(重点分析EventBus)

    Android的UI更新只能在UI线程中,即主线程.子线程中如果要进行UI更新,都是要通知主线程来进行. 几种实现方式总结如下,欢迎补充. 1.runOnUiThread() 子线程中持有当前Acti ...

  9. (C++)窗口置前SetForegroundWindow(pThis->hwndWindow);

    一段代码主要是创建一个Window,然后将其置顶显示.奇怪的是这个功能有时候无效. pThis->bWindowDisplayed = SetForegroundWindow(pThis-> ...

  10. php extract 函数的妙用 数组键名为声明为变量,键值赋值为变量内容

    extract 函数的妙用 数组键名为声明为变量,键值赋值为变量内容 它的主要作用是将数组展开,键名作为变量名,元素值为变量值,可以说为数组的操作提供了另外一个方便的工具