public static string ReportPackager( int cropYear, string statementDate, string shid, string fromShid, string toShid, int paymentDescID, bool isCumulative, string footerText, string fileName, string logoUrl, string pdfTempfolder) { const string METHOD_NAME = "rptPaymentSummary.ReportPackager: "; DirectoryInfo pdfDir = null; FileInfo[] pdfFiles = null; string filePath = ""; try { pdfDir = new DirectoryInfo(pdfTempfolder); // Build the output file name by getting a list of all PDF files // that begin with this session ID: use this as a name incrementer. pdfFiles = pdfDir.GetFiles(fileName + "*.pdf"); fileName += "_" + Convert.ToString(pdfFiles.Length + 1) + ".pdf"; filePath = pdfDir.FullName + @"\" + fileName; try { // Because this report is built by data in one data set driving the selection of // data in a dependent dataset, all the data retrival has to be driven down to the // ReportBuilder. This is not the typical situation. if (shid.Length == 0 && fromShid.Length == 0 && toShid.Length == 0) { WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter SHID information before requesting a report."); throw (warn); } else { if (shid.Length > 0 && (fromShid.Length > 0 || toShid.Length > 0)) { WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("Please enter a single SHID or a SHID range, but not both."); throw (warn); } List <SHPaySumListItem> stateList = WSCPayment.GetPaymentSummary(ConfigurationManager.ConnectionStrings["BeetConn"].ToString(), cropYear, shid, fromShid, toShid, paymentDescID, isCumulative); if (stateList.Count != 0) { using (FileStream fs = new FileStream(filePath, FileMode.Create, FileAccess.Write)) { ReportBuilder(stateList, cropYear, statementDate, shid, fromShid, toShid, paymentDescID, isCumulative, footerText, logoUrl, fs); } } else { WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("SHID does not have the required transmittal records or rollup records to create a Payment Summary report."); throw (warn); } } } catch (System.Exception ex) { string errMsg = "cropYear: " + cropYear.ToString() + "; " + "SHID: " + shid + "; " + "From SHID: " + fromShid + "; " + "To SHID: " + toShid + "; " + "filePath: " + filePath + "; " + "Payment Desc ID: " + paymentDescID.ToString(); WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(METHOD_NAME + errMsg, ex); throw (wscEx); } return(filePath); } catch (System.Exception ex) { string errMsg = "cropYear: " + cropYear.ToString() + "; " + "SHID: " + shid + "; " + "From SHID: " + fromShid + "; " + "To SHID: " + toShid + "; " + "Payment Desc ID: " + paymentDescID.ToString(); WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(METHOD_NAME + errMsg, ex); throw (wscEx); } }