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)); } } }
public ViewPrintDocument( string docLabelName, string receiptNo, string docStorageId, Document.DocTypeNames dType, CouchDbUtils.PawnDocInfo docInfo) { InitializeComponent(); this.DocumentName = docLabelName + receiptNo; this.DocumentType = dType; this.StorageId = docStorageId; this.hasLaserInfo = false; this.hasReceiptInfo = false; this.laserIp = string.Empty; this.receiptIp = string.Empty; this.laserPort = 0; this.receiptPort = 0; this.DocInfo = docInfo; }
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)); } } }
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; } }
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) { } }
/// <summary> /// Sets the storage id from the lookup data. /// </summary> /// <returns>True upon success.</returns> private bool SetStorageIDFromLookup() { var productsList = (System.Windows.Forms.ComboBox)productTypeList1.Controls[0]; var ticketNumber = -1; if (productsList.SelectedIndex == 0 || !int.TryParse(txtTicketNumber.Text.Trim(), out ticketNumber)) { System.Windows.Forms.MessageBox.Show( "Please ensure you have selected a product and ticket number."); return(false); } var docInfo = new CouchDbUtils.PawnDocInfo(); string errString; docInfo.StoreNumber = GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber; if (productsList.SelectedValue.ToString() == DocumentHelper.RECIEPT) { docInfo.ReceiptNumber = ticketNumber; docInfo.SetDocumentSearchType(CouchDbUtils.DocSearchType.RECEIPT); } else if (productsList.SelectedValue.ToString() == DocumentHelper.POLICE_CARD) { docInfo.ReceiptNumber = ticketNumber; docInfo.TicketNumber = ticketNumber; docInfo.SetDocumentSearchType(CouchDbUtils.DocSearchType.POLICE_CARD); } else if (productsList.SelectedValue.ToString() == DocumentHelper.RELEASE_FINGERPRINTS) { docInfo.TicketNumber = ticketNumber; docInfo.SetDocumentSearchType(CouchDbUtils.DocSearchType.RELEASE_FINGERPRINTS); } else { docInfo.TicketNumber = ticketNumber; docInfo.SetDocumentSearchType(CouchDbUtils.DocSearchType.STORE_TICKET); } //Also set the meta tag here as well as search type. if (productsList.SelectedValue.Equals(DocumentHelper.CUSTOMER_BUY) || productsList.SelectedValue.Equals(DocumentHelper.PURCHASE_RETURN)) { if (GlobalDataAccessor.Instance.CurrentSiteId.State == States.Indiana) { docInfo.AuxInfo = PurchaseDocumentIndiana.PURCHASE_AUXINFOTAG; } else { docInfo.AuxInfo = PurchaseDocumentGenerator.PURCHASE_AUXINFOTAG; } } else if (productsList.SelectedValue.Equals(DocumentHelper.PAWN_LOAN)) { PawnLoan pawnLoan; PawnAppVO pApp; CustomerVO customerVO; string errorCode; string errorText; if (!CustomerLoans.GetPawnLoan(GlobalDataAccessor.Instance.DesktopSession, Utilities.GetIntegerValue(GlobalDataAccessor.Instance.CurrentSiteId.StoreNumber), ticketNumber, "0", StateStatus.BLNK, true, out pawnLoan, out pApp, out customerVO, out errorCode, out errorText)) { FileLogger.Instance.logMessage(LogLevel.ERROR, this, "Error trying to get loan data" + errorText); MessageBox.Show("Error trying to get loan details for the number entered."); return(false); } if (pawnLoan.DateMade.Date != ShopDateTime.Instance.FullShopDateTime.Date) { FileLogger.Instance.logMessage(LogLevel.WARN, this, "Cannot reprint loan documents for " + ticketNumber.ToString() + " on a previous date"); MessageBox.Show("This document is not eligible for reprint after the loan date."); return(false); } } else if (productsList.SelectedValue.Equals(DocumentHelper.POLICE_CARD)) { this.DocumentType = Document.DocTypeNames.TEXT; } else if (productsList.SelectedValue.Equals(DocumentHelper.RECIEPT)) { this.DocumentType = Document.DocTypeNames.RECEIPT; } else if (productsList.SelectedValue.Equals(DocumentHelper.RELEASE_FINGERPRINTS)) { this.DocumentType = Document.DocTypeNames.PDF; } else { throw new NotImplementedException("This product has not been implemented yet."); } var lastStorageId = documentHelper.GetStorageId(Utilities.GetStringValue(productsList.SelectedValue, null), docInfo, out errString); if (!string.IsNullOrEmpty(lastStorageId)) { this.StorageId = lastStorageId; } else { MessageBox.Show("Could not find the document."); return(false); } return(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)); } }