Просмотр исходного кода

Use 10cpi font for printing voucher PINs.
Remove emphasise-on command from printer init string.

Andrew Klopper лет назад: 7
Родитель
Сommit
84b2b3761e

+ 9 - 1
BulkPrinting/BulkPrinting/Globals.cs

23
         public static LogUploader LogUploader;
23
         public static LogUploader LogUploader;
24
         public static LogDownloader LogDownloader;
24
         public static LogDownloader LogDownloader;
25
 
25
 
26
-        public static string DefaultPrinterInitString = "1B401B451B55301B4D1B43000C";
26
+        // NOTE: The printer must be in Epson emulation mode for these commands to work. If the printer is in the
27
+        // wrong emulation mode (e.g. IBM PPR) then unexpected things will happen, such as the final '0C' of the 12 inch
28
+        // page length command resulting in an unwanted form feed.
29
+        public static string DefaultPrinterInitString =
30
+            "1B40" +        // Initialise printer
31
+            //"1B45" +        // Emphasise on
32
+            "1B5530" +      // Unidirectional off
33
+            "1B4D" +        // 12cpi, 10.5pt
34
+            "1B43000C";     // Page length 12 inches
27
     }
35
     }
28
 }
36
 }

+ 1 - 1
BulkPrinting/BulkPrinting/PrintAlignmentDialog.cs

78
                 //AlignmentPage += "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\r\n";
78
                 //AlignmentPage += "ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789\r\n";
79
                 
79
                 
80
                 AlignmentPage += "\r\n\n\n" +
80
                 AlignmentPage += "\r\n\n\n" +
81
-                "[--VOUCHER  PIN  CODE--]      [--VOUCHER  PIN  CODE--]      [--VOUCHER  PIN  CODE--]       [--VOUCHER  PIN  CODE--]      [--VOUCHER  PIN  CODE--]\r\n\n" +
81
+                "\x1B\x50[-VOUCHER PIN CODE-]     [-VOUCHER PIN CODE-]     [-VOUCHER PIN CODE-]      [-VOUCHER PIN CODE-]     [-VOUCHER PIN CODE-]\x1B\x4D\r\n\n" +
82
                 "[--VOUCHER SERIAL NUM--]      [--VOUCHER SERIAL NUM--]      [--VOUCHER SERIAL NUM--]       [--VOUCHER SERIAL NUM--]      [--VOUCHER SERIAL NUM--]\r\n" +
82
                 "[--VOUCHER SERIAL NUM--]      [--VOUCHER SERIAL NUM--]      [--VOUCHER SERIAL NUM--]       [--VOUCHER SERIAL NUM--]      [--VOUCHER SERIAL NUM--]\r\n" +
83
                 "[--BATCHNO/SEQNO/PAGE--]      [--BATCHNO/SEQNO/PAGE--]      [--BATCHNO/SEQNO/PAGE--]       [--BATCHNO/SEQNO/PAGE--]      [--BATCHNO/SEQNO/PAGE--]\r\n" +
83
                 "[--BATCHNO/SEQNO/PAGE--]      [--BATCHNO/SEQNO/PAGE--]      [--BATCHNO/SEQNO/PAGE--]       [--BATCHNO/SEQNO/PAGE--]      [--BATCHNO/SEQNO/PAGE--]\r\n" +
84
                 "[--VOUCHERDESCRIPTION--]      [--VOUCHERDESCRIPTION--]      [--VOUCHERDESCRIPTION--]       [--VOUCHERDESCRIPTION--]      [--VOUCHERDESCRIPTION--]\r\n" +
84
                 "[--VOUCHERDESCRIPTION--]      [--VOUCHERDESCRIPTION--]      [--VOUCHERDESCRIPTION--]       [--VOUCHERDESCRIPTION--]      [--VOUCHERDESCRIPTION--]\r\n" +

+ 1 - 1
BulkPrinting/BulkPrinting/Properties/AssemblyInfo.cs

33
 // by using the '*' as shown below:
33
 // by using the '*' as shown below:
34
 // [assembly: AssemblyVersion("1.0.*")]
34
 // [assembly: AssemblyVersion("1.0.*")]
35
 [assembly: AssemblyVersion("1.0.*")]
35
 [assembly: AssemblyVersion("1.0.*")]
36
-[assembly: AssemblyFileVersion("1.9")]
36
+[assembly: AssemblyFileVersion("1.10")]

+ 15 - 13
BulkPrinting/BulkPrinting/Utility.cs

37
 
37
 
38
         public static string GetPrinterInitString(DBHelper db)
38
         public static string GetPrinterInitString(DBHelper db)
39
         {
39
         {
40
-            var hex = GetSavedParameter(db, "PrinterInitString");
40
+            //var hex = GetSavedParameter(db, "PrinterInitString");
41
+            var hex = Globals.DefaultPrinterInitString;
41
             return Encoding.ASCII.GetString(HexStringToBytes(hex));
42
             return Encoding.ASCII.GetString(HexStringToBytes(hex));
42
         }
43
         }
43
 
44
 
438
             string VendorId = Globals.SessionData.Credentials.Payload.Vendor.id.ToString();
439
             string VendorId = Globals.SessionData.Credentials.Payload.Vendor.id.ToString();
439
 
440
 
440
             var PrinterInitString = GetPrinterInitString(db);
441
             var PrinterInitString = GetPrinterInitString(db);
441
-            int initJobID = Globals.MaxPrinter.Open("Printer_Init");
442
+            int initJobID = Globals.MaxPrinter.Open("Vouchers");
442
             if (initJobID == 0) return;
443
             if (initJobID == 0) return;
443
             Globals.MaxPrinter.Print(PrinterInitString.ToString());
444
             Globals.MaxPrinter.Print(PrinterInitString.ToString());
444
-            Globals.MaxPrinter.Close();
445
+            //Globals.MaxPrinter.Close();
445
 
446
 
446
             List<EventLog> LogEvents = new List<EventLog>();
447
             List<EventLog> LogEvents = new List<EventLog>();
447
 
448
 
453
             {
454
             {
454
                 using (SQLiteDataReader read = Command.ExecuteReader())
455
                 using (SQLiteDataReader read = Command.ExecuteReader())
455
                 {
456
                 {
456
-                    int JobID = Globals.MaxPrinter.Open("Vouchers");
457
-                    if (JobID == 0) return;
457
+                    //int JobID = Globals.MaxPrinter.Open("Vouchers");
458
+                    //if (JobID == 0) return;
458
                     while (read.Read())
459
                     while (read.Read())
459
                     {
460
                     {
460
                         VoucherCount++;
461
                         VoucherCount++;
477
                         if (VoucherCount >= 5 || TotalCount == (EndSeqNo - StartSeqNo))
478
                         if (VoucherCount >= 5 || TotalCount == (EndSeqNo - StartSeqNo))
478
                         {
479
                         {
479
                             RowCount++;
480
                             RowCount++;
480
-                            string PrintRow = "\r\n\n\n  ";
481
+                            string PrintRow = "\r\n\n\n\x1B\x50  ";
481
                             for (int Column = 0; Column < VoucherRow.Count(); Column++)
482
                             for (int Column = 0; Column < VoucherRow.Count(); Column++)
482
                             {
483
                             {
483
                                 IndividualVoucher = VoucherRow[Column];
484
                                 IndividualVoucher = VoucherRow[Column];
484
-                                PrintRow += (Column == 2 ? " " : "") + ("  " + IndividualVoucher.DecryptedPIN).PadRight(30, ' ');
485
+                                PrintRow += (Column == 3 ? " " : "") + (IndividualVoucher.DecryptedPIN).PadRight(25, ' ');
485
                             }
486
                             }
486
-                            PrintRow = PrintRow.TrimEnd() + "\r\n\n  ";
487
+                            PrintRow = PrintRow.TrimEnd() + "\x1B\x4D\r\n\n  ";
487
                             for (int Column = 0; Column < VoucherRow.Count(); Column++)
488
                             for (int Column = 0; Column < VoucherRow.Count(); Column++)
488
                             {
489
                             {
489
                                 IndividualVoucher = VoucherRow[Column];
490
                                 IndividualVoucher = VoucherRow[Column];
492
                                 {
493
                                 {
493
                                     SerialNumberTrimmed = SerialNumberTrimmed.Substring(0, 24);
494
                                     SerialNumberTrimmed = SerialNumberTrimmed.Substring(0, 24);
494
                                 }
495
                                 }
495
-                                PrintRow += (Column == 2 ? " " : "") + SerialNumberTrimmed.PadRight(30, ' ');
496
+                                PrintRow += (Column == 3 ? " " : "") + SerialNumberTrimmed.PadRight(30, ' ');
496
                             }
497
                             }
497
                             PrintRow = PrintRow.TrimEnd() + "\r\n  ";
498
                             PrintRow = PrintRow.TrimEnd() + "\r\n  ";
498
                             for (int Column = 0; Column < VoucherRow.Count(); Column++)
499
                             for (int Column = 0; Column < VoucherRow.Count(); Column++)
499
                             {
500
                             {
500
                                 IndividualVoucher = VoucherRow[Column];
501
                                 IndividualVoucher = VoucherRow[Column];
501
                                 int CurrentPage = (int)Math.Ceiling(((decimal)IndividualVoucher.SequenceNumber) / 20);
502
                                 int CurrentPage = (int)Math.Ceiling(((decimal)IndividualVoucher.SequenceNumber) / 20);
502
-                                PrintRow += (Column == 2 ? " " : "") + String.Format("{0}/{1}/{2}", IndividualVoucher.BatchId, IndividualVoucher.SequenceNumber, PageCount).PadRight(30, ' ');
503
+                                PrintRow += (Column == 3 ? " " : "") + String.Format("{0}/{1}/{2}", IndividualVoucher.BatchId, IndividualVoucher.SequenceNumber, PageCount).PadRight(30, ' ');
503
                             }
504
                             }
504
                             PrintRow = PrintRow.TrimEnd() + "\r\n  ";
505
                             PrintRow = PrintRow.TrimEnd() + "\r\n  ";
505
                             for (int Column = 0; Column < VoucherRow.Count(); Column++)
506
                             for (int Column = 0; Column < VoucherRow.Count(); Column++)
506
                             {
507
                             {
507
                                 IndividualVoucher = VoucherRow[Column];
508
                                 IndividualVoucher = VoucherRow[Column];
508
-                                PrintRow += (Column == 2 ? " " : "") + IndividualVoucher.Description.PadRight(30, ' ');
509
+                                PrintRow += (Column == 3 ? " " : "") + IndividualVoucher.Description.PadRight(30, ' ');
509
                             }
510
                             }
510
                             PrintRow = PrintRow.TrimEnd() + "\r\n  ";
511
                             PrintRow = PrintRow.TrimEnd() + "\r\n  ";
511
                             for (int Column = 0; Column < VoucherRow.Count(); Column++)
512
                             for (int Column = 0; Column < VoucherRow.Count(); Column++)
512
                             {
513
                             {
513
-                                PrintRow += (Column == 2 ? " " : "") + VendorId.PadRight(30, ' ');
514
+                                PrintRow += (Column == 3 ? " " : "") + VendorId.PadRight(30, ' ');
514
                             }
515
                             }
515
 
516
 
516
                             PrintRow = PrintRow.TrimEnd() + "\r\n\n\n\n\n\n\n\n\n\n";
517
                             PrintRow = PrintRow.TrimEnd() + "\r\n\n\n\n\n\n\n\n\n\n";
536
                         }
537
                         }
537
                         TotalCount++;
538
                         TotalCount++;
538
                     }
539
                     }
539
-                    Globals.MaxPrinter.Close();
540
+                    //Globals.MaxPrinter.Close();
540
                 }
541
                 }
541
             }
542
             }
543
+            Globals.MaxPrinter.Close();
542
             LogBulkEvents(db, LogEvents);
544
             LogBulkEvents(db, LogEvents);
543
         }
545
         }
544
 
546