private async Task LoadMoviesAsync() { Indicator.IsVisible = true; Indicator.IsRunning = true; RESTService service = new RESTService(); var list = await service.GetMovies(); if (!list.HasError) { List <MovieViewModel> movies = new List <MovieViewModel>(); foreach (var item in list.results) { MovieViewModel movie = new MovieViewModel(); movie.Id = item.id; movie.MovieName = item.title; movie.MoviePoster = Helper.ImagePathHelper.GetFullImageURL(item.poster_path); movie.Detail = string.Format("Release Date {0}, {1}", item.release_date.ToString("dd/MM/yyyy"), GetMovieGenre(item.genre_ids)); movies.Add(movie); } listaMovies.ItemsSource = movies; } else { await DisplayAlert("Error", string.Format("An error occurred on the server: {0}", list.ErrorMessage), "OK"); } Indicator.IsVisible = false; Indicator.IsRunning = false; }
private async Task ExecuteOnChangePassword() { IsBusy = true; if (!string.IsNullOrEmpty(PassWord) && PassWord == Confirm_PassWord) { if (await DependencyService.Get <IDialog>().AlertAsync("", "Voulez Vous Changer le Mot de Passe ?", "Oui", "Non")) { var _restService = new RESTService(); var Result = await _restService.Change_password_async(PassWord); if (Result.Item1) { PassWord = string.Empty; Confirm_PassWord = string.Empty; OnPropertyChanged("PassWord"); OnPropertyChanged("Confirm_PassWord"); IsVisible = false; DependencyService.Get <IMessage>().ShortAlert("Mot de Passe Chnger avec Succes"); } else { DependencyService.Get <IMessage>().ShortAlert(Result.Item2); } } } else { DependencyService.Get <IMessage>().ShortAlert("Veuillez Confirmer le Mot de Pass !"); } IsBusy = false; }
async Task DeleteCharacter() { var confirm = await UserDialogs.Instance.ConfirmAsync("Are you sure?", "Delete?", "Yes", "No"); if (confirm) { var hpCharacter = CharacterVM.GetCharacter(); var success = 0; var useLocalStorage = Preferences.Get("UsingLocalStorage", true); if (useLocalStorage) { success = await App.Context.DeleteItemAsync <HPCharacter>(hpCharacter); } else { var service = new RESTService(); var result = await service.DeleteCharacter(hpCharacter._id); success = result ? 2 : 0; } await UserDialogs.Instance.AlertAsync((success > 0)? "Success!" : "Error!", "Deleting...", "OK"); } }
protected void btnAuthenticate_Click(object sender, EventArgs e) { string[] urls = txtUrls.Text.Split(new[] { '\r', '\n' }, StringSplitOptions.RemoveEmptyEntries); txtUrls.Text = ""; foreach (string url in urls) { string urlWithoutHash = URLHelper.RemoveParameterFromUrl(url, "hash"); string newUrl = HttpUtility.UrlDecode(urlWithoutHash); string query = URLHelper.GetQuery(newUrl).TrimStart('?'); int index = newUrl.IndexOfCSafe("/rest"); if (index >= 0) { // Extract the domain string domain = URLHelper.GetDomain(newUrl); // Separate the query newUrl = URLHelper.RemoveQuery(newUrl.Substring(index)); // Rewrite the URL to physical URL string[] rewritten = BaseRESTService.RewriteRESTUrl(newUrl, query, domain, "GET"); newUrl = rewritten[0].TrimStart('~') + "?" + rewritten[1]; // Get the hash from real URL txtUrls.Text += URLHelper.AddParameterToUrl(urlWithoutHash, "hash", RESTService.GetHashForURL(newUrl, domain)) + Environment.NewLine; } else { txtUrls.Text += url + Environment.NewLine; } } }
private async Task GetProductsAsync() { IsBusy = true; var _restService = new RESTService(); var result = await _restService.GetProductsAsync(); if (result.Item1 == true) { var json = result.Item2; if (DataStore.GetDataStoredJson("Products").ToList().Count > 0) { DataStore.UpdateData("Products", json); } else { var Data = new Stored_Data_Model { Type = "Products", json = json }; DataStore.AddData(Data); } UpdateProductsListview(); } else { DependencyService.Get <IMessage>().ShortAlert(result.Item2); } IsBusy = false; }
async Task LoadData() { Characters = new ObservableCollection <CharacterViewModel>(); List <HPCharacter> hpCharacters = new List <HPCharacter>(); if (UseLocalStorage) { hpCharacters = string.IsNullOrWhiteSpace(SearchText) ? await App.Context.GetItemsAsync <HPCharacter>() : await App.Context.FilterItemsAsync <HPCharacter>("HPCharacter", $"name LIKE '%{SearchText}%'"); } else { var service = new RESTService(); var result = await service.GetCharacters(); hpCharacters = result; } Device.BeginInvokeOnMainThread(() => { foreach (var item in hpCharacters) { Characters.Add(new CharacterViewModel(item)); } }); }
public static AccessToken GetAccessToken(AppClient appClient) { AccessToken result = new AccessToken(); result.access_token = ObtemToken(); if (!string.IsNullOrEmpty(result.access_token)) { return(result); } try { using (var client = new RESTService <HttpRestClientRestSharp>(string.Format("https://login.microsoftonline.com/{0}/oauth2/v2.0/token", appClient.TenanId))) { client.AddHeader("Content-Type", "application /x-www-form-urlencoded"); var response = client.Post <AccessToken>(appClient.QueryString).Result; result = response.Data; SalvarToken(result.access_token); } } catch (Exception ex) { result.access_token = "Excepion : " + ex.Message; } return(result); }
private async Task ExecuteOnMyStatisticsTapped() { IsBusy = true; var _restService = new RESTService(); var firstdayofmonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, 1); var lastdayofmonth = new DateTime(DateTime.Now.Year, DateTime.Now.Month, DateTime.DaysInMonth(DateTime.Now.Year, DateTime.Now.Month)); var Result = await _restService.GetStatsPeriode(firstdayofmonth, lastdayofmonth, Token.id); if (Result.Item1) { try { List <Stats_Model> stats = JsonConvert.DeserializeObject <List <Stats_Model> >(Result.Item2); if (stats.Count > 0) { await Navigation.PushModalAsync(new MyStatistics_View(stats, Token), true); } else { DependencyService.Get <IMessage>().ShortAlert("Pas De Statistiques pour ce mois !"); } } catch { DependencyService.Get <IMessage>().ShortAlert("Pas De Statistiques pour ce mois !"); } } else { DependencyService.Get <IMessage>().ShortAlert(Result.Item2); } IsBusy = false; }
private async Task ExecuteOnEndMission() { if (TodayChecked | WeekChecked) { TodayChecked = (WeekChecked == true) ? true : TodayChecked; IsBusy = true; PopUpVisible = false; var _restService = new RESTService(); var Global_mission = Missions.Where(i => i.global_mission_start.Date <= DateTime.Now.Date & i.global_mission_deadline.Date >= DateTime.Now.Date & i.missions.Exists(j => j.mission_deadline.Date == DateTime.Now.Date)).ToList(); foreach (var global in Global_mission) { var missions = global.missions.Where(i => i.mission_deadline.Date == DateTime.Now.Date).ToList(); foreach (var mission in missions) { var Result = await _restService.Post_mission_completed(mission._id, global._id, WeekChecked, TodayChecked); if (!Result.Item1) { DependencyService.Get <IMessage>().ShortAlert(Result.Item2); break; } } } IsBusy = false; } else { DependencyService.Get <IMessage>().ShortAlert("Veuillez Selectioner un type de Tournée à Terminer !"); } }
public async Task <Response> GetPhoto <TPhoto>(string userId) where TPhoto : new() { //https://graph.microsoft.com/v1.0/me/photos/48x48/$value Response ResultResponse = new Response(); this.AccessToken = AccessTokenConfig.GetAccessToken(AppClient); ResultResponse = await ExecuteLocalRequest(); //var stream = ResultResponse.HttpResponse.Content.ReadAsStreamAsync(); // var pic = Convert.ToBase64String(ResultResponse.HttpResponse.Content); return(ResultResponse); //Função local que executa a requisição das infromações do usuário. //Essa função só é visivel nesse metodo. async Task <Response> ExecuteLocalRequest() { using (var client = new RESTService <HttpRestClientNative>(getUserEndPoint("/photos/48x48/$value", userId))) { //Headers necessário para obtenção da foto.Content-Type e Authrization Token //client.AddHeader("Content-Type", "image/jpg"); client.AddHeader("Authorization", "Bearer " + this.AccessToken.access_token); return(await client.Get <TPhoto>()); } } }
public List <SFeedback> GetFeedbacksCreatedSince(string year, string month, string day, string hour, string minute, bool use_site_name) { Dictionary <string, string> get_params = new Dictionary <string, string>(); get_params.Add("year", year); get_params.Add("month", month); get_params.Add("day", day); get_params.Add("hour", hour); get_params.Add("minute", minute); SBasic <List <SFeedback> > response; if (use_site_name) { response = RESTService.MakeAndExecuteGetRequest <List <SFeedback> >("/api/sync/feedbacks/created/since/{year}/{month}/{day}/{hour}/{minute}/at/" + Configurations.GetSiteNameForServer(), get_params); } else { response = RESTService.MakeAndExecuteGetRequest <List <SFeedback> >("/api/sync/feedbacks/created/since/{year}/{month}/{day}/{hour}/{minute}", get_params); } if (response != null) { if (response.data != null) { return(response.data); } } return(null); }
public async Task DownloadProductsFromAPI() { Task task = RESTService.DownloadProductsFromAPI(); await task; Assert.AreEqual(SessionService.cachedProducts, ProductsMocks.JakiesFejkoweProdukty); }
private async Task ExecuteOnGetHistory() { IsBusy = true; if (Selected_MinDate <= Selected_MaxDate) { var _restService = new RESTService(); var Result = await _restService.GetPeriodHistryAsync(Selected_MinDate, Selected_MaxDate); if (Result.Item1) { try { Contacts_List = JsonConvert.DeserializeObject <List <ContactVisiteHistory_Model> >(Result.Item2); var sorted = from contact in Contacts_List orderby contact.DateSort group contact by contact.DateSort into contactGroup select new Grouping <string, ContactVisiteHistory_Model>(contactGroup.Key, contactGroup); Contacts = new ObservableCollection <Grouping <string, ContactVisiteHistory_Model> >(sorted); } catch (Exception e) { DependencyService.Get <IMessage>().ShortAlert(e.Message); } } else { DependencyService.Get <IMessage>().ShortAlert(Result.Item2); } } else { DependencyService.Get <IMessage>().ShortAlert("Erreur Date !"); } IsBusy = false; }
private async Task ExecuteOnSendMessage() { if (Selected_Contact != null & Title != null & Message != null) { IsBusy = true; var _restService = new RESTService(); var Result = await _restService.Send_Mail_Async(Selected_Contact._id, "False", Title, Message, Selected_Contact.Name); if (Result.Item1) { DependencyService.Get <IMessage>().ShortAlert("Message Envoyé Avec Succes"); Initialize(); SendMessageVisible = false; Selected_Contact = null; Title = null; Message = null; OnPropertyChanged("Selected_Contact"); OnPropertyChanged("Title"); OnPropertyChanged("Message"); } else { SendMessageVisible = false; DependencyService.Get <IMessage>().ShortAlert(Result.Item2); } IsBusy = false; } else { DependencyService.Get <IMessage>().ShortAlert("Veuillez Remplir les Champs Obligatoire !"); } }
public ItemApi(RESTService service, string title, string description, string method, string resourceFormat, Type resultType) : base(service, title, description, method, string.Empty, resultType) { ResourceFormat = resourceFormat; ItemPath = string.Empty; ItemName = string.Empty; }
public void Test_GetUrlFromEndPoint() { RESTService service = new RESTService("https://maps.googleapis.com/maps/api/place/textsearch/json?"); Dictionary <string, string> parameters = new Dictionary <string, string>(); parameters["query"] = "Primary School in E1"; parameters["key"] = "AIzaSyAKp3OYYL_JOPAiLLW0bp6y4IlK8QFa4Tw"; Console.Out.WriteLine(service.GetRequest(parameters)); Console.In.Read(); }
private async Task GetGenresAsync() { RESTService service = new RESTService(); StringBuilder result = new StringBuilder(); Genres = await service.GetGenres(); //System.Threading.Thread.Sleep(3000); Indicator.IsRunning = false; Indicator.IsVisible = false; }
public LocationSelectionPage(BreatheKlerePage parent, bool isHomeSelected = true) { InitializeComponent(); this.parent = parent; this.isHomeSelected = isHomeSelected; timer = new Stopwatch(); rest = new RESTService(); if (isHomeSelected) { locationEntry.Placeholder = "Choose start point"; } }
// Feedback public List <SFeedback> GetFeedbacks() { SBasic <List <SFeedback> > response = RESTService.MakeAndExecuteGetRequest <List <SFeedback> >("/api/feedbacks", null); if (response != null) { if (response.data != null) { return(response.data); } } return(null); }
public List <SAccount> GetAccounts() { SBasic <List <SAccount> > response = RESTService.MakeAndExecuteGetRequest <List <SAccount> >("/api/accounts", null); if (response != null) { if (response.data != null) { return(response.data); } } return(null); }
public List <SSite> GetSites() { SBasic <List <SSite> > response = RESTService.MakeAndExecuteGetRequest <List <SSite> >("/api/sites", null); if (response != null) { if (response.data != null) { return(response.data); } } return(null); }
public List <SMedia> GetMedias() { SBasic <List <SMedia> > response = RESTService.MakeAndExecuteGetRequest <List <SMedia> >("/api/medias", null); if (response != null) { if (response.data != null) { return(response.data); } } return(null); }
public async Task <ActionResult> Remote() { //Using remote web api RESTService service = new RESTService(); CancellationTokenSource cts = new CancellationTokenSource(); Task <List <Product> > task = service.GetProductsAsync(cts.Token); //Cancel operation //cts.CancelAfter(1000); return(View(await task)); //return View(await service.GetProductByIdAsync(34872)); }
public RegistrationPage() { InitializeComponent(); genderList = new List <string>(); genderList.Add("Y"); genderList.Add("N"); foreach (var item in genderList) { userSegment.Children.Add(new SegmentedControl.FormsPlugin.Abstractions.SegmentedControlOption { Text = item }); } rest = new RESTService(); }
public async Task <Response> GetUser <TUser>() where TUser : new() { TUser result = new TUser(); Response ResultResponse = new Response(); try { //Efetua a requisição invocando a função local ExecuteLocalRequest() ResultResponse = await ExecuteLocalRequest(); //Trata o retorno da requisição. if (ResultResponse.Status == HttpStatusCode.OK) { var data = ResultResponse.Data; result = data; } else { if (ResultResponse.Status == HttpStatusCode.Unauthorized) { //Token invalido, requisita um novo AccessToken = AccessTokenConfig.GetAccessToken(AppClient); //Executa novamente a consulta com o novo Token ResultResponse = await ExecuteLocalRequest(); } else { return(ResultResponse); } } //Função local que executa a requisição das infromações do usuário. //Essa função só é visivel nesse metodo. async Task <Response> ExecuteLocalRequest() { this.EndPoint = string.Empty; using (var client = new RESTService <HttpRestClientRestSharp>(getUserEndPoint())) { client.AddHeader("Authorization", "Bearer " + this.AccessToken.access_token); return(await client.Get <TUser>()); } } } catch { } return(ResultResponse); }
public MyCityDetail(string id, string cityName, string cityCountry) { InitializeComponent(); this.id = id; this.cityName = cityName; this.cityCountry = cityCountry; this.nextDayTemperatures = new List <int>(); _restService = new RESTService(); InitializeToolbar(); SendAPIRequests(); }
public static async Task LogResponse(IDialogContext context, RESTService service) { if (service.ResponseViewModel != null) { var request = service.RequestViewModel; if ((request.Api.Method == "POST") || (request.Api.Method == "PATCH")) { await context.PostAsync($"{request.Model.Api.Method} {request.Model.Api.RequestUri}\n\n{request.Body}"); } else { await context.PostAsync($"{request.Model.Api.Method} {request.Model.Api.RequestUri}"); } } }
// Notification public string SendAliveMessage() { Dictionary <string, string> get_params = new Dictionary <string, string>(); get_params.Add("site", Configurations.site_name); SBasic <string> response = RESTService.MakeAndExecuteGetRequest <string>("/api/notification/alive/at/{site}", get_params); if (response != null) { if (response.data != null) { return(response.data); } } return(null); }
public List <SNote> GetNotesMostRecent(int n) { Dictionary <string, string> get_params = new Dictionary <string, string>(); get_params.Add("n", n.ToString()); SBasic <List <SNote> > response = RESTService.MakeAndExecuteGetRequest <List <SNote> >("/api/sync/recent/{n}", get_params); if (response != null) { if (response.data != null) { return(response.data); } } return(null); }
public SFeedback GetFeedback(string feedback_id) { Dictionary <string, string> get_params = new Dictionary <string, string>(); get_params.Add("id", feedback_id); SBasic <SFeedback> response = RESTService.MakeAndExecuteGetRequest <SFeedback>("/api/feedback/{id}", get_params); if (response != null) { if (response.data != null) { return(response.data); } } return(null); }
public void AddToNoSqlDocuments(RESTService.Smeedee.Client.Web.Services.DTO.NoSql.NoSqlDocumentDTO noSqlDocumentDTO) { base.AddObject("NoSqlDocuments", noSqlDocumentDTO); }
public void AddToNoSqlCollections(RESTService.Smeedee.Client.Web.Services.DTO.NoSql.NoSqlCollectionDTO noSqlCollectionDTO) { base.AddObject("NoSqlCollections", noSqlCollectionDTO); }