private async Task ExecutePageAppearingCommand() { if (ConnectionManager.TerminateIfNoInternetAccess(true)) { return; } try { IsBusy = true; Users.Clear(); var users = await _userService.GetAllFavouritesUsers(); users.ForEach(Users.Add); } catch (Exception e) { AlertService.ShowError(e.Message); Logger.LogError(e); } finally { IsBusy = false; } }
void Run(CmdArg Arg) { try { var pClass = SPCTypes.GetClassType(Arg.GetShortCutSegment(0)); if (pClass != null) { //Runable non UI command if (pClass.GetInterfaces().Contains(typeof(IRunable))) { var Sample = BOFactory.CreateSample(pClass) as IRunable; Task.Run(async() => await Sample.RunAsync(Arg)); } } else { var prs = new ProcessStartInfo(@"C:\Program Files (x86)\Google\Chrome\Application\chrome.exe"); prs.Arguments = Arg.Url.Replace(@" ", "%20"); Process.Start(prs); } } catch (Exception ex) { WaitingService.Done(); AlertService.ShowError(ex); } }
private void ExecuteCardDraggingCommand(DraggingCardEventArgs args) { try { if (args.Direction == SwipeCardDirection.Right) { _userService.SaveFavouriteUser(args.Item as UserDetails); } } catch (Exception e) { AlertService.ShowError(e.Message); Logger.LogError(e); } }
async static Task Main(string[] args) { try { Console.WriteLine("Phoebus Console"); Console.WriteLine("--------------------"); Config.RegisterServices(); await SPC.Security.AzureLogin.LoginWithSubscriberId("*****@*****.**", "123"); await SPC.Ctx.AppConfig.SetDefaultConnectionAsync("Local"); await SPC.BO.PS.DB.SwitchToAsync("VSA"); string theclassName = ""; do { theclassName = await SPC.Services.UI.UserInputService.GetStringMatchRegexAsync("", "Enter the Full Name of the Editable Class:", "(Ex: SPC.BO.LA.NA)"); var theType = SPCTypes.GetClassType(theclassName, true); if (theType != null) { if (theType.GetInterfaces().Contains(typeof(ISingleton))) { await TestSingleton(theType); } else if (theType.GetInterfaces().Contains(typeof(SPC.Interfaces.IEditable))) { await TestEditable(theType); } } } while (string.IsNullOrEmpty(theclassName)); } catch (Exception ex) { AlertService.ShowError(ex); } Console.ReadKey(); WaitingService.Done(); }
private async Task <bool> ValidateAndCallApi(Func <Task <string> > apiAction) { var result = await _validator.ValidateAsync(LoginModel); if (!result.IsValid) { AlertService.ShowError(result.Errors.First().ErrorMessage, ValidationError); return(false); } if (ConnectionManager.TerminateIfNoInternetAccess()) { return(false); } try { IsBusy = true; var token = await apiAction(); //in real app we might store this token and use in future requests, but our API we never need it :P //await _storage.SetAsync(nameof(token),token); return(true); } catch (ApiException apiException) { AlertService.ShowError(apiException.GetContentErrorString()); Logger.LogError(apiException); } catch (Exception e) { AlertService.ShowError(e.Message); Logger.LogError(e); } finally { IsBusy = false; } return(false); }
private async Task RunTaskAsync(CmdArg Arg) { try { if (Arg.Action == Helper.Action._Help) { SPC.Services.InternetChecker.OnlineGuard(); string Topic = Arg.ShortCut; if (!string.IsNullOrEmpty(Topic)) { WaitingService.Wait("Openning Online Help".Translate(), Arg.Url); var theHelpUrl = await SPC.Cloud.HelpService.GetHelpTopicUrlAsync(Topic); nav.NavigateTo(theHelpUrl); WaitingService.Done(); } } else if (Arg.GetShortCutSegment(0).Equals("Debug", StringComparison.OrdinalIgnoreCase)) { var onoff = Arg.GetDefaultParameter(); if (string.IsNullOrEmpty(onoff)) { Ctx.AppConfig.DebugMode = !Ctx.AppConfig.DebugMode; } else { Ctx.AppConfig.DebugMode = onoff.ToBoolean(); } AlertService.Toast($"Debug Mode is : {(Ctx.AppConfig.DebugMode ? "ON" : "OFF")}"); } else if (Arg.Url.StartsWith("http", StringComparison.OrdinalIgnoreCase)) //Open online resources { WaitingService.Wait("Openning browser", Arg.Url); nav.NavigateTo(Arg.Url); WaitingService.Done(); } else if (Arg.Url.StartsWith(@"/", StringComparison.OrdinalIgnoreCase)) //Open Local files { WaitingService.Done(); } else if (Arg.Url.StartsWith(@"mailto://", StringComparison.OrdinalIgnoreCase)) { WaitingService.Wait("Composing mail ...", ""); nav.NavigateTo(Arg.Url); WaitingService.Done(); } else if (Arg.Url.MatchesRegExp(@"^[A-Za-z]+://")) //Open other apps "lyft:// { WaitingService.Done(); } else if (Arg.Action.MatchesRegExp("^Insert$|^Update$|^InsertUpdate$|^UpdateAll$|^Delete$|^DeleteAll$")) //NON-UI Commands { WaitingService.Wait(Arg.Action, Arg.Url); await SPC.Commands.NonUIActionRunner.RunURLCommandAsync(Arg); WaitingService.Done(); } else { var pClass = SPCTypes.GetClassType(Arg.GetShortCutSegment(0), true); if (pClass != null) { //Runable non UI command if Action = Run or the command is not a mix of Editable and Runnable if (pClass.GetInterfaces().Contains(typeof(IRunable)) && (Arg.Action == Helper.Action._Run || !pClass.GetInterfaces().Contains(typeof(IEditable)))) { var Sample = BOFactory.CreateSample(pClass) as IRunable; await Sample.RunAsync(Arg); } //Class is ISupportQueryInfoList and the Action = Select else if (Arg.Action == Helper.Action._Select && pClass.GetInterfaces().Contains(typeof(SPC.Interfaces.ISupportQueryInfoList))) //Query BO { if (BOFactory.CreateSample(pClass) is ISupportQueryInfoList sample) { var theList = await sample.GetInfoListAsync(Arg.GetDictionary()) as IList; await ValueSelector.SelectAsync(theList, "Info List"); } } else { AlertService.Toast($"Could not find any suitable Page for class : {Arg.ShortCut}"); WaitingService.Done(); } } else //Short Command is not a class { WaitingService.Done(); AlertService.Toast($"Could not find the class {Arg.GetShortCutSegment(0)}"); } } } catch (Exception ex) { WaitingService.Done(); if (ex.GetType() == typeof(NullReferenceException)) //file extension is not support by ios { try { AlertService.ShowError(ex); } catch (Exception ex1) { //ExceptionHandler.LogAndAlert(ex1); // AlertService.ShowError(ex1); } } //if (ex.GetType() == typeof(ExitScriptException)) //file extension is not support by ios //ExceptionHandler.LogAndToast(ex); //else //ExceptionHandler.LogAndAlert(ex); //AlertService.ShowError(ex); } }