Exemplo n.º 1
0
 private void toolStripMenuItem5_Click(object sender, EventArgs e)
 {
     if (AnswerCard.Card_Test() == 1)
     {
         loadNofityForm("\r亲爱的老师\r\n可以开始上课啦!", 0, 10);
     }
     else
     {
         loadNofityForm("\r\n请检查接收器是否插好?", 0, 10);
     }
 }
Exemplo n.º 2
0
 public static void RaiseStart()
 {
     //AnswerStop();
     Global.RaiseStu = "";
     if (answer_card == null)
     {
         answer_card       = new AnswerCard();
         answer_card.Raise = true;
     }
     else
     {
         answer_card.Raise = true;
     }
     AnswersCollection.HX_SetWorkMode(TBModeDef.HX_MODE_RAISE, "");
     AnswersCollection.HX_Start();
 }
Exemplo n.º 3
0
        public Form1()
        {
            //Form_xiti1 ff = new Form_xiti1();
            //ff.Show();
            fController = new FormController();
            fController.Display(false);

            InitializeComponent();
            //启动初始化接收机
            if (answer_card == null)
            {
                answer_card = new AnswerCard();
                answer_card.Message();
                string date     = DateTime.Now.ToString("yyyyMMdd");
                int    schoolID = Global.getSchoolID();
                Global.g_roommsg = Common.getClassroomCourseTable(schoolID, 101, "20170905");
                //Common.getClassroomCourseTable(93,23,"");
            }
            else
            {
                answer_card.Message();
            }
            Log.Info("F1_1 set notifyIcon");

            //show in taskbar
            {
                this.ShowInTaskbar       = false;
                this.notifyIcon1.Visible = true;//在通知区显示Form的Icon
                this.WindowState         = FormWindowState.Minimized;
            }

            //if (Global.isWithCamera())
            //{
            //    this.toolStripMenuItem5.Visible = true;
            //}
            //else
            //{
            //    this.toolStripMenuItem5.Visible = false;
            //}

            FileInfo fi       = new FileInfo(Application.StartupPath + "\\如e小助手.exe");
            string   lasttime = fi.LastWriteTime.ToString("yyyyMMdd HHmmss");
            string   MMdd     = fi.LastWriteTime.ToString("MMdd");
            string   version  = GetAssembly(typeof(System.Reflection.AssemblyVersionAttribute));

            string[] szV       = version.Split('.');
            string   version_1 = szV[0] + "." + szV[1] + "." + szV[2] + "." + MMdd;

            this.Text            = "如e小助手 v" + version;
            this.labelAbout.Text = "关于 如e小助手(v" + version_1 + ")";

            //设置自启动
            Log.Info("F1_2 set autorun");
            SetAutoRun(Global.getAutorun());

            //清除历史文件夹
            Log.Info("F1_3 remove historyDir");
            RemoveHistoryDir();

            //获取学校和班级的参数
            int schoolid = Global.getSchoolID();
            int classid  = Global.getClassID();

            Log.Info("F1_4 get parameters: schoolid=" + schoolid + ", classid=" + classid);
            string assistanturl = Global.url_assistant;

            Log.Info("F1_5 get class");
            Classes c = m_db.getClassById(classid);

            if (c != null)
            {
                Global.setClassID(c.id);
                Global.setClassname(c.name);
                Global.setGrade(c.grade);
            }

            //更新班级的接收机ID
            Thread th = new Thread(delegate()
            {
                Log.Info("F1_6 setPCIP/syncHDId");
                Thread.Sleep(3000);
                setHD_PcIp();

                string hdid = Common.getHDID();
                if (hdid.Length > 0)
                {
                    Common.uploadHDBind();
                }
            });

            th.Start();

            //上传历史数据
            Thread thOfflineProcess = new Thread(delegate()
            {
                Log.Info("F1_7 syncOfflineData");
                OfflineProcessor.UploadHistoryData();
            });

            thOfflineProcess.Start();

            while (Global.g_TeacherArray == null)
            {
                Thread.Sleep(50);
            }
            fNotifyToStart = new FormNotifyToStart();
            fNotifyToStart.Show();
        }
Exemplo n.º 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);
            }
        }
Exemplo n.º 5
0
        public void CallbackFun(int iDevice, AnswersCollection.CALLBACK_MSG msg, int param1, string param2)
        {
            if (msg == AnswersCollection.CALLBACK_MSG.MSG_PULLEDOUT)
            {
                MessageBox.Show("设备拔出");
                if (isDati)
                {
                    AnswersCollection.HX_Stop();
                }
                AnswersCollection.HX_CloseDevice();
            }

            if (msg == AnswersCollection.CALLBACK_MSG.MSG_ANSWER_DATA)
            {
                for (int i = 0; i < param1; i++)
                {
                    Console.WriteLine(param2);
                    string[] s = param2.ToString().Split(new char[] { '"' });

                    //this.BeginInvoke((MethodInvoker)delegate
                    //{
                    //   textBox1.AppendText("StudentID:" + s[3] + " " + "CardID:" + s[7] + " " + "answer:" + s[11] + "\r\n");
                    //});



                    if (answer_card == null)
                    {
                        answer_card       = new AnswerCard();
                        answer_card.Raise = false;
                    }

                    if (answer_card.Raise)
                    {
                        Console.WriteLine("有人举手");
                        if (Global.RaiseStu == "")
                        {
                            Global.RaiseStu = s[7];
                        }
                        else
                        {
                            Global.RaiseStu += "|" + s[7];
                        }

                        if (Global.setSeatBtn)
                        {
                            Httpd.setSeatfn(Global.RaiseStu);
                        }
                        else
                        {
                            Httpd.setHandon(Global.RaiseStu);
                            //Console.WriteLine(Global.RaiseStu);
                        }
                    }
                    else
                    {
                        if (Global.AnswerStu == "")
                        {
                            if (s[11].Replace(" ", "") == "√")
                            {
                                Global.judgeAnsewer = "R";
                                Global.AnswerStu    = s[7] + ":" + Global.judgeAnsewer;
                            }
                            else if (s[11].Replace(" ", "") == "×")
                            {
                                Global.judgeAnsewer = "W";
                                Global.AnswerStu    = s[7] + ":" + Global.judgeAnsewer;
                            }
                            else
                            {
                                Global.AnswerStu = s[7] + ":" + s[11].Replace(" ", "");
                            }
                        }
                        else
                        {
                            if (Global.AnswerStu.IndexOf(s[7]) >= 0)
                            {
                                //有的话去重
                                string[]      stringArray = Global.AnswerStu.Split('|');
                                List <string> listString  = new List <string>(stringArray);
                                int           count       = listString.Count;
                                for (int t = 0; t < count; t++)
                                {
                                    if (listString[t].IndexOf(s[7]) >= 0)
                                    {
                                        listString.Remove(listString[t]);
                                        if (s[11].Replace(" ", "") == "√")
                                        {
                                            Global.judgeAnsewer = "R";
                                            listString.Add(s[7] + ":" + Global.judgeAnsewer);
                                        }
                                        else if (s[11].Replace(" ", "") == "×")
                                        {
                                            Global.judgeAnsewer = "W";
                                            listString.Add(s[7] + ":" + Global.judgeAnsewer);
                                        }
                                        else
                                        {
                                            listString.Add(s[7] + ":" + s[11].Replace(" ", ""));
                                        }
                                    }
                                }
                                //foreach (string eachString in listString)
                                //{
                                //    if (eachString.IndexOf(s[3]) >= 0)
                                //    {
                                //        listString.Remove(eachString);
                                //        listString.Add(s[3] + ":" + s[11].Replace(" ", ""));
                                //    }
                                //}
                                Global.AnswerStu = string.Join("|", listString);
                            }
                            else
                            {
                                //没有
                                if (s[11].Replace(" ", "") == "√")
                                {
                                    Global.judgeAnsewer = "R";
                                    Global.AnswerStu   += "|" + s[7] + ":" + Global.judgeAnsewer;
                                }
                                else if (s[11].Replace(" ", "") == "×")
                                {
                                    Global.judgeAnsewer = "W";
                                    Global.AnswerStu   += "|" + s[7] + ":" + Global.judgeAnsewer;
                                }
                                else
                                {
                                    Global.AnswerStu += "|" + s[7] + ":" + s[11].Replace(" ", "");
                                }
                            }
                        }
                        Httpd.setPracticeResult(Global.AnswerStu);
                    }
                }
            }
            else if (msg == AnswersCollection.CALLBACK_MSG.MSG_DOUTE_DATA)
            {
                Console.WriteLine(param2);
                string[] s2 = param2.ToString().Split(new char[] { '"' });

                //this.BeginInvoke((MethodInvoker)delegate
                //{
                //   textBox1.AppendText("StudentID:" + s2[3] + " " + "CardID:" + s2[7] + "\r\n");
                //});
            }

            if (msg == AnswersCollection.CALLBACK_MSG.MSG_ERROR)
            {
                Console.Write("ErrCode:{0:D} ", param1);
                Console.WriteLine("Description:" + param2);
            }
        }
Exemplo n.º 6
0
 public int extiAnswer()
 {
     return(AnswerCard.AnswerStop());
 }