コード例 #1
0
        public static void check()
        {
            if (CatReg.task_name == CatStatus.taskName.NO_TASK.ToString())
            {
                string ssid = CatNet.serverSsid;
                //set ap to server  // change server ap workaround
                if (CatReg.task_ap != ssid)
                {
                    CatReg.task_ap = ssid;
                }
            }



            var  ap  = CatReg.task_ap;
            bool ret = false;

            if (ap != "Disconnect")
            {
                if (currentssid != ap)
                {
                    ret = connectwifi(ap);
                }
                else if (currentssid == ap)
                {
                    ret = true;
                }
            }
            else
            {
                ret = CatNet.disconnect();
            }


            Console.WriteLine($"netcheck finish {ap} {ret}");
        }
コード例 #2
0
        public async void Execute()
        {
            try
            {
                CatData.databaseCheck();

                while (device != null && device.sn != "NA")
                {
                    await Task.Delay(new TimeSpan(0, 0, new Random().Next(5, 11)));

                    CatNet.check();

                    if (CatData.databaseConnection)
                    {
                        if (!CatData.catinfoEnroll(device))
                        {
                            continue;
                        }
                        CatData.sync();
                        CatData.pull();
                        CatReg.connect = true;
                    }

                    Console.WriteLine($"CatReg.status {CatReg.status}");
                    if (CatReg.status == CatStatus.uutStatus.STANDBY)
                    {
                        var next_task = CatData.getNexttask();
                        if (next_task != null)
                        {
                            oldlogCheck(next_task.task1);
                            if (executeTest(next_task.task1))
                            {
                                next_task.state = CatStatus.taskStatus.RUNNING.ToString();
                                next_task.start = DateTime.Now;
                                if (CatData.taskUpdate(next_task))
                                {
                                    CatReg.task_name       = next_task.task1;
                                    CatReg.task_status     = CatStatus.taskStatus.RUNNING.ToString();
                                    CatReg.task_id         = next_task.server_id.ToString();
                                    CatReg.task_start_time = DateTime.Now.ToString();
                                    CatReg.task_ap         = next_task.ap;

                                    var catinfo = CatData.getCatInfo();
                                    if (catinfo != null)
                                    {
                                        catinfo.STATUS       = CatStatus.taskStatus.RUNNING.ToString();
                                        catinfo.LastUsedTime = DateTime.Now;
                                        CatData.catinfoUpdate(catinfo);
                                        if (next_task.ap != CatNet.currentssid)
                                        {
                                            CatNet.connectwifi(next_task.ap);
                                        }
                                    }
                                }
                            }
                            else
                            {
                                next_task.state = CatStatus.taskStatus.SCRIPT_ERROR.ToString();
                                next_task.start = DateTime.Now;
                                CatData.taskUpdate(next_task);
                            }
                        }
                        else
                        {
                            Console.WriteLine("task null"); continue;
                        }
                    }
                    else if (CatReg.status == CatStatus.uutStatus.RUNNING)
                    {
                        var current_task = CatData.getCurrenttask();
                        if (current_task != null)
                        {
                            if (!haltOnErrorFind())
                            {
                                var summary = resultFind(current_task.task1);
                                if (summary != null)
                                {
                                    current_task.finish = DateTime.Now;
                                    processKill();
                                    CatNet.ConnectServer();
                                    if (logSummarize(summary, ref current_task))
                                    {
                                        current_task.state        = CatStatus.taskStatus.DONE.ToString();
                                        CatReg.task_status        = CatStatus.taskStatus.DONE.ToString();
                                        CatReg.task_name          = CatStatus.taskName.NO_TASK.ToString();
                                        CatReg.task_id            = "";
                                        CatReg.task_start_time    = "";
                                        CatReg.task_result_folder = "";
                                        CatReg.task_path          = "";
                                        CatReg.task_ap            = CatNet.serverSsid;

                                        CatData.taskUpdate(current_task);
                                    }
                                }
                            }
                            else
                            {
                                current_task.state = CatStatus.taskStatus.HALT.ToString();
                                CatReg.task_status = CatStatus.taskStatus.HALT.ToString();
                                CatData.taskUpdate(current_task);
                            }
                        }
                    }
                    else if (CatReg.status == CatStatus.uutStatus.HALT)
                    {
                        if (!haltOnErrorFind())
                        {
                            var current_task = CatData.getCurrenttask();
                            if (current_task.state != CatStatus.taskStatus.RUNNING.ToString())
                            {
                                Console.WriteLine($"current_task.state {current_task.state}"); current_task.state = CatStatus.taskStatus.RUNNING.ToString();
                            }
                            if (CatReg.task_status != CatStatus.taskStatus.RUNNING.ToString())
                            {
                                Console.WriteLine($"CatReg.task_status {CatReg.task_status}"); CatReg.task_status = CatStatus.taskStatus.RUNNING.ToString();
                            }
                            CatData.taskUpdate(current_task);
                        }
                    }
                }
            }
            catch (Exception e)
            {
                Log(e.ToString());
            }
        }