public bool Execute()
        {
            bool r = false;

            //set lamp off
            VNPT_Lamp.Output(LampStatus.AllOFF);

            try {
                //init log
                MyGlobal.testFunctionLogInfo = new IO.VnptAsmTestFunctionLogInfo()
                {
                    Rework             = string.Format("small:{0}", reworkInformation.ReworkSerial),
                    Production_Command = "",
                    ProductionLot      = reworkInformation.ProductionLot,
                    LotProgress        = reworkInformation.LotProgress,
                    ProductCode        = product.code
                };

                reworkInformation.ErrorMessage = string.Format("Product: \"{0}\"\n", reworkInformation.NewProductSerial);

                //validate serial number
                if (!_validate_product_serialnumber())
                {
                    goto END;
                }

                //check serial printed or not
                if (!_serial_was_printed())
                {
                    goto END;
                }

                //check product weight
                if (!_product_weight_is_valid())
                {
                    goto END;
                }

                r = true;
                goto END;
            }
            catch {
                goto END;
            }

END:
            new LogTotal().To_CSV_File(MyGlobal.testFunctionLogInfo, new VnptLogMoreInfo());

            //set lamp on
            VNPT_Lamp.Output(r ? LampStatus.GreenON : LampStatus.RedON);

            //return value
            return(r);
        }
        void _jud_fail()
        {
            MyGlobal.MyTesting.FailParameters(); //display fail
            _save_log_();                        //save log

            _load_ms_datatable_();               //load ms database

            //set red lamp
            VNPT_Lamp.Output(LampStatus.RedON);

            Dispatcher.Invoke(new Action(() => { txt_SN.Clear(); txt_SN.IsEnabled = true; txt_SN.Focus(); })); //set focus for txt_SN
        }
        //bulk rework
        bool _run_Bulk_Rework()
        {
            Thread zzz = new Thread(new ThreadStart(() => {
                //set off lamp
                VNPT_Lamp.Output(LampStatus.AllOFF);

                //run check
                var run = new imp_BulkRework();
                if (!run.Execute())
                {
                    _jud_fail();
                }
                else
                {
                    _jud_pass();
                }
            }));

            zzz.IsBackground = true;
            zzz.Start();

            return(true);
        }
        //sub function --------------------------------------------//
        void _jud_pass()
        {
            Stopwatch st = new Stopwatch();

            st.Start();

            MyGlobal.MyTesting.ErrorMessage += string.Format("Serial Number is valid.");
            MyGlobal.MyTesting.PassParameters();
            MyGlobal.MyTesting.LotCount = string.Format("{0}", int.Parse(MyGlobal.MyTesting.LotCount) + 1);

            _save_log_(); //save log
            st.Stop();
            MyGlobal.MyTesting.TestTime += string.Format("<save_log={0}>", st.ElapsedMilliseconds);

            st.Reset();
            st.Restart();
            if (MyGlobal.MyTesting.LotCount.Equals(MyGlobal.MyTesting.LotLimit))    //gen lot
            //set green lamp
            {
                VNPT_Lamp.Output(LampStatus.YellowON);

                //Thread t = new Thread(new ThreadStart(() => {
                MyGlobal.MasterBox.Print_Access_Report("IMEI_SN_fPrint"); //print label
                Thread.Sleep(200);
                new io_msaccdb_tbIMEISerialPrint().DeleteAll();           //delete all row in table imei print

                MyGlobal.MyTesting.LotCount = "0";
                MyGlobal.MyTesting.LotName  = new GenerateLOT(MyGlobal.MySetting.LineIndex, MyGlobal.MySetting.ProductionPlace, MyGlobal.MySetting.ProductionYear, MyGlobal.MySetting.ProductNumber, MyGlobal.MySetting.LOTIndex, true).Gererate();
                //}));
                //t.IsBackground = true;
                //t.Start();
            }
            else
            {
                //set green lamp
                VNPT_Lamp.Output(LampStatus.GreenON);
            }
            st.Stop();
            MyGlobal.MyTesting.TestTime += string.Format("<set_lamp={0}>", st.ElapsedMilliseconds);

            st.Reset();
            st.Restart();
            _load_ms_datatable_(); //load ms database
            st.Stop();
            MyGlobal.MyTesting.TestTime += string.Format("<load_dblog={0}>", st.ElapsedMilliseconds);

            st.Reset();
            st.Restart();
            io_dll_Recent.ToFile(MyGlobal.MyTesting.LotName, MyGlobal.MyTesting.LotProgress);  //save recent file
            Dispatcher.Invoke(new Action(() => { txt_SN.IsEnabled = true; txt_SN.Focus(); })); //set focus for txt_SN
            st.Stop();
            MyGlobal.MyTesting.TestTime += string.Format("<save_recent={0}>", st.ElapsedMilliseconds);

            //save log test time
            if (System.IO.Directory.Exists(string.Format("{0}\\Log", AppDomain.CurrentDomain.BaseDirectory)) == false)
            {
                System.IO.Directory.CreateDirectory(string.Format("{0}\\Log", AppDomain.CurrentDomain.BaseDirectory));
                Thread.Sleep(100);
            }
            var sw = new System.IO.StreamWriter(string.Format("{0}\\Log\\{1}.txt", AppDomain.CurrentDomain.BaseDirectory, DateTime.Now.ToString("yyyyMMdd")), true);

            sw.WriteLine(MyGlobal.MyTesting.TestTime);
            sw.Close();
        }