Exemplo n.º 1
0
        // This method gets called by the runtime. Use this method to configure the HTTP request pipeline.
        public void Configure(IApplicationBuilder app, IWebHostEnvironment env, IHostApplicationLifetime appLifetime)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }

            app.UseStatusCodePagesWithReExecute("/NotFound", "?statusCode={0}");

            app.UseStaticFiles();

            app.UseRouting();

            app.UseEndpoints(endpoints =>
            {
                // endpoints.MapControllers();
                endpoints.MapRazorPages();

                endpoints.MapControllerRoute(
                    name: "default",
                    pattern: "{controller}/{action=Index}/{id?}");

                endpoints.MapHub <LogHub>("/loghub");

                // endpoints.MapFallbackToController("Index", "Home");
            });

            app.Use(async(context, next) =>
            {
                var url = context.Request.Path.Value ?? "";
                if (url.ToLower().EndsWith("/home"))
                {
                    context.Response.Redirect("/");
                    return;
                }

                await next();
            });

            appLifetime.ApplicationStarted.Register(() => {
                Settings.GetSettings().AppUrl = app.ServerFeatures.Get <IServerAddressesFeature>().Addresses.ToList().First();
                if (Settings.GetSettings().AppSettings.OpenBrowserOnLaunch)
                {
                    UrlOpener.Open(Settings.GetSettings().AppUrl);
                }
            });
        }
Exemplo n.º 2
0
        private void LnkHelp_LinkClicked(object sender, EventArgs e)
        {
            const string helpUrl = "https://github.com/OpenMLTD/MLTDTools/wiki/MillionDance-Manual";

            try {
                UrlOpener.OpenUrl(helpUrl);
            } catch (Exception ex) {
                var sb = new StringBuilder();
                sb.AppendLine("Cannot open URL <" + helpUrl + ">; please manually open it in your browser.");
                sb.AppendLine();
                sb.Append(ex.ToString());

                var message = sb.ToString();

                MessageBox.Show(message, ApplicationHelper.GetApplicationTitle(), MessageBoxButtons.OK, MessageBoxIcon.Warning);
            }
        }
Exemplo n.º 3
0
        private void CheckIfThisVersionIsUpToDate()
        {
            if (new VersionChecker().ThisVersionIsUpToDate())
            {
                return;
            }
            DialogBox.Show("This version of TTAP is outdated.",
                           "Do you want to download the latest version? ",
                           "CANCEL",
                           "DOWNLOAD");
            switch (DialogBox.Result)
            {
            case DialogBox.Result_.LeftButtonClicked: return;

            case DialogBox.Result_.RightButtonClicked:
                UrlOpener.OpenLinkInBrowser(new UrlProvider().DownloadLink);
                Application.Current.Shutdown();
                break;

            default:
                throw new ArgumentOutOfRangeException();
            }
        }