foreach (var o in order)
{
var path = Server.MapPath("~/FileExplorerContent/" + o.CustomerName + "/" + o.OrderId);
Directory.CreateDirectory(path);
try
{
foreach (var p in db.Product)
{
if (p.Pid == o.Pid)
{
string fileName = null;
HttpContext httpContext = System.Web.HttpContext.Current;
ReportWriter reportWriter = new ReportWriter(path);
reportWriter.ReportPath = Server.MapPath("~/App_Data/Report.rdl");
reportWriter.ReportProcessingMode = ProcessingMode.Remote;
List<ReportParameter> parameters = new List<ReportParameter>();
parameters.Add(new ReportParameter() { Name = "Pid", Labels = new List<string>() { o.Pid }, Values = new List<string>() { o.Pid } });
reportWriter.SetParameters(parameters);
fileName = o.Pid+ ".pdf";
reportWriter.Save(fileName, WriterFormat.PDF, httpContext.Response);
}
}
}
catch (Exception ex){}
}
}
public ActionResult Index(string button)
{
try
{
var path = Server.MapPath("~/App_Data/Test");
Directory.CreateDirectory(path);
string fileName = null;
HttpContext httpContext = System.Web.HttpContext.Current;
ReportWriter reportWriter = new ReportWriter();
reportWriter.ReportPath = Server.MapPath("~/App_Data/Report.rdl");
reportWriter.ReportProcessingMode = ProcessingMode.Remote;
List<ReportParameter> parameters = new List<ReportParameter>();
parameters.Add(new ReportParameter() { Name = "Ord", Labels = new List<string>() { "AAA" }, Values = new List<string>() { "AAA" } });
reportWriter.SetParameters(parameters);
fileName = "file.pdf";
reportWriter.Save(path+"/"+fileName, WriterFormat.PDF);
}
catch
{
}
return View();
} |