backup1
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的更多相关文章
- backup1:开始数据库备份
数据库备份分为数据文件备份和日志文件备份,数据文件的备份分为:完整备份和差异备份.在SQL Server 2012中,能够将数据分布式备份到不同的存储设备上,一般情况,只将数据备份到一个备份文件(.b ...
- 工行ICBC_WAPB_B2C支付接口
一. 前期准备 手机银行(WAP)B2C在线支付接口说明V1.0.0.6.doc 手机银行移动生活商户及门户网站js接口API.doc 支付组件ICBCEBankUtil.dll和infosecapi ...
- ngx_http_upstream_module模块.md
ngx_http_upstream_module ngx_http_upstream_module模块用于定义可由proxy_pass,fastcgi_pass,uwsgi_pass,scgi_pas ...
- Linux下部署docker记录(1)-Volume使用
之前部署了Linux下部署docker记录(0)-基础环境安装,接下来看看Docker Volume的使用. Docker volume使用1)一个数据卷是一个特别指定的目录,该目录利用容器的UFS文 ...
- Linux下不同服务器间数据传输--转载
因为工作原因,需要经常在不同的服务器见进行文件传输,特别是大文件的传输,因此对linux下不同服务器间数据传输命令和工具进行了研究和总结.主要是rcp,scp,rsync,ftp,sftp,lftp, ...
- Linux下不同服务器间数据传输
因为工作原因,需要经常在不同的服务器见进行文件传输,特别是大文件的传输,因此对linux下不同服务器间数据传输命令和工具进行了研究和总结.主要是rcp,scp,rsync,ftp,sftp,lftp, ...
- RMAN备份与恢复之初入茅庐
理解数据库备份 所谓备份实际上是把数据库复制到转储设备的过程. 从备份方式来看数据库备份分为物理备份和逻辑备份,物理备份是把构成数据库的所有文件拷贝到指定的位置的过程,而逻辑备份只是利用SQL语言从数 ...
- nginx的反向代理和负载均衡的一个总结
之前一直觉的nginx的反向代理和负载均衡很厉害的样子,最近有机会接触了一下公司的这方面的技术,发现技术就是一张窗户纸呀,捅破了啥都明白了! 接下来先看一下nginx的反向代理: 简单的来说就是ngi ...
- 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) 收藏 举 ...
随机推荐
- bash while/until循环学习
while循环:条件满足,则循环:失败,则退出 如何退出? 必须有时刻,条件测试不成功 ? :条件控制变量 while 条件测试:do 循环体 done until循环:条件不满足,则循环:否则,退出 ...
- java疑问-继承问题
存在两个类,B 继承 A,C 继承 B,我们能将 B 转换为 C 么?如 C = (C) B:
- javaWeb——图片验证
publicvoid doGet(HttpServletRequest request, HttpServletResponse response) throws ServletException, ...
- win版本对比
Win+R 输入:slmgr.vbs -dlv 显示:最为详尽的激活信息,包括:激活ID.安装ID.激活截止日期slmgr.vbs -dli 显示:操作系统版本.部分产品密钥.许可证状态slmgr.v ...
- Python 获得对象内存占用内存大小 sys.getsizeof
from sys import getsizeof class A(object): pass class B: pass for x in (None, 1, 1L, 1.2, 'c', [], ( ...
- [转]windows下编译及使用libevent
http://www.cnblogs.com/luxiaoxun/p/3603399.html Libevent官网:http://libevent.org/ windows 7下编译: 编译环境: ...
- Eclipse debug高级技巧(转)
Debug视图 认识debug视图,红色部分框为线程堆栈视图,黄色部分框为表达式.断点.变量视图,蓝色部分为代码视图. 线程堆栈视图 分别介绍一下这几个按钮的含义: 1.表示当前实现继续运行直到下一个 ...
- ife-task0003学习收获总结
+ 编写可维护的css原则是,尽量减少改动时要编辑的地方(减少代码重复). + CSS布局奇淫技巧之-高度自适应 高度自适应:通过绝对定位来解决高度自适应的问题,元素不设置高度,设置绝对定位,将top ...
- C# WinForm 禁止最大化、最小化、双击标题栏、双击图标等操作(转载)
protected override void WndProc(ref Message m) { if (m.Msg==0x112) { switch ((int) m.WParam) { //禁止双 ...
- <<redis设计和实现>>读书笔记
redis如何实现主从同步的高效率?? 主从复制的同步有一个命令数据的同步文本,然后利用两个不同服务器的偏移量来进行进行同步,避免每次都是全部同步(并非会保存所有的命令数据,而是会有一个缓冲区(比如1 ...