/// <summary> /// Creates a printing request based on the action, that is, /// the <see cref="IngenicoPrinterAction"/>. /// </summary> /// <param name="item">Item to print.</param> /// <returns>Request to print something through thermal printer.</returns> private PrtRequest GetRequestByType(PrinterItem item) { switch (item.Type) { case IngenicoPrinterAction.Start: return(this.CreateRequestToStartPrinting()); case IngenicoPrinterAction.PrintImage: return(this.CreateRequestToPrintLogo()); case IngenicoPrinterAction.PrintQrCode: return(this.CreateRequestToPrintQrCode(item)); case IngenicoPrinterAction.PrintText: return(this.CreateRequestToPrintText(item)); case IngenicoPrinterAction.SkipLine: return(this.CreateRequestToSkipLine(item)); case IngenicoPrinterAction.End: return(this.CreateRequestToFinishPrinting()); } return(null); }
public static dynamic GetTSObject(PrinterItem dynObject) { if (dynObject is null) { return(null); } return(dynObject.teklaObject); }
public void PrinterItem_Construction_ShouldReturnFontSizeDefaultValue_IfConstructorDoesNotModifyIt() { // Arrange && Act PrinterItem item = new PrinterItem(); // Assert Assert.AreEqual(item.FontSize, default(PrinterFontSize)); }
public void PrinterItem_Construction_ShouldReturnAlignmentDefaultValue_IfConstructorDoesNotModifyIt() { // Arrange && Act PrinterItem item = new PrinterItem(); // Assert Assert.AreEqual(item.Alignment, default(PrinterAlignmentCode)); }
public void PrinterItem_Construction_ShouldReturnStopsToSkipDefaultValue_IfConstructorDoesNotModifyIt() { // Arrange && Act PrinterItem item = new PrinterItem(); // Assert Assert.AreEqual(item.StepsToSkip, default(int)); }
public void PrinterItem_Construction_ShouldReturnTextDefaultValue_IfConstructorDoesNotModifyIt() { // Arrange && Act PrinterItem item = new PrinterItem(); // Assert Assert.AreEqual(item.Text, default(string)); }
public void PrinterItem_Construction_ShouldReturnTypeDefaultValue_IfConstructorDoesNotModifyIt() { // Arrange && Act PrinterItem item = new PrinterItem(); // Assert Assert.AreEqual(item.Type, default(IngenicoPrinterAction)); }
/// <summary> /// Creates a <see cref="PrtRequest"/> configured with skip lines. /// </summary> /// <param name="item">Item with skip configuration.</param> /// <returns>The skip line request.</returns> private PrtRequest CreateRequestToSkipLine(PrinterItem item) { PrtRequest skipLineRequest = new PrtRequest(); // Setup request to skip line: skipLineRequest.PRT_Action.Value = IngenicoPrinterAction.SkipLine; skipLineRequest.PRT_Steps.Value = item.StepsToSkip; return(skipLineRequest); }
/// <summary> /// Creates a <see cref="PrtRequest"/> configured with a text to print. /// </summary> /// <param name="item">Item with text to print information.</param> /// <returns>The text printing request.</returns> private PrtRequest CreateRequestToPrintText(PrinterItem item) { PrtRequest printTextRequest = new PrtRequest(); // Setup request to print text: printTextRequest.PRT_Action.Value = IngenicoPrinterAction.PrintText; printTextRequest.PRT_Alignment.Value = item.Alignment; printTextRequest.PRT_Size.Value = item.FontSize; printTextRequest.PRT_DATA.Value = item.Text; return(printTextRequest); }
public bool UpdatePrinterStatus(PrintGroupItem pgi, PrinterItem pi) { bool bRet = false; try { bRet = RemoteObject.UpdatePrinterStatus(pgi, pi); } catch (Exception ex) { throw new RemClientControlObjectProxyException("Call to printer service failed.", ex); } return(bRet); }
public bool RemovePrinterFromPrinterGroup(PrintGroupItem it, PrinterItem pi) { bool bRet = false; try { bRet = RemoteObject.RemovePrinterFromPrinterGroup(it, pi); } catch (Exception ex) { throw new RemClientControlObjectProxyException("Call to printer service failed.", ex); } return(bRet); }
public bool AddPrinterToPrintGroupItem(PrintGroupItem it, string PrinterName) { GlobalDataStore.Logger.Debug("RemClientControlObject.AddPrinterToPrintGroupItem"); bool bRet = false; string PrintJobsRootFolder; string LabelDefinitionsRootFolder; string PaperDefinitionsRootFolder; string SettingsRootFolder; string MachineName; int PollFrequency; PrintGroupItemList PrintGroups; PrintGroups = new PrintGroupItemList(); string AppPath = GlobalDataStore.AppPath; // System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); string RemotingConfigFilePath = AppPath + @"\ACALabelXClient.config.xml"; lock (GlobalDataStore.LockClass) { if (!File.Exists(RemotingConfigFilePath)) { throw new LabelXRemClientControlOjectException(string.Format("Remoting configuration file doesn't exist: {0}", RemotingConfigFilePath)); } } Toolbox.Toolbox toolbox = new Toolbox.Toolbox(); toolbox.GetGeneralClientConfiguratonEx(AppPath + @"\ACALabelXClient.config.xml", out PrintJobsRootFolder, out LabelDefinitionsRootFolder, out PaperDefinitionsRootFolder, out SettingsRootFolder, out MachineName, out PollFrequency, ref PrintGroups); //First check if the printgroupitem still exists foreach (PrintGroupItem item in PrintGroups) { if (item.Name.Equals(it.Name, StringComparison.OrdinalIgnoreCase)) { PrinterItem pi; pi = new PrinterItem(); pi.LongName = PrinterName; pi.Enabled = true; pi.Trays = new PrinterTrayItems(); bRet = Toolbox.Toolbox.StorePrinter(AppPath + @"\ACALabelXClient.config.xml", item, pi); break; } } return(bRet); }
/// <summary> /// Creates a <see cref="PrtRequest"/> configured with a QR code to print. /// </summary> /// <param name="item">Item with QR code information.</param> /// <returns>The QR code printing request.</returns> private PrtRequest CreateRequestToPrintQrCode(PrinterItem item) { PrtRequest printQrCodeRequest = new PrtRequest(); // Setup request to print a QR code: printQrCodeRequest.PRT_Action.Value = IngenicoPrinterAction.PrintQrCode; printQrCodeRequest.PRT_Size.Value = item.FontSize; printQrCodeRequest.PRT_Alignment.Value = item.Alignment; printQrCodeRequest.PRT_Horizontal.Value = 1; printQrCodeRequest.PRT_DATA.Value = item.Text; printQrCodeRequest.PRT_DATA.Value = printQrCodeRequest .PRT_DATA.Value; return(printQrCodeRequest); }
/// <summary> /// Add line of text to the printer buffer. /// </summary> /// <param name="alignment">Text alignment.</param> /// <param name="fontSize">Font size.</param> /// <param name="text">Text to print.</param> /// <param name="args">Arguments to the text to print.</param> /// <returns>Itself.</returns> public IPinpadPrinter AppendLine(PrinterAlignmentCode alignment, PrinterFontSize fontSize, string text, params object[] args) { PrinterItem newLine = new PrinterItem { Type = IngenicoPrinterAction.PrintText, Text = this.GetNormalizedText(string.Format(text, args)), Alignment = alignment, FontSize = fontSize }; this.ItemsToPrint.Add(newLine); return(this); }
public bool UpdatePrinterForPrintgroup(PrintGroupItem it, PrinterItem pi) { GlobalDataStore.Logger.Debug("RemClientControlObject.UpdatePrinterForPrintgroup"); bool bRet = true; string AppPath = GlobalDataStore.AppPath;; // System.IO.Path.GetDirectoryName(Assembly.GetEntryAssembly().Location); string sXMLFile; sXMLFile = AppPath + @"\ACALabelXClient.config.xml"; PrintGroupItem theItem; theItem = GetLabelPrintGroupByName(it.Name); //Retrieve again... could be changed on the server bRet = Toolbox.Toolbox.StorePrinter(sXMLFile, theItem, pi); return(bRet); }
/// <summary> /// Add QR code to the printer buffer. /// </summary> /// <param name="alignment">QR code alignment.</param> /// <param name="qrCodeMessage">QR code message.</param> /// <returns>Itself.</returns> public IPinpadPrinter AddQrCode(PrinterAlignmentCode alignment, string qrCodeMessage) { PrinterItem newQrCode = new PrinterItem { Type = IngenicoPrinterAction.PrintQrCode, FontSize = PrinterFontSize.Big, Alignment = alignment, Text = qrCodeMessage }; this.ItemsToPrint.Add(newQrCode); return(this); }
/// <summary> /// Add Stone logotype to the printer buffer. /// </summary> /// <returns>Itself.</returns> public IPinpadPrinter AddLogo() { // If image does not exist in pinpad memory: if (this.VerifyIfLogoExists() == false) { // Loads the image into the memory: this.ReloadImage(); } PrinterItem newQrCode = new PrinterItem { Type = IngenicoPrinterAction.PrintImage }; this.ItemsToPrint.Add(newQrCode); return(this); }
public PrinterItems GetLocalPrintersEx() { GlobalDataStore.Logger.Debug("RemClientControlObject.GetLocalPrintersEx"); PrinterItems retItems = new PrinterItems(); System.Printing.LocalPrintServer localServer; localServer = new System.Printing.LocalPrintServer(); System.Printing.EnumeratedPrintQueueTypes[] myEnum = { EnumeratedPrintQueueTypes.Connections , EnumeratedPrintQueueTypes.Local }; System.Printing.PrintQueueCollection col = localServer.GetPrintQueues(myEnum); foreach (System.Printing.PrintQueue qit in col) { PrinterItem it; it = new PrinterItem(); it.QueueLength = qit.NumberOfJobs; it.LongName = qit.FullName; it.ShortName = qit.Name; it.Enabled = true; it.Online = !qit.IsOffline; it.NeedsUserIntervention = qit.NeedUserIntervention; System.Drawing.Printing.PrinterSettings ps; ps = new System.Drawing.Printing.PrinterSettings(); ps.PrinterName = qit.FullName; foreach (System.Drawing.Printing.PaperSource src in ps.PaperSources) { PrinterTrayItem theTray; theTray = new PrinterTrayItem(); theTray.TrayName = src.SourceName; it.Trays.Add(theTray); } retItems.Add(it); } col.Dispose(); return(retItems); }
public bool RemovePrinterFromPrinterGroup(PrintGroupItem it, PrinterItem pi) { GlobalDataStore.Logger.Debug("RemClientControlObject.RemovePrinterFromPrinterGroup"); return(RemovePrinterFromPrinterGroup(it, pi.LongName)); }
public bool UpdatePrinterStatus(PrintGroupItem it, PrinterItem pi) { GlobalDataStore.Logger.Debug("RemClientControlObject.UpdatePrinterStatus"); return(UpdatePrinterStatus(it, pi.LongName, pi.Enabled)); }
public ACA.LabelX.Toolbox.PrintGroupItem GetLabelPrintGroupByName(string sName) { GlobalDataStore.Logger.Debug("RemClientControlObject.GetLabelPrintGroupByName"); string AppPath = GlobalDataStore.AppPath; string RemotingConfigFilePath = AppPath + @"\ACALabelXClient.config.xml"; FileInfo fi; fi = new FileInfo(RemotingConfigFilePath); if (!fi.Exists) { throw new LabelXRemClientControlOjectException(string.Format("Remoting configuration file doesn't exist: {0}", RemotingConfigFilePath)); } // if (!File.Exists(RemotingConfigFilePath)) // throw new LabelXRemClientControlOjectException(string.Format("Remoting configuration file doesn't exist: {0}", RemotingConfigFilePath)); PrintGroupItem pgItem = null; lock (GlobalDataStore.LockClass) { XPathDocument theDoc; XPathNavigator nav; string sHelp; try { theDoc = new XPathDocument(RemotingConfigFilePath); } catch (System.Xml.XmlException e1) { ApplicationException e2; e2 = new ApplicationException(string.Format("XML syntax error in {0}: {1}", RemotingConfigFilePath, e1.Message), e1); throw e2; } nav = theDoc.CreateNavigator(); XPathNodeIterator nit; nit = nav.Select("/configuration/general-settings/print-groups/print-group[@name='" + sName + "']"); if (nit != null) { nit.MoveNext(); pgItem = new PrintGroupItem(); pgItem.GroupPrinters = new PrinterItems(); pgItem.Name = nit.Current.GetAttribute("name", string.Empty); pgItem.Enabled = nit.Current.GetAttribute("enabled", string.Empty).Equals("true", StringComparison.OrdinalIgnoreCase); nit = nav.Select("/configuration/general-settings/print-groups/print-group[@name='" + sName + "']/printer"); while (nit.MoveNext()) { PrinterItem pit; pit = new PrinterItem(); sHelp = nit.Current.GetAttribute("name", string.Empty); pit.LongName = sHelp; sHelp = nit.Current.GetAttribute("enabled", string.Empty); pit.Enabled = sHelp.Equals("true", StringComparison.OrdinalIgnoreCase); //Retrieve some other data for this printer... System.Printing.LocalPrintServer localServer; localServer = new System.Printing.LocalPrintServer(); System.Printing.PrintQueueCollection col; System.Printing.EnumeratedPrintQueueTypes[] myEnum = { EnumeratedPrintQueueTypes.Connections , EnumeratedPrintQueueTypes.Local }; col = localServer.GetPrintQueues(myEnum); System.Printing.PrintQueue theQueue = null; foreach (System.Printing.PrintQueue q in col) { if (q.FullName.Equals(pit.LongName, StringComparison.OrdinalIgnoreCase)) { theQueue = q; break; } } if (theQueue != null) { pit.QueueLength = theQueue.NumberOfJobs; pit.ShortName = theQueue.Name; pit.Online = !theQueue.IsOffline; pit.NeedsUserIntervention = theQueue.NeedUserIntervention; // //theQueue.NeedUserIntervention; } else { pit.QueueLength = 0; pit.NeedsUserIntervention = false; pit.ShortName = pit.LongName; pit.Online = true; } if (col != null) { col.Dispose(); col = null; } if (theQueue != null) { theQueue.Dispose(); theQueue = null; } if (nit.Current.HasChildren) { //nit.Current.MoveToFirstChild(); nit.Current.MoveToFirstChild(); //MoveToNext("tray", nav.LookupNamespace(nav.Prefix))) do { PrinterTrayItem ptit; ptit = new PrinterTrayItem(); ptit.TrayName = nit.Current.GetAttribute("name", string.Empty); ptit.CurrentPapertypeName = nit.Current.GetAttribute("papertype", string.Empty); pit.Trays.Add(ptit); } while (nit.Current.MoveToNext("tray", nav.LookupNamespace(nav.Prefix))); nit.Current.MoveToParent(); } //pit.CurrentPapertypeName = nit.Current.GetAttribute("papertype",string.Empty); //pit.Tray = nit.Current.GetAttribute("tray", string.Empty); pgItem.GroupPrinters.Add(pit); localServer.Dispose(); } } } return(pgItem); }