private void PrintAndStoreReport(int ticketNumber, string reportName, bool store, int numCopies)
        {
            var cds = GlobalDataAccessor.Instance.DesktopSession;
            var dA  = GlobalDataAccessor.Instance.OracleDA;
            var cC  = GlobalDataAccessor.Instance.CouchDBConnector;

            if (SecurityAccessor.Instance.EncryptConfig.ClientConfig.ClientConfiguration.PrintEnabled &&
                cds.LaserPrinter.IsValid)
            {
                if (FileLogger.Instance.IsLogInfo)
                {
                    FileLogger.Instance.logMessage(LogLevel.INFO, "CreateReportObject", "Printing {0} on printer {1}", reportName,
                                                   cds.LaserPrinter);
                }
                string errMsg =
                    PrintingUtilities.printDocument(
                        reportObject.ReportTempFileFullName,
                        cds.LaserPrinter.IPAddress,
                        cds.LaserPrinter.Port, numCopies);
                if (errMsg.IndexOf("SUCCESS", StringComparison.OrdinalIgnoreCase) == -1)
                {
                    if (FileLogger.Instance.IsLogError)
                    {
                        FileLogger.Instance.logMessage(LogLevel.ERROR, this, "Cannot print {0} on {1}", reportName, cds.LaserPrinter);
                    }
                }
            }

            if (store)
            {
                var pDoc = new CouchDbUtils.PawnDocInfo();

                //Set document add calls
                pDoc.UseCurrentShopDateTime = true;
                pDoc.StoreNumber            = GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber;
                pDoc.CustomerNumber         = GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.CustomerNumber;
                pDoc.DocumentType           = Document.DocTypeNames.PDF;
                pDoc.DocFileName            = reportObject.ReportTempFileFullName;
                pDoc.TicketNumber           = ticketNumber;
                long   recNumL = 0L;
                string errText;
                if (!CouchDbUtils.AddPawnDocument(dA, cC, cds.UserName, ref pDoc, out errText))
                {
                    if (FileLogger.Instance.IsLogError)
                    {
                        FileLogger.Instance.logMessage(LogLevel.ERROR, this,
                                                       "Could not store Layaway Contract in document storage: {0} - FileName: {1}", errText, reportObject.ReportTempFileFullName);
                    }
                    BasicExceptionHandler.Instance.AddException(
                        "Could not store Layaway Contract in document storage",
                        new ApplicationException("Could not store receipt in document storage: " + errText));
                }
            }
        }
        private bool IsDocumentDSTR(string id, out Document doc)
        {
            var rt = false;

            doc = null;
            if (!string.IsNullOrEmpty(id))
            {
                //Fetch document meta-data
                string errMsg;
                if (CouchDbUtils.GetDocument(id, this.couchConnector, out doc, out errMsg, true))
                {
                    if (doc != null && !string.IsNullOrEmpty(doc.FileName) &&
                        doc.FileName.IndexOf("dstr", StringComparison.OrdinalIgnoreCase) > -1)
                    {
                        rt = true;
                    }
                }
            }

            return(rt);
        }
        private void printButton_Click(object sender, EventArgs e)
        {
            int printOption = -1;
            int startPage   = -1;
            int endPage     = -1;

            if (radioButton1.Checked)
            {
                printOption = 1;
            }
            else if (radioButton2.Checked)
            {
                printOption = 2;
            }
            else if (radioButton3.Checked)
            {
                if (!validate())
                {
                    MessageBox.Show(message, "Errors", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    return;
                }
                startPage   = Int32.Parse(startPageTextBox.Text);
                endPage     = Int32.Parse(endPageTextBox.Text);
                printOption = 3;
            }
            else if (radioButton4.Checked)
            {
                printOption = 4;
            }
            else if (radioButton5.Checked)
            {
                printOption = 5;
            }
            else if (radioButton6.Checked)
            {
                printOption = 6;
            }

            DataTable data              = null;
            var       errorCode         = string.Empty;
            var       errorMessage      = string.Empty;
            String    reportTitle       = "Gun Book";
            var       reportType        = string.Empty;
            bool      reprintGunRecords = false;
            String    userName          = GlobalDataAccessor.Instance.DesktopSession.UserName;
            string    storeNumber       = GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber;

            switch (printOption)
            {
            case 1:
                GunBookUtilities.getGunbookRecords(NEW, -1, -1, "", storeNumber, userName, out data, out errorCode, out errorMessage);
                break;

            case 2:
                GunBookUtilities.getGunbookRecords(REPRINT, -1, -1, "", storeNumber, userName, out data, out errorCode, out errorMessage);
                //reprintGunRecords = true;
                break;

            case 3:
                GunBookUtilities.getGunbookRecords("", startPage, endPage, "", storeNumber, userName, out data, out errorCode, out errorMessage);
                break;

            case 4:
                GunBookUtilities.getGunbookRecords("", -1, -1, ALL, storeNumber, userName, out data, out errorCode, out errorMessage);
                break;

            case 5:
                reportTitle = "Report of All Open Gun Records as of " + ShopDateTime.Instance.ShopDateCurTime;
                GunBookUtilities.getGunbookRecords("", -1, -1, OPEN, storeNumber, userName, out data, out errorCode, out errorMessage);
                reportType = "Open";
                break;

            case 6:
                reportTitle = "Report of All Closed Gun Records as of " + ShopDateTime.Instance.ShopDateCurTime;
                GunBookUtilities.getGunbookRecords("", -1, -1, CLOSE, storeNumber, userName, out data, out errorCode, out errorMessage);
                reportType = "Closed";
                break;

            default:
                MessageBox.Show("Please select one option", "Message", MessageBoxButtons.OK);
                return;
            }
            if (data == null || data.Rows.Count == 0)
            {
                if (printOption == 3)
                {
                    MessageBox.Show("The page range indicated does not exist.");
                }
                else
                {
                    MessageBox.Show("There are no new or updated records since the last print date");
                }
            }
            else
            {
                Cursor = Cursors.WaitCursor;
                //PrintGunBook myForm = new PrintGunBook(data, reportTitle);
                //myForm.ShowDialog();
                GunBookUtility gunBookPrinting = new GunBookUtility(PdfLauncher.Instance);

                ReportObject rptObj = new ReportObject();
                rptObj.ReportTitle            = reportTitle;
                rptObj.ReportTempFileFullName = string.Format("{0}\\GunBook{1}.pdf", SecurityAccessor.Instance.EncryptConfig.ClientConfig.GlobalConfiguration.BaseLogPath, DateTime.Now.ToString("MMddyyyyhhmmssFFFFFFF"));
                rptObj.ReportStore            = GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber;
                rptObj.ReportStoreDesc        = GlobalDataAccessor.Instance.CurrentSiteId.StoreName;
                rptObj.ReportError            = string.Empty;
                rptObj.ReportErrorLevel       = 0;
                rptObj.ReportParms.Add(reportType);
                gunBookPrinting.GunBookData = data;
                gunBookPrinting.RptObject   = rptObj;
                if (gunBookPrinting.Print())
                {
                    //Print the Gun Book
                    if (SecurityAccessor.Instance.EncryptConfig.ClientConfig.ClientConfiguration.PrintEnabled)
                    {
                        string strReturnMessage;
                        if (GlobalDataAccessor.Instance.DesktopSession.PDALaserPrinter.IsValid)
                        {
                            if (FileLogger.Instance.IsLogInfo)
                            {
                                FileLogger.Instance.logMessage(LogLevel.INFO, this, "Printing gunbook report on PDA Laser printer: {0}",
                                                               GlobalDataAccessor.Instance.DesktopSession.PDALaserPrinter);
                            }
                            strReturnMessage = PrintingUtilities.printDocument(
                                rptObj.ReportTempFileFullName,
                                GlobalDataAccessor.Instance.DesktopSession.PDALaserPrinter.IPAddress,
                                GlobalDataAccessor.Instance.DesktopSession.PDALaserPrinter.Port,
                                1);
                        }
                        else if (GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IsValid)
                        {
                            if (FileLogger.Instance.IsLogWarn)
                            {
                                FileLogger.Instance.logMessage(LogLevel.WARN, this,
                                                               "Could not find valid PDA laser printer to print the gunbook report." + Environment.NewLine +
                                                               " Printing on default pawn laser printer: {0}",
                                                               GlobalDataAccessor.Instance.DesktopSession.LaserPrinter);
                            }
                            strReturnMessage = PrintingUtilities.printDocument(
                                rptObj.ReportTempFileFullName,
                                GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IPAddress,
                                GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.Port,
                                1);
                        }
                        else
                        {
                            if (FileLogger.Instance.IsLogError)
                            {
                                FileLogger.Instance.logMessage(LogLevel.ERROR, this,
                                                               "Could not find a valid laser printer to print the gunbook report");
                            }
                            strReturnMessage = "FAIL - NO PRINTER FOUND";
                        }
                        if (strReturnMessage.IndexOf("SUCCESS", StringComparison.OrdinalIgnoreCase) == -1)
                        {
                            if (FileLogger.Instance.IsLogError)
                            {
                                FileLogger.Instance.logMessage(LogLevel.ERROR, this,
                                                               "Cannot print Gun Book utility report: " + strReturnMessage);
                            }
                        }
                        //Store Gun Book report
                        var cds = GlobalDataAccessor.Instance.DesktopSession;
                        if (cds != null)
                        {
                            var pDoc = new CouchDbUtils.PawnDocInfo
                            {
                                UseCurrentShopDateTime = true,
                                StoreNumber            = cds.CurrentSiteId.StoreNumber,
                                DocumentType           = Document.DocTypeNames.PDF,
                                DocFileName            = rptObj.ReportTempFileFullName
                            };

                            //Set document add calls

                            //Add this document to the pawn document registry and document storage
                            string errText;
                            if (!CouchDbUtils.AddPawnDocument(GlobalDataAccessor.Instance.OracleDA, GlobalDataAccessor.Instance.CouchDBConnector,
                                                              cds.UserName, ref pDoc, out errText))
                            {
                                FileLogger.Instance.logMessage(LogLevel.ERROR, this, "Cannot store Gun Book utility report!");
                            }
                        }

                        // File.Delete(rptObj.ReportTempFileFullName);
                        MessageBox.Show(@"Gun Book Utility Printing Complete");
                    }
                }
                else
                {
                    MessageBox.Show(@"Failed to generate gun book document");
                }
            }
            Cursor = Cursors.Default;
        }
        private void printAuthorizationToReleaseFingerprints(ReleaseFingerprintsInfo releaseFingerprintsInfo, CustomerVO currentCustomer, int seizeNumber)
        {
            //Call print Police seize form if print is enabled
            if (SecurityAccessor.Instance.EncryptConfig.ClientConfig.ClientConfiguration.PrintEnabled)
            {
                var address = currentCustomer.getHomeAddress();

                var releaseFingerprintsContext = new Reports.AuthorizationToReleaseFingerprints.
                                                 ReleaseFingerprintsContext()
                {
                    EmployeeNumber =
                        GlobalDataAccessor.Instance.DesktopSession.
                        UserName,
                    ShopName =
                        GlobalDataAccessor.Instance.CurrentSiteId.
                        StoreName,
                    ShopAddress =
                        GlobalDataAccessor.Instance.CurrentSiteId.
                        StoreAddress1 + " " +
                        GlobalDataAccessor.Instance.CurrentSiteId.
                        StoreAddress2,
                    ShopCity =
                        GlobalDataAccessor.Instance.CurrentSiteId.
                        StoreCityName,
                    ShopState =
                        GlobalDataAccessor.Instance.CurrentSiteId.State,
                    ShopZipCode =
                        GlobalDataAccessor.Instance.CurrentSiteId.
                        StoreZipCode,
                    CustomerName        = currentCustomer.CustomerName,
                    CustomerAddress1    = address.Address1,
                    CustomerAddress2    = address.Address2,
                    CustomerCity        = address.City,
                    CustomerState       = address.State_Code,
                    CustomerAddressUnit = address.UnitNum,
                    CustomerZipCode     = address.ZipCode,
                    TicketNumber        = releaseFingerprintsInfo.RefNumber,
                    Agency         = releaseFingerprintsInfo.Agency,
                    CaseNumber     = releaseFingerprintsInfo.CaseNumber,
                    SubpoenaNumber =
                        releaseFingerprintsInfo.SubpoenaNumber,
                    OfficerName =
                        releaseFingerprintsInfo.OfficerFirstName + " " +
                        releaseFingerprintsInfo.OfficerLastName,
                    BadgeNumber     = releaseFingerprintsInfo.BadgeNumber,
                    TransactionDate = releaseFingerprintsInfo.TransactionDate,
                    OutputPath      =
                        SecurityAccessor.Instance.EncryptConfig.
                        ClientConfig.GlobalConfiguration.
                        BaseLogPath +
                        "\\AuthorizationToReleaseFingerprints_" +
                        DateTime.Now.ToString("MMddyyyyhhmmssFFFFFFF") +
                        ".pdf"
                };

                var authorizationToReleaseFingerprints = new AuthorizationToReleaseFingerprints(
                    seizeNumber, GlobalDataAccessor.Instance.DesktopSession.TicketTypeLookedUp,
                    releaseFingerprintsContext, null);

                authorizationToReleaseFingerprints.Print();

                string strReturnMessage =
                    PrintingUtilities.printDocument(
                        releaseFingerprintsContext.OutputPath,
                        GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IPAddress,
                        GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.Port, 2);
                if (!strReturnMessage.Contains("SUCCESS"))
                {
                    FileLogger.Instance.logMessage(LogLevel.ERROR, this,
                                                   "Authorization to release fingerprints : " +
                                                   strReturnMessage);
                }

                //---------------------------------------------------
                // Place document into couch
                var filePath = releaseFingerprintsContext.OutputPath;
                //authorizationToReleaseFingerprints.Save(policeCardFilePath);

                var pDoc = new CouchDbUtils.PawnDocInfo();
                var dA   = GlobalDataAccessor.Instance.OracleDA;
                var cC   = GlobalDataAccessor.Instance.CouchDBConnector;
                //Set document add calls
                pDoc.UseCurrentShopDateTime = true;
                pDoc.SetDocumentSearchType(CouchDbUtils.DocSearchType.POLICE_CARD);
                pDoc.StoreNumber    = GlobalDataAccessor.Instance.DesktopSession.CurrentSiteId.StoreNumber;
                pDoc.CustomerNumber = GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.CustomerNumber;
                pDoc.TicketNumber   = seizeNumber;
                pDoc.DocumentType   = Common.Libraries.Objects.Doc.Document.DocTypeNames.PDF;
                pDoc.DocFileName    = filePath;
                //Add this document to the pawn document registry and document storage
                string errText;
                if (!CouchDbUtils.AddPawnDocument(dA, cC, GlobalDataAccessor.Instance.DesktopSession.UserName, ref pDoc, out errText))
                {
                    if (FileLogger.Instance.IsLogError)
                    {
                        FileLogger.Instance.logMessage(LogLevel.ERROR, this,
                                                       "Could not store release authorization to release fingerprints document in document storage: {0} - FileName: {1}", errText, filePath);
                    }

                    BasicExceptionHandler.Instance.AddException(
                        "Could not store police card document in document storage",
                        new ApplicationException("Could not store authorization to release fingerprints document in document storage: " + errText));
                }
            }
        }
Example #5
0
        private void History_dg_CellContentClick(object sender, DataGridViewCellEventArgs e)
        {
            if (e.ColumnIndex != 1)
            {
                return;
            }

            int ticketNumber = Convert.ToInt32(History_dg.Rows[e.RowIndex].Cells[0].Value.ToString());
            List <CouchDbUtils.PawnDocInfo> pawnDocs;
            string errString = String.Empty;

            //If a legit ticket number was pulled, then continue.
            if (ticketNumber <= 0)
            {
                return;
            }

            //Instantiate docinfo which will return info we need to be able to
            //call reprint ticket.
            var docInfo = new CouchDbUtils.PawnDocInfo();

            docInfo.SetDocumentSearchType(CouchDbUtils.DocSearchType.RECEIPT);
            docInfo.StoreNumber  = GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber;
            docInfo.TicketNumber = ticketNumber;
            int receiptNumber = 0;

            if (!string.IsNullOrEmpty(History_dg.Rows[e.RowIndex].Cells[1].Value.ToString()))
            {
                receiptNumber = Convert.ToInt32(History_dg.Rows[e.RowIndex].Cells[1].Value.ToString());
            }
            docInfo.ReceiptNumber = receiptNumber;

            //Use couch DB to get the document.
            if (!CouchDbUtils.GetPawnDocument(GlobalDataAccessor.Instance.OracleDA, GlobalDataAccessor.Instance.CouchDBConnector,
                                              docInfo, false, out pawnDocs, out errString))
            {
                return;
            }

            if (pawnDocs == null)
            {
                return;
            }

            //Find that there is a document with a receipt.
            var results = from p in pawnDocs
                          where p.DocumentType ==
                          Document.DocTypeNames.RECEIPT
                          select p;

            if (results.Any())
            {
                //Get the only one receipt that should exist.
                docInfo = results.First();

                //Call the reprint screen
                ViewPrintDocument docViewPrint = new ViewPrintDocument("Receipt# ", docInfo.ReceiptNumber.ToString(), docInfo.StorageId, docInfo.DocumentType, docInfo);
                this.TopMost = false; // "this" is modal, must not be on top to display dialog
                docViewPrint.ShowDialog();
                this.TopMost = true;
            }
        }
Example #6
0
        public void PrintAndStoreReport(AuditReportsObject ro, string report)
        {
            OracleDataAccessor    dA = GlobalDataAccessor.Instance.OracleDA;
            SecuredCouchConnector cC = GlobalDataAccessor.Instance.CouchDBConnector;

            try
            {
                if (SecurityAccessor.Instance.EncryptConfig.ClientConfig.ClientConfiguration.PrintEnabled &&
                    ADS.LaserPrinter.IsValid)
                {
                    if (FileLogger.Instance.IsLogInfo)
                    {
                        FileLogger.Instance.logMessage(LogLevel.INFO, "CallAuditReport", "Printing " + report + " on printer {0}",
                                                       ADS.LaserPrinter);
                    }

                    string errMsg = PrintingUtilities.printDocument(
                        ro.ReportTempFileFullName,
                        ADS.LaserPrinter.IPAddress,
                        ADS.LaserPrinter.Port, 1);

                    if (errMsg.IndexOf("SUCCESS", StringComparison.OrdinalIgnoreCase) == -1)
                    {
                        if (FileLogger.Instance.IsLogError)
                        {
                            FileLogger.Instance.logMessage(LogLevel.ERROR, this, "Cannot print " + report + " on {0}", ADS.LaserPrinter);
                        }
                    }
                }

                var pDoc = new CouchDbUtils.PawnDocInfo();

                //Set document add calls
                pDoc.UseCurrentShopDateTime = true;
                pDoc.StoreNumber            = ADS.ActiveAudit.StoreNumber;
                pDoc.CustomerNumber         = "0";
                pDoc.DocumentType           = Document.DocTypeNames.PDF;
                pDoc.DocFileName            = ro.ReportTempFileFullName;
                pDoc.TicketNumber           = ADS.ActiveAudit.AuditId;
                pDoc.AuxInfo = report;
                //pDoc.DocumentSearchType = CouchDbUtils.DocSearchType.STORE_TICKET;
                //pDoc.TicketNumber = layaway.TicketNumber;
                long recNumL = 0L;
                //if (long.TryParse(receiptDetailsVO.ReceiptNumber, out recNumL))
                // {
                //     pDoc.ReceiptNumber = recNumL;
                // }

                //Add this document to the pawn document registry and document storage
                string errText;
                if (!CouchDbUtils.AddPawnDocument(dA, cC, ADS.UserName, ref pDoc, out errText))
                {
                    if (FileLogger.Instance.IsLogError)
                    {
                        FileLogger.Instance.logMessage(LogLevel.ERROR, this,
                                                       "Could not store " + report + " in document storage: {0} - FileName: {1}", errText, ro.ReportTempFileFullName);
                    }
                    BasicExceptionHandler.Instance.AddException(
                        "Could not store " + report + " in document storage",
                        new ApplicationException("Could not store " + report + " in document storage: " + errText));
                }
            }
            catch (Exception ex)
            {
            }
        }
        private void printDocButton_Click(object sender, EventArgs e)
        {
            if (productTypeList1.ComboBox.SelectedValue != null)
            {
                if (productTypeList1.ComboBox.SelectedValue.ToString() == DocumentHelper.REPRINT_TAGS)
                {
                    this.Hide();
                    var reprintTag = new ReprintTag();
                    reprintTag.ShowDialog(this);
                    this.Close();
                    return;
                }
            }
            if (_isLookup)
            {
                if (!SetStorageIDFromLookup())
                {
                    return;
                }
            }

            //TODO: Finalize printing
            this.printDocButton.Enabled = false;

            //Get the accessors
            var cC = GlobalDataAccessor.Instance.CouchDBConnector;

            //Retrieve the document data
            var pLoadMesg = new ProcessingMessage("* Printing Document *");

            //Connect to couch and retrieve document
            Document doc;
            string   errText;

            if (!CouchDbUtils.GetDocument(
                    this.StorageId,
                    cC, out doc, out errText))
            {
                pLoadMesg.Close();
                pLoadMesg.Dispose();
                this.ShowErrorMessage("print", errText);
                this.Close();
            }
            else if (doc != null)
            {
                this.DocumentType = doc.TypeName;

                //Fetch data
                byte[] fileData;
                if (!doc.GetSourceData(out fileData))
                {
                    pLoadMesg.Close();
                    pLoadMesg.Dispose();
                    this.ShowErrorMessage("print", "Cannot retrieve file data to print file");
                    this.Close();
                    return;
                }

                //Send byte stream to printer based on type
                var printSuccess = false;
                switch (this.DocumentType)
                {
                case Document.DocTypeNames.PDF:
                    //If we do not have the laser printer info, get out
                    if (!hasLaserInfo)
                    {
                        pLoadMesg.Close();
                        pLoadMesg.Dispose();
                        this.ShowErrorMessage("print", "Cannot determine laser printer IP/Port");
                        this.Close();
                        return;
                    }
                    //Send raw pdf data to printer
                    var resStrPdf = GenerateDocumentsPrinter.printDocument(fileData, laserIp, laserPort, 1);
                    if (!string.IsNullOrEmpty(resStrPdf) && resStrPdf.Contains("SUCCESS"))
                    {
                        printSuccess = true;
                    }
                    break;

                case Document.DocTypeNames.RECEIPT:
                    //If we do not have the receipt printer info, get out
                    if (!hasReceiptInfo)
                    {
                        pLoadMesg.Close();
                        pLoadMesg.Dispose();
                        this.ShowErrorMessage("print", "Cannot determine receipt printer IP/Port");
                        this.Close();
                        return;
                    }
                    //Send raw receipt data to receipt printer
                    var resStrRec = GenerateDocumentsPrinter.printDocument(fileData,
                                                                           receiptIp,
                                                                           receiptPort,
                                                                           1);
                    if (!string.IsNullOrEmpty(resStrRec) && resStrRec.Contains("SUCCESS"))
                    {
                        printSuccess = true;
                    }
                    break;

                case Document.DocTypeNames.BARCODE:
                    MessageBox.Show("Nothing to print");
                    //Nothing for now - should go to Intermec printer
                    break;

                case Document.DocTypeNames.TEXT:
                    //If we do not have the laser printer info, get out
                    if (!hasLaserInfo && !hasIndianaPoliceCardPrinterInfo)
                    {
                        pLoadMesg.Close();
                        pLoadMesg.Dispose();
                        this.ShowErrorMessage("print", "Cannot determine printer IP/Port");
                        this.Close();
                        return;
                    }

                    //Send raw text data to laser printer
                    var resStrTxt = GenerateDocumentsPrinter.printDocument(
                        fileData,
                        hasIndianaPoliceCardPrinterInfo ? indianaPoliceCardPrinterIp : laserIp,
                        hasIndianaPoliceCardPrinterInfo ? indianaPoliceCardPrinterPort : laserPort,
                        1);

                    if (!string.IsNullOrEmpty(resStrTxt) && resStrTxt.Contains("SUCCESS"))
                    {
                        printSuccess = true;
                    }
                    break;

                case Document.DocTypeNames.BINARY:
                    MessageBox.Show("Nothing to print");
                    //Nothing for now)
                    //Nothing for now
                    break;

                case Document.DocTypeNames.INVALID:
                    MessageBox.Show("Nothing to print");
                    //Nothing for now)
                    //Nothing for now
                    break;
                }

                pLoadMesg.Close();
                pLoadMesg.Dispose();
                if (!printSuccess)
                {
                    this.ShowErrorMessage("print", "Reprint operation failed");
                }
                else
                {
                    MessageBox.Show("Document has successfully reprinted",
                                    "Pawn Application Message");
                }
            }

            //Re-enable print button
            this.printDocButton.Enabled = true;
        }
Example #8
0
        private void viewDocButton_Click(object sender, EventArgs e)
        {
            //Ensure that the button is not clicked twice
            this.viewDocButton.Enabled = false;

            //Get the accessors
            var cds = GlobalDataAccessor.Instance.DesktopSession;
            var cC  = GlobalDataAccessor.Instance.CouchDBConnector;

            //Retrieve the document data
            var pLoadMesg = new ProcessingMessage("* Loading Document *");

            //Connect to couch and retrieve document
            Document doc;
            string   errText;

            if (!CouchDbUtils.GetDocument(
                    this.StorageId,
                    cC, out doc, out errText))
            {
                pLoadMesg.Close();
                pLoadMesg.Dispose();
                this.showErrorMessage("view", errText);
                this.Close();
            }
            else if (doc != null)
            {
                pLoadMesg.Message = "* Document Loaded...Displaying *";
                //Fetch data
                string tmpFileName;
                byte[] fileData;
                if (!doc.GetSourceData(out fileData))
                {
                    this.showErrorMessage("view", "Cannot retrieve file data to show file");
                    pLoadMesg.Close();
                    pLoadMesg.Dispose();
                    this.Close();
                    return;
                }

                //Create temporary file
                if (!this.createTempFile(fileData, out tmpFileName))
                {
                    this.showErrorMessage("view", "Cannot generate file data to show file");
                    pLoadMesg.Close();
                    pLoadMesg.Dispose();
                    this.Close();
                    return;
                }
                pLoadMesg.Close();
                pLoadMesg.Dispose();
                switch (this.DocumentType)
                {
                case Document.DocTypeNames.PDF:
                    DesktopSession.ShowPDFFile(tmpFileName, true);
                    break;

                case Document.DocTypeNames.RECEIPT:
                    //GJL - do nothing for now until complete receipt renderer
                    ReceiptRenderer receiptR = new ReceiptRenderer(fileData);
                    //Desktop.PrintQueue.ReceiptRenderer receiptR = new Desktop.PrintQueue.ReceiptRenderer(fileData);
                    //receiptDataRetrieved = receiptR.ExecuteServicePawnLoanForReceiptRenderer(this.DocInfo);

                    //receiptR.RichTextBoxContent = bbyteArrayString;
                    receiptR.ShowDialog();
                    //MessageBox.Show("Show receipt renderer");
                    //Invoke View receipt rendering form
                    break;

                case Document.DocTypeNames.BARCODE:
                    MessageBox.Show("Nothing to show");
                    //Nothing for now)
                    break;

                case Document.DocTypeNames.TEXT:
                    MessageBox.Show("Nothing to show");
                    //Nothing for now)
                    //Notepad??
                    break;

                case Document.DocTypeNames.BINARY:
                    MessageBox.Show("Nothing to show");
                    //Nothing for now)
                    //Nothing for now
                    break;

                case Document.DocTypeNames.INVALID:
                    MessageBox.Show("Nothing to show");
                    //Nothing for now)
                    //Nothing for now
                    break;
                }

                //Delete temporary file
                try
                {
                    File.Delete(tmpFileName);
                }
                catch (Exception eX)
                {
                    if (FileLogger.Instance.IsLogError)
                    {
                        FileLogger.Instance.logMessage(LogLevel.ERROR, this, "Could not delete file: {0}  Exception: {1}", tmpFileName, eX);
                    }
                }
            }

            //Re-enable show button
            this.viewDocButton.Enabled = true;
        }
        private void LoadDocs()
        {
            List <CouchDbUtils.PawnDocInfo> pawnDocs;
            string errString = "";

            //If a legit ticket number was pulled, then continue.
            if (ADS.ActiveAudit.AuditId > 0)
            {
                //Instantiate docinfo which will return info we need to be able to
                //call reprint ticket.
                CouchDbUtils.PawnDocInfo docInfo = new CouchDbUtils.PawnDocInfo();
                docInfo.SetDocumentSearchType(CouchDbUtils.DocSearchType.STORE_TICKET);
                docInfo.StoreNumber  = ADS.ActiveAudit.StoreNumber; // CashlinxDesktopSession.Instance.CurrentSiteId.StoreNumber;
                docInfo.TicketNumber = ADS.ActiveAudit.AuditId;
                //Use couch DB to get the document.
                if (CouchDbUtils.GetPawnDocument(GlobalDataAccessor.Instance.OracleDA, GlobalDataAccessor.Instance.CouchDBConnector,
                                                 docInfo, false, out pawnDocs, out errString))
                {
                    if (pawnDocs != null)
                    {
                        int columnCount = 0;
                        int rowCount    = 0;
                        int docCount    = 0;
                        int panelHeight = 0;
                        documentsPanel.Controls.Clear();

                        foreach (CouchDbUtils.PawnDocInfo document in pawnDocs)
                        {
                            docCount++;
                            if (columnCount == 3)
                            {
                                rowCount    = rowCount + 2;
                                columnCount = 0;
                                //documentsPanel.Height = documentsPanel.Height + panelHeight;
                            }
                            Label fileLabel = new Label();
                            fileLabel.Font = new Font(lblAuditScope.Font, FontStyle.Regular);
                            fileLabel.Dock = System.Windows.Forms.DockStyle.Fill;
                            PictureBox pic = new PictureBox();
                            pic.BackgroundImageLayout = ImageLayout.None;
                            //Label fileLabel = new Label();
                            //fileLabel.Font = new Font(PS_OriginationDateLabel.Font, FontStyle.Bold);
                            pic.Click += pic_Click;
                            pic.Cursor = Cursors.Hand;
                            pic.Tag    = document.DocumentType.ToString();
                            pic.Name   = document.StorageId;

                            fileLabel.Text = docCount + "." + document.AuxInfo;

                            string tagText = "";
                            if (document.DocumentType ==
                                Document.DocTypeNames.PDF)
                            {
                                pic.BackgroundImage = Properties.Resources.pdf_icon;
                            }
                            documentsPanel.Controls.Add(pic, columnCount, rowCount);
                            int incrow = rowCount + 1;
                            documentsPanel.Controls.Add(fileLabel, columnCount, incrow);
                            columnCount++;
                            //if(panelHeight == 0)
                            //panelHeight = documentsPanel.Height;
                        }
                    }
                }
            }
        }
        void pic_Click(object sender, EventArgs e)
        {
            if (ADS.ActiveAudit.AuditId > 0)
            {
                //Instantiate docinfo which will return info we need to be able to
                //call reprint ticket.
                CouchDbUtils.PawnDocInfo docInfo = new CouchDbUtils.PawnDocInfo();
                docInfo.DocumentType = Document.DocTypeNames.PDF;

                /*docInfo.SetDocumentSearchType(CouchDbUtils.DocSearchType.STORAGE);
                 * docInfo.StoreNumber = ADS.ActiveAudit.StoreNumber;
                 * docInfo.TicketNumber = ADS.ActiveAudit.AuditId;
                 * int receiptNumber = 0;*/

                string storageID = ((PictureBox)sender).Name.ToString();

                if (!string.IsNullOrEmpty(storageID))
                {
                    //Get the accessors
                    SecuredCouchConnector cC = GlobalDataAccessor.Instance.CouchDBConnector;

                    //Retrieve the document data
                    var pLoadMesg = new ProcessingMessage("* Loading Document *");

                    //Connect to couch and retrieve document
                    Document doc;
                    string   errText;
                    if (!CouchDbUtils.GetDocument(
                            storageID,
                            cC, out doc, out errText))
                    {
                        pLoadMesg.Close();
                        pLoadMesg.Dispose();
                        this.showErrorMessage("view", errText, storageID);
                        this.Close();
                    }
                    else if (doc != null)
                    {
                        pLoadMesg.Message = "* Document Loaded...Displaying *";
                        //Fetch data
                        string tmpFileName;
                        byte[] fileData;
                        if (!doc.GetSourceData(out fileData))
                        {
                            this.showErrorMessage("view", "Cannot retrieve file data to show file", storageID);
                            pLoadMesg.Close();
                            pLoadMesg.Dispose();
                            this.Close();
                            return;
                        }

                        //Create temporary file
                        if (!this.createTempFile(fileData, out tmpFileName))
                        {
                            this.showErrorMessage("view", "Cannot generate file data to show file", storageID);
                            pLoadMesg.Close();
                            pLoadMesg.Dispose();
                            this.Close();
                            return;
                        }
                        pLoadMesg.Close();
                        pLoadMesg.Dispose();
                        switch (docInfo.DocumentType)
                        {
                        case Document.DocTypeNames.PDF:
                            AuditDesktopSession.ShowPDFFile(tmpFileName, true);
                            break;
                        }
                    }
                }
            }
        }
        private void PrintAndStoreReport(LayawayVO layaway)
        {
            var cds = GlobalDataAccessor.Instance.DesktopSession;
            var dA  = GlobalDataAccessor.Instance.OracleDA;
            var cC  = GlobalDataAccessor.Instance.CouchDBConnector;

            if (SecurityAccessor.Instance.EncryptConfig.ClientConfig.ClientConfiguration.PrintEnabled &&
                GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IsValid)
            {
                if (FileLogger.Instance.IsLogInfo)
                {
                    FileLogger.Instance.logMessage(LogLevel.INFO, "LayawayCreateReportObject", "Printing layaway contract on printer {0}",
                                                   GlobalDataAccessor.Instance.DesktopSession.LaserPrinter);
                }

                string errMsg = PrintingUtilities.printDocument(
                    reportObject.ReportTempFileFullName,
                    GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.IPAddress,
                    GlobalDataAccessor.Instance.DesktopSession.LaserPrinter.Port, 1);

                if (errMsg.IndexOf("SUCCESS", StringComparison.OrdinalIgnoreCase) == -1)
                {
                    if (FileLogger.Instance.IsLogError)
                    {
                        FileLogger.Instance.logMessage(LogLevel.ERROR, this, "Cannot print Layaway Contract on {0}", GlobalDataAccessor.Instance.DesktopSession.LaserPrinter);
                    }
                }
            }

            var pDoc = new CouchDbUtils.PawnDocInfo();

            //Set document add calls
            pDoc.UseCurrentShopDateTime = true;
            pDoc.StoreNumber            = GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber;
            pDoc.CustomerNumber         = GlobalDataAccessor.Instance.DesktopSession.ActiveCustomer.CustomerNumber;
            pDoc.DocumentType           = Document.DocTypeNames.PDF;
            pDoc.DocFileName            = reportObject.ReportTempFileFullName;
            //pDoc.TicketNumber = cds.ActiveCustomer.c
            //pDoc.DocumentSearchType = CouchDbUtils.DocSearchType.STORE_TICKET;
            pDoc.TicketNumber = layaway.TicketNumber;
            long recNumL = 0L;
            //if (long.TryParse(receiptDetailsVO.ReceiptNumber, out recNumL))
            // {
            //     pDoc.ReceiptNumber = recNumL;
            // }

            //Add this document to the pawn document registry and document storage
            string errText;

            if (!CouchDbUtils.AddPawnDocument(dA, cC, cds.UserName, ref pDoc, out errText))
            {
                if (FileLogger.Instance.IsLogError)
                {
                    FileLogger.Instance.logMessage(LogLevel.ERROR, this,
                                                   "Could not store Layaway Contract in document storage: {0} - FileName: {1}", errText, reportObject.ReportTempFileFullName);
                }
                BasicExceptionHandler.Instance.AddException(
                    "Could not store Layaway Contract in document storage",
                    new ApplicationException("Could not store receipt in document storage: " + errText));
            }
        }