public void CheckLogin(string name, string password,LoginYesTaskHandler loggYesTask,LoginNoTaskHandler loggNoTask) { string URL = loginUrl; SystemWebClient client = new SystemWebClient(); string data = String.Format("{0}\n{1}",name,GetMd5Sum(password+SALT)); //\n{2}\n{3}",name,GetMd5Sum(password+SALT),Environment.MachineName,Environment.UserName); try{ string result = client.UploadString(new Uri(URL),data); string token = ""; string licence = ""; ParseResult(result, ref token,ref licence); if(String.IsNullOrEmpty(token)){ if(loggNoTask!= null) loggNoTask(null,"Wrong username or password."); return; } Account ac = CreateAccount(token); if( ac!= null ){ ac.Login = name ; Licenses lsl = Licenses.LoadLicenses(licence); //ac.Licenses = lsl; if(lsl!= null && lsl.Items.Count>0){ ac.LicenseId = lsl.Items[0].Typ; } else { ac.LicenseId = "-100"; } if(loggYesTask!= null) loggYesTask(null,ac); } else { if(loggNoTask!= null) loggNoTask(null,"Wrong username or password."); return; } } catch (Exception ex){ Logger.Error(ex.Message); //if(loggNoTask!= null) loggNoTask(null,"Wrong username or password."); if(loggNoTask!= null) loggNoTask(null,ex.Message); return; } }
public bool SendFeedback(string xmlData, LoginYesTaskHandler loggYesTask, LoginNoTaskHandler loggNoTask) { if ((MainClass.Settings.Account == null) || (String.IsNullOrEmpty(MainClass.Settings.Account.Token))) { return(false); } string token = MainClass.Settings.Account.Token; string URL = feedbackUrl; SystemWebClient client = new SystemWebClient(); if (!string.IsNullOrEmpty(token)) { URL = String.Format(URL + "?token={0}&action={1}", token, (int)action); } else { return(false); } //string data = ""; try{ string resp = client.UploadString(new Uri(URL), xmlData); Console.WriteLine(resp); if (loggYesTask != null) { loggYesTask(null, null); } }catch (Exception ex) { string statusDesc = ""; GetStatusCode(client, out statusDesc); Console.WriteLine(ex.Message); if (loggNoTask != null) { loggNoTask(null, ex.Message); } return(false); } return(true); }
public bool LoggWeb(string token,ActionId action,string data,LoginYesTaskHandler loggYesTask,LoginNoTaskHandler loggNoTask) { string URL =loggUrl; SystemWebClient client = new SystemWebClient(); if( !string.IsNullOrEmpty(token)) URL = String.Format(URL+"?token={0}&action={1}&data={2}",token,(int)action,data); else { return false; } //Console.WriteLine(URL); client.DownloadStringCompleted+= delegate(object sender, DownloadStringCompletedEventArgs e) { if (e.Cancelled){ if(loggNoTask!= null) loggNoTask(null,"Wrong username or password."); return ; } if (e.Error != null){ if(loggNoTask!= null) loggNoTask(null,"Wrong username or password."); return ; } }; try{ client.DownloadStringAsync(new Uri(URL)); }catch(Exception ex){ string statusDesc = ""; GetStatusCode(client,out statusDesc); Console.WriteLine(ex.Message); return false; } return true; }
public bool LoggWeb(string token, ActionId action, string data, LoginYesTaskHandler loggYesTask, LoginNoTaskHandler loggNoTask) { string URL = loggUrl; SystemWebClient client = new SystemWebClient(); if (!string.IsNullOrEmpty(token)) { URL = String.Format(URL + "?token={0}&action={1}&data={2}", token, (int)action, data); } else { return(false); } //Console.WriteLine(URL); client.DownloadStringCompleted += delegate(object sender, DownloadStringCompletedEventArgs e) { if (e.Cancelled) { if (loggNoTask != null) { loggNoTask(null, "Wrong username or password."); } return; } if (e.Error != null) { if (loggNoTask != null) { loggNoTask(null, "Wrong username or password."); } return; } }; try{ client.DownloadStringAsync(new Uri(URL)); }catch (Exception ex) { string statusDesc = ""; GetStatusCode(client, out statusDesc); Console.WriteLine(ex.Message); return(false); } return(true); }
public bool LoggWebString(ActionId action, string str, LoginYesTaskHandler loggYesTask, LoginNoTaskHandler loggNoTask) { if ((MainClass.Settings.Account == null) || (String.IsNullOrEmpty(MainClass.Settings.Account.Token))) { return(false); } string token = MainClass.Settings.Account.Token; string URL = loggUrl; SystemWebClient client = new SystemWebClient(); if (!string.IsNullOrEmpty(token)) { URL = String.Format(URL + "?token={0}&action={1}", token, (int)action); } else { return(false); } //Console.WriteLine(URL); /*client.UploadStringCompleted+= delegate(object sender, UploadStringCompletedEventArgs e) { * * if (e.Cancelled){ * Console.WriteLine("e.Cancelled->"+e.Cancelled); * if(loggNoTask!= null) loggNoTask(null,"Wrong username or password."); * return; * } * if (e.Error != null){ * Console.WriteLine("e.Error->"+e.Error); * if(loggNoTask!= null) loggNoTask(null,"Wrong username or password."); * return; * } * string result = e.Result; * Console.WriteLine("e.Result->"+e.Result); * };*/ string data = str; try{ string resp = client.UploadString(new Uri(URL), data); Console.WriteLine(resp); if (loggYesTask != null) { loggYesTask(null, null); } }catch (Exception ex) { string statusDesc = ""; GetStatusCode(client, out statusDesc); Console.WriteLine(ex.Message); if (loggNoTask != null) { loggNoTask(null, ex.Message); } return(false); } return(true); }
public void Register(string email, string login, string password, LoginYesTaskHandler loggYesTask, LoginNoTaskHandler loggNoTask) { string URL = redgisterUrl; SystemWebClient client = new SystemWebClient(); string data = String.Format("{0}\n{1}\n{2}", email, login, GetMd5Sum(password + SALT)); client.UploadStringCompleted += delegate(object sender, UploadStringCompletedEventArgs e) { if (e.Cancelled) { if (loggNoTask != null) { loggNoTask(null, "Register failed."); } return; } if (e.Error != null) { if (loggNoTask != null) { loggNoTask(null, "Register failed."); } return; } string result = e.Result; string token = ""; string licence = ""; ParseResult(result, ref token, ref licence); if (String.IsNullOrEmpty(token)) { if (loggNoTask != null) { loggNoTask(null, "Register failed."); } return; } Account ac = CreateAccount(token); if (ac != null) { ac.Login = login; Licenses lsl = Licenses.LoadLicenses(licence); if (lsl != null && lsl.Items.Count > 0) { ac.LicenseId = lsl.Items[0].Typ; } else { ac.LicenseId = "-100"; } if (loggYesTask != null) { loggYesTask(null, ac); } } else { if (loggNoTask != null) { loggNoTask(null, "Register failed."); } return; } /*Account ac = CreateAccount(result); * if(ac!= null ){ * ac.Login = login; * if(loggYesTask!= null) loggYesTask(null,ac); * * } else { * if(loggNoTask!= null) loggNoTask(null,"Login failed."); * return; * }*/ }; client.UploadStringAsync(new Uri(URL), data); }
public void CheckLogin(string name, string password, LoginYesTaskHandler loggYesTask, LoginNoTaskHandler loggNoTask) { string URL = loginUrl; SystemWebClient client = new SystemWebClient(); string data = String.Format("{0}\n{1}", name, GetMd5Sum(password + SALT)); //\n{2}\n{3}",name,GetMd5Sum(password+SALT),Environment.MachineName,Environment.UserName); try{ string result = client.UploadString(new Uri(URL), data); string token = ""; string licence = ""; ParseResult(result, ref token, ref licence); if (String.IsNullOrEmpty(token)) { if (loggNoTask != null) { loggNoTask(null, "Wrong username or password."); } return; } Account ac = CreateAccount(token); if (ac != null) { ac.Login = name; Licenses lsl = Licenses.LoadLicenses(licence); //ac.Licenses = lsl; if (lsl != null && lsl.Items.Count > 0) { ac.LicenseId = lsl.Items[0].Typ; } else { ac.LicenseId = "-100"; } if (loggYesTask != null) { loggYesTask(null, ac); } } else { if (loggNoTask != null) { loggNoTask(null, "Wrong username or password."); } return; } } catch (Exception ex) { Logger.Error(ex.Message); //if(loggNoTask!= null) loggNoTask(null,"Wrong username or password."); if (loggNoTask != null) { loggNoTask(null, ex.Message); } return; } }
public bool SendFeedback(string xmlData,LoginYesTaskHandler loggYesTask,LoginNoTaskHandler loggNoTask) { if((MainClass.Settings.Account == null) || (String.IsNullOrEmpty(MainClass.Settings.Account.Token))){ return false; } string token =MainClass.Settings.Account.Token; string URL =feedbackUrl; SystemWebClient client = new SystemWebClient(); if( !string.IsNullOrEmpty(token)) URL = String.Format(URL+"?token={0}&action={1}",token,(int)action); else { return false; } //string data = ""; try{ string resp = client.UploadString(new Uri(URL),xmlData); Console.WriteLine(resp); if(loggYesTask!= null) loggYesTask(null,null); }catch(Exception ex){ string statusDesc = ""; GetStatusCode(client,out statusDesc); Console.WriteLine(ex.Message); if(loggNoTask!= null) loggNoTask(null,ex.Message); return false; } return true; }
public bool LoggWebString(ActionId action,string str,LoginYesTaskHandler loggYesTask,LoginNoTaskHandler loggNoTask) { if((MainClass.Settings.Account == null) || (String.IsNullOrEmpty(MainClass.Settings.Account.Token))){ return false; } string token =MainClass.Settings.Account.Token; string URL =loggUrl; SystemWebClient client = new SystemWebClient(); if( !string.IsNullOrEmpty(token)) URL = String.Format(URL+"?token={0}&action={1}",token,(int)action); else { return false; } //Console.WriteLine(URL); /*client.UploadStringCompleted+= delegate(object sender, UploadStringCompletedEventArgs e) { if (e.Cancelled){ Console.WriteLine("e.Cancelled->"+e.Cancelled); if(loggNoTask!= null) loggNoTask(null,"Wrong username or password."); return; } if (e.Error != null){ Console.WriteLine("e.Error->"+e.Error); if(loggNoTask!= null) loggNoTask(null,"Wrong username or password."); return; } string result = e.Result; Console.WriteLine("e.Result->"+e.Result); };*/ string data = str; try{ string resp = client.UploadString(new Uri(URL),data); Console.WriteLine(resp); if(loggYesTask!= null) loggYesTask(null,null); }catch(Exception ex){ string statusDesc = ""; GetStatusCode(client,out statusDesc); Console.WriteLine(ex.Message); if(loggNoTask!= null) loggNoTask(null,ex.Message); return false; } return true; }
public void Register(string email,string login,string password,LoginYesTaskHandler loggYesTask,LoginNoTaskHandler loggNoTask) { string URL = redgisterUrl; SystemWebClient client = new SystemWebClient(); string data = String.Format("{0}\n{1}\n{2}",email,login,GetMd5Sum(password+SALT)); client.UploadStringCompleted+= delegate(object sender, UploadStringCompletedEventArgs e) { if (e.Cancelled){ if(loggNoTask!= null) loggNoTask(null,"Register failed."); return; } if (e.Error != null){ if(loggNoTask!= null) loggNoTask(null,"Register failed."); return; } string result = e.Result; string token = ""; string licence = ""; ParseResult(result, ref token,ref licence); if(String.IsNullOrEmpty(token)){ if(loggNoTask!= null) loggNoTask(null,"Register failed."); return; } Account ac = CreateAccount(token); if( ac!= null ){ ac.Login = login ; Licenses lsl = Licenses.LoadLicenses(licence); if(lsl!= null && lsl.Items.Count>0){ ac.LicenseId = lsl.Items[0].Typ; }else { ac.LicenseId = "-100"; } if(loggYesTask!= null) loggYesTask(null,ac); } else { if(loggNoTask!= null) loggNoTask(null,"Register failed."); return; } /*Account ac = CreateAccount(result); if(ac!= null ){ ac.Login = login; if(loggYesTask!= null) loggYesTask(null,ac); } else { if(loggNoTask!= null) loggNoTask(null,"Login failed."); return; }*/ }; client.UploadStringAsync(new Uri(URL),data); }