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) 收藏 举 ...
随机推荐
- CentOS7 安装 net-speeder 提升 VPS 网络性能
参考:http://blog.csdn.net/u010027419/article/details/46129639 1.安装依赖库 先安装epel源 rpm -Uvh http://dl.fedo ...
- clang编译器简介
本文部分内容引用: 中文维基百科. 结构化编译器前端--clang介绍. 什么是clang编译器? clang是LLVM编译器工具集的一个用于编译C.C++.Objective-C的前端.LLVM项目 ...
- 关于javascript中闭包的理解
闭包就是能够读取其他函数内部变量的函数. 在javascript中,只有函数内部的子函数可以读取局部变量,因此,我理解闭包就是定义在一个函数内部的函数. 例子: var f1 = function() ...
- Python之路,day5-Python基础
for#列表生成式 data = [1,2,3,4,5,6,7] #####列表生成式 #data = [i+1 for i in data] data = [i*2 if i>5 else i ...
- python——socket网络编程
一.OSI七层模型
- Hadoop Pipeline详解[摘抄]
最近使用公司内部的一个框架写map reduce发现没有封装hadoop streaming这些东西,查了下pipeline相关的东西 Hadoop Pipeline详解 20. Aug / had ...
- oracle case when
http://www.cnblogs.com/kevin2013/archive/2010/07/02/1769682.html
- ListView 中含有 EditText 导致焦点丢失的问题
ListView 中的 item 中有 EditText 时. 如果activity的输入法选项设置为 android:windowSoftInputMode="adjustResize&q ...
- 【MySQL】分页优化
前段时间由于项目的原因,对一个由于分页而造成性能较差的SQL进行优化,现在将优化过程中学习到关于分页优化的知识跟大家简单分享下. 分页不外乎limit,offset,在这两个关键字中,limit其实不 ...
- PHPCMS v9 超级安全防范教程!
一.目录权限设置很重要:可以有效防范黑客上传木马文件.如果通过 chmod 644 * -R 的话,php文件就没有权限访问了.如果通过chmod 755 * -R 的话,php文件的权限就高了. 所 ...