Advertisement
Advertisement
| 01.21.2008 at 04:09AM PST, ID: 23097957 |
|
[x]
Attachment Details
|
||
1: 2: 3: 4: 5: 6: 7: 8: 9: 10: 11: 12: 13: 14: 15: 16: 17: 18: 19: 20: 21: 22: 23: 24: 25: 26: 27: 28: 29: 30: 31: 32: 33: 34: 35: 36: 37: 38: 39: 40: 41: 42: 43: 44: 45: 46: 47: 48: 49: 50: 51: 52: 53: 54: 55: 56: 57: 58: 59: 60: 61: |
//web application
private void Imprimir()
{
logger.Debug(string.Format("Imprimir"));
string nombreFichero = Server.MapPath(@"~\Serializacion") + "\\Informe_" + DateTime.Now.ToString("yyyyMMdd") + "_" +
DateTime.Now.ToString("HHmmss") + ".rpt";
ReportDocument reportDocument = (ReportDocument)Session["report"];
if (reportDocument != null)
{
reportDocument.SaveAs(nombreFichero, true);
}
string rutaEjecutable = Server.MapPath(@"~\bin\Impresion.exe");
ProcessStartInfo startInfo = new ProcessStartInfo(rutaEjecutable);
startInfo.Arguments = nombreFichero;
Process process = Process.Start(startInfo);
while (!process.HasExited)
{
}
process.Close();
process.Dispose();
}
//windows application
private void Form1_Load(object sender, EventArgs e)
{
try
{
throw new Exception("hola");
ReportDocument reportDocument = new ReportDocument();
reportDocument.Load(@"C:\Inetpub\wwwroot\WebSetupPLS\Serializacion\Informe_20080121_123421.rpt");
if (reportDocument != null)
{
PrintDialog printDialog = new PrintDialog();
if (printDialog.ShowDialog() == DialogResult.OK)
{
reportDocument.PrintOptions.PrinterName = printDialog.PrinterSettings.PrinterName;
reportDocument.PrintToPrinter(printDialog.PrinterSettings.Copies, printDialog.PrinterSettings.Collate,
printDialog.PrinterSettings.FromPage, printDialog.PrinterSettings.ToPage);
}
reportDocument.Close();
reportDocument.Dispose();
}
}
catch (Exception ex)
{
}
Application.Exit();
}
|