Exemple #1
0
 public static void closeFormNotify()
 {
     if (fNotify != null)
     {
         bFormNotifyClosed = true;
         fNotify           = null;
     }
 }
Exemple #2
0
        public void loadNofityForm(string msg, int bHide, int seconds)
        {
            if (this.InvokeRequired)
            {
                InvokeLoadNofityForm cb = new InvokeLoadNofityForm(loadNofityForm);
                this.Invoke(cb, new object[] { msg, bHide, seconds });
                return;
            }
            string classname = Global.getClassname();

            if (Global.IsPublicClassroom())
            {
                classname = "公共教室";
            }
            string title = Global.getSchoolname() + " - " + classname + "";

            if (fNotify != null)
            {
                if (bHide == 1)
                {
                    fNotify.Hide();
                }
                else
                {
                    fNotify.updateForm(title, msg);
                    if (!FormNotify.m_PPTImgExporting)
                    {
                        fNotify.Show();
                    }
                }
            }
            else
            {
                fNotify = new FormNotify(title, msg, seconds);
                if (!FormNotify.m_PPTImgExporting)
                {
                    fNotify.Show();
                }
            }
        }
 public void showForm(object sender, EventArgs e)
 {
     fNotify = sender as FormNotify;
     fNotify.Show();
 }
        private void ReadFilePath(string diskPath, int field, bool bNotify = false)
        {
            currentdir = diskPath;
            if (diskPath.LastIndexOf("\\") == diskPath.Length - 1)
            {
                diskPath = diskPath.Substring(0, diskPath.Length - 1);
            }
            ArrayList autoAddedFileList = new ArrayList();
            ArrayList al = Disk.MergrObj(diskPath.Replace("\r\n", ""));

            btnList = new ArrayList();
            if (field == 1)
            {
                Button backBtn = CreateBackBtn();
                btnList.Add(backBtn);
            }

            bool bAutoSync = false;

            string[]  szType    = { "ppt", "pptx", "doc", "docx", "pdf", "mp3", "wma", "wmv", "mp4", "swf" };
            ArrayList filelist0 = Disk.getFilelist(diskPath.Replace("\r\n", ""), szType);

            if (filelist0.Count <= 5)
            {
                bAutoSync = true;
            }
            else
            {
                Httpd.pushFilelistTips("U盘课件文件超过5个!\r\n请手动选择课件文件,并使用鼠标\"右键\"选择\"添加到如e小助手\"");
            }
            bAutoSync = false;

            for (int k = 0; k < al.Count; k++)
            {
                string value = al[k].ToString();
                Button btn   = new Button();
                btn.Size      = new System.Drawing.Size(70, 70);
                btn.BackColor = System.Drawing.Color.FromArgb(255, 255, 255);
                btn.FlatStyle = FlatStyle.Flat;
                btn.FlatAppearance.BorderColor        = System.Drawing.Color.FromArgb(153, 209, 255);
                btn.FlatAppearance.BorderSize         = 0;
                btn.FlatAppearance.MouseDownBackColor = System.Drawing.Color.FromArgb(204, 232, 255);
                btn.FlatAppearance.MouseOverBackColor = System.Drawing.Color.FromArgb(229, 243, 255);
                btn.TextAlign  = ContentAlignment.BottomCenter;
                btn.MouseMove += new System.Windows.Forms.MouseEventHandler(btn_MouseMove);
                btn.MouseDown += new System.Windows.Forms.MouseEventHandler(btn_MouseDown);
                btn.AllowDrop  = true;
                if (value.Split('|')[0].ToString() == "0")
                {
                    btn.BackgroundImage = global::RueHelper.Properties.Resources.wenjianjia;
                    btn.Name            = "0|" + diskPath + "|" + value.Split('|')[2].ToString();
                }
                else
                {
                    string filename = value.Split('|')[2].ToString();
                    string extName  = filename.Substring(filename.LastIndexOf(".") + 1, (filename.Length - filename.LastIndexOf(".") - 1));
                    btn.BackgroundImage = FileICON(extName);//load
                    if (btn.BackgroundImage == null)
                    {
                        continue;
                    }
                    btn.Name = "1|" + diskPath + "|" + value.Split('|')[2].ToString();

                    if (filename.StartsWith("~$"))
                    {
                        continue;
                    }

                    if (field == 0 && bAutoSync)
                    {
                        //仅仅在插上U盘时自动加载
                        string _filepath = diskPath + "\\" + filename;
                        autoAddedFileList.Add(_filepath);
                        continue;
                    }
                }
                this.label6.Text = diskPath + "\\" + value.Split('|')[2].ToString();
                btn.Text         = value.Split('|')[1].ToString();
                string tooltipStr = value.Split('|')[2].ToString() + "\r\n类型:" + value.Split('|')[3].ToString() + "\r\n修改日期:" + value.Split('|')[5].ToString() + "\r\n大小:" + value.Split('|')[4].ToString() + "";
                this.toolTip1.SetToolTip(btn, tooltipStr);
                addButtonlist_Left(btn);
            }

            try
            {
                for (int i = 0; i < autoAddedFileList.Count; i++)
                {
                    string _path = (string)autoAddedFileList.ToArray()[i];
                    string _name = Path.GetFileName(_path);
                    EService.selectFile(_name, _path);
                    this.AddFile(_path, false);
                }
            }catch (Exception e1) {
                ;//
            }

            Thread thread = new Thread(delegate()
            {
                if (autoAddedFileList.Count == 0)
                {
                    return;
                }

                bExporting = true;

                try
                {
                    string title = Global.getSchoolname() + " - " + Global.getClassname() + "";
                    if (bNotify)
                    {
                        if (fNotify == null)
                        {
                            fNotify = new FormNotify(title, "\r\n 课件导入中,请稍后!", 30);
                        }
                        this.Invoke(new System.EventHandler(this.showForm), new object[] { fNotify, null });
                        fNotify.InvokeUpdate(title, "\r\n 课件导入中,请稍后!");
                    }

                    for (int i = 0; i < autoAddedFileList.Count; i++)
                    {
                        string filepathSrc = (string)autoAddedFileList.ToArray()[i];
                        Log.Info("copy ppt......0:" + filepathSrc);
                        string _fname = Path.GetFileName(filepathSrc);
                        if (_fname.IndexOf("ppt") > 0 || _fname.IndexOf("PPT") > 0)
                        {
                            Log.Info("copy ppt......3");
                            MyPPT.exportImg(filepathSrc);
                            Log.Info("copy ppt......4");
                        }
                        Log.Info("copy ppt......5");
                    }
                    bExporting = false;
                    if (bNotify && fNotify != null)
                    {
                        fNotify.InvokeUpdate(title, "\r\n 课件导入完毕!");
                        Thread.Sleep(5000);
                        fNotify.InvokeClose();
                        fNotify = null;
                    }
                }catch (Exception e1) {
                    Log.Error("Err!!! " + e1.Message);
                    bExporting = false;
                    try
                    {
                        if (fNotify != null)
                        {
                            fNotify.InvokeClose();
                            fNotify = null;
                        }
                    }
                    catch (Exception e2)
                    {
                        Log.Error("Err!!! " + e2.Message);
                    }
                }
            });

            thread.Start();

            RefreshControls();
        }
Exemple #5
0
        private void Exit()
        {
            try
            {
                MyPPT.clearImg();
            }
            catch (Exception e) { Log.Error(e.Message); }

            isExit = true;
            //2016-04-09
            Log.Info("From1.exit now...");
            try
            {
                if (m_db != null)
                {
                    m_db.Close();
                    m_db = null;
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            this.timer_lessonOff.Enabled = false;
            this.ShowInTaskbar           = false;
            this.notifyIcon1.Visible     = false;

            try
            {
                Process p = Process.GetCurrentProcess();
                if (p != null)
                {
                    Log.Info("From1 KillProcess now. pid=" + p.Id);
                    Thread.Sleep(1000);
                    p.Kill();
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (m_Host != null)
                {
                    m_Host.Close();
                    m_Host = null;
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (m_HttpdComet != null)
                {
                    m_HttpdComet.stop();
                    m_HttpdComet = null;
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (thread_comet != null)
                {
                    thread_comet.Abort();
                    thread_comet.Interrupt();
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (thread_Manage != null)
                {
                    thread_Manage.Abort();
                    thread_Manage.Interrupt();
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (thread_DeviceStatusCheck != null)
                {
                    thread_DeviceStatusCheck.Abort();
                    thread_DeviceStatusCheck.Interrupt();
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (fNotify != null)
                {
                    fNotify.Close();
                    fNotify = null;
                }
            }
            catch (Exception e) { Log.Error(e.Message); }

            try
            {
                if (f12 != null)
                {
                    f12.Close();
                    f12 = null;
                }
                Application.Exit();
            }
            catch (Exception e) { Log.Error(e.Message); }


            Log.Info("From1 exit over.");
        }
Exemple #6
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);
            }
        }