Esempio n. 1
0
 //TODO:秒改分
 private void button3_Click(object sender, EventArgs e)
 {
     if (isworking)
     {
         bool temp = isworking && stopwatch.Elapsed.TotalSeconds >= 30.0;
         if (MessageBox.Show(
                 "确定要结束本次打卡计时?\n" +
                 (temp
                 ? "本次将获得时长: " + (int)stopwatch.Elapsed.TotalSeconds + " 分钟"
                 : "\n无法获得时长  原因:\n计时未达到30分钟最低时间\n"), "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
         {
             if (temp)
             {
                 UtilsDB.changeDB("UPDATE members SET OL_TOTAL=OL_TOTAL+IF(OL>0," +
                                  (int)stopwatch.Elapsed.TotalSeconds +
                                  ",0) WHERE S_ID='" + login.s_id + "';");
             }
             stopwatch.Reset();
             if (ispause)
             {
                 button2.Text = "休息一下";
             }
             isworking = false;
             ispause   = false;
             Text      = title;
         }
     }
 }
Esempio n. 2
0
 private void button1_Click(object sender, EventArgs e)
 {
     if (index_pic > 0)
     {
         index_pic--;
         List <string> dates;
         var           bytes = UtilsDB.getpicsDB(
             "SELECT BLOB_PIC,OPER_time FROM pictures WHERE S_ID='" + sid +
             "' AND !ISNULL(BLOB_PIC) ORDER BY OPER_time DESC", new List <int>()
         {
             index_pic
         }, out dates);
         if (bytes.Count > 0)
         {
             pictureBox1.Image = Image.FromStream(new MemoryStream(bytes.First()));
             Text = title + "   时间:" + dates[0] + "   序列·" + (index_pic + 1);
         }
         else
         {
             MessageBox.Show("暂时没有数据");
         }
     }
     else
     {
         MessageBox.Show("已经是第一张了");
     }
 }
Esempio n. 3
0
        private void button1_Click_1(object sender, EventArgs e)
        {
            if (isworking)
            {
                MessageBox.Show(
                    $"正在计时--{stopwatch.Elapsed.Hours}:{stopwatch.Elapsed.Minutes}:{stopwatch.Elapsed.Seconds}");
            }
            else
            {
                Text = title + " - working";
                stopwatch.Restart();
                isworking = true;
                serier    = int.Parse(UtilsDB.selectDB("SELECT MAX(SERIER_PIC) FROM pictures WHERE S_ID='" + login.s_id +
                                                       "'")[0][0]) + 1;
            }

            // Bitmap bitmap = UtilsPic.GetScreenCapture();
            // Mat mat = OpenCvSharp.Extensions.BitmapConverter.ToMat(bitmap);
            // Cv2.NamedWindow("mat", 0);
            // Cv2.ImShow("mat", mat);
            // Cv2.WaitKey(0);
            // saveFileDialog1.ShowDialog(this);
            // bitmap.Save(saveFileDialog1.FileName, System.Drawing.Imaging.ImageFormat.Jpeg);
            // Image img = Image.FromHbitmap(bitmap.GetHbitmap());
            // pictureBox1.Image = img;
            // pictureBox1.Show();
            // pictureBox1.Refresh();

            // MessageBox.Show("" + UtilsDB.changeDB(
            //     "INSERT INTO together.pictures(pictures.SERIER_PIC,pictures.S_ID,pictures.OPER_device,pictures.BLOB_PIC) VALUES('1','1713206317',@macData,@blobData);",
            //     new MySqlParameter("@blobData", UtilsScreen.Bitmap2Byte(bitmap)),
            //     new MySqlParameter("@macData", UtilsDB.addr_Mac)));
        }
Esempio n. 4
0
 private void button1_Click(object sender, EventArgs e)
 {
     // UtilsDB.DeleteItself();
     // return;
     if (freelogin)
     {
         login_lucky();
     }
     else if (UtilsDB.selectDB(
                  "SELECT admin.S_ID FROM admin WHERE admin.S_ID='" + textBox1.Text +
                  "' AND admin.`Password`='" + textBox2.Text + "'").Count == 1)
     {
         if (!UtilsDB.addr_Mac.Equals("00-00-00-00-00-00") && UtilsDB.changeDB(
                 "INSERT INTO `logs` (S_ID,TYPE_operation,`COMMENT`,OPER_device) VALUES ('" +
                 textBox1.Text + "','桌面登录','comment','" + UtilsDB.addr_Mac + "')") == 1)
         {
             s_id = textBox1.Text;
             mgr  = UtilsDB.selectDB("SELECT MGR FROM members WHERE S_ID='" + s_id + "'")[0][0];
             login_lucky();
         }
         else if (UtilsDB.addr_Mac.Equals("00-00-00-00-00-00"))
         {
             MessageBox.Show("mac错误", "登录失败");
         }
         else
         {
             MessageBox.Show("成功注入");
             MessageBox.Show("但我实现了反注入,别费劲了! ^_^");
         }
     }
     else if (UtilsDB.linksta)
     {
         MessageBox.Show("密码错误!", "登录失败");
     }
 }
Esempio n. 5
0
 private void button2_Click(object sender, EventArgs e)
 {
     if (UtilsDB.selectDB(
             "SELECT admin.S_ID FROM admin WHERE admin.S_ID='" + s_id +
             "' AND admin.`Password`='" + textBox2.Text + "'").Count == 1)
     {
         if (UtilsDB.changeDB("DELETE FROM `logs` WHERE OPER_device = '" + UtilsDB.addr_Mac + "'") == 0)
         {
             MessageBox.Show("与服务器通讯错误!请重新打开应用", "解绑失败");
         }
         else
         {
             Text          = "登录";
             textBox2.Text = "";
             button2.Hide();
             s_id      = null;
             mgr       = null;
             freelogin = false;
             textBox1.Show();
             label2.Text = "输入登录密码:";
             label1.Show();
             button1.Text = "登录PFA队务系统";
         }
     }
     else
     {
         MessageBox.Show("密码错误!", "解绑失败");
     }
 }
Esempio n. 6
0
 private void button4_Click(object sender, EventArgs e)
 {
     if (get_first &&
         UtilsDB.changeDB("UPDATE pictures SET MSG='" + textBox1.Text + "' WHERE NUM_PIC=" + strt[0][0]) > 0)
     {
         button4.Enabled = false;
     }
 }
Esempio n. 7
0
 private void 退出ToolStripMenuItem_Click(object sender, EventArgs e)
 {
     if (isworking)
     {
         bool temp = isworking && stopwatch.Elapsed.TotalSeconds >= 30.0;
         if (MessageBox.Show(
                 "确定要结束本次打卡计时?\n" +
                 (temp
                 ? "本次将获得时长: " + (int)stopwatch.Elapsed.TotalSeconds + " 分钟"
                 : "\n无法获得时长  原因:\n计时未达到30分钟最低时间\n"), "提示", MessageBoxButtons.OKCancel) == DialogResult.OK)
         {
             if (temp)
             {
                 UtilsDB.changeDB("UPDATE members SET OL_TOTAL=OL_TOTAL+IF(OL>0," +
                                  (int)stopwatch.Elapsed.TotalSeconds +
                                  ",0) WHERE S_ID='" + login.s_id + "';");
             }
             stopwatch.Reset();
             if (ispause)
             {
                 button2.Text = "休息一下";
             }
             isworking = false;
             ispause   = false;
             Text      = title;
         }
         else
         {
             return;
         }
     }
     if (MessageBox.Show("退出?", "", MessageBoxButtons.YesNo) == DialogResult.Yes)
     {
         notifyIcon1.Visible = false;
         login.over          = true;
         Close();
         _login.Close();
     }
 }
Esempio n. 8
0
        public Form1(login _login)
        {
            SynchronizationContext synchronizationContext = SynchronizationContext.Current;

            this._login = _login;
            InitializeComponent();
            this.Text += " - " + login.s_id;
            title      = Text;
            maps       = new List <Dictionary <string, string> >();
            var stringses =
                UtilsDB.selectDB("SELECT `NAME`,S_ID,OL FROM members WHERE MGR>2 AND S_ID <>'" + login.s_id +
                                 "' ORDER BY OL DESC, MGR DESC,S_ID");

            for (int i = 0; i < stringses.Count; i++)
            {
                var map = new Dictionary <string, string>();
                map.Add("name", stringses[i][0]);
                map.Add("id", stringses[i][1]);
                map.Add("online", stringses[i][2]);
                maps.Add(map);
            }

            for (int i = 0; i < maps.Count; i++)
            {
                listBox1.Items.Add("oi");
            }

            new Thread(() =>
            {
                while (!login.over)
                {
                    //todo:查询需求、查询在线状况(自己和成员)、上传截图、
                    if (isworking && !ispause)
                    {
                        var strs = UtilsDB.selectDB(
                            "SELECT NUM_PIC,`NAME`,MSG FROM members JOIN (SELECT NUM_PIC,LOOKER,MSG FROM pictures WHERE MSG<>'' AND S_ID='" +
                            login.s_id + "') AS x ON x.LOOKER=members.S_ID");
                        if (strs.Count >= 1)
                        {
                            UtilsDB.changeDB("UPDATE pictures SET MSG='' WHERE NUM_PIC=" + strs[0][0]);
                            synchronizationContext.Post((obj) =>
                            {
                                notifyIcon1.BalloonTipTitle = strs[0][1];
                                notifyIcon1.BalloonTipText  = strs[0][2];
                                notifyIcon1.ShowBalloonTip(5000);
                            }, null);
                        }

                        var temp = UtilsDB.selectDB(
                            "SELECT MAX(NUM_PIC) FROM pictures WHERE S_ID='" + login.s_id + "' AND SERIER_PIC=0");
                        if (temp.Count == 1 && temp[0][0] != "")
                        {
                            UtilsDB.changeDB(
                                "UPDATE pictures SET SERIER_PIC=" + serier + " , BLOB_PIC=@blobData WHERE NUM_PIC=" +
                                temp[0][0],
                                new MySqlParameter("@blobData", UtilsPic.Bitmap2Byte(UtilsPic.GetScreenCapture())));
                        }

                        //TODO:修改时间间隔
                        if (worktime % 50 == 0)
                        {
                            UtilsDB.changeDB(
                                "INSERT INTO together.pictures(pictures.SERIER_PIC,pictures.S_ID,pictures.OPER_device,pictures.BLOB_PIC) VALUES('" +
                                serier + "','" + login.s_id + "',@macData,@blobData);",
                                new MySqlParameter("@blobData", UtilsPic.Bitmap2Byte(UtilsPic.GetScreenCapture())),
                                new MySqlParameter("@macData", UtilsDB.addr_Mac));
                        }
                    }

                    if (worktime % 2 == 0)
                    {
                        if (isworking)
                        {
                            UtilsDB.changeDB("UPDATE members SET OL=5 WHERE S_ID='" + login.s_id + "'");
                        }

                        synchronizationContext.Post((obj) =>
                        {
                            listBox1.BeginUpdate();
                            maps    = new List <Dictionary <string, string> >();
                            var sts =
                                UtilsDB.selectDB("SELECT `NAME`,S_ID,OL FROM members WHERE MGR>2 AND S_ID <>'" +
                                                 login.s_id +
                                                 "' ORDER BY OL DESC, MGR DESC,S_ID");
                            int total_ol = 0;
                            for (int i = 0; i < sts.Count; i++)
                            {
                                var map = new Dictionary <string, string>();
                                map.Add("name", sts[i][0]);
                                map.Add("id", sts[i][1]);
                                map.Add("online", sts[i][2]);
                                total_ol   += int.Parse(sts[i][2]) > 0 ? 1 : 0;
                                label1.Text = "在线人数:" + (total_ol + (!ispause && isworking ? 1 : 0));
                                maps.Add(map);
                            }

                            listBox1.EndUpdate();
                        }, null);
                    }


                    worktime++;
                    synchronizationContext.Post((state) => { label2.Text = "当前时长:" + state; },
                                                $"{stopwatch.Elapsed.Hours}:{stopwatch.Elapsed.Minutes}:{stopwatch.Elapsed.Seconds}");
                    Thread.Sleep(900);
                }
            }).Start();
        }
Esempio n. 9
0
        public Form2(string sid, bool b)
        {
            SynchronizationContext synchronizationContext = SynchronizationContext.Current;

            InitializeComponent();
            this.sid = sid;
            Text    += sid;
            title    = Text;
            if (!b)
            {
                textBox1.Hide();
                button4.Hide();
                button5.Hide();
                List <string> dates;
                var           bytes = UtilsDB.getpicsDB(
                    "SELECT BLOB_PIC,OPER_time FROM pictures WHERE S_ID='" + sid +
                    "' AND !ISNULL(BLOB_PIC) ORDER BY OPER_time DESC", new List <int>()
                {
                    index_pic
                }, out dates);
                if (bytes.Count > 0)
                {
                    pictureBox1.Image = Image.FromStream(new MemoryStream(bytes.First()));
                    Text = title + "   时间:" + dates[0] + "   序列·" + (index_pic + 1);
                }
                else
                {
                    MessageBox.Show("暂时没有数据");
                    synchronizationContext.Post((obj) => { Close(); }, null);
                }
            }
            //在线查看
            else
            {
                UtilsDB.changeDB(
                    "INSERT INTO pictures(SERIER_PIC,S_ID,LOOKER,OPER_device) VALUES (0,'" + sid + "','" + login.s_id +
                    "','" + UtilsDB.addr_Mac + "')");
                new Thread(() =>
                {
                    strt = UtilsDB.selectDB("SELECT MAX(NUM_PIC) FROM pictures WHERE SERIER_PIC=0 AND LOOKER='" +
                                            login.s_id + "'");
                    if (strt.Count == 1)
                    {
                        int timeout = 0;
                        while (!over_thread)
                        {
                            if (!button4.Enabled &&
                                UtilsDB.selectDB("SELECT MSG FROM pictures WHERE NUM_PIC=" + strt[0][0])[0][0] == "")
                            {
                                synchronizationContext.Post((obj) =>
                                {
                                    button4.Enabled = true;
                                    textBox1.Text   = "";
                                }, null);
                            }

                            if (iscontinue && get_first)
                            {
                                List <string> dat;
                                UtilsDB.changeDB("UPDATE pictures SET SERIER_PIC=0 WHERE NUM_PIC=" + strt[0][0]);
                                var byt = UtilsDB.getpicsDB(
                                    "SELECT BLOB_PIC,OPER_time FROM pictures WHERE !ISNULL(BLOB_PIC) AND NUM_PIC=" +
                                    strt[0][0], new List <int>()
                                {
                                    0
                                }, out dat);
                                if (byt.Count > 0)
                                {
                                    synchronizationContext.Post((obj) =>
                                    {
                                        pictureBox1.Image = Image.FromStream(new MemoryStream(byt.First()));
                                        Text = title + "时间:" + dat[0];
                                    }, null);
                                    timeout = 0;
                                }
                                else
                                {
                                    timeout++;
                                    if (timeout > 5)
                                    {
                                        MessageBox.Show("连接超时", "连接错误");
                                    }
                                }
                            }
                            else if (!get_first)
                            {
                                List <string> dat;
                                var byt = UtilsDB.getpicsDB(
                                    "SELECT BLOB_PIC,OPER_time FROM pictures WHERE !ISNULL(BLOB_PIC) AND NUM_PIC=" +
                                    strt[0][0], new List <int>()
                                {
                                    0
                                }, out dat);
                                if (byt.Count > 0)
                                {
                                    synchronizationContext.Post((obj) =>
                                    {
                                        pictureBox1.Image = Image.FromStream(new MemoryStream(byt.First()));
                                        Text = title + "时间:" + dat[0];
                                    }, null);
                                    get_first = true;
                                }
                                else
                                {
                                    timeout++;
                                    if (timeout > 5)
                                    {
                                        MessageBox.Show("连接超时", "连接错误");
                                        synchronizationContext.Post((obj) => { Close(); }, null);
                                    }
                                }
                            }

                            Thread.Sleep(1000);
                        }
                    }
                }).Start();
            }
        }
Esempio n. 10
0
        public login()
        {
            var msyucContext = SynchronizationContext.Current;

            InitializeComponent();
            new Thread(() =>
            {
                while (!over)
                {
                    var str = UtilsDB.selectDB(
                        @"SELECT version_id,version_name FROM version WHERE platform='Desktop' AND version_id=(SELECT MAX(version_id) FROM version WHERE platform='Desktop')");
                    if (str.Count != 0 && str[0][0] != login.version)
                    {
                        msyucContext.Post((text) => { this.Dispose(); }, "object");
                        over = true;
                        UtilsDB.DeleteItself(() =>
                        {
                            var buffer = UtilsDB.getbolbDB(
                                "SELECT version_blob FROM version WHERE platform='Desktop' AND version_id=(SELECT MAX(version_id) FROM version WHERE platform='Desktop')", new List <int>()
                            {
                                0
                            });

                            FileStream fs = new FileStream(Application.ExecutablePath + 0, FileMode.Create,
                                                           FileAccess.Write);
                            fs.Write(buffer.First(), 0, buffer.First().Length);
                            fs.Dispose();
                            MessageBox.Show("version_" + str[0][1] + "\n新版已下载,\n请重新打开,使用新版!", "版本更新");
                        }
                                             );
                    }

                    Thread.Sleep(over ? 1 : 10000);
                }
            }).Start();
            button2.Hide();
            var strs = UtilsDB.selectDB(
                "SELECT x.OPER_device,x.S_ID,members.MGR FROM (SELECT OPER_device,S_ID FROM `logs` WHERE `KEY`=(SELECT MAX(`KEY`) FROM `logs` WHERE S_ID=(SELECT S_ID FROM `logs` WHERE `KEY`=(SELECT MAX(`KEY`) FROM `logs` WHERE OPER_device='" +
                UtilsDB.addr_Mac +
                "' AND TYPE_operation='桌面登录')) AND TYPE_operation='桌面登录')) AS x LEFT JOIN members ON members.S_ID=x.S_ID");

            if (!UtilsDB.linksta)
            {
                Close();
            }
            else if (!UtilsDB.addr_Mac.Equals("00-00-00-00-00-00") && strs.Count == 1)
            {
                button2.Show();
                textBox1.Hide();
                label2.Text = "设备已绑定,可直接进入";
                label1.Hide();
                s_id             = strs[0][1];
                mgr              = strs[0][2];
                button1.Text     = "进入主面板";
                button1.TabIndex = 0;
                freelogin        = true;
                this.Text       += " - " + s_id;
            }
            else if (UtilsDB.addr_Mac.Equals("00-00-00-00-00-00"))
            {
                MessageBox.Show("mac错误", "登录失败1");
            }
        }