Exemplo n.º 1
0
        static public int Main(string[] args)
        {
            //  development GPDC-PC60
            // ceTe.DynamicPDF.Document.AddLicense("MER80NSSNPPNFDJ/+tFdG64tA51eMVpcD/SLKaMyia0Lo3DoXqKwR0Q/TT2bCdTLvdqoDUzoGkaCO178Bvj6lABsHvxDUGcptI8g");

            // GPDC-ORACLE  (Production / 60.8 and Test 144.234)

            ceTe.DynamicPDF.Document.AddLicense("MER80NSSNPPNFDrknfU84ZvBJwN89tBRokt4dClNfa11CGFZi895ceFyCUFkb0dFv5qDno6eEM5tGmBz1+MZ1p4AjttBviN//ZFg");


            // Handle the arguments""
            if (args == null || args.Length == 0)
            {
                Console.WriteLine(string.Format("RdlCmd Version {0}, Copyright (C) 2004-2008 Advanced Consulting Enterprises",
                                                Assembly.GetExecutingAssembly().GetName().Version.ToString()));
                Console.WriteLine("");
                Console.WriteLine("RdlCmd comes with ABSOLUTELY NO WARRANTY.  This is free software,");
                Console.WriteLine("and you are welcome to redistribute it under certain conditions.");
                Console.WriteLine("");
                Console.WriteLine("For help, type RdlCmd /?");
            }



            Ward         ward;
            DocHelper    dh = new DocHelper();
            ReportRunner rr = new ReportRunner();

            string[] files = new string[1];
            string[] types = new string[1];

            char[] breakChars = new char[] { '+' };
            // string files = " ";
            string logFile = null;
            string dir     = null;
            int    cnt     = 0;

            string outputFolder = null;
            string reportType   = "accounting";


            string oradb = ConfigurationManager.AppSettings["dbconnection"];

            outputFolder = ConfigurationManager.AppSettings["AnnualAccounting"];   // default folder  p:\Annuals\AnnualAccounting or p:\Annuals\AnnualPlan
            logFile      = ConfigurationManager.AppSettings["logFile"];

            string StartDate = null;
            string EndDate   = null;
            string Ward      = null;
            string reportURL = null;

            types[0] = "pdf";

            foreach (string s in args)
            {
                string t = s.Substring(0, 2);
                cnt++;

                switch (t)
                {
                case "/e":
                case "-e":
                    EndDate = s.Substring(2);
                    break;

                case "/f":                 // choices are -faccounting or -fplan or -fcjis
                case "-f":
                    if (s.Substring(2).ToLower() == "cjis")
                    {
                        outputFolder = ConfigurationManager.AppSettings["CJISMemoFolder"];
                        reportType   = "cjis";
                    }
                    if (s.Substring(2).ToLower() == "accounting")
                    {
                        files[0]     = ConfigurationManager.AppSettings["AccountingURL"];
                        outputFolder = ConfigurationManager.AppSettings["AnnualAccountingFolder"];
                        reportType   = "accounting";
                    }
                    if (s.Substring(2).ToLower() == "plan")
                    {
                        reportURL    = ConfigurationManager.AppSettings["AnnualPlanURL"];
                        outputFolder = ConfigurationManager.AppSettings["AnnualPlanFolder"];
                        reportType   = "plan";
                    }
                    break;

                case "/s":
                case "-s":
                    StartDate = s.Substring(2);
                    break;

                case "-w":
                case "/w":
                    Ward = s.Substring(2);
                    break;

                default:
                    Console.WriteLine("Unknown command '{0}' ignored.", s);
                    //returnCode = 4;
                    break;
                }
            }
            if (files == null)
            {
                Console.WriteLine("/f parameter is required.");
                return(8);
            }

            if (dir == null)
            {
                //dir = Environment.CurrentDirectory;
                dir = outputFolder;
            }

            if (dir[dir.Length - 1] != Path.DirectorySeparatorChar)
            {
                dir += Path.DirectorySeparatorChar;
            }

            OracleConnection connection = new OracleConnection(oradb);

            connection.Open();
            Console.WriteLine("DB Connection is: {0}", connection.State.ToString());

            ward = dh.getWardInformation(int.Parse(Ward), connection);


            if (reportType == "accounting")
            {
                Console.WriteLine("Processing Annual Accounting");
                createAccountingPDF(rr, ward, dh, files, outputFolder, StartDate, EndDate, connection);
            }

            if (reportType == "plan")
            {
                createAnnualPlanPDF(ward, dh, reportURL, outputFolder, StartDate, EndDate, connection, logFile);                                                                     // end of if accounting
                Console.WriteLine("Processing Annual Plan");
            }
            if (reportType == "cjis")
            {
                createCJISPDF(ward, dh, outputFolder, connection, logFile);
                Console.WriteLine("Processed CJIS Memo");     // end of if CJIS
            }
            return(1);
        }    /*   end of main  */
Exemplo n.º 2
0
        }       /* 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();
            }
        }
Exemplo n.º 3
0
        private static void createCJISPDF(Ward ward, DocHelper dh, string outputFolder, OracleConnection connection, string logFile)
        {
            decimal guardianLetterCount = 0;
            decimal cjisMemoCount       = 0;

            WardDocument[] wardDocArray;
            string         pdfTargetFolder = null;

            PdfDocument   profilePDF = null;
            MergeDocument document   = new MergeDocument();

            string cjisProfileURL = ConfigurationManager.AppSettings["CJIS_ProfileURL"];

            guardianLetterCount = dh.getguardianLetterCount(ward.getWardNumber(), connection); // count all of the documents we need, doctype "GRDLET"

            wardDocArray = new WardDocument[(int)guardianLetterCount];                         // create an array large enough to contain all of the necessary documents

            pdfTargetFolder = System.IO.Path.Combine(outputFolder, ward.getWardName() + "_" + ward.getWardNumber());

            if (!System.IO.Directory.Exists(pdfTargetFolder))                                                           // create output directory as needed for each ward
            {
                System.IO.Directory.CreateDirectory(pdfTargetFolder);
            }


            string profileDocumentPath = System.IO.Path.Combine(pdfTargetFolder, ward.getWardNumber() + "_Profile.pdf");        // the document created by Jasper

            /*    C R E A T E    T H E  3  B A S E  C J I S    R E P O R T S */
            WebClient client = new WebClient();
            string    url    = cjisProfileURL + 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, profileDocumentPath);


            profilePDF = new PdfDocument(profileDocumentPath);
            document   = new MergeDocument(profilePDF);

            if (wardDocArray.Length > 0 && ward.getStatus() != "X")                         // if we have a letter of Guardianship
            {
                dh.getLetterOfGuardianship(wardDocArray, connection, ward.getWardNumber()); // populate wardDocArray with the documents
                Console.WriteLine("Ward has {0} Letter(s) of Guardianship to copy", guardianLetterCount);

                //   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 Ward Profile pdf

                try
                {
                    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(@logFile, "Could not find ward document: " + w.getStoragePath() + "\\" + w.getDocPath() + " - " + DateTime.Now + "\r\n");
                        }
                    }
                }
                catch (Exception e)
                {
                    Console.WriteLine("Letters of Guardianship should exist but could not be found for ward {0}", ward.getWardNumber());
                }
            }
            else
            {
                Console.WriteLine("LOG: => No Letters of Guardianship found for ward {0}", ward.getWardNumber());
                System.IO.File.AppendAllText(@logFile, "Ward: " + ward.getWardNumber() + " Missing Letter of Gurardianship or CJIS Memorandum " + DateTime.Now + "\r\n");
            }



            document.Draw(System.IO.Path.Combine(pdfTargetFolder, ward.getWardNumber() + "_CJISMemo_" + document.Pages.Count.ToString() + ".pdf")); // name of the final output document
            File.Delete(profileDocumentPath);                                                                                                       // delete the profile.pdf
            dh.updateCJISStatus(ward.getWardNumber(), guardianLetterCount, cjisMemoCount, connection, ward.getStatus());
            connection.Close();
        }
Exemplo n.º 4
0
        }    /*   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  */