Ejemplo n.º 1
0
        static void Command(string input)
        {
            if (input.ToLower().StartsWith("exit"))
            {
                var stream = proxy.Journal(0x4154000000000001, 0, DateTime.UtcNow.Ticks);
                var sr     = new System.IO.StreamReader(stream);

                Console.WriteLine("{0:G} ========== RKSV-DEP ==========", DateTime.Now);

                Console.WriteLine(sr.ReadToEnd());

                Environment.Exit(0);
            }


            Random r = new Random((int)DateTime.Now.Ticks);

            int inputInt;

            if (!int.TryParse(input, out inputInt))
            {
                Console.WriteLine($"\"{input}\" nicht erkannt.");
                return;
            }

            if (inputInt == 1)
            {
                var req = UseCase17Request(++i, decimal.Round((decimal)(r.NextDouble() * 100), 2), decimal.Round((decimal)(r.NextDouble() * 100), 2), cashBoxId);
                Console.WriteLine("{0:G} Barumsatz request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));

                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 2)
            {
                var req = ZeroReceiptRequest(++i, cashBoxId, 0x4154000000000002);
                Console.WriteLine("{0:G} Null-Beleg request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 3)
            {
                var req = ZeroReceiptRequest(++i, cashBoxId, 0x4154000000000003);
                Console.WriteLine("{0:G} Inbetriebnahme-Beleg request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 4)
            {
                var req = ZeroReceiptRequest(++i, cashBoxId, 0x4154000000000004);
                Console.WriteLine("{0:G} Außerbetriebnahme-Beleg request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 5)
            {
                var req = ZeroReceiptRequest(++i, cashBoxId, 0x4154000000000005);
                Console.WriteLine("{0:G} Monats-Beleg request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 6)
            {
                var req = ZeroReceiptRequest(++i, cashBoxId, 0x4154000000000006);
                Console.WriteLine("{0:G} Jahres-Beleg request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 7)
            {
                var req = UseCase17Request(++i, decimal.Round((decimal)(r.NextDouble() * 100), 2), decimal.Round((decimal)(r.NextDouble() * 100), 2), cashBoxId);

                req.ftReceiptCase |= 0x010000;


                Console.WriteLine("{0:G} Barumsatz request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));

                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 9)
            {
                string filename = $"c:\\temp\\{cashBoxId}_{DateTime.UtcNow.Ticks}.json";

                Console.Write("{0:G} RKSV-DEP export ({1})", DateTime.Now, filename);

                string inputFilename = Console.ReadLine();
                if (!string.IsNullOrWhiteSpace(inputFilename))
                {
                    filename = inputFilename;
                }

                using (var file = System.IO.File.Open(filename, System.IO.FileMode.Create))
                {
                    using (var journal = proxy.Journal(0x4154000000000001, 0, 0 /*(new DateTime(2999,12,31)).Ticks*/))
                    {
                        journal.CopyTo(file);
                    }

                    Console.WriteLine("{0:G} RKSV-DEP exportiert nach {1} ({2:0.00}Mb)", DateTime.Now, filename, ((decimal)file.Length) / 1024m / 1024m);
                }
            }
            else if (inputInt >= 10 && inputInt < MAX_GENERATED_RECEIPT_COUNT)
            {
                long max = long.MinValue;
                long min = long.MaxValue;
                long sum = 0;
                int  n   = 0;
                while (n++ < inputInt)
                {
                    var sw = new System.Diagnostics.Stopwatch();
                    sw.Start();
                    var req  = UseCase17Request(++i, decimal.Round((decimal)(r.NextDouble() * 100), 2), decimal.Round((decimal)(r.NextDouble() * 100), 2), cashBoxId);
                    var resp = proxy.Sign(req);
                    sw.Stop();
                    sum += sw.ElapsedMilliseconds;
                    if (sw.ElapsedMilliseconds > max)
                    {
                        max = sw.ElapsedMilliseconds;
                    }
                    if (sw.ElapsedMilliseconds < min)
                    {
                        min = sw.ElapsedMilliseconds;
                    }
                    Response(resp);
                }

                Console.WriteLine("Performance in ms => max: {0}, min: {1}, avg: {2}", max, min, sum / (decimal)inputInt);
            }
            else
            {
                Console.WriteLine($"\"{input}\" nicht erkannt.");
            }

            Menu();
        }
Ejemplo n.º 2
0
        static void Command(string input)
        {
            if (input.ToLower().StartsWith("exit"))
            {
                var stream = proxy.Journal(0xFE, 0, DateTime.UtcNow.Ticks);
                var sr     = new System.IO.StreamReader(stream);

                Console.WriteLine("{0:G} ========== Default Journal ==========", DateTime.Now);

                Console.WriteLine(sr.ReadToEnd());

                Environment.Exit(0);
            }

            Random r = new Random((int)DateTime.Now.Ticks);

            int inputInt;

            if (!int.TryParse(input, out inputInt))
            {
                Console.WriteLine($"\"{input}\" not recognised.");
                return;
            }

            if (inputInt == 1)
            {
                var req = TicketRequest(++i, decimal.Round((decimal)(r.NextDouble() * 100), 2), decimal.Round((decimal)(r.NextDouble() * 100), 2), cashBoxId);

                Console.WriteLine("{0:G} Ticket request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 2)
            {
                var req = PaymentProveRequest(++i, decimal.Round((decimal)(r.NextDouble() * 100), 2), decimal.Round((decimal)(r.NextDouble() * 100), 2), cashBoxId);

                Console.WriteLine("{0:G} Payment Prove request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 3)
            {
                var req = InvoiceRequest(++i, decimal.Round((decimal)(r.NextDouble() * 100), 2), decimal.Round((decimal)(r.NextDouble() * 100), 2), cashBoxId);

                Console.WriteLine("{0:G} Invoice request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 4)
            {
                var req = ZeroReceiptRequest(++i, cashBoxId, GetReceiptCase(0x4652000000000004));

                Console.WriteLine("{0:G} Shift Receipt request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 5)
            {
                var req = ZeroReceiptRequest(++i, cashBoxId, GetReceiptCase(0x4652000000000005));

                Console.WriteLine("{0:G} Daily Receipt request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 6)
            {
                var req = ZeroReceiptRequest(++i, cashBoxId, GetReceiptCase(0x4652000000000006));

                Console.WriteLine("{0:G} Monthly Receipt request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 7)
            {
                var req = ZeroReceiptRequest(++i, cashBoxId, GetReceiptCase(0x4652000000000007));

                Console.WriteLine("{0:G} Yearly Receipt request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 8)
            {
                var req = BillRequest(++i, decimal.Round((decimal)(r.NextDouble() * 100), 2), decimal.Round((decimal)(r.NextDouble() * 100), 2), cashBoxId);

                Console.WriteLine("{0:G} Bill request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));

                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 9)
            {
                var req = DeliveryNoteRequest(++i, decimal.Round((decimal)(r.NextDouble() * 100), 2), decimal.Round((decimal)(r.NextDouble() * 100), 2), cashBoxId);

                Console.WriteLine("{0:G} Delivery Note request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));

                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 10)
            {
                var req = CashDepositRequest(++i, decimal.Round((decimal)(r.NextDouble() * 100), 2), decimal.Round((decimal)(r.NextDouble() * 100), 2), cashBoxId);

                Console.WriteLine("{0:G} Cash Deposit request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));

                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 11)
            {
                var req = PayoutRequest(++i, decimal.Round((decimal)(r.NextDouble() * 100), 2), decimal.Round((decimal)(r.NextDouble() * 100), 2), cashBoxId);

                Console.WriteLine("{0:G} Payout request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 12)
            {
                var req = PaymentTransferRequest(++i, decimal.Round((decimal)(r.NextDouble() * 100), 2), decimal.Round((decimal)(r.NextDouble() * 100), 2), cashBoxId);

                Console.WriteLine("{0:G} Payment Transfer request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 13)
            {
                var req = InternalRequest(++i, decimal.Round((decimal)(r.NextDouble() * 100), 2), decimal.Round((decimal)(r.NextDouble() * 100), 2), cashBoxId);

                Console.WriteLine("{0:G} Internal request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 14)
            {
                var req = ForeignSaleRequest(++i, decimal.Round((decimal)(r.NextDouble() * 100), 2), decimal.Round((decimal)(r.NextDouble() * 100), 2), cashBoxId);

                Console.WriteLine("{0:G} Foreign Sale request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 15)
            {
                var req = ZeroReceiptRequest(++i, cashBoxId, GetReceiptCase(0x465200000000000F));

                Console.WriteLine("{0:G} Zero Receipt request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 16)
            {
                var req = ZeroReceiptRequest(++i, cashBoxId, GetReceiptCase(0x4652000000000010));

                Console.WriteLine("{0:G} Start Receipt request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 17)
            {
                var req = ZeroReceiptRequest(++i, cashBoxId, GetReceiptCase(0x4652000000000011));

                Console.WriteLine("{0:G} Stop Receipt request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 18)
            {
                var req = ZeroReceiptRequest(++i, cashBoxId, GetReceiptCase(0x4652000000000012));

                Console.WriteLine("{0:G} Log Receipt request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 19)
            {
                var req = ZeroReceiptRequest(++i, cashBoxId, GetReceiptCase(0x4652000000000013));

                Console.WriteLine("{0:G} Audit Receipt request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 20)
            {
                var req = ZeroReceiptRequest(++i, cashBoxId, GetReceiptCase(0x4652000000000014));

                Console.WriteLine("{0:G} Protocol Receipt request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 21)
            {
                var req = ZeroReceiptRequest(++i, cashBoxId, GetReceiptCase(0x4652000000000015));

                Console.WriteLine("{0:G} Archive Receipt request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 22)
            {
                Console.WriteLine("Enter the receipt reference for the requested copy: [1]");

                var req = ZeroReceiptRequest(++i, cashBoxId, GetReceiptCase(0x4652000000000016));

                req.ftReceiptCaseData = Console.ReadLine();

                if (string.IsNullOrWhiteSpace(req.ftReceiptCaseData))
                {
                    req.ftReceiptCaseData = "1";
                }

                Console.WriteLine("{0:G} Copy Receipt request: {1}", DateTime.Now, JsonConvert.SerializeObject(req));
                var resp = proxy.Sign(req);

                Response(resp);
            }
            else if (inputInt == 23)
            {
                isTraining = !isTraining;
            }
            else if (inputInt == 24)
            {
                string path = $"c:\\temp";

                Console.Write("{0:G} Journal export folder ({1})", DateTime.Now, path);

                string inputPath = Console.ReadLine();
                if (!string.IsNullOrWhiteSpace(inputPath))
                {
                    path = inputPath;
                }

                ExportJournal(path, 0x4652000000000001, "Ticket");
                ExportJournal(path, 0x4652000000000002, "Payment Prove");
                ExportJournal(path, 0x4652000000000003, "Invoice");
                ExportJournal(path, 0x4652000000000004, "Grand Total");
                ExportJournal(path, 0x4652000000000007, "Bill");
                ExportJournal(path, 0x4652000000000008, "Archive");
                ExportJournal(path, 0x4652000000000009, "Log");
                ExportJournal(path, 0x465200000000000A, "Copy");
                ExportJournal(path, 0x465200000000000B, "Training");
            }
            else if (inputInt >= 25 && inputInt < MAX_GENERATED_RECEIPT_COUNT)
            {
                long max = long.MinValue;
                long min = long.MaxValue;
                long sum = 0;
                int  n   = 0;
                while (n++ < inputInt)
                {
                    var sw = new System.Diagnostics.Stopwatch();
                    sw.Start();
                    var req = TicketRequest(++i, decimal.Round((decimal)(r.NextDouble() * 100), 2), decimal.Round((decimal)(r.NextDouble() * 100), 2), cashBoxId);

                    var resp = proxy.Sign(req);
                    sw.Stop();
                    sum += sw.ElapsedMilliseconds;
                    if (sw.ElapsedMilliseconds > max)
                    {
                        max = sw.ElapsedMilliseconds;
                    }
                    if (sw.ElapsedMilliseconds < min)
                    {
                        min = sw.ElapsedMilliseconds;
                    }
                    Response(resp);
                }

                Console.WriteLine("Performance in ms => max: {0}, min: {1}, avg: {2}", max, min, sum / (decimal)inputInt);
            }
            else
            {
                Console.WriteLine($"\"{input}\" not recognised.");
            }

            Menu();
        }
Ejemplo n.º 3
0
 private static string GetJournal(int inputInt)
 {
     using var streamReader = new StreamReader(_pos.Journal(inputInt, 0, long.MaxValue));
     return(streamReader.ReadToEnd());
 }
 public Stream Journal(long ftJournalType, long from, long to) => _innerPOS.Journal(ftJournalType, from, to);