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 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); } }