private void Optionstart_DoWork(object sender, DoWorkEventArgs e) { dynamic data = e.Argument; switch (data.action.ToString()) { case "Shutdown": { Notificare.ShowBalloonTip(1000, "Optimised Cloud", "Sistemul se va opri in 2 secunde.", ToolTipIcon.Info); //Trimite messajul primit de la actiunea trimisa din Cloud. Functii.DownloadString("http://" + Functii.webip + "/notify/" + Key + "/" + token + "/shutdown/"); Thread.Sleep(2000); Shutdown.Shut(); break; } case "Restart": { Notificare.ShowBalloonTip(1000, "Optimised Cloud", "Sistemul se va reseta in 2 secunde.", ToolTipIcon.Info); //Trimite messajul primit de la actiunea trimisa din Cloud. Functii.DownloadString("http://" + Functii.webip + "/notify/" + Key + "/" + token + "/restart/"); Thread.Sleep(2000); Shutdown.Restart(); break; } default: break; } }
static void LoginAuto(string key) { dynamic logininfo; try { logininfo = Newtonsoft.Json.JsonConvert.DeserializeObject(Functii.DownloadString("http://" + Functii.webip + "/loginapp/" + key.ToString())); } catch (Exception ex) { MessageBox.Show(ex.ToString()); throw; } if (logininfo.token.ToString().Length == 60) { Key = key; tokens = logininfo.token.ToString(); Id = logininfo.id.ToString(); Email = logininfo.email.ToString(); statie = logininfo.statie.ToString(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Optimised()); } else { error = logininfo.error.ToString(); Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Login()); } }
private void Sendonline_DoWork(object sender, DoWorkEventArgs e) { while (true) { var sendstats = Functii.DownloadString("http://" + Functii.webip + "/sendonline/" + Key + "/" + token); Thread.Sleep(10000); } }
static void Main(string[] args) { RegistryKey regKeyAppRoot = Registry.CurrentUser.OpenSubKey(@"Software\Optimised", true); RegistryKey regKeyAppRoot1; if (regKeyAppRoot == null) { RegistryKey key = Registry.CurrentUser.CreateSubKey(@"Software\Optimised"); key.SetValue("Key", "0"); regKeyAppRoot1 = Registry.CurrentUser.OpenSubKey(@"Software\Optimised", true); regKeyAppRoot.Close(); } else { int c = 0; foreach (string value in regKeyAppRoot.GetValueNames()) { c++; } if (c != 1) { regKeyAppRoot.SetValue("Key", "0"); } regKeyAppRoot1 = Registry.CurrentUser.OpenSubKey(@"Software\Optimised", true); regKeyAppRoot.Close(); } if (!mutex.WaitOne(TimeSpan.Zero, true)) { MessageBox.Show("Nu poti deschide aplicatia de mai multe ori"); } else { while (!Functii.CheckForInternetConnection()) { } if (Functii.CheckForInternetConnection()) { if (regKeyAppRoot1 != null) { try { if (regKeyAppRoot1.GetValue("Key") != null && regKeyAppRoot1.GetValue("Key").ToString().Length == 30) { LoginAuto(regKeyAppRoot1.GetValue("Key").ToString()); } else { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Application.Run(new Login()); } } catch { } } } } }
private void Closeproc_DoWork(object sender, DoWorkEventArgs e) { dynamic data = Newtonsoft.Json.JsonConvert.DeserializeObject(e.Argument.ToString()); Process p = Process.GetProcessById(Int32.Parse((string)(data.pid))); var proc = Process.GetProcessById((int)data.pid).ProcessName; p.Kill(); Functii.DownloadString("http://" + Functii.webip + "/notify/" + Key + "/" + token + "/close/" + proc); }
private void Opensite_DoWork(object sender, DoWorkEventArgs e) { dynamic data = e.Argument; if (data.url != null) { Process.Start(data.url.ToString()); //Porneste site-ul trimis din cloud. Notificare.ShowBalloonTip(1000, "Optimised Cloud", "Site-ul: " + data.url + " a pornit.", ToolTipIcon.Info); //Trimite messajul primit de la actiunea trimisa din Cloud. Functii.DownloadString("http://" + Functii.webip + "/notify/" + Key + "/" + token + "/site/" + Functii.Base64Encode(data.url.ToString())); } }
private void iTalk_Button_21_Click(object sender, EventArgs e) { if (mesaj.Text != string.Empty && nume.Text != string.Empty) { Functii.DownloadString("http://" + Functii.webip + "/report/" + Key + "/" + Token + "/" + Id + "/" + Email + "/" + nume.Text + "/" + mesaj.Text); this.Close(); } else { MessageBox.Show("Ambele campuri sunt necesare."); } }
private void SendInfo_Tick(object sender, EventArgs e) { dynamic ips = null; this.Hide(); try { var name = (from x in new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem").Get().Cast <ManagementObject>() select x.GetPropertyValue("Caption")).FirstOrDefault(); while (name == null) { name = (from x in new ManagementObjectSearcher("SELECT Caption FROM Win32_OperatingSystem").Get().Cast <ManagementObject>() select x.GetPropertyValue("Caption")).FirstOrDefault(); } var dataip = Functii.DownloadString("https://httpbin.org/ip"); if (dataip != null) { ips = Newtonsoft.Json.JsonConvert.DeserializeObject(dataip); } sistem = name.ToString(); if (ips != null) { ip = (ips["origin"]); } else { ip = "Error!"; } localip = (Functii.GetLocalIPAddress()); ManagementClass oMClass = new ManagementClass("Win32_NetworkAdapterConfiguration"); ManagementObjectCollection MObjCol = oMClass.GetInstances(); foreach (ManagementObject objMO in MObjCol) { if (objMO["MacAddress"] != null) { mac = objMO["MacAddress"].ToString(); } } Functii.DownloadString("http://" + Functii.webip + "/setinfo/" + Key + "/" + token + "/" + ip + "/" + mac + "/" + sistem + "/" + localip); } catch (Exception ex) { MessageBox.Show(ex.ToString()); } SendInfo.Stop(); }
private void Offline_FormClosing(object sender, FormClosingEventArgs e) { if (Functii.isadmin()) { notifyIcon1.Dispose(); var proc = Process.GetCurrentProcess().ProcessName; foreach (var process in Process.GetProcessesByName(proc)) { process.Kill(); } } else { notifyIcon1.ShowBalloonTip(1000, "Optimised", "Nu esti Administrator.", ToolTipIcon.Info); //Trimite messajul primit de la actiunea trimisa din Cloud. } }
//clearGC_Timer End #endregion #region Sistem_Login private void iTalk_Button_21_Click(object sender, EventArgs e) { if (iTalk_TextBox_Big3.Text != "") { dynamic logininfo; try { logininfo = Newtonsoft.Json.JsonConvert.DeserializeObject(Functii.DownloadString("http://" + Functii.webip + "/loginapp/" + iTalk_TextBox_Big3.Text)); //Cere informatii despre Login la API. if (logininfo.token.ToString().Length != 60) //Verifica daca a returnat token sau nu. { try { notifyIcon1.ShowBalloonTip(1000, "Optimised Login", logininfo.error.ToString(), ToolTipIcon.Info); //Trimite messajul primit de la API. } catch (Exception) { notifyIcon1.ShowBalloonTip(1000, "Optimised Login", "Eroare la server!", ToolTipIcon.Info); //Trimite messajul primit de la API. throw; } } else { RegistryKey keys = Registry.CurrentUser.OpenSubKey(@"Software\Optimised", true); //Se deschide calea catre regedit. keys.SetValue("Key", iTalk_TextBox_Big3.Text.ToString()); //Se seteaza codul introdus pentru login in regedit. this.Hide(); //Ascunde Form-ul de Login. token = logininfo.token.ToString(); //Salveaza token-ul primit. Id = logininfo.id.ToString(); //Salveaza ID-ul primit. statie = logininfo.statie.ToString(); Email = logininfo.email.ToString(); //Salveaza Email-ul primit. Key = iTalk_TextBox_Big3.Text.ToString(); //Salveaza key Optimised optimised = new Optimised(); //Deschide calea catre noul Form. notifyIcon1.Dispose(); //Stinge Iconita din sistem Tray. optimised.Show(); //Porneste Form-ul cu aplicatia propriuzisa. clearGC.Stop(); //Opreste timerul pentru optimizarea programului. } } catch (Exception) { throw; } } else { notifyIcon1.ShowBalloonTip(1000, "Optimised Login", "Parola lipseste!", ToolTipIcon.Info); //Trimite messajul primit de la API. } }
private void exitToolStripMenuItem_Click(object sender, EventArgs e) { if (Functii.isadmin()) { notifyIcon1.Dispose(); var proc = Process.GetCurrentProcess().ProcessName; foreach (var process in Process.GetProcessesByName(proc)) { process.Kill(); } //Stinge Aplicatia. } else { notifyIcon1.ShowBalloonTip(1000, "Optimised", "Nu esti Administrator.", ToolTipIcon.Info); //Trimite messajul primit de la actiunea trimisa din Cloud. } }
private void UpdateProces_DoWork(object sender, DoWorkEventArgs e) { int lastPID = -1; string lastPROC = ""; while (true) { var nameproc = Functii.GetActiveWindowTitle(); var PID = Functii.GetActivePID(); var proc = Process.GetProcessById((int)PID).ProcessName; if (lastPID != (int)PID || lastPROC != nameproc) { Functii.DownloadString("http://" + Functii.webip + "/setmainproc/" + Key + "/" + token + "/" + PID + "/" + nameproc + "/" + proc); lastPID = (int)PID; } Thread.Sleep(5000); } }
private void ClearRam_Tick(object sender, EventArgs e) { Functii.FlushMemory(); //Elibereaza memoria din program. }
private void Optimised_All_DoWork(object sender, DoWorkEventArgs e) { ListBox.CheckForIllegalCrossThreadCalls = false; iTalk.iTalk_GroupBox.CheckForIllegalCrossThreadCalls = false; Notificare.ShowBalloonTip(1000, "Optimised Cloud", "Optimizarea trimisa din cloud pentru toti utilizatorii a inceput.", ToolTipIcon.Info); //Trimite messajul primit de la actiunea trimisa din Cloud. dynamic obj = (dynamic)e.Argument; if (obj["muic"] == 1) { try { regKey = Registry.CurrentUser.OpenSubKey(@"Software\Classes\Local Settings\Software\Microsoft\Windows\Shell\MuiCache", true); foreach (string value in regKey.GetValueNames()) { regKey.DeleteValue(value, true); } regKey.Close(); } catch { } } if (obj["pref"] == 1) { try { Array.ForEach(Directory.GetFiles(windows + @"Windows\Prefetch\", "*.pf"), delegate(string path) { File.Delete(path); if (!File.Exists(path)) { } }); } catch { }//Delete Prefetch } if (obj["rapp"] == 1) { try { RegistryKey regKeyAppRoot = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Search\RecentApps", true); foreach (string value in regKeyAppRoot.GetSubKeyNames()) { regKeyAppRoot.DeleteSubKeyTree(value, true); } regKeyAppRoot.Close(); } catch { }//Delete Regedit } if (obj["temp"] == 1) { string pat = Path.GetTempPath(); System.IO.DirectoryInfo di = new DirectoryInfo(pat.ToString()); foreach (FileInfo file in di.GetFiles()) { try { file.Delete(); if (!File.Exists(file.FullName)) { } } catch { } } foreach (DirectoryInfo dir in di.GetDirectories()) { try { dir.Delete(true); if (!Directory.Exists(dir.FullName)) { } } catch { } } } if (obj["trac"] == 1) { try { RegistryKey regKeyAppRoot = Registry.LocalMachine.OpenSubKey(@"Software\WOW6432Node\Microsoft\Tracing", true); foreach (string value in regKeyAppRoot.GetSubKeyNames()) { regKeyAppRoot.DeleteSubKeyTree(value, true); } regKeyAppRoot.Close(); } catch { }//Delete Regedit } if (obj["rebin"] == 1) { try { uint result = SHEmptyRecycleBin(IntPtr.Zero, null, RecycleFlags.SHERB_NOCONFIRMATION); } catch { } } if (obj["rfile"] == 1) { String recent = Environment.ExpandEnvironmentVariables("%APPDATA%") + @"\Microsoft\Windows\Recente"; try { Array.ForEach(Directory.GetFiles(recent, "*.*"), delegate(string path) { File.Delete(path); if (!File.Exists(path)) { } }); } catch { }//Delete Recent files try { SHAddToRecentDocs(ShellAddToRecentDocsFlags.Pidl, (IntPtr)(0)); } catch { } } if (obj["wlogs"] == 1) { foreach (var eventLog in EventLog.GetEventLogs()) { try { eventLog.Clear(); eventLog.Dispose(); } catch { } } } if (obj["mpoint"] == 1) { try { RegistryKey regKeyAppRoot = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Explorer\MountPoints2", true); foreach (string values in regKeyAppRoot.GetSubKeyNames()) { regKeyAppRoot.DeleteSubKeyTree(values, true); } } catch { }//Delete Regedit } if (obj["rstart"] == 1) { try { regKey = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows\CurrentVersion\Run", true); foreach (string value in regKey.GetValueNames()) { regKey.DeleteValue(value, true); } regKey.Close(); } catch { } } if (obj["useras"] == 1) { try { regKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\UserAssist", true); foreach (string value in regKey.GetSubKeyNames()) { regKey = Registry.CurrentUser.OpenSubKey(@"SOFTWARE\Microsoft\Windows\CurrentVersion\Explorer\UserAssist\" + value.ToString() + @"\Count", true); foreach (string cont in regKey.GetValueNames()) { regKey.DeleteValue(cont, true); } } regKey.Close(); } catch { } } if (obj["compstore"] == 1) { try { RegistryKey regKeyAppRoot = Registry.CurrentUser.OpenSubKey(@"Software\Microsoft\Windows NT\CurrentVersion\AppCompatFlags\Compatibility Assistant\Store", true); foreach (string values in regKeyAppRoot.GetValueNames()) { regKeyAppRoot.DeleteValue(values, true); } } catch { }//Delete Regedit } Notificare.ShowBalloonTip(1000, "Optimised Cloud End", "Optimizarea trimisa din cloud pentru toti utilizatorii a fost efectuata.", ToolTipIcon.Info); //Trimite messajul primit de la actiunea trimisa din Cloud se termina. Functii.DownloadString("http://" + Functii.webip + "/notify/" + Key + "/" + token + "/all/"); }
//Initializare Form Login End #endregion #region clearGC_Timer_Wipe_Ram //clearGC_Timer Start private void clearGC_Tick(object sender, EventArgs e) { Functii.FlushMemory(); //Colecteaza tot ramul utilizat si il sterge. }
private void GClean_Tick(object sender, EventArgs e) { Functii.FlushMemory(); }