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(); }
public IDScanner() { explorer = new PosExplorer(); var deviceCollection = explorer.GetDevices("Scanner"); foreach (DeviceInfo deviceInfo in deviceCollection) { if (deviceInfo.ServiceObjectName != "Honeywell3310g") continue; scanner = (Scanner)explorer.CreateInstance(deviceInfo); break; } }
private void ActivateScanner(DeviceInfo selectedScanner) { //Verifify that the selectedScanner is not null // and that it is not the same scanner already selected if (selectedScanner != null && !selectedScanner.IsDeviceInfoOf(activeScanner)) { // Configure the new scanner DeactivateScanner(); // Activate the new scanner try { activeScanner = (Scanner)_posexplorer.CreateInstance(selectedScanner); activeScanner.Open(); activeScanner.Claim(1000); activeScanner.DeviceEnabled = true; activeScanner.DecodeData = true; activeScanner.DataEventEnabled = true; Helper.ShowMessage("Test successful", "Test Successful", MessageBoxButtons.OK, MessageBoxIcon.Information); } catch (PosControlException ex) { _logger.LogError(ex, "The application received an error ", "frmHardwaresetup", "ActivateScanner"); Helper.ShowMessage("The application received an error \n" + ex.Message, "Test Failed", MessageBoxButtons.OK, MessageBoxIcon.Error); } finally { activeScanner = null; } } }
public ICashDrawer GetCashDrawer() { if (_drawer == null) { DeviceInfo drawerDeviceInfo = _exp.GetDevice("CashDrawer"); CashDrawer drawer = (CashDrawer)_exp.CreateInstance(drawerDeviceInfo); _drawer = new DrawerWrapper(drawer, _messageBus); drawer.Open(); } return(_drawer); }
private void ActivateScanner(DeviceInfo selectedScanner) { //Verifify that the selectedScanner is not null // and that it is not the same scanner already selected if (selectedScanner != null && !selectedScanner.IsDeviceInfoOf(activeScanner)) { // Configure the new scanner DeactivateScanner(); try { activeScanner = (Scanner)posExplorer.CreateInstance(selectedScanner); activeScanner.Open(); activeScanner.Claim(1000); activeScanner.DeviceEnabled = true; activeScanner.DecodeData = true; activeScanner.DataEventEnabled = true; } catch (PosControlException ex) { // Log error and set the active scanner to none activeScanner = null; _logger.LogError(ex, "An error occurred", "frmMain", "ActivateScanner"); } } }
private PosPrinter GetReceiptPrinter() { PosExplorer posExplorer = new PosExplorer(this); DeviceInfo receiptPrinterDevice = posExplorer.GetDevice("PosPrinter", "ReceiptPrinter"); //May need to change this if you don't use a logicial name or use a different one. return((PosPrinter)posExplorer.CreateInstance(receiptPrinterDevice)); }
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 void Connect() { if (string.IsNullOrEmpty(txtLogicalName.Text)) { SetStatus(Level.Warning, "Enter a logical name to connect to the scanner"); return; } txtLogicalName.Enabled = false; txtConnectScanner.Text = "Disconnect Scanner"; try { var explorer = new PosExplorer(); _scanner = explorer.CreateInstance(explorer.GetDevice(DeviceType.Scanner, txtLogicalName.Text)) as Scanner; AddDataEvent(_scanner); SetStatus(Level.Info, "Opening " + txtLogicalName.Text); _scanner.Open(); SetStatus(Level.Info, "Claiming scanner"); _scanner.Claim(1000); SetStatus(Level.Info, "Enabling scanner"); _scanner.DeviceEnabled = true; _scanner.DataEventEnabled = true; _scanner.DecodeData = true; SetStatus(Level.Success, "Ready"); } catch (PosControlException ex) { SetStatus(Level.Error, "Failed to connect to scanner. " + ex.Message); } }
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); } }
public Scanner(string logicalName) { var explorer = new PosExplorer(); var device = explorer.GetDevice(DeviceType.Scanner, logicalName); Device = explorer.CreateInstance(device) as Microsoft.PointOfService.Scanner; }
private void Panel_Empleados_Load(object sender, EventArgs e) { //<<< step1 >>> --Start //Use a Logical Device Name which has been set on the SetupPOS. string strLogicalName = "CashDrawer"; try { //Create PosExplorer PosExplorer posExplorer = new PosExplorer(); DeviceInfo deviceInfo = null; try { deviceInfo = posExplorer.GetDevice(DeviceType.CashDrawer, strLogicalName); m_Drawer = (CashDrawer)posExplorer.CreateInstance(deviceInfo); } catch (Exception) { //Nothing can be used. return; } } catch (PosControlException) { //Nothing can be used. //Nothing can be used. } //<<<step1>>>--End }
private PosPrinter FindPrinter(string objectName) { PosExplorer myPosExplorer = new PosExplorer(); DeviceCollection myDevices = myPosExplorer.GetDevices(DeviceType.PosPrinter, DeviceCompatibilities.Opos); //find the printer by expected service object name foreach (DeviceInfo devInfo in myDevices) { if (devInfo.ServiceObjectName == objectName) { try { var p = myPosExplorer.CreateInstance(devInfo) as PosPrinter; //open p.Open(); //claim the printer for use p.Claim(CLAIM_TIMEOUT_MS); //make sure it is enabled p.DeviceEnabled = true; return(p); } catch (Exception) { // Eating exception for other printers may be connected } } } return(null); }
public OPOSLineDisplayServer(string deviceName) { PosExplorer myPosExplorer = new PosExplorer(); DeviceCollection myDevices = myPosExplorer.GetDevices(DeviceType.LineDisplay); foreach (DeviceInfo devInfo in myDevices) { if (devInfo.ServiceObjectName == deviceName) { _lineDisplay = myPosExplorer.CreateInstance(devInfo) as LineDisplay; //open _lineDisplay.Open(); //claim the printer for use _lineDisplay.Claim(CLAIM_TIMEOUT_MS); //make sure it is enabled _lineDisplay.DeviceEnabled = true; } } if (_lineDisplay == null) { throw new Exception("No Customer Display Available!"); } }
public OPOSCashDrawerServer(string deviceName) { PosExplorer myPosExplorer = new PosExplorer(); DeviceCollection myDevices = myPosExplorer.GetDevices(DeviceType.CashDrawer); try { foreach (DeviceInfo devInfo in myDevices) { if (devInfo.ServiceObjectName == deviceName) { _cashDrawer = myPosExplorer.CreateInstance(devInfo) as CashDrawer; //open _cashDrawer.Open(); //claim the printer for use _cashDrawer.Claim(CLAIM_TIMEOUT_MS); //make sure it is enabled _cashDrawer.DeviceEnabled = true; } } if (_cashDrawer == null) { throw new Exception("No Cash Drawer Available!"); } } catch (Exception ex) { throw new Exception("No Cash Drawer Available!"); } }
private PosPrinter GetReceiptPrinter() { //PosExplorer explorer = new PosExplorer(); //return explorer.GetDevices(DeviceType.PosPrinter, DeviceCompatibilities.OposAndCompatibilityLevel1); PosExplorer posExplorer = null; try { posExplorer = new PosExplorer(); } catch (Exception) { //posExplorer = new PosExplorer(this); } //var ppp = posExplorer.GetDevices(DeviceType.PosPrinter, DeviceCompatibilities.OposAndCompatibilityLevel1); // var pp = posExplorer.GetDevices(); // DeviceInfo receiptPrinterDevice = posExplorer.GetDevice("EPSON TM-T20II Receipt", "EPSON TM-T20II Receipt"); //May need to change this if you don't use a logicial name or //use a different one. DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter, "POSPrinter"); //May need to change this if you don't use a logicial name or//my_device //DeviceInfo receiptPrinterDevice1 = posExplorer.GetDevice(DeviceType.LineDisplay, "my_device"); //May need to change this if you don't use a logicial name or//my_device // receiptPrinterDevice. return((PosPrinter)posExplorer.CreateInstance(receiptPrinterDevice)); }
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(); } } }
private void ActivateScanner(DeviceInfo selectedScanner) { //Verifify that the selectedScanner is not null // and that it is not the same scanner already selected if (selectedScanner != null && !selectedScanner.IsDeviceInfoOf(activeScanner)) { // Configure the new scanner DeactivateScanner(); // Activate the new scanner UpdateEventHistory(string.Format("Activate Scanner: {0}", selectedScanner.ServiceObjectName)); try { activeScanner = (Scanner)explorer.CreateInstance(selectedScanner); activeScanner.Open(); activeScanner.Claim(1000); activeScanner.DeviceEnabled = true; activeScanner.DataEvent += new DataEventHandler(activeScanner_DataEvent); activeScanner.ErrorEvent += new DeviceErrorEventHandler(activeScanner_ErrorEvent); activeScanner.DecodeData = true; activeScanner.DataEventEnabled = true; } catch (PosControlException) { // Log error and set the active scanner to none UpdateEventHistory(string.Format("Activation Failed: {0}", selectedScanner.ServiceObjectName)); activeScanner = null; } } }
static Scale Scale_ClaimOpenEnable(DeviceInfo di) { InitPosCheck(); if (di == null) { return(null); } try { Scale scale = (Scale)explorer.CreateInstance(di); scale.Open(); WriteLog(" Opened {0}.", di.ServiceObjectName); scale.Claim(5000); WriteLog(" Claimed {0}.", di.ServiceObjectName); scale.DeviceEnabled = true; WriteLog(" Enabled {0}.", di.ServiceObjectName); scale.DataEvent += Scale_DataEvent; return(scale); } catch (PosControlException pe) { WriteLog("EXCEPTION: ClaimScale({0}) - {1} ", di.ServiceObjectName, pe.Message); } return(null); }
private void backgroundWorker_LightsOff(object sender, DoWorkEventArgs e) { PosExplorer explorer = new PosExplorer(); PosCommon doorhub = null; var commonCollection = explorer.GetDevices("PosCommon"); foreach (DeviceInfo deviceInfo in commonCollection) { if (deviceInfo.ServiceObjectName != "DoorHub") continue; doorhub = (PosCommon)explorer.CreateInstance(deviceInfo); break; } if (doorhub == null) { MessageBox.Show("Doorhub not activated"); return; } doorhub.Open(); doorhub.Claim(1000); doorhub.DeviceEnabled = true; DirectIOData data = doorhub.DirectIO(1, 0, new string[] { "HexMaskGPB", "00" }); doorhub.DeviceEnabled = false; doorhub.Release(); doorhub.Close(); }
public Printer(string logicalName) { var explorer = new PosExplorer(); var device = explorer.GetDevice(DeviceType.PosPrinter, logicalName); Device = explorer.CreateInstance(device) as PosPrinter; }
public CashDrawerClass() { explorer = new PosExplorer(this); DeviceInfo ObjDevicesInfo = explorer.GetDevice("CashDrawer"); myCashDrawer = explorer.CreateInstance(ObjDevicesInfo); }
/// <summary> /// How to use "PosExplorer" sample1. /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void btnExample1_Click(object sender, System.EventArgs e) { //Use a Logical Device Name which has been set on the SetupPOS. try { //Create PosExplorer PosExplorer posExplorer = new PosExplorer(); DeviceInfo deviceInfo = null; //Get DeviceInfo use devicecategory and logicalname. deviceInfo = posExplorer.GetDevice(DeviceType.PosPrinter, m_strLogicalName); m_PosCommon = (PosCommon)posExplorer.CreateInstance(deviceInfo); //Open the device m_PosCommon.Open(); //Get the exclusive control right for the opened device. //Then the device is disable from other application. m_PosCommon.Claim(1000); //Enable the device. m_PosCommon.DeviceEnabled = true; //CheckHealth. m_PosCommon.CheckHealth(Microsoft.PointOfService.HealthCheckLevel.Interactive); //Close device m_PosCommon.Close(); } catch (Exception) { } }
public void OpenCashDrawer(bool IsWaited = false) { try { string strLogicalName = "CashDrawer"; //PosExplorerを生成します。 PosExplorer posExplorer = new PosExplorer(); DeviceInfo deviceInfo = null; deviceInfo = posExplorer.GetDevice(DeviceType.CashDrawer, strLogicalName); m_Drawer = (CashDrawer)posExplorer.CreateInstance(deviceInfo); try { // m_Drawer.DeviceEnabled = true; } catch { } m_Drawer.Open(); m_Drawer.Claim(1000); //デバイスを使用可能(動作できる状態)にします。 m_Drawer.DeviceEnabled = true; } catch (PosControlException) { } m_Drawer.OpenDrawer(); // ドロワーが開いている間、待ちます。 while (m_Drawer.DrawerOpened == false) { System.Threading.Thread.Sleep(100); } //開いてから10秒間経っても閉じられない場合はビープ音を断続的に鳴らします。 //このメソッドを実行すると、ドロワーが閉じられるまで処理が戻ってこないので注意してください。 if (IsWaited) { m_Drawer.WaitForDrawerClose(10000, 2000, 100, 1000); } try { CloseCashDrawer(); } catch { try { m_Drawer = null; } catch { } } }
//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; } }
void explorer_DeviceAddedEvent(object sender, DeviceChangedEventArgs e) { if (e.Device.Type == "Scanner") { scanner = (Scanner)explorer.CreateInstance(e.Device); scanner.Open(); scanner.Claim(1000); scanner.DeviceEnabled = true; scanner.DataEvent += new DataEventHandler(scanner_DataEvent); scanner.DataEventEnabled = true; scanner.DecodeData = true; } }
private void init_scanner_and_printer() { PosExplorer exp = new PosExplorer(); DeviceInfo scanner_info = null, printer_info = null; string scanner_so_name = "SYMBOL_SCANNER"; string printer_so_name = "Star TSP100 Cutter (TSP143)_1"; DeviceCollection devices = exp.GetDevices(DeviceCompatibilities.OposAndCompatibilityLevel1); foreach (DeviceInfo info in devices) { Debug.WriteLine(info.Type + " \"" + info.ServiceObjectName + "\""); if (info.ServiceObjectName == scanner_so_name) { scanner_info = info; } else if (info.ServiceObjectName == printer_so_name) { printer_info = info; } } if (scanner_info == null) { Debug.WriteLine("Scanner \"" + scanner_so_name + "\" NOT found."); } else { Debug.WriteLine("Scanner \"" + scanner_so_name + "\" found."); s = (Scanner)exp.CreateInstance(scanner_info); test_scanner(s); } if (printer_info == null) { Debug.WriteLine("Printer \"" + printer_so_name + "\" NOT found."); } else { Debug.WriteLine("Printer \"" + printer_so_name + "\" found."); p = (PosPrinter)exp.CreateInstance(printer_info); open_claim_enable_printer(p); } }
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 PosPrinter GetReceiptPrinter() { PosExplorer posExplorer = new PosExplorer(this); //May need to change this if you don't use a logical name or use a different one. // Since, I don't know what is the printer's logical name DeviceInfo receiptPrinterDevice = posExplorer.GetDevice(DeviceType.PosPrinter.ToString()); return((PosPrinter)posExplorer.CreateInstance(receiptPrinterDevice)); }
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 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; } }
public IDNFC() { explorer = new PosExplorer(); var deviceCollection = explorer.GetDevices("RFIDScanner"); foreach (DeviceInfo deviceInfo in deviceCollection) { if (deviceInfo.ServiceObjectName != "FeigRFID") continue; nfc = (RFIDScanner)explorer.CreateInstance(deviceInfo); break; } }
private void InitializeScanner() { if (activeScanner != null) { if (activeScanner.DeviceEnabled || activeScanner.DataEventEnabled) { MessageBox.Show("USB Bar Scanner already enabled."); return; } } try { devExplorer = new PosExplorer(); try { DeviceCollection lUSBScanners = devExplorer.GetDevices(DeviceType.Scanner); foreach (DeviceInfo devInfo in lUSBScanners) { if (devInfo.ServiceObjectName == "USBHHScanner") { if (activeScanner == null) { activeScanner = devExplorer.CreateInstance(devInfo) as Scanner; } activeScanner.Open(); activeScanner.AutoDisable = true; activeScanner.DecodeData = true; activeScanner.Claim(1000); activeScanner.DataEvent += new DataEventHandler(activeScanner_DataEvent); activeScanner.ErrorEvent += new DeviceErrorEventHandler(activeScanner_ErrorDataEvent); activeScanner.DataEventEnabled = true; activeScanner.DeviceEnabled = true; } } } catch (Exception ex) { if (activeScanner.DataEventEnabled) { activeScanner.Release(); activeScanner.DeviceEnabled = true; } MessageBox.Show("Failed to find USB Scanner : " + ex.Message); } } catch (Exception ex) { MessageBox.Show("Pos Explorer : " + ex.Message); } }
private static void InitializeBumpBar() { DeviceCollection bumpBarList = BumpBarDeviceCollection; if (bumpBarList.Count > 0) { try { DeviceInfo bumpBar = GetActiveDeviceInfo(bumpBarList, "BumpBarName", true); if (bumpBar != null) { activeBumpBar = (BumpBar)explorer.CreateInstance(bumpBar); activeBumpBar.Open(); activeBumpBar.Claim(1000); activeBumpBar.DeviceEnabled = true; } } catch (PosControlException) { // Log error and set the active to nil activeBumpBar = null; Logger.Error("InitializePosDevices", Strings.InitializationException); } } }
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(); }
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 CashUnit() { explorer = new PosExplorer(); if (cashUnit == null) { var deviceCollection = explorer.GetDevices("CashChanger"); foreach (DeviceInfo deviceInfo in deviceCollection) { if (deviceInfo.ServiceObjectName != "Hoeft & Wessel Cash Unit") continue; cashUnit = (CashChanger)explorer.CreateInstance(deviceInfo); break; } } }
private async void Foo() { var explorer = new PosExplorer(new DispatcherThunk(this.Dispatcher)); var devices = explorer.GetDevices(DeviceType.Scanner); var scanner = (Scanner)explorer.CreateInstance(devices[1]); scanner.Open(); scanner.Claim(0); scanner.DeviceEnabled = true; scanner.DataEvent += Scanner_DataEvent; scanner.DataEventEnabled = true; scanner.DecodeData = true; this.OpenScanner = scanner; }
public FeigRFID() { PosExplorer explorer = new PosExplorer(); var deviceCollection = explorer.GetDevices("RFIDScanner"); FeigRFID rfid = null; foreach (DeviceInfo deviceInfo in deviceCollection) { if (deviceInfo.ServiceObjectName != "FeigRFID") continue; rfid = (FeigRFID)explorer.CreateInstance(deviceInfo); break; } }
public FeigRFID() { explorer = new PosExplorer(); if (rfid == null) { var deviceCollection = explorer.GetDevices("RFIDScanner"); foreach (DeviceInfo deviceInfo in deviceCollection) { if (deviceInfo.ServiceObjectName != "FeigRFID") continue; rfid = (RFIDScanner)explorer.CreateInstance(deviceInfo); log.Info(deviceInfo.ToString()); break; } } }
public ScannerManager() { checkTimer = new System.Windows.Threading.DispatcherTimer(); checkTimer.Interval = new TimeSpan(0, 0, 2); checkTimer.Tick += checkTimer_Tick; explorer = new PosExplorer(); scannerList = explorer.GetDevices(DeviceType.Scanner); try { foreach (DeviceInfo di in scannerList) { if (di.ServiceObjectName == "USBHHScanner") { activeScanner = (Scanner)explorer.CreateInstance(di); break; } } } catch (PosException) { } }
//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 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(); } }
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; } }