/// <summary> /// save screen shots and all other in-outs to azure /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <bool> SaveData(RoverEntity input) { try { RoverFinalPoints finalData = new RoverFinalPoints(); JObject oJsonObject = new JObject(); oJsonObject.Add("input", input.input); oJsonObject.Add("output", input.output); oJsonObject.Add("image", input.image); var content = new StringContent(oJsonObject.ToString(), Encoding.UTF8, "application/json"); HttpResponseMessage response = await _client.PostAsync("https://savescreenshot.azurewebsites.net/api/SaveToStorage?code=fRSf6ebJvgZj7JjUaabFGLT8uABeC/VrsTX8jU97P325wIfA0tbdyw==", content); if (response.IsSuccessStatusCode) { return(true); } return(false); } catch (Exception ex) { Debug.WriteLine("\tERROR {0}", ex.Message); return(false); } }
/// <summary> /// save current screenshot and input commands and output position /// </summary> /// <param name="sender"></param> /// <param name="e"></param> async void OnSave(System.Object sender, System.EventArgs e) { if (outputpath == null || outputpath.Length == 0) { await DisplayAlert(Constants.Error, Constants.InvalidInput, Constants.Ok); return; } ShowActivityControl(true); var screnshot = DependencyService.Get <IScreenshotService>().Capture(); RoverEntity input = new RoverEntity() { input = "input : " + CommandEditor.Text, output = outputpath }; // add screenshot data to model input.image = Encoding.UTF8.GetString(screnshot, 0, screnshot.Length); // invoke save web service, return true if success HomeViewModel model = (HomeViewModel)this.BindingContext.DataContext; var res = await model.SaveScreenShotData(input); if (res) { await DisplayAlert("Success", Constants.SavedToServer, Constants.Ok); } ShowActivityControl(false); }
/// <summary> /// save screenshots and other in-outs /// </summary> /// <param name="input"></param> /// <returns></returns> public async Task <bool> SaveScreenShotData(RoverEntity input) { RoverService service = new RoverService(); var res = await service.SaveData(input); return(res); }