Report

martedì 28 dicembre 2010 - 15.52
Tag Elenco Tags  Windows Server 2008 R2  |  SQL Server 2008 R2

iif Profilo | Expert

Ciao, volevo sapere se è possibile schedulare dal sql server 2008 un report standard.
Grazie.

freeteo Profilo | Guru

Ciao,
adesso purtroppo non ho possibilità di provare con un report server per dirti esattamente come fare, cmq è possibile schedulare il report nelle impostazioni del report server, tral'altro se non ricordo male puoi anche dirgli di inviartelo via mail dopo che l'ha eseguito (nella schedulazione).

Cmq rimane il fatto che il report lo puoi schedulare automaticamente se hai il ReportServer, altrimenti puoi fare una schedulazione (operazione pianificata) di windows che lanci un tuo programma, il quale da codice renderizza magari in pdf il report.
Se ti serve ti posto il codice di quest'ultima strada.

Ciao.

Matteo Raumer
[MCAD .net, MVP Visual C#]
http://blogs.dotnethell.it/freeteo

iif Profilo | Expert

Magari, grazie.

freeteo Profilo | Guru

Ciao,
ti basta farti un'applicazione Console che quindi diventi un exe che possa essere lanciato da windows, ed usare un codice di questo tipo:
public class ReportManager { static ReportViewer GetViewer(string path) { ReportViewer viewer = new ReportViewer(); viewer.ProcessingMode = ProcessingMode.Local; viewer.LocalReport.ReportPath = path; viewer.Dock = DockStyle.Fill; viewer.ShowPrintButton = false; viewer.ShowExportButton = false; viewer.ShowParameterPrompts = false; return viewer; } public static byte[] Render(LocalReport report, string format) { //---queste ci vogliono string mimeType; string encoding; string fileNameExtension; string[] streams; Warning[] warnings; string deviceInfo = "<DeviceInfo>" + "<PageHeight>29cm</PageHeight>" + "<PageWidth>21cm</PageWidth>" + "</DeviceInfo>"; return report.Render(format, deviceInfo, out mimeType, out encoding, out fileNameExtension, out streams, out warnings); } public static void GeneraReport(string path, string fileDestinazione) { ReportViewer viewer = GetViewer(path); LocalReport report = viewer.LocalReport; byte[] bytes = Render(report, "PDF"); File.WriteAllBytes(fileDestinazione, bytes); } }

la tua applicazione console avrà un entrypoint di questo tipo:
[STAThread] static void Main(string[] args) { //--- riceve in input il nome del report da renderizzare //--- metto un valore di default se devi provarlo if (args == null || args.Count() == 0) args = new string[] { "ReportTest.rdlc" }; ReportManager.GeneraReport(args[0],"c:\\test.pdf"); }

Questo è un'esempio, tu adattalo e mettilo a posto come va meglio alla tua esigenza chiaramente...

Ciao.

Matteo Raumer
[MCAD .net, MVP Visual C#]
http://blogs.dotnethell.it/freeteo
Partecipa anche tu! Registrati!
Hai bisogno di aiuto ?
Perchè non ti registri subito?

Dopo esserti registrato potrai chiedere
aiuto sul nostro Forum oppure aiutare gli altri

Consulta le Stanze disponibili.

Registrati ora !
Copyright © dotNetHell.it 2002-2024
Running on Windows Server 2008 R2 Standard, SQL Server 2012 & ASP.NET 3.5