public override void SetOpened(bool opened) { if (_printer == null) { _printer = (PosPrinter)PosCommon; } }
public Printer(string deviceName = "PosPrinter") { var posExplorer = new PosExplorer(); var deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, deviceName); m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo); m_Printer.Open(); m_Printer.Claim(500); m_Printer.DeviceEnabled = true; m_Printer.RecLetterQuality = true; m_Printer.MapMode = MapMode.Metric; m_Printer.ClearOutput(); }
/// <summary> /// When the method "closing" is called, /// the following code is run. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> public void ReleasePrinter() { //<<<step1>>>--Start if (m_Printer != null && HavePrinter) { try { //Cancel the device //m_Printer.DeviceEnabled = false; m_Printer.Close(); //Release the device exclusive control right. m_Printer.Release(); m_Printer = null; HavePrinter = false; } catch (PosException) { } finally { //Finish using the device. //m_Printer.Close(); HavePrinter = false; } } //<<<step1>>>--End }
public void Execute(PosPrinter printer, PrinterStation station) { if (!printer.CapRecBitmap && station == PrinterStation.Receipt || !printer.CapSlpBitmap && station == PrinterStation.Slip) { return; } if (!File.Exists(FileName)) { return; } var alignment = 0; switch (Alignment) { case Alignment.Center: alignment = PosPrinter.PrinterBitmapCenter; break; case Alignment.Left: alignment = PosPrinter.PrinterBitmapLeft; break; case Alignment.Right: alignment = PosPrinter.PrinterBitmapRight; break; } printer.PrintBitmap(PrinterStation.Receipt, FileName, PosPrinter.PrinterBitmapAsIs, alignment); }
/// <summary> /// Reset all instances of claimed printer and remove event handlers. /// </summary> private void ResetTheScenarioState() { IsAnImportantTransactionInstance1 = true; IsAnImportantTransactionInstance2 = false; chkInstance1.IsChecked = true; chkInstance2.IsChecked = false; //Remove releasedevicerequested handler and dispose claimed printer object. if (claimedPrinter1 != null) { claimedPrinter1.ReleaseDeviceRequested -= ClaimedPrinter1_ReleaseDeviceRequested; claimedPrinter1.Dispose(); claimedPrinter1 = null; } if (claimedPrinter2 != null) { claimedPrinter2.ReleaseDeviceRequested -= ClaimedPrinter2_ReleaseDeviceRequested; claimedPrinter2.Dispose(); claimedPrinter2 = null; } if (printerInstance1 != null) { printerInstance1.Dispose(); printerInstance1 = null; } if (printerInstance2 != null) { printerInstance2.Dispose(); printerInstance2 = null; } }
private void DeactivatePrinter() { if (activePrinter != null) { // We have an active scanner, lets log that we are // about to close it. try { // Close the active scanner activePrinter.Close(); } catch (PosControlException ex) { _logger.LogError(ex, "The application received an error", "frmHardwaresetup", "DeactivatePrinter"); Helper.ShowMessage("The application received an error \n" + ex.Message, "Test Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { // Don't forget to set activeScanner to null to // indicate that we no longer have an active // scanner configured. activePrinter = null; } } }
public cImpresora(string nombreLogico) { try { _nombreLogico = nombreLogico; PosExplorer posExplorer = new PosExplorer(); DeviceInfo deviceInfo = null; deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, _nombreLogico); _oPrinter = (PosPrinter)posExplorer.CreateInstance(deviceInfo); _oPrinter.Open(); _oPrinter.Claim(1000); _oPrinter.DeviceEnabled = true; //Output by the high quality mode _oPrinter.RecLetterQuality = true; // Even if using any printers, 0.01mm unit makes it possible to print neatly. _oPrinter.MapMode = MapMode.Metric; } catch (PosControlException ex) { throw new Exception("Error al abrir la impresora fiscal. " + ex.Message); } catch (Exception ex) { throw new Exception("Error al abrir la impresora fiscal. " + ex.Message); } }
private void test_printer(PosPrinter p) { try { Debug.WriteLine("CapRecPresent: {0}", p.CapRecPresent); Debug.WriteLine("CapRecPageMode: {0}", p.CapRecPageMode); Debug.WriteLine("CapRecMarkFeed: {0}", p.CapRecMarkFeed); Debug.WriteLine("CapRuledLine: {0}", p.CapRecRuledLine); Debug.WriteLine("CapRecDWideDHigh: {0}", p.CapRecDWideDHigh); Debug.WriteLine("CapRecBitmap: {0}", p.CapRecBitmap); Debug.WriteLine("CapTransaction: {0}", p.CapTransaction); Debug.WriteLine("High quality?: {0}", p.RecLetterQuality); Debug.WriteLine("Receipt paper low?: {0}", p.RecNearEnd); Debug.WriteLine("Lines to paper cut: {0}", p.RecLinesToPaperCut); Debug.WriteLine("Line width: {0}", p.RecLineWidth); Debug.WriteLine(Directory.GetCurrentDirectory()); p.RecLetterQuality = true; p.SetBitmap(1, PrinterStation.Receipt, Resources.outpost_logo_receipt.ToString(), p.RecLineWidth, PosPrinter.PrinterBitmapCenter); //p.TransactionPrint(PrinterStation.Receipt, PrinterTransactionControl.Transaction); p.PrintNormal(PrinterStation.Receipt, PrintCommands.bitmap_1 + "Hello world!" + PrintCommands.bold + PrintCommands.double_size + "Hello world!" + PrintCommands.feed_cut); //p.TransactionPrint(PrinterStation.Receipt, PrinterTransactionControl.Normal); } catch (PosControlException e) { Debug.WriteLine("Point of sale control exception: {0}", e); if (e.ErrorCode == ErrorCode.Extended) { Debug.WriteLine("Extended: ", e.ErrorCodeExtended); } } }
private void PrintLineItem(PosPrinter printer, string itemCode, int quantity, double unitPrice) { PrintText(printer, TruncateAt(itemCode.PadRight(9), 9)); PrintText(printer, TruncateAt(quantity.ToString("#0.00").PadLeft(9), 9)); PrintText(printer, TruncateAt(unitPrice.ToString("#0.00").PadLeft(10), 10)); PrintTextLine(printer, TruncateAt((quantity * unitPrice).ToString("#0.00").PadLeft(10), 10)); }
async void ClaimSamePrinter_Click() { ClaimResultText.Text = ""; rootPage.NotifyUser("", NotifyType.StatusMessage); if (rootPage.Printer == null) { rootPage.NotifyUser("Use scenario 1 to find a printer first.", NotifyType.ErrorMessage); return; } using (var printer = await PosPrinter.FromIdAsync(rootPage.Printer.DeviceId)) { if (printer == null) { rootPage.NotifyUser("Cannot create same printer as scenario 1.", NotifyType.ErrorMessage); } using (var claimedPrinter = await printer.ClaimPrinterAsync()) { if (claimedPrinter != null) { ClaimResultText.Text = "Claimed the printer."; // This scenario doesn't do anything with the printer aside from claim it. // The "using" statement will dispose the claimed printer. } else { ClaimResultText.Text = "Did not claim the printer."; } } // The "using" statement will dispose the duplicate printer. } }
private void PrintReceiptFooter(PosPrinter printer, int subTotal, double tax, double discount, string footerText) { string offSetString = new string(' ', printer.RecLineChars / 2); PrintTextLine(printer, new string('-', (printer.RecLineChars / 3) * 2)); PrintTextLine(printer, offSetString + String.Format("SUB-TOTAL {0}", subTotal.ToString("#0.00"))); PrintTextLine(printer, offSetString + String.Format("TAX {0}", tax.ToString("#0.00"))); PrintTextLine(printer, offSetString + String.Format("DISCOUNT {0}", discount.ToString("#0.00"))); PrintTextLine(printer, offSetString + new string('-', (printer.RecLineChars / 3))); PrintTextLine(printer, offSetString + String.Format("TOTAL {0}", (subTotal - (tax + discount)).ToString("#0.00"))); PrintTextLine(printer, offSetString + new string('-', (printer.RecLineChars / 3))); PrintTextLine(printer, String.Empty); //Embed 'center' alignment tag on front of string below to have it printed in the center of the receipt. PrintTextLine(printer, System.Text.ASCIIEncoding.ASCII.GetString(new byte[] { 27, (byte)'|', (byte)'c', (byte)'A' }) + footerText); //Added in these blank lines because RecLinesToCut seems to be wrong on my printer and //these extra blank lines ensure the cut is after the footer ends. PrintTextLine(printer, String.Empty); PrintTextLine(printer, String.Empty); PrintTextLine(printer, String.Empty); PrintTextLine(printer, String.Empty); PrintTextLine(printer, String.Empty); //Print 'advance and cut' escape command. PrintTextLine(printer, System.Text.ASCIIEncoding.ASCII.GetString(new byte[] { 27, (byte)'|', (byte)'1', (byte)'0', (byte)'0', (byte)'P', (byte)'f', (byte)'P' })); }
private void SetUpPrinter() { string strLogicalName = "PosPrinter"; try { PosExplorer posExplorer = new PosExplorer(); DeviceInfo deviceInfo = null; myDevices = posExplorer.GetDevices(DeviceType.PosPrinter); try { deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName); m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo); } catch (Exception) { } m_Printer.Open(); } catch (PosControlException) { Console.WriteLine("Failed to load printer: " + strLogicalName); } }
private static void Print(PrintDestination printDestination, PosPrinter printer, Ticket ticket, List <TicketItem> ticketItems, TicketItemPrintOptions printOptions, bool checkPrintDestination) { bool isKitchen = ((printDestination == PrintDestination.Kitchen1) || (printDestination == PrintDestination.Kitchen2) || (printDestination == PrintDestination.Kitchen3)); if (!HasPrintableTicketItems(ticketItems, printDestination, printOptions, checkPrintDestination)) { return; } #if DEBUG PrintLineToReceipt(printer, "** Debug: Printer Destination is \'" + printDestination + "\' **"); #endif // Header PrintHeaderInformation(printDestination, printer, ticket, printOptions); // Ticket Items PrintTicketItems(ticketItems, printDestination, printer, ticket, printOptions); // Footer if (!isKitchen) { PrintFooterInformation(printer, ticket); } }
public static void Print(PrintDestination printDestination, PosPrinter printer, Ticket ticket, TicketItemPrintOptions printOptions) { List <TicketItem> ticketItems = new List <TicketItem>(TicketItem.GetAll(ticket.PrimaryKey)); Print(printDestination, printer, ticket, ticketItems, printOptions, false); }
/// <summary> /// GetDeviceSelector method returns the string needed to identify a PosPrinter. This is passed to FindAllAsync method to get the list of devices currently available and we connect the first device. /// </summary> private async Task <bool> FindReceiptPrinter() { if (printer == null) { rootPage.NotifyUser("Finding printer", NotifyType.StatusMessage); DeviceInformationCollection deviceCollection = await DeviceInformation.FindAllAsync(PosPrinter.GetDeviceSelector()); if (deviceCollection != null && deviceCollection.Count > 0) { DeviceInformation deviceInfo = deviceCollection[0]; printer = await PosPrinter.FromIdAsync(deviceInfo.Id); if (printer != null) { if (printer.Capabilities.Receipt.IsPrinterPresent) { rootPage.NotifyUser("Got Printer with Device Id : " + printer.DeviceId, NotifyType.StatusMessage); return(true); } } else { rootPage.NotifyUser("No Printer found", NotifyType.ErrorMessage); return(false); } } else { rootPage.NotifyUser("No devices returned by FindAllAsync.", NotifyType.ErrorMessage); return(false); } } return(true); }
private static void InitializePosDevices() { explorer = new PosExplorer(); InitializeCashDrawer1(); InitializeCashDrawer2(); InitializeScanners(); #if DEBUG activePosPrinterLocal = activePosPrinterJournal = activePosPrinterKitchen1 = activePosPrinterKitchen2 = activePosPrinterKitchen3 = activePosPrinterBar1 = activePosPrinterBar2 = activePosPrinterBar3 = InitializePosPrinter("PrinterDebugAll"); if (activePosPrinterLocal != null) { activePosPrinterLocal.PrintNormal(PrinterStation.Receipt, "** Debug Mode: Capturing all printer outputs **" + Environment.NewLine); } #else activePosPrinterLocal = InitializePosPrinter("PrinterName"); activePosPrinterJournal = InitializePosPrinter("PrinterNameJournal"); activePosPrinterKitchen1 = InitializePosPrinter("PrinterNameKitchen1"); activePosPrinterKitchen2 = InitializePosPrinter("PrinterNameKitchen2"); activePosPrinterKitchen3 = InitializePosPrinter("PrinterNameKitchen3"); activePosPrinterBar1 = InitializePosPrinter("PrinterNameBar1"); activePosPrinterBar2 = InitializePosPrinter("PrinterNameBar2"); activePosPrinterBar3 = InitializePosPrinter("PrinterNameBar3"); #endif InitializeCoinDispenser(); InitializeBumpBar(); }
private void GunlukRapor_Click(object sender, EventArgs e) { string zaman = DateTime.Now.ToShortDateString(); DialogResult Uyari = new DialogResult(); Uyari = MessageBox.Show("TÜM GİDERLERİN RAPORU BASILACAK BU RAPOR UZUNLUĞU GİDERLERİNİZİN UZUNLUĞU KADAR OLACAKTIR. ESKİ GİDERLERİNİZİ SİLERSENİZ RAPOR DAHA KISA OLABİLİR. DEVAM EDİLSİN Mİ?", "UYARI!", MessageBoxButtons.YesNo); if (Uyari == DialogResult.Yes) { try { var explorer = new PosExplorer(); var deviceInfo = explorer.GetDevice(DeviceType.PosPrinter); if (deviceInfo == null) { MessageBox.Show("BİLGİSAYARA BAĞLI YAZICI YOK YADA BAĞLANTI KURULAMADI", "ÇEKİRDEK KOD TERS MÜHENDİSLİK KORUMASI!"); return; } Yazici = (PosPrinter)explorer.CreateInstance(deviceInfo); Yazici.Open(); Yazici.Claim(500); Yazici.DeviceEnabled = true; Yazici.StatusUpdateEvent += (s, evt) => { if (evt.Status == PosPrinter.StatusCoverOpen) { MessageBox.Show("Yazıcının kağıt kapağı açıldı"); } if (evt.Status == PosPrinter.StatusCoverOK) { MessageBox.Show("Yazıcının kağıt kapağı kapandı"); } if (evt.Status == PosPrinter.StatusJournalCartridgeEmpty) { MessageBox.Show("Yazıcının kartuşu bitmek üzere"); } }; Yazici.PrintNormal(PrinterStation.Slip, " PRESTIGE CAFE " + Environment.NewLine); Yazici.PrintNormal(PrinterStation.Slip, "GÜnlük Gider Raporu" + " TARİH: " + DateTime.Now.ToShortDateString() + Environment.NewLine); Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine); VeriEntities3 context = new VeriEntities3(); foreach (var bul in context.Giderler.Where(p => p.Tarih == zaman)) { Yazici.PrintNormal(PrinterStation.Slip, "Gider adı: " + bul.GiderAdi + " Gider Tutarı: " + bul.GiderTutari + " Tarih: " + bul.Tarih + Environment.NewLine); } Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine); Yazici.PrintNormal(PrinterStation.Slip, "MARKETMATİK BETA V.1.0.2 [email protected]" + Environment.NewLine); Yazici.CutPaper(100); MessageBox.Show("Gider Yazdırıldı.", "Kullanıcı İşlemleri"); this.Close(); formdd1.Visible = true; } catch { MessageBox.Show("DÖNGÜSEL VERİTABANI HATASI. DATA BULUNAMADI YADA VERİTABANI BAĞLANTISI KESİLDİ.", "ÇEKİRDEK KOD ÖLÜMCÜL HATA!"); MessageBox.Show("LÜTFEN GELİŞTİRİCİ İLE İRTİBAT KURUN. PROGRAM SONLANICAK", "ÇEKİRDEK KOD TERS MÜHENDİSLİK KORUMASI"); Application.Exit(); } } }
public void Execute(PosPrinter printer, PrinterStation station) { if (!printer.CapRecBarCode && station == PrinterStation.Receipt || !printer.CapSlpBarCode && station == PrinterStation.Slip) { return; } var alignment = 0; switch (Alignment) { case Alignment.Center: alignment = PosPrinter.PrinterBarCodeCenter; break; case Alignment.Left: alignment = PosPrinter.PrinterBarCodeLeft; break; case Alignment.Right: alignment = PosPrinter.PrinterBarCodeRight; break; } printer.PrintBarCode(station, Data, Symbology, Height, Width, alignment, TextPosition); }
async Task <bool> CreateDeviceList_OneTime(Type[] deviceClasses) { foreach (Type ty in deviceClasses) { DeviceInformationCollection deviceList = null; if (ty == typeof(BarcodeScanner)) { deviceList = await DeviceInformation.FindAllAsync(BarcodeScanner.GetDeviceSelector()); } else if (ty == typeof(PosPrinter)) { deviceList = await DeviceInformation.FindAllAsync(PosPrinter.GetDeviceSelector()); } else if (ty == typeof(CashDrawer)) { deviceList = await DeviceInformation.FindAllAsync(CashDrawer.GetDeviceSelector()); } else if (ty == typeof(MagneticStripeReader)) { deviceList = await DeviceInformation.FindAllAsync(MagneticStripeReader.GetDeviceSelector()); } else if (ty == typeof(LineDisplay)) { deviceList = await DeviceInformation.FindAllAsync(LineDisplay.GetDeviceSelector()); } AddToSelectionList(ty, deviceList); } return(true); }
private void ActivatePrinter(DeviceInfo selectedPrinter) { //Verifify that the selectedScanner is not null // and that it is not the same scanner already selected if (selectedPrinter != null && !selectedPrinter.IsDeviceInfoOf(activePrinter)) { // Configure the new scanner DeactivatePrinter(); // Activate the new scanner try { activePrinter = (PosPrinter)_posexplorer.CreateInstance(selectedPrinter); activePrinter.Open(); activePrinter.Claim(1000); activePrinter.DeviceEnabled = true; Helper.ShowMessage("Test successful", "Test Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (PosControlException ex) { _logger.LogError(ex, "The application received an error", "frmHardwaresetup", "ActivatePrinter"); Helper.ShowMessage("The application received an error \n" + ex.Message, "Test Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { activePrinter = null; } } }
//public void printReceipt(InvoiceLine[] giftCards) //{ // try // { // // return; // setupPrinter(); // try // { // m_Printer.Open(); // //Get the exclusive control right for the opened device. // //Then the device is disable from other application. // m_Printer.Claim(1000); // //Enable the device. // bool result = m_Printer.DeviceEnabled = true; // // this call also causes the "It is not initialized" error // //string health = m_Printer.CheckHealth(HealthCheckLevel.External); // } // catch (PosControlException) // { // // ChangeButtonStatus(); // } // foreach (var invoiceLine in giftCards) // { // string receiptString = Receipt40Col.GetStandardReceipt(invoiceLine); // // int test = m_Printer.JrnLineChars // var file = Path.GetFullPath("Resources/logo.bmp"); // // m_Printer.PrintNormal(PrinterStation.Receipt,((char)27).ToString() + "|cA" + receiptString); // m_Printer.PrintBitmap(PrinterStation.Receipt, file, 300, PosPrinter.PrinterBitmapCenter); // m_Printer.PrintNormal(PrinterStation.Receipt, receiptString); // m_Printer.PrintNormal(PrinterStation.Receipt, Receipt40Col.extraLines(8)); // Thread.Sleep(3000); // } // } // catch (Exception ex) // { // ErrorLogging.logError(ex); // } //} //public void printReceipt(Buyback buyback, bool openDrawer = false) //{ // //return; // setupPrinter(); // try // { // m_Printer.Open(); // //Get the exclusive control right for the opened device. // //Then the device is disable from other application. // m_Printer.Claim(1000); // //Enable the device. // bool result = m_Printer.DeviceEnabled = true; // // this call also causes the "It is not initialized" error // //string health = m_Printer.CheckHealth(HealthCheckLevel.External); // string receiptString = Receipt40Col.GetStandardReceipt(buyback); // string barcodeString = buyback.Id.ToString(); // while (barcodeString.Length < 8) // { // barcodeString = " " + barcodeString; // } // // int test = m_Printer.JrnLineChars // var file = Path.GetFullPath("Resources/logo.bmp"); // // m_Printer.PrintNormal(PrinterStation.Receipt,((char)27).ToString() + "|cA" + receiptString); // m_Printer.PrintBitmap(PrinterStation.Receipt, file, 300, PosPrinter.PrinterBitmapCenter); // m_Printer.PrintNormal(PrinterStation.Receipt, receiptString); // m_Printer.PrintNormal(PrinterStation.Receipt, Receipt40Col.extraLines(8)); // if (openDrawer) // m_Printer.PrintNormal(PrinterStation.Receipt, ((char)27).ToString() + "|\x07"); // } // catch (Exception ex) // { // ErrorLogging.logError(ex); // } //} void setupPrinter() { //Create PosExplorer var posExplorer = new PosExplorer(); var devices = posExplorer.GetDevices("PosPrinter"); DeviceInfo deviceInfo = null; try { var printerName = ConfigurationManager.AppSettings["ReceiptPrinter"]; deviceInfo = devices.OfType <DeviceInfo>().FirstOrDefault(x => x.ServiceObjectName.Contains(printerName)) ?? devices.OfType <DeviceInfo>().FirstOrDefault(x => x.ServiceObjectName.Contains("Star")); // this call returns a valid object var p = posExplorer.CreateInstance(deviceInfo); m_Printer = (PosPrinter)p; // posExplorer.CreateInstance(deviceInfo); } catch (Exception exception) { Console.WriteLine(exception); // ChangeButtonStatus(); return; } }
private static PosPrinter InitializePosPrinter(string configSettingName) { PosPrinter result = null; DeviceCollection printerList = PosPrinterDeviceCollection; if (printerList.Count > 0) { try { #if DEBUG //DeviceInfo printer = GetActiveDeviceInfo(printerList, configSettingName, true); DeviceInfo printer = printerList[0]; #else DeviceInfo printer = GetActiveDeviceInfo(printerList, configSettingName); #endif if (printer != null) { result = (PosPrinter)explorer.CreateInstance(printer); result.Open(); result.Claim(1000); result.DeviceEnabled = true; } } catch (PosControlException) { // Log error and set the active to nil Logger.Error("InitializePosDevices", Strings.InitializationException); } } return(result); }
private void cariodetamaminiode_Click(object sender, EventArgs e) { Musteriler musteriler = new Musteriler(); var MusteriCariOde = db.Musteriler.Where(w => w.MusteriAdi == cariodemusteriadi.Text).FirstOrDefault(); try { String Odeme = MusteriCariOde.MusteriBakiyesi; MusteriCariOde.MusteriBakiyesi = "0"; db.SaveChanges(); var explorer = new PosExplorer(); var deviceInfo = explorer.GetDevice(DeviceType.PosPrinter); if (deviceInfo == null) { MessageBox.Show("BİLGİSAYARA BAĞLI YAZICI YOK YADA BAĞLANTI KURULAMADI", "ÇEKİRDEK KOD TERS MÜHENDİSLİK KORUMASI!"); return; } Yazici = (PosPrinter)explorer.CreateInstance(deviceInfo); Yazici.Open(); Yazici.Claim(500); Yazici.DeviceEnabled = true; Yazici.StatusUpdateEvent += (s, evt) => { if (evt.Status == PosPrinter.StatusCoverOpen) { MessageBox.Show("Yazıcının kağıt kapağı açıldı"); } if (evt.Status == PosPrinter.StatusCoverOK) { MessageBox.Show("Yazıcının kağıt kapağı kapandı"); } if (evt.Status == PosPrinter.StatusJournalCartridgeEmpty) { MessageBox.Show("Yazıcının kartuşu bitmek üzere"); } }; Yazici.PrintNormal(PrinterStation.Slip, " PRESTIGE CAFE " + Environment.NewLine); Yazici.PrintNormal(PrinterStation.Slip, "CARİ ÖDEME BİLGİ FİŞİ" + " TARİH: " + DateTime.Now.ToShortDateString() + Environment.NewLine); Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine); Yazici.PrintNormal(PrinterStation.Slip, "MÜŞTERİ ADI : " + MusteriCariOde.MusteriAdi + Environment.NewLine); Yazici.PrintNormal(PrinterStation.Slip, "--------------------------------------------------------------" + Environment.NewLine); Yazici.PrintNormal(PrinterStation.Slip, "MÜŞTERİ CARİSİ: " + Odeme + Environment.NewLine); Yazici.PrintNormal(PrinterStation.Slip, "--------------------------------------------------------------" + Environment.NewLine); Yazici.PrintNormal(PrinterStation.Slip, "ÖDENEN MİKTAR : " + Odeme + Environment.NewLine); Yazici.PrintNormal(PrinterStation.Slip, "**************************************************************" + Environment.NewLine); Yazici.PrintNormal(PrinterStation.Slip, " TEŞEKKÜR EDERİZ " + Environment.NewLine); Yazici.PrintNormal(PrinterStation.Slip, "MARKETMATİK BETA V.1.0.2 [email protected]" + Environment.NewLine); Yazici.CutPaper(100); musteriyonetimformu = new MusteriYonetimFormu(); musteriyonetimformu.Show(); this.Close(); } catch { MessageBox.Show("DÖNGÜSEL VERİTABANI HATASI. DATA BULUNAMADI YADA VERİTABANI BAĞLANTISI KESİLDİ.", "ÇEKİRDEK KOD ÖLÜMCÜL HATA!"); MessageBox.Show("LÜTFEN GELİŞTİRİCİ İLE İRTİBAT KURUN. PROGRAM SONLANICAK", "ÇEKİRDEK KOD TERS MÜHENDİSLİK KORUMASI"); Application.Exit(); } }
private void tsbtnPrint_Click(object sender, EventArgs e) { if (_retailsOrder != null) { PosPrinterModel docu = InitPosPrinterModel(_retailsOrder); PosPrinter pp = new PosPrinter(docu); pp.print(); } }
public void Execute(PosPrinter printer, PrinterStation station) { if (!printer.CapRecStamp && station == PrinterStation.Receipt) { return; } printer.PrintNormal(station, EscapeSequence.FireStamp); }
public void Execute(PosPrinter printer) { if (CharactersPerLine.HasValue) { printer.RecLineChars = CharactersPerLine.Value; } printer.Print(ToString()); }
public void Execute(PosPrinter printer, PrinterStation station) { if (!printer.CapRecPaperCut && station == PrinterStation.Receipt) { return; } printer.PrintNormal(station, EscapeSequence.FeedAndPaperCut(PercentCut)); }
public void Execute(PosPrinter printer, PrinterStation station) { if (!printer.CapRecBitmap && station == PrinterStation.Receipt || !printer.CapSlpBitmap && station == PrinterStation.Slip) { return; } printer.PrintNormal(station, EscapeSequence.PrintBitmap(BitmapNumber)); }
public static void createPos() { explorer = new PosExplorer(); DeviceInfo receiptPrinterDevice = explorer.GetDevice("PosPrinter", Properties.Settings.Default.KitchenPrinter); //May need to change this if you don't use a logicial name or use a different one. kitchenPrinter = (PosPrinter)explorer.CreateInstance(receiptPrinterDevice); kitchenPrinter.Open(); kitchenPrinter.Claim(10000); kitchenPrinter.DeviceEnabled = true; }
public IReceiptPrinter GetReceiptPrinter() { if (_printer == null) { DeviceInfo printerDeviceInfo = _exp.GetDevice("PosPrinter"); PosPrinter printer = (PosPrinter)_exp.CreateInstance(printerDeviceInfo); _printer = new ReceiptPrinterWrapper(printer); printer.Open(); } return(_printer); }
public void ReleaseAllPrinters() { ReleaseClaimedPrinter(); if (Printer != null) { Printer.Dispose(); Printer = null; StateChanged?.Invoke(); } }
public Printer() { explorer = new PosExplorer(); var deviceCollection = explorer.GetDevices("PosPrinter"); foreach (DeviceInfo deviceInfo in deviceCollection) { if (deviceInfo.ServiceObjectName != "VoRiMTD300Printer") continue; printer = (PosPrinter)explorer.CreateInstance(deviceInfo); break; } }
private void ResetTheScenarioState() { //Remove releasedevicerequested handler and dispose claimed printer object. if (claimedPrinter != null) { claimedPrinter.ReleaseDeviceRequested -= ClaimedPrinter_ReleaseDeviceRequested; claimedPrinter.Dispose(); claimedPrinter = null; } printer = null; }
public Printer() { explorer = new PosExplorer(); var deviceCollection = explorer.GetDevices(); Console.WriteLine("DeViCe count: " + deviceCollection.Count); foreach (DeviceInfo deviceInfo in deviceCollection) { Console.WriteLine("devvv: " + deviceInfo.ServiceObjectName + deviceInfo.ManufacturerName); if (deviceInfo.ServiceObjectName != "VoRiMTD300Printer") continue; printer = (PosPrinter)explorer.CreateInstance(deviceInfo); break; } }
//public void printReceipt(InvoiceLine[] giftCards) //{ // try // { // // return; // setupPrinter(); // try // { // m_Printer.Open(); // //Get the exclusive control right for the opened device. // //Then the device is disable from other application. // m_Printer.Claim(1000); // //Enable the device. // bool result = m_Printer.DeviceEnabled = true; // // this call also causes the "It is not initialized" error // //string health = m_Printer.CheckHealth(HealthCheckLevel.External); // } // catch (PosControlException) // { // // ChangeButtonStatus(); // } // foreach (var invoiceLine in giftCards) // { // string receiptString = Receipt40Col.GetStandardReceipt(invoiceLine); // // int test = m_Printer.JrnLineChars // var file = Path.GetFullPath("Resources/logo.bmp"); // // m_Printer.PrintNormal(PrinterStation.Receipt,((char)27).ToString() + "|cA" + receiptString); // m_Printer.PrintBitmap(PrinterStation.Receipt, file, 300, PosPrinter.PrinterBitmapCenter); // m_Printer.PrintNormal(PrinterStation.Receipt, receiptString); // m_Printer.PrintNormal(PrinterStation.Receipt, Receipt40Col.extraLines(8)); // Thread.Sleep(3000); // } // } // catch (Exception ex) // { // ErrorLogging.logError(ex); // } //} //public void printReceipt(Buyback buyback, bool openDrawer = false) //{ // //return; // setupPrinter(); // try // { // m_Printer.Open(); // //Get the exclusive control right for the opened device. // //Then the device is disable from other application. // m_Printer.Claim(1000); // //Enable the device. // bool result = m_Printer.DeviceEnabled = true; // // this call also causes the "It is not initialized" error // //string health = m_Printer.CheckHealth(HealthCheckLevel.External); // string receiptString = Receipt40Col.GetStandardReceipt(buyback); // string barcodeString = buyback.Id.ToString(); // while (barcodeString.Length < 8) // { // barcodeString = " " + barcodeString; // } // // int test = m_Printer.JrnLineChars // var file = Path.GetFullPath("Resources/logo.bmp"); // // m_Printer.PrintNormal(PrinterStation.Receipt,((char)27).ToString() + "|cA" + receiptString); // m_Printer.PrintBitmap(PrinterStation.Receipt, file, 300, PosPrinter.PrinterBitmapCenter); // m_Printer.PrintNormal(PrinterStation.Receipt, receiptString); // m_Printer.PrintNormal(PrinterStation.Receipt, Receipt40Col.extraLines(8)); // if (openDrawer) // m_Printer.PrintNormal(PrinterStation.Receipt, ((char)27).ToString() + "|\x07"); // } // catch (Exception ex) // { // ErrorLogging.logError(ex); // } //} void setupPrinter() { //Create PosExplorer var posExplorer = new PosExplorer(); var devices = posExplorer.GetDevices("PosPrinter"); DeviceInfo deviceInfo = null; try { var printerName = ConfigurationManager.AppSettings["ReceiptPrinter"]; deviceInfo = devices.OfType<DeviceInfo>().FirstOrDefault(x => x.ServiceObjectName.Contains(printerName)) ?? devices.OfType<DeviceInfo>().FirstOrDefault(x => x.ServiceObjectName.Contains("Star")); // this call returns a valid object var p = posExplorer.CreateInstance(deviceInfo); m_Printer = (PosPrinter) p; // posExplorer.CreateInstance(deviceInfo); } catch (Exception exception) { Console.WriteLine(exception); // ChangeButtonStatus(); return; } }
public PosPrinterEvents(PosPrinter This) { this.This = This; }
public void openConnection() { SesionEnt.printerEnabled = false; string logicalName = "PosPrinter2"; PosExplorer posExplorer = new PosExplorer(); DeviceInfo deviceInfo = null; try { deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, logicalName); } catch (Exception exceptionX) { throw exceptionX; } if (deviceInfo != null) { try { posPrinter = (PosPrinter)posExplorer.CreateInstance(deviceInfo); } catch (Exception exceptionX) { throw exceptionX; } try { posPrinter.Open(); posPrinter.PowerNotify = PowerNotification.Enabled; } catch (Exception exceptionX) { throw exceptionX; } if (posPrinter != null) { try { posPrinter.Claim(1000); } catch (PosControlException posControlExceptionX) { throw posControlExceptionX; } try { posPrinter.DeviceEnabled = true; } catch (PosControlException posControlExceptionX) { throw posControlExceptionX; } try { posPrinter.RecLetterQuality = false; posPrinter.MapMode = MapMode.Metric; SesionEnt.posPrinter = posPrinter; SesionEnt.printerEnabled = true; } catch (PosControlException posControlExceptionX) { throw posControlExceptionX; } } } }
//prepare printer private void prepare() { string strLogicalName = "PosPrinter"; try { PosExplorer posExplorer = new PosExplorer(); DeviceInfo deviceInfo = null; try { deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, strLogicalName); m_Printer = (PosPrinter)posExplorer.CreateInstance(deviceInfo); } catch (Exception e) { Console.WriteLine("error2"); Console.WriteLine(e); } m_Printer.Open(); m_Printer.Claim(1000); m_Printer.DeviceEnabled = true; } catch (PosControlException e) { Console.WriteLine("error3"); Console.WriteLine(e); } finally { //release(); } }
private void PrintLocalDefaultImage(PosPrinter actualPrinter) { try { Image Dummy = Image.FromFile(Properties.Settings.Default.DefaultAd); string directory = Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData); string fileName = directory + @"/default.bmp"; Bitmap ADimg = Helpers.ConvertPNGToBitmap(Dummy); ADimg.Save(fileName, ImageFormat.Bmp); actualPrinter.PrintBitmap(PrinterStation.Receipt, fileName, PosPrinter.PrinterBitmapAsIs, PosPrinter.PrinterBitmapCenter); } catch (Exception ex) { AddLog(ex.ToString(),true); } actualPrinter.PrintNormal(PrinterStation.Receipt, "\r\n\r\nPowered by www.docketplace.com.au"); actualPrinter.PrintNormal(PrinterStation.Receipt, "\r\n\r\n\r\n\r\n"); actualPrinter.CutPaper(10); AddLog("Local Image printed",false); }
/// <summary> /// PosPrinter GetDeviceSelector gets the string format used to search for pos printer. This is then used to find any pos printers. /// The method then takes the first printer id found and tries to create two instances for that printer. /// </summary> /// <returns></returns> private async Task<bool> FindReceiptPrinterInstances() { if (printerInstance1 == null || printerInstance2 == null) { rootPage.NotifyUser("Finding printer", NotifyType.StatusMessage); DeviceInformationCollection deviceCollection = await DeviceInformation.FindAllAsync(PosPrinter.GetDeviceSelector()); if (deviceCollection != null && deviceCollection.Count > 0) { DeviceInformation deviceInfo = deviceCollection[0]; printerInstance1 = await PosPrinter.FromIdAsync(deviceInfo.Id); if (printerInstance1.Capabilities.Receipt.IsPrinterPresent) { rootPage.NotifyUser("Got Printer Instance 1 with Device Id : " + printerInstance1.DeviceId, NotifyType.StatusMessage); printerInstance2 = await PosPrinter.FromIdAsync(deviceInfo.Id); if (printerInstance2.Capabilities.Receipt.IsPrinterPresent) { rootPage.NotifyUser("Got Printer Instance 2 with Device Id : " + printerInstance2.DeviceId, NotifyType.StatusMessage); } return true; } else { rootPage.NotifyUser("Did not find a Receipt printer ", NotifyType.ErrorMessage); return false; } } else { rootPage.NotifyUser("No devices returned by FindAllAsync.", NotifyType.ErrorMessage); return false; } } return true; }
/// <summary> /// Reset all instances of claimed printer and remove event handlers. /// </summary> private void ResetTheScenarioState() { IsAnImportantTransactionInstance1 = true; IsAnImportantTransactionInstance2 = false; chkInstance1.IsChecked = true; chkInstance2.IsChecked = false; //Remove releasedevicerequested handler and dispose claimed printer object. if (claimedPrinter1 != null) { claimedPrinter1.ReleaseDeviceRequested -= ClaimedPrinter1_ReleaseDeviceRequested; claimedPrinter1.Dispose(); claimedPrinter1 = null; } if (claimedPrinter2 != null) { claimedPrinter2.ReleaseDeviceRequested -= ClaimedPrinter2_ReleaseDeviceRequested; claimedPrinter2.Dispose(); claimedPrinter2 = null; } printerInstance1 = null; printerInstance2 = null; }
public Printer(string logicalName, bool connect) { instance = this; if (connect) { this.profile = null; this.deviceStatus = PrintDeviceStatus.Properly; this.PrintStatus = PrintStatus.Stopped; try { DeviceInfo deviceInfo = null; PosExplorer posExplorer = new PosExplorer(); deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, logicalName); device = (PosPrinter)posExplorer.CreateInstance(deviceInfo); device.Open(); device.Claim(1000); device.AsyncMode = false; device.DeviceEnabled = true; device.StatusUpdateEvent += Device_StatusUpdateEvent; device.ErrorEvent += (a, b) => { WriteLog("ERROR - " + b.ToString()); }; WriteLog(""); WriteLog("Drucker initialisiert; Status: " + device.State + device); if (device.RecNearEnd) Device_StatusUpdateEvent(this, new StatusUpdateEventArgs(25)); this.connected = connect; } catch (Exception ex) { string s = ex.Source; try { if (device != null) device.Release(); } catch { } throw new Exception("Verbindung zum Drucker fehlgeschlagen.", ex); } } else { this.connected = false; this.PrintStatus = PrintStatus.Stopped; this.deviceStatus = PrintDeviceStatus.Properly; } }