示例#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  */
示例#2
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  */