} /* end of createAccountingPDF */ private static void createAnnualPlanPDF(Ward ward, DocHelper dh, string reportURL, string outputFolder, string StartDate, string EndDate, OracleConnection connection, string logFile) { decimal physicianDocCount = 0; WardDocument[] wardDocArray; string[] types = null; types = new string[] { "pdf" }; string pdfTargetFolder = null; Console.WriteLine("Processing Annual Plan"); physicianDocCount = dh.getPhysicianDocumentCount(ward.getWardNumber(), connection); // count all of the documents we need, doctype "MELLON" and "BANK" wardDocArray = new WardDocument[(int)physicianDocCount]; pdfTargetFolder = System.IO.Path.Combine(outputFolder, ward.getWardName() + "_" + ward.getFileNumber()); if (!System.IO.Directory.Exists(pdfTargetFolder)) // create output directory as needed for each ward { System.IO.Directory.CreateDirectory(pdfTargetFolder); } string document1 = System.IO.Path.Combine(pdfTargetFolder, ward.getWardNumber() + "_deleteME.pdf"); // the document created by the RDL component string document2; MergeDocument document; /* C R E A T E T H E B A S E A N N U A L P L A N R E P O R T */ WebClient client = new WebClient(); string url = reportURL + ward.getWardNumber();; client.Headers.Add("user-agent", "Mozilla/4.0 (compatible; MSIE 6.0; Windows NT 5.2; .NET CLR 1.0.3705;)"); client.DownloadFile(url, document1); if (physicianDocCount > 0) { dh.getWardPhysicianReport(wardDocArray, connection, ward.getWardNumber()); // populate wardDocArray with the documents Console.WriteLine("Ward has {0} Physician Report(s) to copy", physicianDocCount); dh.updatePlanStatus(ward.getWardNumber(), connection); connection.Close(); // create the AnnualAccounting PDF document document = new MergeDocument(document1); // B E G I N M E R G E O F P D F D O C U M E N T S Console.WriteLine("output folder is: {0}", pdfTargetFolder); // loop over any additional documents here and merge with the AnnualAccouting pdf foreach (WardDocument w in wardDocArray) { if (File.Exists(System.IO.Path.Combine(w.getStoragePath(), w.getDocPath()))) { document.Append(System.IO.Path.Combine(w.getStoragePath(), w.getDocPath())); } else { System.IO.File.AppendAllText(@"AnnualAccountingLog.txt", "Could not find ward document: " + w.getStoragePath() + "\\" + w.getDocPath() + " - " + DateTime.Now + "\r\n"); } } ceTe.DynamicPDF.PageList pl = new PageList(); // find out how many pages the resulting PDF document has so we can add the count to the final filename pl = document.Pages; Console.WriteLine("File has {0} Pages", pl.Count); document2 = System.IO.Path.Combine(pdfTargetFolder, ward.getWardNumber() + "_AnnualPlan_" + pl.Count.ToString() + ".pdf"); // name of the final output document document.Draw(document2); File.Delete(document1); // delete the 9999_temporary.pdf document2 = null; } else { Console.WriteLine("LOG: => No Physician Documents found for ward {0}", ward.getWardNumber()); System.IO.File.AppendAllText(@logFile, "Ward: " + ward.getWardNumber() + " has no Doctor Reports to process " + DateTime.Now + "\r\n"); ceTe.DynamicPDF.PageList pl = new PageList(); document = new MergeDocument(document1); pl = document.Pages; document2 = System.IO.Path.Combine(pdfTargetFolder, ward.getWardNumber() + "_AnnualPlan_" + pl.Count.ToString() + ".pdf"); // name of the final output document document.Draw(document2); File.Delete(document1); // delete the 9999_temporary.pdf document2 = null; dh.updatePlanStatus(ward.getWardNumber(), connection); connection.Close(); } }
} /* end of main */ private static void createAccountingPDF(ReportRunner rr, Ward ward, DocHelper dh, string[] files, string outputFolder, string StartDate, string EndDate, OracleConnection connection) { decimal wardDocCount = 0; WardDocument[] wardDocArray; string[] types = null; types = new string[] { "pdf" }; string pdfTargetFolder = null; wardDocCount = dh.getBankStatementCount(ward.getWardNumber(), connection, EndDate); // count all of the documents we need, doctype "MELLON" and "BANK" wardDocArray = new WardDocument[(int)wardDocCount]; pdfTargetFolder = System.IO.Path.Combine(outputFolder, ward.getWardName() + "_" + ward.getFileNumber()); if (!System.IO.Directory.Exists(pdfTargetFolder)) // create output directory as needed for each ward { System.IO.Directory.CreateDirectory(pdfTargetFolder); } string document1 = System.IO.Path.Combine(pdfTargetFolder, ward.getWardNumber() + "_temporary.pdf"); // the document created by the RDL component string document2; MergeDocument document; if (wardDocCount > 0) { dh.getWardBankDocs(wardDocArray, connection, ward.getWardNumber(), EndDate); // populate wardDocArray with the documents Console.WriteLine("Ward has {0} Bank document(s) to copy", wardDocCount); // rc.returnCode = returnCode; // MBG 08/15/15 rr.DoRender(pdfTargetFolder, files, types, ward.getWardNumber().ToString(), StartDate, EndDate); // create the AnnualAccounting PDF document document = new MergeDocument(document1); document = new MergeDocument(System.IO.Path.Combine(pdfTargetFolder, ward.getWardNumber() + "_temporary.pdf")); // B E G I N M E R G E O F P D F D O C U M E N T S Console.WriteLine("output folder is: {0}", pdfTargetFolder); // loop over any additional documents here and merge with the AnnualAccouting pdf foreach (WardDocument w in wardDocArray) { if (File.Exists(System.IO.Path.Combine(w.getStoragePath(), w.getDocPath()))) { document.Append(System.IO.Path.Combine(w.getStoragePath(), w.getDocPath())); } else { System.IO.File.AppendAllText(@"P:\Annuals\AnnualAccountingLog.txt", "Could not find ward document: " + w.getStoragePath() + "/" + w.getDocPath() + " - " + DateTime.Now + "\r\n"); } } ceTe.DynamicPDF.PageList pl = new PageList(); // find out how many pages the resulting PDF document has so we can add the count to the final filename pl = document.Pages; Console.WriteLine("File has {0} Pages", pl.Count); document2 = System.IO.Path.Combine(pdfTargetFolder, ward.getWardNumber() + "_AnnualAccounting_" + pl.Count.ToString() + ".pdf"); // name of the final output document document.Draw(document2); File.Delete(document1); // delete the 9999_temporary.pdf document2 = null; } else { Console.WriteLine("LOG: => No Bank Documents found for ward {0}", ward.getWardNumber()); System.IO.File.AppendAllText(@"C:\Annuals\AnnualAccountingLog.txt", "Ward: " + ward.getWardNumber() + " has no Bank Statements to process " + DateTime.Now + "\r\n"); // rc.returnCode = returnCode; // MBG 08/15/15 rr.DoRender(pdfTargetFolder, files, types, ward.getWardNumber().ToString(), StartDate, EndDate); ceTe.DynamicPDF.PageList pl = new PageList(); document = new MergeDocument(document1); pl = document.Pages; document2 = System.IO.Path.Combine(pdfTargetFolder, ward.getWardNumber() + "_AnnualAccounting_" + pl.Count.ToString() + ".pdf"); // name of the final output document document.Draw(document2); File.Delete(document1); // delete the 9999_temporary.pdf document2 = null; connection.Close(); } dh.updateAnnualAccounting(ward.getWardNumber(), connection); connection.Close(); } /* end of createAccountingPDF */