private void trackBar1_Scroll(object sender, EventArgs e) { int Value = -1; Optimizasyon.Delagate(trackBar1, () => { Value = trackBar1.Value; }); Delegates.Text.Set(lblZamanAsimi, string.Format("{0} saniye", Value.ToString())); }
public void SetDurum(Durum value) { durum = value; Optimizasyon.Delagate(pBox, () => { switch (value) { case Durum.None: pBox.Image = null; break; case Durum.Aktif: pBox.Image = Properties.Resources.tick_box_24px; break; case Durum.Pasif: pBox.Image = Properties.Resources.close_window_24px; break; case Durum.Yukleniyor: pBox.Image = Properties.Resources.loading; break; default: break; } }); }
private void Form1_Load(object sender, EventArgs e) { if (string.IsNullOrEmpty(CommonLogFolderPath)) { CommonLogFolderPath = Application.StartupPath + "\\Logs"; Properties.Settings.Default.CommonLogFolderPath = CommonLogFolderPath; Properties.Settings.Default.Save(); } srv = ChromeDriverService.CreateDefaultService(); srv.HideCommandPromptWindow = true; StringCollection pids = Properties.Settings.Default.AcilanServisler; if (pids != null) { foreach (string pid in pids) { Process prc; try { prc = Process.GetProcessById(int.Parse(pid)); prc.Kill(); } catch { } } Properties.Settings.Default.AcilanServisler = new StringCollection(); Properties.Settings.Default.Save(); } Optimizasyon.ArkaplandaCalistir(() => CreateDriver()); }
private void BtnGirisYap_Click(object sender, EventArgs e) { Optimizasyon.ArkaplandaCalistir(() => { SetStatusDelegate(Durum.Yukleniyor); Optimizasyon.ArkaplandaCalistir(() => GirisYap()); if (IsEnteredInvalid(driver)) { SaveKYKLog("Giriş Yapılamadı!\nGiriş bilgileri geçersiz!"); SetStatusDelegate(Durum.Pasif); MessageBox.Show("Giriş Yapılamadı!\nGiriş bilgileri geçersiz!", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } if (IsEnteredSucceed(driver)) { SetStatusDelegate(Durum.Aktif); SaveKYKLog("Giriş Yapıldı!"); MessageBox.Show("Giriş Yapıldı!", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information); } else { SaveKYKLog("Giriş Yapılamadı!"); SetStatusDelegate(Durum.Pasif); MessageBox.Show("Giriş Yapılamadı!", "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } }); }
private void btnSave_Click(object sender, EventArgs e) { Properties.Settings.Default.KYKLogPath = Delegates.Text.Get(txtKYKLogPath); Properties.Settings.Default.KYKUserName = Delegates.Text.Get(txtUserName); Properties.Settings.Default.KYKPassword = Delegates.Text.Get(txtPass); Properties.Settings.Default.ADSOYAD = Delegates.Text.Get(txtAdSoyad); Optimizasyon.Delagate(trackBar1, () => { Properties.Settings.Default.ZamanAsimi = trackBar1.Value; }); Properties.Settings.Default.Save(); MessageBox.Show("Ayarlar başarıyla kaydedildi!", "Bilgi", MessageBoxButtons.OK, MessageBoxIcon.Information); }
private void ShowLogs_Shown(object sender, EventArgs e) { Delegates.Text.Set(richTextBox1, "Kayıtlar Yükleniyor..."); Optimizasyon.ArkaplandaCalistir(() => { if (!string.IsNullOrEmpty(LogFileFullPath) && File.Exists(LogFileFullPath)) { try { Delegates.Text.Set(richTextBox1, File.ReadAllText(LogFileFullPath)); } catch (Exception ex) { Delegates.Text.Set(richTextBox1, "Kayıtlar Yüklenemedi!"); MessageBox.Show("Kayıtlar açılırken bir hata oluştu!\nHata Mesajı:" + ex.Message, "Hata", MessageBoxButtons.OK, MessageBoxIcon.Error); } } }); }
private void SettingsForm_Load(object sender, EventArgs e) { Delegates.Text.Set(txtKYKLogPath, Properties.Settings.Default.KYKLogPath); Delegates.Text.Set(txtUserName, Properties.Settings.Default.KYKUserName); Delegates.Text.Set(txtPass, Properties.Settings.Default.KYKPassword); Delegates.Text.Set(txtAdSoyad, Properties.Settings.Default.ADSOYAD); Optimizasyon.Delagate(trackBar1, () => { trackBar1.Value = Properties.Settings.Default.ZamanAsimi; }); int Value = -1; Optimizasyon.Delagate(trackBar1, () => { Value = trackBar1.Value; }); Delegates.Text.Set(lblZamanAsimi, string.Format("{0} saniye", Value.ToString())); }
private void SaveKYKLog(string logText) { if (!Directory.Exists(CommonLogFolderPath)) { Directory.CreateDirectory(CommonLogFolderPath); } if (!string.IsNullOrEmpty(KYKLogFileFullPath) && !File.Exists(KYKLogFileFullPath)) { File.WriteAllText(KYKLogFileFullPath, string.Empty); } Optimizasyon.ArkaplandaCalistir(async() => { await SaveLogAsync(KYKLogFileFullPath, logText); }); }
private void chckKYK_CheckedChanged(object sender, EventArgs e) { if (Delegates.Enabled.Get(chckKYK)) { Optimizasyon.ArkaplandaCalistir(() => CheckSessionOpen()); tmrKYK.Start(); } else { tmrKYK.Stop(); } }
private void checkBox1_CheckedChanged(object sender, EventArgs e) { bool check = false; Optimizasyon.Delagate(checkBox1, () => { check = checkBox1.Checked; }); Optimizasyon.Delagate(txtPass, () => { txtPass.UseSystemPasswordChar = !check; }); }
private void CreateDriver() { srv.Start(); Properties.Settings.Default.AcilanServisler.Add(srv.ProcessId.ToString()); Properties.Settings.Default.Save(); ChromeOptions options = new ChromeOptions(); options.AddArgument("disable-infobars"); driver = new ChromeDriver(srv, options); driver.Manage().Timeouts().PageLoad = new TimeSpan(0, 0, ZamanAsimi); driver.Manage().Window.Minimize(); DriverChanged(); Optimizasyon.Delagate(this, () => { this.Focus(); }); }
private void CheckSessionOpen() { SaveKYKLog("Oturum Kontrol Ediliyor..."); status1.SetDurum(Durum.Yukleniyor); if (driver == null) { CreateDriver(); } try { driver.Navigate().GoToUrl("https://wifi.kyk.gov.tr/"); } catch { } Optimizasyon.Delagate(chckKYK, () => { string caption = string.Format("30 sn de bir oturumuzu kontrol eder eğer wifi.kyk.gov.tr \nüzerinde oturum açılması gerekiyorsa otomatik giriş yapar.\nEn son kontrol edilme :{0}", DateTime.Now.ToLongTimeString()); toolTip1.SetToolTip(chckKYK, caption); }); if (IsEnteredSucceed(driver)) { status1.SetDurum(Durum.Aktif); if (girisyapti == false) { girisyapti = true; GirisYapildi(); } } else { status1.SetDurum(Durum.Pasif); girisyapti = false; SaveKYKLog("Oturum Kapalı! Oturum Açılıyor..."); GirisYap(); if (IsEnteredSucceed(driver)) { status1.SetDurum(Durum.Aktif); } } }
private void btnLogout_click(object sender, EventArgs e) { Optimizasyon.ArkaplandaCalistir(() => { SetStatusDelegate(Durum.Yukleniyor); driver.Navigate().GoToUrl("https://wifi.kyk.gov.tr/"); ReadOnlyCollection <IWebElement> liste = driver.FindElementsByClassName("ui-button-text"); IWebElement btnLogout = null; foreach (IWebElement element in liste) { if (element.Text == "Logout" || element.Text == "Çıkış") { btnLogout = element; break; } } if (btnLogout != null) { btnLogout.Click(); SetStatusDelegate(Durum.Pasif); SaveKYKLog("Çıkış Yapıldı!"); } }); }
private void SetStatusDelegate(Durum durum) { Optimizasyon.Delagate(status1, () => { status1.SetDurum(durum); }); }
private void tmrKYK_Tick(object sender, EventArgs e) { Optimizasyon.ArkaplandaCalistir(() => CheckSessionOpen()); }