示例#1
0
        public int PrintThree(string[] info, List <string> code, PrintStatus _one)
        {
            one       = _one;
            this.info = info;
            this.code = code;
            // MessageBox.Show("555");
            string code_3 = "";
            int    i      = 0;

            foreach (string oneCode in this.code)
            {
                while (true)
                {
                    if (workFlag)
                    {
                        string[] codeArray = oneCode.Split('^');
                        if (codeArray[1] == 2.ToString())//小包
                        {
                            if (i == 2 || oneCode.Equals(this.code[this.code.Count - 1]))
                            {
                                one.curNum++;
                                code_3 += codeArray[0];

                                PrintThree(code_3);



                                code_3 = "";
                                i      = 0;
                            }
                            else
                            {
                                code_3 += codeArray[0] + " ";
                                i++;
                                one.curNum++;
                            }
                        }
                        else
                        {
                            if (code_3.Length > 5)
                            {
                                PrintThree(code_3);
                            }

                            PrintThree(codeArray[0]);

                            i = 0;
                        }
                        break;
                    }
                    else
                    {
                        Thread.Sleep(100);
                    }
                }
            }

            return(0);
        }
示例#2
0
        private void printProgress(string[] taskarray, List <string> listCode)
        {
            ComboboxItem ci = skinComboBox2.SelectedItem as ComboboxItem;

            if (ci == null)
            {
                MessageBox.Show("选择打码机");
            }
            string[] printer = (string [])ci.Value;//打印机名称,ip以及端口信息;
            if (printer[2].Length < 8)
            {
                MessageBox.Show(string.Format("ip error {0},{1}", printer[2], printer[1]));
                //normalPrinter print_N = new normalPrinter();
                //print_N.init();
                //print_N.PrintThree(taskarray, listCode);
                //listView1.Items.Remove(this.listView1.SelectedItems[0]);
            }
            else
            {
                //string printer_type = ci.Value.ToString();

                // circularProgressBar1.Visible = true;
                string printer_name = ci.Text;

                PrintStatus one = new PrintStatus();
                one.printTtoSo[0] = printer[0];
                one.printTtoSo[1] = printer[2];
                one.printTtoSo[2] = printer[3];
                one.totalNum      = Convert.ToInt32(this.info[2]);
                one.print_task    = info[0];
                TtoPrinter tp = new TtoPrinter(taskarray, listCode, one);
                if (printer[1].IndexOf("duo") > -1)  //打码机类型

                {
                    BeginPrinting(taskarray, listCode, one, 0);
                    skinLabel1.Text = "打印中";
                }
                else if (printer[1].IndexOf("wdj") > -1)
                {
                    BeginPrinting(taskarray, listCode, one, 1);
                    skinLabel1.Text = "打印中";
                }
                else if (printer[1].IndexOf("markem") > -1)
                {
                    BeginPrinting(taskarray, listCode, one, 2);
                    skinLabel1.Text = "打印中";
                }
                Control.CheckForIllegalCrossThreadCalls = false;
                thread_set_progress = new Thread(new ParameterizedThreadStart(PrintNum));
                thread_set_progress.IsBackground = true;
                thread_set_progress.Start(one);
            }
        }
示例#3
0
        private void button1_Click(object sender, EventArgs e)
        {
            int           type = skinComboBox1.SelectedIndex;
            normalPrinter np   = new normalPrinter();

            string[] normaltaskarray = new string[6];

            /*
             * 0,二维码前缀如http://  cpc
             *
             * 1,名称  重量
             * 2,产地
             * 3,生产日期
             * 4,批号
             * 5,厂家名称 company_name
             *
             */

            normaltaskarray[0] = skinTextBox2.Text;

            normaltaskarray[1] = info[1] + info[2];
            normaltaskarray[2] = info[2];
            normaltaskarray[3] = info[5];
            normaltaskarray[5] = "厂家:" + myUser.company_name;
            normaltaskarray[4] = info[4];
            PrintStatus one = new PrintStatus();

            one.totalNum   = Convert.ToInt32(this.info[2]);
            one.print_task = info[0];
            List <string> normallistCode = new List <string>();

            for (int i = 0; i < 5; i++)
            {
                string s = "1234567890123456789012345678^2";
                normallistCode.Add(s);
            }
            if (type == 1)
            {//三列
                np.PrintThree(normaltaskarray, normallistCode, one);
            }
            else
            {//两列
            }
        }
示例#4
0
        private void PrintNum(object obj)
        {
            PrintStatus one = (PrintStatus)obj;

            while (true)
            {
                try
                {
                    //this.listView1.Items[one.index].SubItems[7].Text = one.printName + ":" + one.curNum + "/" + one.totalNum;
                    if (one.workStatus > 2)
                    {
                        this.listView1.Items[one.index].SubItems[7].Text = "打印结束";
                        break;
                    }
                }
                catch (Exception)
                {
                    return;
                }
                Thread.Sleep(1000);
            }
        }
示例#5
0
        private void printThread(string[] taskarray, List <string> listCode)
        {
            if (myUser.curPrinter[1].Length < 8)
            {
                normalPrinter print_N = new normalPrinter();
                // print_N.init();
                // print_N.PrintThree(taskarray, listCode);
                listView1.Items.Remove(this.listView1.SelectedItems[0]);
            }
            else
            {
                this.listView1.SelectedItems[0].SubItems[7].Text = myUser.curPrinter[0] + "打印中";
                int index = this.listView1.SelectedItems[0].Index;
                this.label3.Text = ":打印中";
                this.listView1.SelectedItems[0].SubItems[8].Text = myUser.curPrinter[0];
                PrintStatus one = new PrintStatus();
                one.index = index;
                //one.printName = myUser.curPrinter[0];
                one.totalNum   = Convert.ToInt32(listView1.SelectedItems[0].SubItems[4].Text);
                one.print_task = listView1.SelectedItems[0].SubItems[1].Text;

                if (myUser.curPrinter[3].IndexOf("duo") > -1)
                {
                    BeginPrinting(taskarray, listCode, one, 0);
                }
                else if (myUser.curPrinter[3].IndexOf("wdj") > -1)
                {
                    BeginPrinting(taskarray, listCode, one, 1);
                }
                else if (myUser.curPrinter[3].IndexOf("markem") > -1)
                {
                    BeginPrinting(taskarray, listCode, one, 2);
                }
                thread_set_progress = new Thread(new ParameterizedThreadStart(PrintNum));
                thread_set_progress.Start(one);
            }
        }
示例#6
0
        private void PrintNum(object obj)
        {
            PrintStatus one = (PrintStatus)obj;

            while (true)
            {
                try
                {
                    if (printer.stop_signal)
                    {
                        return;
                    }
                    skinLabel4.Text = one.curNum + "/" + one.totalNum;
                    //circularProgressBar1.Value = Convert.ToInt32(one.curNum) / Convert.ToInt32(one.totalNum);
                    if (one.workStatus > 2)
                    {
                        skinLabel1.Text = "打印结束";
                        //circularProgressBar1.Visible = false;
                        Printflag = 0;
                        func.sendToServer("finishtask," + one.print_task + ",3");//3为打印完成

                        break;
                    }
                    else if (one.workStatus == 2)
                    {
                        skinLabel1.Text = "暂停中";
                    }
                }
                catch (Exception e)
                {
                    //  MessageBox.Show(e.Message);
                    return;
                }
                Thread.Sleep(1000);
            }
        }
示例#7
0
 public void initPrintData(string[] taskarray, List <string> listCode, PrintStatus one)
 {
     this.taskarray = taskarray;
     this.listCode  = listCode;
     this.one       = one;
 }
示例#8
0
 public TtoPrinter(string[] taskarray, List <string> listCode, PrintStatus one)
 {
     this.taskarray = taskarray;
     this.listCode  = listCode;
     this.one       = one;
 }
示例#9
0
        public IAsyncResult BeginPrinting(string [] taskarray, List <string> listCode, PrintStatus one, int printer_type)
        {
            AysnPrintDelegate PrintDelegate = null;

            printer = new TtoPrinter();
            printer.initPrintData(taskarray, listCode, one);
            if (printer_type == 0)
            {
                PrintDelegate = new AysnPrintDelegate(printer.DuoMiNuo);
            }
            else if (printer_type == 1)
            {
                PrintDelegate = new AysnPrintDelegate(printer.WDJ);
            }
            else
            {
                PrintDelegate = new AysnPrintDelegate(printer.Markem);
            }
            return(PrintDelegate.BeginInvoke(Printed, PrintDelegate));
        }
示例#10
0
        private void skinButton4_Click(object sender, EventArgs e)
        {
            string  printtask_code = info[0];
            DataSet ds             = func.getLocalCode(myUser.user_code, printtask_code);
            string  localCode      = func.Splice(ds.Tables[0]);

            int i = 0;

            i = localCode.IndexOf('|');
            string temp = "";

            try
            {
                temp = localCode.Substring(0, i);
            }
            catch (Exception)
            {
                MessageBox.Show("本地任务已删除");
                string sql = "";
                sql = "update task_info set task_flag=2 where task_code='" + printtask_code + "'";
                func.sendToServer("finishtask," + printtask_code + ",3");
                func.ExecuteSql(sql);
                return;
            }
            if (skinComboBox2.SelectedIndex == -1 || skinComboBox2.SelectedIndex == 0)
            {//打印机
                int type = skinComboBox1.SelectedIndex;
                Printflag = 1;
                PrintStatus one = new PrintStatus();

                one.totalNum   = Convert.ToInt32(this.info[2]);
                one.print_task = info[0];

                thread_set_progress = new Thread(new ParameterizedThreadStart(PrintNum));
                thread_set_progress.Start(one);
                string[] normaltaskarray = new string[7];

                /*
                 * 0,二维码前缀如http://  cpc
                 *
                 * 1,名称  重量
                 * 2,产地
                 * 3,生产日期
                 * 4,批号
                 * 5,厂家名称 company_name
                 *
                 */

                normaltaskarray[0] = skinTextBox2.Text;//前缀

                normaltaskarray[1] = info[1];
                normaltaskarray[2] = info[2];//名称重量
                if (info[8] == null)
                {
                    info[8] = "四川省成都市";
                }
                if (info[8].Contains("广西壮族自治区"))
                {
                    info[8] = "广西" + info[8].Substring(7);
                }
                else if (info[8].Contains("新疆维吾尔自治区"))
                {
                    info[8] = "新疆" + info[8].Substring(8);
                }
                else if (info[8].Contains("宁夏回族自治区"))
                {
                    info[8] = "宁夏" + info[8].Substring(7);
                }
                else if (info[8].Contains("西藏自治区"))
                {
                    info[8] = "西藏" + info[8].Substring(5);
                }
                else if (info[8].Contains("内蒙古自治区"))
                {
                    info[8] = "内蒙" + info[8].Substring(6);
                }
                normaltaskarray[3] = info[8];                  //产地
                normaltaskarray[5] = info[6];                  //批号

                normaltaskarray[4] = info[4].Substring(0, 10); //日期
                normaltaskarray[6] = "厂家:" + myUser.company_name;
                List <string> normallistCode = func.GetStrlist(localCode, '|', false);
                if (type == 1)
                {//三列
                    //前缀0 溯源码 名称重量1 产地2 生产日期(日)3 批号4 公司5
                    np.PrintThree(normaltaskarray, normallistCode, one);
                    //Dispose(true);
                }
                else
                {//两列
                    MessageBox.Show("2");
                    np.PrintTwo(normaltaskarray, normallistCode, one);
                }
            }
            else
            {
                Printflag = 2;
                int j = temp.IndexOf('^');//判读是否为中包,不打印中包
                temp = localCode.Substring(0, j);
                string type = localCode.Substring(j + 1, 1);
                if (type == "1")
                {
                    localCode = localCode.Substring(i + 1);
                }
                localCode = localCode.Substring(i + 1);

                string[] taskarray = new string[9];

                /*
                 * 0,二维码前缀如http://  cpc
                 * 1,第一个溯源码
                 * 2,名称
                 * 3,重量
                 * 4,规格
                 * 5,厂家名称 company_name
                 * 6,时间
                 * 7,批次
                 * 8,一维码数据
                 */

                taskarray[0] = skinTextBox2.Text;
                taskarray[1] = temp;
                // MessageBox.Show(temp);
                // MessageBox.Show(localCode);
                taskarray[2] = info[1];
                taskarray[3] = info[2];
                taskarray[4] = info[5];
                taskarray[5] = "厂家:" + myUser.company_name;
                taskarray[7] = info[4];
                taskarray[6] = info[6];
                taskarray[8] = "15161";
                List <string> listCode = func.GetStrlist(localCode, '|', false);

                printProgress(taskarray, listCode);
            }
        }
示例#11
0
        public IAsyncResult BeginPrinting(string[] taskarray, List <string> listCode, PrintStatus one, int printer_type)
        {
            //TtoPrinter printer = new TtoPrinter();
            //AysnPrintDelegate PrintDelegate = null;
            //if (printer_type == 0)
            //{
            //    PrintDelegate = new AysnPrintDelegate(printer.DuoMiNuo);
            //}
            //else if (printer_type == 1)
            //{
            //    PrintDelegate = new AysnPrintDelegate(printer.WDJ);
            //}
            //else {
            //    PrintDelegate = new AysnPrintDelegate(printer.Markem);
            //}

            return(null);///PrintDelegate.BeginInvoke(taskarray, listCode, one, Printed, PrintDelegate);
        }