Example #1
0
        //获得txt的线程操作
        private void getDataThread()
        {
            ArrayList a = new ArrayList();

            try
            {
                a = sftp.GetFileList("/root/netrecord", filename);
                if (a.Count > 0)
                {
                    //获得日期的网页监控(txt文件)
                    MyInvoke mi2 = new MyInvoke(updateText);//窗体控件的线程间安全调用
                    this.BeginInvoke(mi2, new Object[] { filename });
                    mi2 = new MyInvoke(updateButton);
                    this.BeginInvoke(mi2, new Object[] { filename });
                }
                else
                {
                    error       = true;
                    progressbar = 0;
                    MessageBox.Show("没有该日期的数据!");
                    return;
                }
            }
            catch (Exception e)
            {
                error = true;
                Console.WriteLine("错误信息:" + e.Message);
            }
        }
Example #2
0
        //获得txt的线程操作
        private void getDataThread()
        {
            ArrayList a = new ArrayList();

            //获得日期+编号的反馈报告(txt文件)
            try
            {
                a = sftp.GetFileList("/root/txt", filename);
                if (a.Count > 0)
                {
                    MyInvoke mi2 = new MyInvoke(updateText);//窗体控件的线程间安全调用
                    this.BeginInvoke(mi2, new Object[] { filename });
                }
                else
                {
                    error       = true;
                    progressbar = 0;
                    MessageBox.Show("没有该日期的数据!");
                    return;
                }
            }
            catch
            {
                error       = true;
                progressbar = 0;
                MessageBox.Show("没有相应数据!请重新选择日期或编号");
                return;
            }
        }
Example #3
0
        //获取图片线程操作
        private void getImageThread()
        {
            //初始化
            sftp.Connect();                                //与服务器建立连接
            MemoryStream ms;                               //内存区域的流,用来读取截图
            MyInvoke     mi = new MyInvoke(UpdateForm);    //窗体控件的线程间安全调用

            arr = sftp.GetFileList("/root/img", filename); //获取文件列表

            progressbar = 10;
            //判断如果没有相应的截图时,则报错
            if (arr.Count == 0)
            {
                MessageBox.Show("没有该日期的数据!");
                progressbar = 0;
                error       = true;
                return;
            }

            //先读取出第一个截图
            ms                = new MemoryStream(sftp.Get("/root/img/" + arr[0]));
            images            = new Image[arr.Count];
            images[0]         = Image.FromStream(ms);
            pictureBox1.Image = images[0];
            flag              = 0;
            ms.Close();
            progressbar = 12;


            //如果有更多图片,则一一读取
            if (arr.Count > 1)
            {
                for (int i = 1; i < arr.Count; i++)
                {
                    Console.WriteLine(arr[i]);
                    ms        = new MemoryStream(sftp.Get("/root/img/" + arr[i]));
                    images[i] = Image.FromStream(ms);
                    ms.Close();
                    if (progressbar >= 92)
                    {
                        progressbar = 92;
                    }
                    else
                    {
                        progressbar = progressbar + 4;
                    }
                }
            }
            sftp.Disconnect();    //断开服务器连接
            this.BeginInvoke(mi); //调用控件的安全线程
            progressbar = 100;
        }