Ejemplo n.º 1
0
        public void PrintAH1501_05(DataTable dt, string printerConnection)
        {
            string destinationDevice     = printerConnection;
            string templateFilename      = "D:\\AH1501-05.prn";
            string defaultQuantityString = "1";
            bool   verbose = true;

            try
            {
                foreach (DataRow row in dt.Rows)
                {
                    using (MemoryStream outputDataStream = new MemoryStream())
                    {
                        using (Stream sourceStream = XmlData(dt))
                        {
                            XmlPrinter.Print(destinationDevice, sourceStream, templateFilename, defaultQuantityString, outputDataStream, verbose);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 2
0
        public void PrintAB(DataTable dt, string printerConnection)
        {
            string destinationDevice     = printerConnection;
            string templateFilename      = "D:\\AB0801-04.prn";
            string defaultQuantityString = "1";
            bool   verbose = true;

            try
            {
                foreach (DataRow row in dt.Rows)
                {
                    using (MemoryStream outputDataStream = new MemoryStream())
                    {
                        string serialNumber = row["serialNumber"].ToString();
                        string week         = row["week"].ToString();
                        string customerPart = row["customerPart"].ToString();
                        string direction    = row["direction"].ToString();
                        string qrCode       = row["qrCode"].ToString();

                        using (Stream sourceStream = XmlData(customerPart, qrCode, serialNumber, week, direction))
                        {
                            XmlPrinter.Print(destinationDevice, sourceStream, templateFilename, defaultQuantityString, outputDataStream, verbose);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 3
0
        private static void Printing(Stream xmlData, string templatePath)
        {
            string destinationDevice     = GetUSBConnection();
            string templateFilename      = templatePath;
            string defaultQuantityString = "1";
            bool   verbose = true;

            try
            {
                using (MemoryStream outputDataStream = new MemoryStream())
                {
                    using (Stream sourceStream = xmlData)
                    {
                        XmlPrinter.Print(destinationDevice, sourceStream, templateFilename, defaultQuantityString, outputDataStream, verbose);
                    }
                }
            }
            catch (Exception e)
            {
                MessageBox.Show(e.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }
Ejemplo n.º 4
0
        public static void Main(string[] args)
        {
            var data = "Hello World !";
            AbstractMediator abstractMediator = new Mediator.Mediator();

            AbstractPrinter textPrinter = new TextPrinter(abstractMediator);
            AbstractPrinter xmlPrinter  = new XmlPrinter(abstractMediator);
            AbstractPrinter htmlPrinter = new HtmlPrinter(abstractMediator);

            abstractMediator.Register(textPrinter);
            abstractMediator.Register(xmlPrinter);
            abstractMediator.Register(htmlPrinter);

            Console.WriteLine("Text Printer talking ......\n");
            textPrinter.Print(data, textPrinter.PrinterType);
            textPrinter.PrintToOtherFormat(data, xmlPrinter.PrinterType, textPrinter.PrinterType);

            Console.WriteLine("\nText Printer talking ......\n");
            xmlPrinter.Print(data, xmlPrinter.PrinterType);
            xmlPrinter.PrintToOtherFormat(data, textPrinter.PrinterType, xmlPrinter.PrinterType);

            Console.WriteLine("\nText Printer talking ......\n");
            htmlPrinter.PrintToOtherFormat(data, xmlPrinter.PrinterType, htmlPrinter.PrinterType);
        }