public PfiPostReport(DataTable dataTable, string sTotalCost, string sTags, string sAsOf, DateTime shopTime, ReportObject reportObject, IPdfLauncher pdfLauncher)
     : base(pdfLauncher)
 {
     if (dataTable != null)
     {
         _Records      = dataTable.Rows;
         _RecordCount  = _Records.Count;
         _ShopTime     = shopTime;
         _StoreNumber  = reportObject.ReportStore;
         _Tags         = sTags;
         _TotalCost    = sTotalCost;
         _AsOf         = sAsOf;
         _ReportObject = reportObject;
     }
 }
Esempio n. 2
0
        public static bool DoReport(ReportObject reportObject, IPdfLauncher pdfLauncher)
        {
            bool reportOK = false;

            RunReport runReport = new RunReport();

            runReport.reportObject = reportObject;

            //runReport.reportObject = this;
            if (FileLogger.Instance.IsLogInfo)
            {
                FileLogger.Instance.logMessage(LogLevel.INFO, "ReportProcessing",
                                               "- Report " + reportObject.ReportTitle + " has been requested.");
            }

            if (runReport.CreateReport(pdfLauncher))
            {
                try
                {
                    //SMurphy 4/13/2010 problem when Adobe is already open
                    Process adbProcess = AdobeReaderOpen();
                    if (adbProcess != null)
                    {
                        adbProcess.Kill();
                    }
                }
                catch (Exception eX)
                {
                    if (FileLogger.Instance.IsLogError)
                    {
                        FileLogger.Instance.logMessage(LogLevel.ERROR, "RunReport", "Exception thrown when killing Adobe processes: {0}:{1} {2}",
                                                       eX, eX.Data, eX.StackTrace ?? "NoStackTrace");
                    }
                }

                try
                {
                    pdfLauncher.ShowPDFFile(reportObject.ReportTempFileFullName, false);
                    reportOK = true;
                }
                catch (Exception /*exc*/)
                {
                    reportOK = false;
                }
            }

            return(reportOK);
        }
        public bool CreateReport()
        {
            bool isSuccessful = false;

            _document = new iTextSharp.text.Document(PageSize.LETTER);

            try
            {
                string reportTitle = "Transfer In Merchandise Summary";
                int    columns     = 6;

                _ReportObject = new ReportObject();
                _ReportObject.CreateTemporaryFullName();

                if (!Directory.Exists(_logPath))
                {
                    Directory.CreateDirectory(_logPath);
                }

                reportFileName = _logPath + "\\" + _ReportObject.ReportTempFileFullName;

                PdfWriter writer = PdfWriter.GetInstance(_document, new FileStream(reportFileName, FileMode.Create));
                writer.PageEvent = this;
                PdfPTable table = new PdfPTable(columns);
                Image     gif   = Image.GetInstance(Resources.logo, BaseColor.WHITE);
                _reportFont               = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL);
                _reportFontLargeBold      = FontFactory.GetFont("Arial", 12, iTextSharp.text.Font.BOLD);
                _reportFontLargeUnderline = FontFactory.GetFont("Arial", 10, iTextSharp.text.Font.UNDERLINE);
                gif.ScalePercent(35);
                _document.AddTitle(reportTitle);
                _document.SetMargins(-50, -55, 10, 45);
                _document.Open();
                createTransInSummaryHeader(gif, reportTitle);
                PrintReportDetail();
                addTotalCostRow();
                _document.Close();
                isSuccessful = true;
            }
            catch (Exception e)
            {
                Console.WriteLine("Error generating report :" + e);
                isSuccessful = false;
            }
            return(isSuccessful);
        }
        public bool CreateReport()
        {
            bool isSuccessful = false;

            _document = new iTextSharp.text.Document(PageSize.LEGAL);

            try
            {
                //set up RunReport event overrides & create doc
                _ReportObject = new ReportObject();
                _ReportObject.CreateTemporaryFullName();

                if (!Directory.Exists(_logPath))
                {
                    Directory.CreateDirectory(_logPath);
                }
                reportFileName = _logPath + "\\" + _ReportObject.ReportTempFileFullName;
                PdfWriter writer = PdfWriter.GetInstance(_document, new FileStream(reportFileName, FileMode.Create));
                //writer.PageEvent = this;

                //set up tables, etc...
                int       columns = 6;
                PdfPTable table   = new PdfPTable(columns);
                Image     gif     = Image.GetInstance(Common.Properties.Resources.logo, BaseColor.WHITE);
                // Image gif = Image.GetInstance(PawnReportResources.calogo, BaseColor.WHITE);
                _reportFont          = FontFactory.GetFont("Arial", 8, iTextSharp.text.Font.NORMAL);
                _reportFontLargeBold = FontFactory.GetFont("Arial", 12, iTextSharp.text.Font.BOLD);

                gif.ScalePercent(35);
                //gif.ScalePercent(75);

                _document.AddTitle(_reportTitle);

                _document.SetPageSize(PageSize.LETTER);
                _document.SetMargins(-50, -55, 10, 45);
                writer.PageEvent = this;
                _document.Open();   //Go ahead and open the document so tables can be added.

                //PrintReportHeader(table, gif, columns);
                PrintReportHeader(gif);
                PrintReportDetail();

                if (!_catcoTransferType.Equals("Appraisal", StringComparison.CurrentCultureIgnoreCase) && !_catcoTransferType.Equals("Wholesale", StringComparison.CurrentCultureIgnoreCase))
                {
                    PopulateMetalTypes();
                    AggregateData();
                    PrintTotalSummaryRow(table, writer);
                }
                table.HeaderRows = 3;

                _document.Add(table);
                _document.Close();
                //OpenFile(reportFileName);
                //CreateReport();
                isSuccessful = true;
            }
            catch (DocumentException de)
            {
                _ReportObject.ReportError      = de.Message;
                _ReportObject.ReportErrorLevel = (int)LogLevel.ERROR;
            }
            catch (IOException ioe)
            {
                _ReportObject.ReportError      = ioe.Message;
                _ReportObject.ReportErrorLevel = (int)LogLevel.ERROR;
            }


            return(isSuccessful);
        }
Esempio n. 5
0
        public bool CreateReport()
        {
            bool isSuccessful = false;

            //_document = new iTextSharp.text.Document(PageSize.HALFLETTER.Rotate());
            _document = new iTextSharp.text.Document(PageSize.LETTER);

            try
            {
                //set up RunReport event overrides & create doc
                _ReportObject = new ReportObject();
                _ReportObject.CreateTemporaryFullName();

                if (!Directory.Exists(_logPath))
                {
                    Directory.CreateDirectory(_logPath);
                }

                reportFileName = string.Format("{0}\\{1}", _logPath, _ReportObject.ReportTempFileFullName);

                PdfWriter writer = PdfWriter.GetInstance(_document, new FileStream(reportFileName, FileMode.Create));
                writer.PageEvent = this;

                //set up tables, etc...
                int       columns = 6;
                PdfPTable table   = new PdfPTable(columns);
                Image     gif     = Image.GetInstance(Resources.logo, BaseColor.WHITE);
                //Image gif = Image.GetInstance(PawnReportResources.calogo, BaseColor.WHITE);

                _reportFont          = FontFactory.GetFont(ARIAL, 8, iTextSharp.text.Font.NORMAL);
                _reportFontLargeBold = FontFactory.GetFont(ARIAL, 12, iTextSharp.text.Font.BOLD);

                gif.ScalePercent(35);
                //gif.ScalePercent(75);

                _document.AddTitle("Transfer Out Report");

                //_document.SetPageSize(PageSize.HALFLETTER.Rotate());
                _document.SetMargins(-50, -55, 10, 45);
                _document.Open();   //Go ahead and open the document so tables can be added.
                var _reportTitle = string.Format("Transfer Out {0} Summary", _type);
                if ((_SHOP_NO).Equals(_type) || (_GUN_ROOM).Equals(_type))
                {
                    if ((_SHOP_NO).Equals(_type))
                    {
                        _reportTitle = String.Format("Transfer Out {0} to Shop Summary", "Shop");
                    }
                    PrintShopReportHeader(gif, _reportTitle);
                }
                else
                {
                    PrintReportHeader(table, gif, columns);
                }
                PrintReportDetail();

                table.HeaderRows = 3;

                _document.Add(table);
                addTotalCostRow();
                //_document.SetPageSize(PageSize.HALFLETTER.Rotate());
                _document.Close();

                //OpenFile(reportFileName);
                //CreateReport();
                isSuccessful = true;
            }
            catch (DocumentException de)
            {
                _ReportObject.ReportError      = de.Message;
                _ReportObject.ReportErrorLevel = (int)LogLevel.ERROR;
            }
            catch (IOException ioe)
            {
                _ReportObject.ReportError      = ioe.Message;
                _ReportObject.ReportErrorLevel = (int)LogLevel.ERROR;
            }

            return(isSuccessful);
        }