/// <summary> /// Generates the report /// @see ITasklet#Execute /// </summary> /// <param name="contribution"></param> /// <param name="chunkContext"></param> /// <returns></returns> public RepeatStatus Execute(StepContribution contribution, ChunkContext chunkContext) { LocalReport report = new LocalReport { ReportPath = ReportFile.GetFileInfo().FullName }; if (Parameters != null && Parameters.Any()) { if (Logger.IsTraceEnabled) { Logger.Trace("{0} parameter(s) were given for the report ", Parameters.Count); } report.SetParameters(Parameters.Select(p => new ReportParameter(p.Key, p.Value))); } else { if (Logger.IsTraceEnabled) { Logger.Trace("No parameter was given for the report "); } } //DataSet DataSet ds = DbOperator.Select(Query, QueryParameterSource); //ReportDataSource ReportDataSource rds = new ReportDataSource { Name = DatasetName, Value = ds.Tables[0] }; report.DataSources.Add(rds); if (Logger.IsTraceEnabled) { Logger.Trace("Report init : DONE => Preparing to render"); } byte[] output = report.Render(ReportFormat); if (Logger.IsTraceEnabled) { Logger.Trace("Report init : rendering DONE => Preparing to serialize"); } //Create target directory if required OutFile.GetFileInfo().Directory.Create(); //dump to target file using (FileStream fs = new FileStream(OutFile.GetFileInfo().FullName, FileMode.Create)) { fs.Write(output, 0, output.Length); } if (Logger.IsTraceEnabled) { Logger.Info("Report init : serialization DONE - end of ReportTasklet execute."); } return(RepeatStatus.Finished); }