private void btnIgnore_Click(object sender, EventArgs e) { String programName = lstUnconfirmed.SelectedItem.ToString(); Cprograms.hide(programName); fillList(); }
private void btnTrack_Click(object sender, EventArgs e) { String programName = lstIgnored.SelectedItem.ToString(); Cprograms.track(programName); fillList(); }
private void closeInactiveSessions() { Cstatus status = new Cstatus(); List <String> systemPrograms = status.GetProcesses(); //tüm takip edilenleri bul DataTable dbPrograms = Cprograms.getAllTracked(); foreach (DataRow dbProgram in dbPrograms.Rows) { //eğer çalışmıyorsa if (!systemPrograms.Contains((String)dbProgram["exe"])) { //açık session(ları) ı kapat Csessions.close((int)dbProgram["programid"]); if (!(bool)dbProgram["is_confirmed"]) { iTimer.Enabled = false; DialogResult result = MessageBox.Show(Strings.Tracking + " " + (String)dbProgram["exe"], (String)dbProgram["exe"], MessageBoxButtons.YesNo); if (result == DialogResult.Yes) { Cprograms.track((String)dbProgram["exe"]); } else if (result == DialogResult.No) { Cprograms.hide((String)dbProgram["exe"]); } iTimer.Enabled = true; } } } }
private void btnSaveProgram_Click(object sender, EventArgs e) { Boolean isTracked = rdTrack.Checked; int categoryId = (int)cmbCategory.SelectedValue; Cprograms.insert(txtTitle.Text, this.programName, isTracked, "", categoryId, true); this.Close(); }
private void fillList() { DataTable dbPrograms = new DataTable(); dbPrograms = Cprograms.getAllIgnored(); lstIgnored.DataSource = dbPrograms.AsEnumerable() .Select(r => r.Field <string>("exe")) .ToList(); }
private void btnSave_Click(object sender, EventArgs e) { DataRowView program = (DataRowView)lstTracked.SelectedItem; Cprograms.update((int)program["programid"], txtTitle.Text.Trim(), (int)cmbCategory.SelectedValue); program["name"] = txtTitle.Text.Trim(); program["categoryid"] = (int)cmbCategory.SelectedValue; lstTracked.SelectedItem = program; }
public void Control_Load_1(object sender, EventArgs e) { DataTable dbPrograms = new DataTable(); dbPrograms = Cprograms.getAllUnconfirmed(); lstApplications.DataSource = dbPrograms.AsEnumerable() .Select(r => r.Field <string>("exe")) .ToList(); }
private void fillList() { DataTable dbPrograms = new DataTable(); dbPrograms = Cprograms.getAllTracked(); lstTracked.DataSource = dbPrograms; lstTracked.DisplayMember = "exe"; lstTracked.ValueMember = "programid"; }
private void updateActiveSessions() { Cstatus status = new Cstatus(); List <String> systemPrograms = status.GetProcesses(); DataTable dbPrograms = new DataTable(); dbPrograms = Cprograms.getAll(); //sistemdeki tüm programları gez ve bağlı olarak sessionları oluştur veya update et foreach (String programExe in systemPrograms) { //program kayıtlı mı kontrol et var rows = dbPrograms.Select("exe = '" + programExe + "'"); //eğer veri tabanında varsa if (rows.Length != 0) { //ve eğer takip ediliyorsa if ((bool)rows[0]["is_tracked"]) { int programId = (int)rows[0]["programid"]; //programa ait açık sessionları bul DataTable sessions = Csessions.getOpen(programId); //eğer session varsa if (sessions.Rows.Count > 0) { //her açık olan her sessionı update et (normalde birden fazla satır olmaması lazım ama yinede kontrol et) foreach (DataRow session in sessions.Rows) { Csessions.update(programId, (Properties.Settings.Default.loopTime / 1000)); } } else { //açık session yok //session oluştur Csessions.create(programId); } } } else //veri tabanında kaydı yok ise { //programı kaydet ama sonra kullanıcıya sormak üzere işaretle Cprograms.insert(null, programExe, true, null, 1, false); } } //end of for system programs }
public List <String> GetUnregistredProcesses() { List <String> programNames = new List <string>(); ManagementClass MgmtClass = new ManagementClass("Win32_Process"); foreach (ManagementObject mo in MgmtClass.GetInstances()) { programNames.Add(mo["Name"].ToString()); //programNames.Add("Name: " + mo["Name"] + "\t\t ID: " + mo["ProcessId"] + "\t\t Path: " + mo["ExecutablePath"]); } programNames = programNames.Distinct().ToList(); DataTable dbPrograms = new DataTable(); dbPrograms = Cprograms.getAll(); List <string> dbList = dbPrograms.AsEnumerable() .Select(r => r.Field <string>("exe")) .ToList(); List <String> difList = programNames.Except(dbList).ToList(); return(difList); }