コード例 #1
0
ファイル: Form1.cs プロジェクト: chenliang123/xiaozhushou
        private void setHD_PcIp()
        {
            string ips = GetInternalIPList();

            string[] iplist = ips.Split(',');
            string   pcip   = "";

            foreach (string ip in iplist)
            {
                if (ip.StartsWith("172.18.20"))
                {
                    pcip = ip;
                    break;
                }
            }

            if (pcip.Length == 0)
            {
                return;
            }

            pcip = "172.18.201.3";

            string host    = Global.getHDIP();
            String url     = "http://P1/EduApi/hd.do?action=pcip.get&callback=CB&tm=P2";//
            String utctime = getUTC();

            url = url.Replace("P1", host);
            url = url.Replace("P2", utctime);
            url = url.Replace("P3", pcip);

            string resp = HTTPReq.HttpGet(url);

            Log.Info(url + ", ret=" + resp);
            if (resp.IndexOf(pcip) < 0)
            {
                String url_set = "http://P1/EduApi/hd.do?action=pcip.set&callback=CB&ip=P2&tm=P3";//
                url_set = url_set.Replace("P1", host);
                url_set = url_set.Replace("P2", pcip);
                url_set = url_set.Replace("P3", utctime);
                string resp2 = HTTPReq.HttpGet(url_set);
                Log.Info(url_set + ", ret=" + resp2);
            }
        }
コード例 #2
0
        public void loadCfg()
        {
            Log.Info(Global.toString());

            textBox_wifi.Text    = Global.getWiFi();
            textBox_wifi.Enabled = false;

            textBox_schoolname.Text = Global.getSchoolname();
            classid   = Global.getClassID();
            classname = Global.getClassname();

            //get Class list
            {
                m_classlist.Clear();
                comboBox_classlist.Text = "";
                comboBox_classlist.Items.Clear();
                m_classlist = m_db.getClassBySchoolid(Global.getSchoolID());

                if (Global.IsPublicClassroom())
                {
                    comboBox_classlist.Items.Add("公共教室");
                    comboBox_classlist.SelectedIndex = comboBox_classlist.Items.Count - 1;
                    button_reloadClasses.Visible     = false;
                }
                else
                {
                    foreach (Classes c in m_classlist)
                    {
                        if (c.name == "" || c.orderid == 0)
                        {
                            continue;
                        }

                        comboBox_classlist.Items.Add(c.name);
                        if (classid == c.id)
                        {
                            comboBox_classlist.SelectedIndex = comboBox_classlist.Items.Count - 1;
                        }
                    }
                }
            }
            if (Global.getClassname() == "")
            {
                Classes c = m_db.getClassById(Global.getClassID());
                if (c != null)
                {
                    Global.setClassname(c.name);
                    Global.setClassID(c.id);
                }
            }

            textBox_hdip.Text = Global.getHDIP();

            ////////////////////////////////
            ArrayList iplist = Util.GetInternalIPList();

            if (iplist.Count == 1)
            {
                textBox_360ip.Text = (string)iplist[0];
            }
            else
            {
                foreach (string ip in iplist)
                {
                    string ip_4 = ip.Substring(ip.LastIndexOf(".") + 1);
                    if (ip == "172.18.201.3")
                    {
                        textBox_360ip.Text = ip;
                        break;
                    }
                }
            }
        }
コード例 #3
0
ファイル: Form1.cs プロジェクト: chenliang123/xiaozhushou
        private void Thread_CheckDeviceStatus()
        {
            int lastCode = 0;
            int nOK      = 0;

            while (true)
            {
                bool     bOK_360 = false;
                bool     bOK_HD  = false;
                string   hdip    = Global.getHDIP();
                string   localip = GetInternalIPList();
                string[] szIP    = localip.Split(',');
                if (szIP.Length == 1)
                {
                    string ip = szIP[0];
                    Log.Debug("Thread_CheckDeviceStatus1 ip=" + ip);
                    //string ip_4 = ip.Substring(ip.LastIndexOf(".") + 1);
                    if (ip == "172.18.201.3")
                    {
                        bOK_360 = true;
                    }
                }
                else
                {
                    foreach (string ip in szIP)
                    {
                        //string ip_4 = ip.Substring(ip.LastIndexOf(".") + 1);
                        if (ip == "172.18.201.3")
                        {
                            bOK_360 = true;
                            break;
                        }
                    }
                }

                //check
                {
                    if (Common.HD_Test() == 1)
                    {
                        bOK_HD = true;
                    }
                    else
                    {
                        if (Common.HD_Test() == 1)
                        {
                            bOK_HD = true;
                        }
                    }
                }
                int code = 0;

                int Sec = 3 * 1000;
                if (!bOK_360)
                {
                    if (bOK_HD)
                    {
                        code = -1;
                    }
                    else
                    {
                        code = -3;
                    }
                }
                else
                {
                    if (bOK_HD)
                    {
                        code = 0;
                    }
                    else
                    {
                        code = -2;
                    }
                }
                //Log.Debug("Thread_CheckDeviceStatus code=" + code);
                int bHide = 0;
                if (code != lastCode)
                {
                    bFormNotifyClosed = false;
                }

                if (code == 0 && lastCode == 0 && nOK >= 3)
                {
                    bHide = 1;
                }
                else
                {
                    bHide = 0;
                }

                if (!bFormNotifyClosed)
                {
                    if (code == -1)
                    {
                        //loadNofityForm("很抱歉,本机IP地址配置错误!\r\n请检查360wifi或无线路由是否正常!", bHide, 1000);
                        loadNofityForm("很抱歉,本机IP地址配置错误!", bHide, 1000);//\r\n请检查360wifi或无线路由是否正常!
                        nOK = 0;
                    }
                    else if (code == -2)
                    {
                        loadNofityForm("很抱歉, 连接采集器失败!\r\n请检查采集器的参数是否正常!\r\n接收机IP:" + Global.getHDIP() + "\r\n本机IP:" + GetLocalIP_1(), bHide, 1000);
                        nOK = 0;
                    }
                    else if (code == -3)
                    {
                        loadNofityForm("很抱歉,本机IP地址配置错误!", bHide, 1000);//\r\n采集器参数或网络异常!
                        nOK = 0;
                    }
                    else
                    {
                        loadNofityForm("\r\n亲爱的老师,可以开始上课啦!", bHide, 10);
                        nOK++;
                    }
                }
                lastCode = code;

                Thread.Sleep(Sec);
            }
        }
コード例 #4
0
        private void Thread_CheckDeviceStatus()
        {
            int lastCode = 0;
            int nOK      = 0;

            while (true)
            {
                bool     bOK_360 = false;
                bool     bOK_HD  = false;
                string   hdip    = Global.getHDIP();
                string   localip = GetInternalIPList();
                string[] szIP    = localip.Split(',');
                if (szIP.Length == 1)
                {
                    string ip = szIP[0];
                    Log.Debug("Thread_CheckDeviceStatus1 ip=" + ip);
                    //string ip_4 = ip.Substring(ip.LastIndexOf(".") + 1);
                    if (ip == "172.18.201.3")
                    {
                        bOK_360 = true;
                    }
                }
                else
                {
                    foreach (string ip in szIP)
                    {
                        //string ip_4 = ip.Substring(ip.LastIndexOf(".") + 1);
                        if (ip == "172.18.201.3")
                        {
                            bOK_360 = true;
                            break;
                        }
                    }
                }

                //check答题卡
                {
                    if (AnswerCard.Card_Test() == 1)
                    {
                        bOK_HD = true;
                        if (fNotify != null)
                        {
                            fNotify.showImg();
                            fNotify.setImgUrl(Global.startPath + "myCode.jpg");
                        }
                        else
                        {
                            fNotify = new FormNotify("", "", 10);
                        }
                    }
                    else
                    {
                        if (AnswerCard.Card_Test() == 1)
                        {
                            bOK_HD = true;
                            if (fNotify != null)
                            {
                                fNotify.showImg();
                            }
                            else
                            {
                                fNotify = new FormNotify("", "", 10);
                            }
                        }
                        else
                        {
                            if (fNotify != null)
                            {
                                fNotify.hideImg();
                            }
                            else
                            {
                                fNotify = new FormNotify("", "", 10);
                            }
                        }
                    }
                }
                int code = 0;

                int Sec = 3 * 1000;
                if (!bOK_360)
                {
                    if (bOK_HD)
                    {
                        code = -1;
                    }
                    else
                    {
                        code = -3;
                    }
                }
                else
                {
                    if (bOK_HD)
                    {
                        code = 0;
                    }
                    else
                    {
                        code = -2;
                    }
                }
                //Log.Debug("Thread_CheckDeviceStatus code=" + code);
                int bHide = 0;
                if (code != lastCode)
                {
                    bFormNotifyClosed = false;
                }

                if (code == 0 && lastCode == 0 && nOK >= 3)
                {
                    bHide = 1;
                }
                else
                {
                    bHide = 0;
                }

                if (!bFormNotifyClosed)
                {
                    if (code == -1)
                    {
                        loadNofityForm("\r亲爱的老师\r\n可以开始上课啦!", 0, 10);
                        nOK = 0;
                    }
                    else if (code == -2)
                    {
                        //应付演示
                        //("很抱歉, 连接采集器失败!\r\n请检查采集器的参数是否正常!\r\n接收机IP:" + Global.getHDIP() + "\r\n本机IP:" + GetLocalIP_1(), bHide, 1000);
                        loadNofityForm("\r\n请检查接收器是否插好?", 0, 10);
                        nOK = 0;
                    }
                    else if (code == -3)
                    {
                        //("很抱歉,本机IP地址配置错误!", bHide, 1000);//\r\n采集器参数或网络异常!
                        loadNofityForm("\r\n请检查接收器是否插好?", 0, 10);
                        nOK = 0;
                    }
                    else
                    {
                        loadNofityForm("\r亲爱的老师\r\n可以开始上课啦!", 0, 10);
                        nOK++;
                    }
                }
                lastCode = code;

                Thread.Sleep(Sec);
            }
        }