Example #1
0
        public static string ReportPackager(int cropYear, string equityType, DateTime certificateDate,
                                            string shid, string fromShid, string toShid, string fileName, string logoUrl, string pdfTempfolder,
                                            string sigName, string sigTitle, string sigImagePath)
        {
            const string  METHOD_NAME = "ReportPackager: ";
            DirectoryInfo pdfDir      = null;

            FileInfo[] pdfFiles = null;
            string     filePath = "";

            try {
                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;

                    if (equityType == "RET")
                    {
                        List <ListStatementPatRetainItem> stateList = WSCReportsExec.RptCertificateRetains(cropYear, shid, fromShid, toShid);

                        if (stateList.Count > 0)
                        {
                            using (System.IO.FileStream fs = new FileStream(filePath, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.Read)) {
                                ReportBuilderRetain(stateList, cropYear, certificateDate, shid, fromShid, toShid, logoUrl, fs, sigName, sigTitle, sigImagePath);
                            }
                        }
                        else
                        {
                            WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("No records matched your report criteria.");
                            throw (warn);
                        }
                    }
                    else
                    {
                        List <ListStatementPatRetainItem> stateList = WSCReportsExec.RptCertificatePat(cropYear, shid, fromShid, toShid);

                        if (stateList.Count > 0)
                        {
                            using (System.IO.FileStream fs = new FileStream(filePath, System.IO.FileMode.Create, System.IO.FileAccess.Write, System.IO.FileShare.Read)) {
                                ReportBuilderPatronage(stateList, cropYear, certificateDate, shid, fromShid, toShid, logoUrl, fs, sigName, sigTitle, sigImagePath);
                            }
                        }
                        else
                        {
                            WSCIEMP.Common.CWarning warn = new WSCIEMP.Common.CWarning("No records matched your report criteria.");
                            throw (warn);
                        }
                    }
                }
                catch (System.Exception ex) {
                    WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + "." + METHOD_NAME, ex);
                    throw (wscEx);
                }

                return(filePath);
            }
            catch (System.Exception ex) {
                WSCIEMP.Common.CException wscEx = new WSCIEMP.Common.CException(MOD_NAME + "." + METHOD_NAME, ex);
                throw (wscEx);
            }
        }