Exemplo n.º 1
0
        public void Print(RecordSet data, string printer_name = null, string copy = null)
        {
            IReportGen      gen    = new TecITGener();
            ReportGenConfig config = new ReportGenConfig()
            {
                Printer        = string.IsNullOrEmpty(printer_name) ? this.Name : printer_name,
                NumberOfCopies = string.IsNullOrEmpty(copy) ? this.Copy : int.Parse(copy),
                PrinterType    = (PrinterType)this.Type,
                Template       = this.TemplatePath
            };

            gen.Print(data, config);
        }
Exemplo n.º 2
0
        public ProcessMsg Print(Hashtable printConfig, PrintDataMessage pmsg)
        {
            ProcessMsg msg = new ProcessMsg();

            try
            {
                IReportGen gen = new TecITGener();
                foreach (PrintTask task in pmsg.PrintTask)
                {
                    task.Config.Printer        = printConfig["PrinterName"].ToString();
                    task.Config.NumberOfCopies = int.Parse(printConfig["Copy"].ToString());
                    task.Config.Template       = System.IO.Path.Combine(AppDomain.CurrentDomain.BaseDirectory, printConfig["Template"].ToString());
                    gen.Print(task.DataSet, task.Config);
                }
                msg.result = true;
                msg.AddMessage(ReturnCode.OK, "打印成功!");
            }
            catch (Exception e)
            {
                msg.result = false;
                msg.AddMessage(ReturnCode.Fail, "打印错误:" + e.Message);
            }
            return(msg);
        }
Exemplo n.º 3
0
        static void Main(string[] args)
        {
            colorHash.Add("R", "Red");
            colorHash.Add("Y", "Yellow");
            colorHash.Add("Br", "Brown");
            colorHash.Add("W", "White");
            colorHash.Add("Gr", "Grey");
            colorHash.Add("Or", "Orange");
            colorHash.Add("B", "Black");
            //string pattern = "^SIDE";
            //Regex r = new Regex(pattern, RegexOptions.IgnoreCase);
            //Regex rr = new Regex("\\w+", RegexOptions.IgnoreCase);
            //Match m = rr.Match("SIDE8");

            //Regex rrr = new Regex("^P", RegexOptions.IgnoreCase);
            //Match mm = rr.Match("PP00");

            //Console.WriteLine(mm.Groups[1].Value);
            //Console.WriteLine(r.Match("SIDE8").Success);
            //List<string> cs = Converts("YBr");
            //Console.WriteLine("--------------------YBr");
            //foreach (string c in cs) {
            //    Console.WriteLine(c);
            //}
            //Console.WriteLine("--------------------Y");
            //cs = Converts("Y");

            //foreach (string c in cs)
            //{
            //    Console.WriteLine(c);
            //}

            //cs = Converts("BY");
            //Console.WriteLine("--------------------BY");
            //foreach (string c in cs)
            //{
            //    Console.WriteLine(c);
            //}

            //cs = Converts("BrY");
            //Console.WriteLine("--------------------BrY");
            //foreach (string c in cs)
            //{
            //    Console.WriteLine(c);
            //}
            //cs = Converts("BrBrBrR");
            //Console.WriteLine("--------------------BrBrBrR");
            //foreach (string c in cs)
            //{
            //    Console.WriteLine(c);
            //}
            //Console.Read();

            string printer = Console.ReadLine();

            // Console.WriteLine(printer);
            // ConfigUtil config = new ConfigUtil("help.sdc");
            //// Console.WriteLine(config.Get("Host"));
            // Console.WriteLine(config.Notes());
            // foreach (string node in config.Notes()) {
            //     Console.WriteLine(node);
            //     Console.WriteLine(config.Get("Host",node));
            // }
            // foreach (string f in Directory.GetFiles(AppDomain.CurrentDomain.BaseDirectory, "*.sdc").ToList()) {
            //     Console.WriteLine(f);
            // }

            // Console.WriteLine(DateTime.Now.ToString("HHmmsss"));

            //   Console.WriteLine("J_0001,9".Split(',')[0].TrimStart("J_".ToCharArray()));
            try
            {
                RecordSet  rs = new RecordSet();
                RecordData rd = new RecordData();
                rd.Add("A", "AAA");
                rs.Add(rd);
                if (printer.Length == 0)
                {
                    printer = "Zebra ZM400 (203 dpi) - ZPL (副本 7)";
                }
                IReportGen      gen    = new TecITGener();
                ReportGenConfig config = new ReportGenConfig()
                {
                    //Printer = "Microsoft XPS Document Writer",
                    //Printer = "Zebra ZM400 (203 dpi) - ZPL (副本 3)",
                    Printer        = printer,
                    NumberOfCopies = 1,
                    PrinterType    = (PrinterType)0,
                    Template       = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "Template\\t2.tff")
                };

                gen.Print(rs, config);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.Message);
                Console.Read();
            }
        }