public async Task AddSolution(string solutionUrl, ValidateSidResponse response) { try { string sid = solutionUrl.Split(CharConstants.DOT)[0]; SolutionInfo info = new SolutionInfo { SolutionName = sid, RootUrl = solutionUrl, SolutionObject = response.SolutionObj, SignUpPage = response.SignUpPage }; await solutionService.SetDataAsync(info); await solutionService.ClearCached(); await solutionService.CreateDB(sid); await solutionService.CreateDirectory(); if (response.Logo != null) { solutionService.SaveLogo(sid, response.Logo); } } catch (Exception ex) { EbLog.Error(ex.Message); } }
public async Task CreateEmbeddedSolution(ValidateSidResponse result, string url) { SolutionInfo sln = new SolutionInfo { SolutionName = url.Split(CharConstants.DOT)[0], RootUrl = url, IsCurrent = true, SolutionObject = result.SolutionObj, SignUpPage = result.SignUpPage }; App.Settings.CurrentSolution = sln; try { await Store.SetJSONAsync(AppConst.MYSOLUTIONS, new List <SolutionInfo> { sln }); await Store.SetJSONAsync(AppConst.SOLUTION_OBJ, sln); await CreateDB(sln.SolutionName); await CreateDirectory(); } catch (Exception ex) { Console.WriteLine(ex.Message); } }
private async void SaveSolution_Clicked(object sender, EventArgs e) { string surl = SolutionName.Text?.Trim(); if (string.IsNullOrEmpty(surl)) { return; } try { if (!Utils.HasInternet) { Utils.Alert_NoInternet(); return; } string domain = App.Settings.Vendor.GetDomain(); if (surl.Split(CharConstants.DOT).Length == 1) { surl += $".{domain}"; } if (viewModel.IsSolutionExist(surl)) { await viewModel.RedirectToExistingSolution(surl, isMasterPage); return; } EbLayout.ShowLoader(); response = await viewModel.Validate(surl); if (response.IsValid) { EbLayout.HideLoader(); SolutionLogoPrompt.Source = ImageSource.FromStream(() => new MemoryStream(response.Logo)); SolutionLabel.Text = surl.Split(CharConstants.DOT)[0]; ShowSIDConfirmBox(); SoluUrl = surl; } else { EbLayout.HideLoader(); Utils.Toast("Invalid solution URL"); } } catch (Exception ex) { EbLog.Error(ex.Message); } }
private void QrScannerCallback(string payload) { SolutionQrMeta meta = null; try { meta = JsonConvert.DeserializeObject <SolutionQrMeta>(payload); } catch (Exception ex) { EbLog.Info("failed to parse qr payload in new solution page"); EbLog.Error(ex.Message); return; } if (meta == null) { return; } Device.BeginInvokeOnMainThread(async() => { try { if (string.IsNullOrEmpty(meta.Sid) || viewModel.IsSolutionExist(meta.Sid)) { Utils.Toast($"{meta.Sid} exist"); return; } EbLayout.ShowLoader(); response = await viewModel.Validate(meta.Sid); if (response.IsValid) { await viewModel.AddSolution(meta.Sid, response); await App.Navigation.NavigateToLogin(isMasterPage); } else { Utils.Toast("invalid qr code meta"); } EbLayout.HideLoader(); } catch (Exception) { EbLayout.HideLoader(); } }); }
private async void StartApplicationClicked(object sender, EventArgs e) { if (!Utils.HasInternet) { Utils.Alert_NoInternet(); return; } if (Vendor.BuildType == Enums.AppBuildType.Embedded) { EbLayout.ShowLoader(); try { ISolutionService service = new SolutionService(); ValidateSidResponse response = await service.ValidateSid(Vendor.SolutionURL); if (response != null && response.IsValid) { await service.CreateEmbeddedSolution(response, Vendor.SolutionURL); await Store.SetValueAsync(AppConst.FIRST_RUN, "true"); await App.Navigation.InitializeNavigation(); } } catch (Exception) { Utils.Toast("Unable to finish the request"); } EbLayout.HideLoader(); } else { await Store.SetValueAsync(AppConst.FIRST_RUN, "true"); await App.Navigation.InitializeNavigation(); } }
public async Task <ValidateSidResponse> ValidateSid(string url) { ValidateSidResponse response = null; RestClient client = new RestClient(ApiConstants.PROTOCOL + url); RestRequest request = new RestRequest(ApiConstants.VALIDATE_SOL, Method.GET); try { IRestResponse iresp = await client.ExecuteAsync(request); if (iresp.IsSuccessful) { response = JsonConvert.DeserializeObject <ValidateSidResponse>(iresp.Content); } } catch (Exception e) { EbLog.Info("validate_solution api failure"); EbLog.Error(e.Message); } return(response ?? new ValidateSidResponse()); }