コード例 #1
0
        async Task Ctx.IAppConfigInfo.SetDefaultConnectionAsync(string ConnnectionCode)
        {
            var cbuilder = new SqlConnectionStringBuilder();

            cbuilder.DataSource         = Server;
            cbuilder.InitialCatalog     = Database;
            cbuilder.UserID             = UserId;
            cbuilder.Password           = Password;
            cbuilder.IntegratedSecurity = false;

            string cs = cbuilder.ConnectionString;

            WaitingService.Wait("Testing Connection to", $"Server {cbuilder.DataSource}/{cbuilder.InitialCatalog}");


            var dic = ((IAppConfigInfo)this).GetApplicationConfigInfos();

            dic.InsertUpdate(Ctx.AppConfig.SQLConnectionString, cs);
            dic.InsertUpdate(nameof(Ctx.AppConfig.DBEngine), "SQL");
            dic.InsertUpdate(nameof(Ctx.AppConfig.UseAppServer), "N");


            using (IDbConnection con = await SPC.Database.ConnectionFactory.GetDBConnectionAsync(true))
            {
                if (con.State == ConnectionState.Open)
                {
                    AlertService.Alert($"Connected to Server {cbuilder.DataSource}/{cbuilder.InitialCatalog}");
                }
                else
                {
                    AlertService.Alert($"Failed to connect to Server {cbuilder.DataSource}/{cbuilder.InitialCatalog}");
                }
            }
        }
コード例 #2
0
        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);
            }
        }
コード例 #3
0
        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();
        }
コード例 #4
0
ファイル: Bootstrapper.cs プロジェクト: krzyszsz/UiHost
        private void RegisterWaitingService()
        {
            var waitingService = new WaitingService();

            Container.ComposeExportedValue <IWaitingService>(waitingService);
        }
コード例 #5
0
        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);
            }
        }