private void SendGetUsersToPHP() { WebClient client = new WebClient(); Uri uri = new Uri("https://adwatcherapplication.000webhostapp.com/get_users_for_event.php"); NameValueCollection parameters = new NameValueCollection(); parameters.Add("event_id", EventId); new Thread(() => { Thread.CurrentThread.IsBackground = true; result = client.UploadValues(uri, parameters); string content = CommonUIHelper.ConvertResult(result); while (!string.IsNullOrEmpty(content)) { int newLine = content.IndexOf('\n'); string user_name, user_id; string line = content.Substring(0, newLine); user_name = line.Substring(0, line.IndexOf(", User Id:")); line = line.Remove(0, line.IndexOf(", User Id:") + 2); user_id = line; user_name = user_name.Remove(0, 11); user_id = user_id.Remove(0, 9); users.Add(new UserView(user_id, user_name)); content = content.Remove(0, newLine + 1); } Device.BeginInvokeOnMainThread(() => { if (users.Count == 0) { UsersList.Children.Add(new Label() { Text = "Noone likes this event now :(" }); return; } foreach (var user in users) { UsersList.Children.Add(user); } }); }).Start(); }
public void OnSubmit() { if (!ControlInput()) { CommonUIHelper.CreateToast("Check something"); return; } SendNewUserToPHP(); }
private void JoinEvent() { byte[] result; WebClient client = new WebClient(); Uri uri = new Uri("https://adwatcherapplication.000webhostapp.com/join_event.php"); NameValueCollection parameters = new NameValueCollection(); parameters.Add("user_id", Settings.UserID); parameters.Add("event_id", EventID); new Thread(() => { Thread.CurrentThread.IsBackground = true; result = client.UploadValues(uri, parameters); string res = CommonUIHelper.ConvertResult(result); }).Start(); }
private void SendNewEventToPHP() { WebClient client = new WebClient(); Uri uri = new Uri("https://adwatcherapplication.000webhostapp.com/add_event.php"); NameValueCollection parameters = new NameValueCollection(); parameters.Add("event_publish_datetime", EventPublishDateTime); parameters.Add("event_datetime", EventDateTime); parameters.Add("event_name", EventName); parameters.Add("event_author_id", EventAuthorId); parameters.Add("event", EventText); new Thread(() => { Thread.CurrentThread.IsBackground = true; result = client.UploadValues(uri, parameters); Console.WriteLine(CommonUIHelper.ConvertResult(result)); }).Start(); }
private void SendNewUserToPHP() { WebClient client = new WebClient(); Uri uri = new Uri("https://adwatcherapplication.000webhostapp.com/register.php"); NameValueCollection parameters = new NameValueCollection(); parameters.Add("user_name", UserName); parameters.Add("user_email", Email); parameters.Add("user_password", Password); new Thread(() => { Thread.CurrentThread.IsBackground = true; //client.UploadValuesCompleted += this.client_UploadDataCompleted; result = client.UploadValues(uri, parameters); Console.WriteLine(CommonUIHelper.ConvertResult(result)); OpenMainPage(); }).Start(); }
private void SendAuthorizationToPHP() { // TODO: send request to "https://adwatcherapplication.000webhostapp.com/login.php" WebClient client = new WebClient(); Uri uri = new Uri("https://adwatcherapplication.000webhostapp.com/login.php"); NameValueCollection parameters = new NameValueCollection(); parameters.Add("user_name", UserName); parameters.Add("user_password", Password); new Thread(() => { Thread.CurrentThread.IsBackground = true; //client.UploadValuesCompleted += this.client_UploadDataCompleted; result = client.UploadValues(uri, parameters); string res = CommonUIHelper.ConvertResult(result); if (!UserExist(res)) { //CommonUIHelper.CreateToast("User does not exist"); Console.WriteLine("User doesn't exist"); return; } SaveUser(); //Console.WriteLine(CommonUIHelper.ConvertResult(result) + " Name: " + UserName + "; Password: " + Password); OpenMainPage(); }).Start(); }
private async void SendGetEventsToPHP() { WebClient client = new WebClient(); Uri uri = new Uri("https://adwatcherapplication.000webhostapp.com/get_events_for_user.php"); NameValueCollection parameters = new NameValueCollection(); parameters.Add("event_author_id", UserId); parameters.Add("user_id", UserId); string content = ""; new Thread(() => { Thread.CurrentThread.IsBackground = true; //client.UploadValuesCompleted += this.client_UploadDataCompleted; result = client.UploadValues(uri, parameters); content = CommonUIHelper.ConvertResult(result); while (!string.IsNullOrEmpty(content)) { int newLine = content.IndexOf('\n'); string name, text, id, author_name, authorId, join_status, datetime, publish_datetime; string line = content.Substring(0, newLine); publish_datetime = line.Substring(0, line.IndexOf(", Event datetime:")); line = line.Remove(0, line.IndexOf(", Event datetime:") + 2); datetime = line.Substring(0, line.IndexOf(", Join Status:")); line = line.Remove(0, line.IndexOf(", Join Status:") + 2); join_status = line.Substring(0, line.IndexOf(", Event Author Username:"******", Event Author Username:"******", Event Author ID:")); line = line.Remove(0, line.IndexOf(", Event Author ID:") + 2); authorId = line.Substring(0, line.IndexOf(", Event ID:")); line = line.Remove(0, line.IndexOf(", Event ID:") + 2); id = line.Substring(0, line.IndexOf(", Event name:")); line = line.Remove(0, line.IndexOf(", Event name:") + 2); name = line.Substring(0, line.IndexOf(", Event text:")); line = line.Remove(0, line.IndexOf(", Event text:") + 2); text = line; author_name = author_name.Remove(0, 23); authorId = authorId.Remove(0, 17); id = id.Remove(0, 10); name = name.Remove(0, 12); text = text.Remove(0, 12); join_status = join_status.Remove(0, 13); publish_datetime = publish_datetime.Remove(0, 24); datetime = datetime.Remove(0, 16); eventList.Add(new EventView(author_name, authorId, id, name, text, join_status, datetime, publish_datetime)); content = content.Remove(0, newLine + 1); } Device.BeginInvokeOnMainThread(() => { foreach (var item in eventList) { eventsLayout.Children.Add(item); } }); }).Start(); }