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 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 PostFile(string appFile, string token, out string signFile) //string email,string login,string password,LoginYesTaskHandler loggYesTask,LoginNoTaskHandler loggNoTask){ { string URL = signUrl; //"http://moscrif.com/ide/signApp.ashx?t={0}&a={1}"; if (!string.IsNullOrEmpty(token)) { string app = System.IO.Path.GetFileNameWithoutExtension(appFile); if (app.ToLower().EndsWith(".app")) { app = app.Substring(0, app.Length - 4); } URL = String.Format(URL, token, app); //URL = String.Format(URL+"?t={0}&a=" + "unsigned.app-hash",token); } else { signFile = "ERROR TOKEN"; return(false); } //Console.WriteLine("URL -> {0}", URL); SystemWebClient client = new SystemWebClient(); string data = ""; using (StreamReader file = new StreamReader(appFile)) { data = file.ReadToEnd(); file.Close(); file.Dispose(); } //Console.WriteLine("data -> {0}", data); /*client.UploadStringCompleted+= delegate(object sender, UploadStringCompletedEventArgs e) { * //Console.WriteLine(1); * * if (e.Cancelled){ * if(loggNoTask!= null) loggNoTask(null,"Register to failed."); * return; * } * * if (e.Error != null){ * if(loggNoTask!= null) loggNoTask(null,"Register to failed."); * return; * } * * string result = e.Result; * //Console.WriteLine(result); * Account ac = CreateAccount(result); * if(ac!= null ){ * ac.Login = login; * if(loggYesTask!= null) loggYesTask(null,ac); * * } else { * if(loggNoTask!= null) loggNoTask(null,"Login to failed."); * return; * } * * };*/ //client.UploadStringAsync(new Uri(URL),data); signFile = client.UploadString(new Uri(URL), data); //(new Uri(URL),data); if (signFile.StartsWith("Error")) { return(false); } //byte[] respons = client.UploadFile(new Uri(URL),appFile);//UploadString(new Uri(URL),data); //Console.WriteLine("Respons is -> {0}",respons); return(true); }
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 bool PostFile(string appFile,string token, out string signFile) { //string email,string login,string password,LoginYesTaskHandler loggYesTask,LoginNoTaskHandler loggNoTask){ string URL = signUrl;//"http://moscrif.com/ide/signApp.ashx?t={0}&a={1}"; if( !string.IsNullOrEmpty(token)){ string app = System.IO.Path.GetFileNameWithoutExtension(appFile); if (app.ToLower().EndsWith(".app")) app = app.Substring(0, app.Length - 4); URL = String.Format(URL,token,app); //URL = String.Format(URL+"?t={0}&a=" + "unsigned.app-hash",token); }else { signFile = "ERROR TOKEN"; return false; } //Console.WriteLine("URL -> {0}", URL); SystemWebClient client = new SystemWebClient(); string data =""; using (StreamReader file = new StreamReader(appFile)) { data = file.ReadToEnd(); file.Close(); file.Dispose(); } //Console.WriteLine("data -> {0}", data); /*client.UploadStringCompleted+= delegate(object sender, UploadStringCompletedEventArgs e) { //Console.WriteLine(1); if (e.Cancelled){ if(loggNoTask!= null) loggNoTask(null,"Register to failed."); return; } if (e.Error != null){ if(loggNoTask!= null) loggNoTask(null,"Register to failed."); return; } string result = e.Result; //Console.WriteLine(result); Account ac = CreateAccount(result); if(ac!= null ){ ac.Login = login; if(loggYesTask!= null) loggYesTask(null,ac); } else { if(loggNoTask!= null) loggNoTask(null,"Login to failed."); return; } };*/ //client.UploadStringAsync(new Uri(URL),data); signFile = client.UploadString(new Uri(URL),data);//(new Uri(URL),data); if(signFile.StartsWith("Error")){ return false; } //byte[] respons = client.UploadFile(new Uri(URL),appFile);//UploadString(new Uri(URL),data); //Console.WriteLine("Respons is -> {0}",respons); return true; }