private async void StaticInfo_Ev_LoginSchool(DataUser dp, bool relog) { _LocalUser = dp.Data; _StateLocUser = dp.Success; if (dp != null) { fio_lbl.Text = _LocalUser.Name + " " + _LocalUser.Surname + " " + _LocalUser.Patronymic; group_lbl.Text = _LocalUser.GroupName; school_name_lbl.Text = _LocalUser.SchoolName; theory_progress_lbl.Text = _LocalUser.MethodicProgress.ToString(); category_lbl.Text = _LocalUser.Category; drive_status_lbl.Text = _LocalUser.AllowDrive ? "Да" : "Нет"; balance_lbl.Text = _LocalUser.Balance.ToString(); date_of_driving_lbl.Text = _LocalUser.NextDriveDateLocal.ToString(); if (!relog) { var b = _LocalUser.GetTotalDrive; foreach (var item in b) { autodrom_list_chk.Items.Add(item, true); } this.Visible = true; if (!string.IsNullOrEmpty(_LocalUser.SchoolLogoUrl)) { school_img.BackgroundImage = await GetImage(_LocalUser.SchoolLogoUrl); } } } }
private void DoEnd(DataUser dt) { BeginInvoke(new Action(() => { //pictureBox1.Visible = false; this.Close(); })); }
public static async Task <DataUser> Relogin() { WebClient wc = new WebClient(); DataUser plochadki_class = new DataUser(); wc.Encoding = Encoding.UTF8; var request = (HttpWebRequest)WebRequest.Create("https://app.dscontrol.ru/Login"); var postData = $"Login={login}"; postData += "&TextPassword="******"&Password={Encoding.UTF8.GetString(bytes)}"; postData += "&PreventPass=false"; var data = Encoding.ASCII.GetBytes(postData); request.Method = "POST"; request.ContentType = "application/x-www-form-urlencoded"; request.ContentLength = data.Length; request.Accept = "*/*"; request.Referer = "https://app.dscontrol.ru/login"; using (var stream = request.GetRequestStream()) { stream.Write(data, 0, data.Length); } HttpWebResponse response; try { response = (HttpWebResponse)request.GetResponse(); } catch (Exception) { plochadki_class.Success = LoginState.denied; return(plochadki_class); } var aa = response.Headers["Set-Cookie"].Split(';')[0]; var za = wc.DownloadString("https://app.dscontrol.ru/Api/StudentSchedulerList?Kinds=D&OnlyMine=falsetimeshift=-360&from=2020-10-01&to=2020-10-30"); string plochadki = string.Empty; try { var zs = JsonConvert.DeserializeObject <DataCalender>(za); plochadki = wc.DownloadString("https://app.dscontrol.ru/api/MobilePersonalData"); plochadki_class = JsonConvert.DeserializeObject <DataUser>(plochadki); } catch (Exception) { HtmlAgilityPack.HtmlDocument hd = new HtmlAgilityPack.HtmlDocument(); hd.LoadHtml(za); HtmlNode formNode = hd.DocumentNode.SelectSingleNode("//input[@name='__RequestVerificationToken']"); var signupFormId = formNode.GetAttributeValue("value", ""); var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); var abb = $"__RequestVerificationToken={signupFormId}; {aa};"; StaticInfo.VeriToken = abb; wc.Headers.Add(HttpRequestHeader.Cookie, abb); plochadki = wc.DownloadString("https://app.dscontrol.ru/api/MobilePersonalData"); try { plochadki_class = JsonConvert.DeserializeObject <DataUser>(plochadki); } catch (Exception ex) { Debug.WriteLine(ex.Message); plochadki_class.Success = LoginState.error; return(plochadki_class);// LoginState.error; } } plochadki_class.Success = LoginState.succ; return(plochadki_class); }
public static void Do_ReLoginSchool(DataUser dp) { Ev_LoginSchool?.Invoke(dp, true); }
private async void login_btn_Click(object sender, EventArgs e) { StaticInfo.login = login_txt.Text; StaticInfo.pass = pass_txt.Text; plochadki_class = await StaticInfo.Relogin(); switch (plochadki_class.Success) { case StaticInfo.LoginState.succ: DoEnd(plochadki_class); break; case StaticInfo.LoginState.denied: case StaticInfo.LoginState.error: BeginInvoke(new Action(() => pictureBox1.Visible = false)); BeginInvoke(new Action(() => status_lbl.Text = "Ошибка логина")); break; } //wc.Headers.Clear(); //pictureBox1.Visible = true; //var request = (HttpWebRequest)WebRequest.Create("https://app.dscontrol.ru/Login"); //var postData = $"Login={login_txt.Text}"; //postData += "&TextPassword="******"&Password={Encoding.UTF8.GetString(bytes)}"; //postData += "&PreventPass=false"; //var data = Encoding.ASCII.GetBytes(postData); //request.Method = "POST"; //request.ContentType = "application/x-www-form-urlencoded"; //request.ContentLength = data.Length; //request.Accept = "*/*"; //request.Referer = "https://app.dscontrol.ru/login"; //await Task.Run(() => //{ // using (var stream = request.GetRequestStream()) // { // stream.Write(data, 0, data.Length); // } // HttpWebResponse response; // try // { // response = (HttpWebResponse)request.GetResponse(); // } // catch (Exception) // { // BeginInvoke(new Action(() => pictureBox1.Visible = false)); // BeginInvoke(new Action(() => status_lbl.Text = "Ошибка логина")); // return; // } // var aa = response.Headers["Set-Cookie"].Split(';')[0]; // var za = wc.DownloadString("https://app.dscontrol.ru/Api/StudentSchedulerList?Kinds=D&OnlyMine=false×hift=-360&from=2020-10-01&to=2020-10-30"); // string plochadki = string.Empty; // try // { // var zs = JsonConvert.DeserializeObject<DataCalender>(za); // plochadki = wc.DownloadString("https://app.dscontrol.ru/api/MobilePersonalData"); // plochadki_class = JsonConvert.DeserializeObject<DataUser>(plochadki); // } // catch (Exception) // { // HtmlAgilityPack.HtmlDocument hd = new HtmlAgilityPack.HtmlDocument(); // hd.LoadHtml(za); // HtmlNode formNode = hd.DocumentNode.SelectSingleNode("//input[@name='__RequestVerificationToken']"); // var signupFormId = formNode.GetAttributeValue("value", ""); // var responseString = new StreamReader(response.GetResponseStream()).ReadToEnd(); // var abb = $"__RequestVerificationToken={signupFormId}; {aa};"; // StaticInfo.VeriToken = abb; // wc.Headers.Add(HttpRequestHeader.Cookie, abb); // //из токенов выбрать айди = валетовским айди // //получить сешентайп с цветом равным выбранным токенам // //лист сешнтайп айди = айди площадок при поиске // plochadki = wc.DownloadString("https://app.dscontrol.ru/api/MobilePersonalData"); // try // { // plochadki_class = JsonConvert.DeserializeObject<DataUser>(plochadki); // //plochadki_class.Data.GetTotalDrive(); // } // catch (Exception ex) // { // Debug.WriteLine(ex.Message); // BeginInvoke(new Action(() => pictureBox1.Visible = false)); // BeginInvoke(new Action(() => status_lbl.Text = "Ошибка логина")); // return; // } // } //}); //if (plochadki_class.Success) //{ // StaticInfo.login = login_txt.Text; // StaticInfo.pass = pass_txt.Text; // DoEnd(plochadki_class); //} }