private void Window_Loaded(object sender, RoutedEventArgs e) { //RegistryKey regKey = Registry.CurrentUser; //regKey = regKey.CreateSubKey(@"Software\"); //object unm = regKey.GetValue("ApplicationId"); string chktmp = ConfigurationManager.AppSettings["ApplicationId"]; string a = "1"; if (chktmp != null) { //username .Text = regKey.GetValue("UserName").ToString(); string b = chktmp.ToString(); if (b != a) { } else { try { this.Hide(); StockD.MainWindow newwin = new StockD.MainWindow(); newwin.InitializeComponent(); newwin.ShowDialog(); } catch (Exception ex) { MessageBox.Show(ex.Message); } // System.Diagnostics.Process.Start(@"C:\Documents and Settings\maheshwar\My Documents\GitHub\shubanet\Shubha RT\bin\Debug\ShubhaRt.exe"); } } }
private void Loginbtn_Click(object sender, RoutedEventArgs e) { CommandManager.InvalidateRequerySuggested(); try { string loginUri = "http://shubhalabha.in/community/wp-login.php"; string reqString = "log=" + username.Text + "&pwd=" + password.Password; byte[] requestData = Encoding.UTF8.GetBytes(reqString); CookieContainer cc = new CookieContainer(); var request = (HttpWebRequest)WebRequest.Create(loginUri); request.Proxy = null; request.AllowAutoRedirect = false; request.CookieContainer = cc; request.Method = "post"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = requestData.Length; using (Stream s = request.GetRequestStream()) s.Write(requestData, 0, requestData.Length); using (HttpWebResponse response = (HttpWebResponse)request.GetResponse()) { int count = 1; foreach (Cookie c in response.Cookies) { //responce 2 contain loggen in or not if (count == 2) { if (c.ToString().Contains("wordpress_logged_in_17e90d9fdb1ef2a442ed2d6aeb707f54")) { System.Windows.MessageBox.Show("Thank you for using shubha downloader "); try { Configuration config; config = ConfigurationManager.OpenExeConfiguration(ConfigurationUserLevel.None); config.AppSettings.Settings.Remove("ApplicationId"); config.AppSettings.Settings.Add("ApplicationId", "1"); config.Save(ConfigurationSaveMode.Full); ConfigurationManager.RefreshSection("ApplicationId"); // SetRegKey(); this.Hide(); StockD.MainWindow newwin = new StockD.MainWindow(); CommandManager.InvalidateRequerySuggested(); newwin.InitializeComponent(); CommandManager.InvalidateRequerySuggested(); newwin.ShowDialog(); CommandManager.InvalidateRequerySuggested(); } catch { CommandManager.InvalidateRequerySuggested(); } } else { System.Windows.MessageBox.Show("Please Enter Valid UserName & Password "); } } else { count++; } } } } catch { } }