Exemple #1
0
        public void localScreenCapture(bool showCursor)
        {
            counter++;
            string        id = getID();
            string        name = "default", text = GetMACAddress();
            SqlConnection con;
            SqlCommand    cmd;


            Point curPos  = new Point(Cursor.Position.X, Cursor.Position.Y);
            Size  curSize = new Size();

            curSize.Height = Cursor.Current.Size.Height;
            curSize.Width  = Cursor.Current.Size.Width;

            //Conceal this form while the screen capture takes place
            this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
            this.TopMost     = false;

            //Allow 250 milliseconds for the screen to repaint itself (we don't want to include this form in the capture)
            System.Threading.Thread.Sleep(250);

            Rectangle bounds = Screen.GetBounds(Screen.GetBounds(Point.Empty));
            string    fi     = ".jpg";

            ScreenShot.CaptureImage(showCursor, curSize, curPos, Point.Empty, Point.Empty, bounds, name + ".jpeg", fi);

            //The screen has been captured and saved to a file so bring this form back into the foreground
            this.WindowState = System.Windows.Forms.FormWindowState.Normal;
            this.TopMost     = true;

            Image        img       = Image.FromFile(name + ".jpeg");
            MemoryStream tmpStream = new MemoryStream();

            img.Save(tmpStream, ImageFormat.Jpeg);
            byte[] imgBytes = new byte[1304140];
            tmpStream.Read(imgBytes, 0, 1304140);

            byte[]       image    = null;
            string       filepath = name + ".jpeg";
            FileStream   fs       = new FileStream(filepath, FileMode.Open, FileAccess.Read);
            BinaryReader br       = new BinaryReader(fs);

            image = br.ReadBytes((int)fs.Length);

            byte[] image2 = localWeb();

            string sql = " insert into table1 (screenSHot,webShot)  values(Convert(varbinary(max),@Imgg),Convert(varbinary(max),@Imgg2))";

            con = new SqlConnection(@"Data Source=(LocalDB)\v11.0;AttachDbFilename=E:\P\PC control Using Android Over Internet (Ahmad  Waris)\User\User\Database2.mdf;Integrated Security=True");
            if (con.State != ConnectionState.Open)
            {
                con.Open();
            }
            cmd = new SqlCommand(sql, con);
            cmd.Parameters.Add(new SqlParameter("@Imgg", image == null ? (object)DBNull.Value : image));
            cmd.Parameters.Add(new SqlParameter("@Imgg2", image2 == null ? (object)DBNull.Value : image2));
            int x = cmd.ExecuteNonQuery();

            con.Close();
        }
Exemple #2
0
        public void screenCapture(bool showCursor)
        {
            string        id = getID();
            string        name = "default", text = GetMACAddress();
            SqlConnection con = new SqlConnection("workstation id=MyPDBPCC.mssql.somee.com;packet size=4096;user id=cma93_SQLLogin_1;pwd=jztlqk3kqs;data source=MyPDBPCC.mssql.somee.com;persist security info=False;initial catalog=MyPDBPCC");
            SqlCommand    cmd = new SqlCommand("Update table1 Set Control='1' where Id='" + id + "'", con);

            con.Open();
            cmd.ExecuteNonQuery();
            con.Close();

            Point curPos  = new Point(Cursor.Position.X, Cursor.Position.Y);
            Size  curSize = new Size();

            curSize.Height = Cursor.Current.Size.Height;
            curSize.Width  = Cursor.Current.Size.Width;

            //Conceal this form while the screen capture takes place
            this.WindowState = System.Windows.Forms.FormWindowState.Minimized;
            this.TopMost     = false;

            //Allow 250 milliseconds for the screen to repaint itself (we don't want to include this form in the capture)
            System.Threading.Thread.Sleep(250);

            Rectangle bounds = Screen.GetBounds(Screen.GetBounds(Point.Empty));
            string    fi     = ".jpg";

            ScreenShot.CaptureImage(showCursor, curSize, curPos, Point.Empty, Point.Empty, bounds, name + ".jpeg", fi);

            //The screen has been captured and saved to a file so bring this form back into the foreground
            this.WindowState = System.Windows.Forms.FormWindowState.Normal;
            this.TopMost     = true;

            Image        img       = Image.FromFile(name + ".jpeg");
            MemoryStream tmpStream = new MemoryStream();

            img.Save(tmpStream, ImageFormat.Jpeg);
            byte[] imgBytes = new byte[1304140];
            tmpStream.Read(imgBytes, 0, 1304140);

            byte[]       image    = null;
            string       filepath = name + ".jpeg";
            FileStream   fs       = new FileStream(filepath, FileMode.Open, FileAccess.Read);
            BinaryReader br       = new BinaryReader(fs);

            image = br.ReadBytes((int)fs.Length);


            string sql = " Update table1 Set Snap = @Imgg where Id='" + id + "'";

            con = new SqlConnection("workstation id=MyPDBPCC.mssql.somee.com;packet size=4096;user id=cma93_SQLLogin_1;pwd=jztlqk3kqs;data source=MyPDBPCC.mssql.somee.com;persist security info=False;initial catalog=MyPDBPCC");
            if (con.State != ConnectionState.Open)
            {
                con.Open();
            }
            cmd = new SqlCommand(sql, con);
            cmd.Parameters.Add(new SqlParameter("@Imgg", image));
            int x = cmd.ExecuteNonQuery();

            con.Close();
        }