Esempio n. 1
0
        /// <summary>
        /// Hata mesajını oturumun dilinde getirir.
        /// </summary>
        /// <param name="cultureCode"></param>
        /// <returns></returns>
        public string GetMessage()
        {
            string message = PxLocalizationManager.Get(_localizedStringCode);

            if (message != null && messageParameters != null && messageParameters.Length > 0)
            {
                message = string.Format(message, messageParameters);
            }
            return(message);
        }
            public string GetMessage()
            {
                string msg = PxLocalizationManager.Get(_localizedStringCode);

                if (msg != null)
                {
                    msg = string.Format(msg, _innerErrorMessage);
                    return(msg);
                }
                return(ERROR_CODE);
            }
 public static void Run()
 {
     lock (lockObj) {
         if (firstRun)
         {
             PxLocalizationManager.Initialize();
             if (PxConfigurationManager.PxConfig.Schedule.Enabled)
             {
                 PxTaskScheduler.Instance.Start();
             }
         }
     }
 }
Esempio n. 4
0
        /// <summary>
        /// ConfigureServices'de eklenen servisleri configure eder.
        /// Error sayfası için Error Controller'daki Index actionı kullanılmaktadır.
        /// Error StatusCode'lar için "/Error/Status/{0}" yapısı kullanılmaktadır.
        /// </summary>
        /// <param name="app"></param>
        /// <param name="env"></param>
        /// <param name="loggerFactory"></param>
        public static void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
        {
            if (env.IsDevelopment())
            {
                app.UseDeveloperExceptionPage();
            }
            else
            {
                app.UseExceptionHandler("/Error");
            }
            if (env.IsDevelopment())
            {
                loggerFactory.AddConsole()
                .AddDebug();
            }
            app.UseStatusCodePagesWithReExecute("/Error/Status/{0}");
            //PxWebMemoryCacheManager.Instance.MemoryCache = app.ApplicationServices.GetService<IMemoryCache>();
            PxRazorViewToStringRenderer.Configure(app.ApplicationServices.GetRequiredService <PxRazorViewToStringRenderer>());
            PxHttpContext.Configure(app.ApplicationServices.GetRequiredService <Microsoft.AspNetCore.Http.IHttpContextAccessor>());
            /* Session kullanımı için gerekli */
            app.UseSession(new SessionOptions()
            {
                CookieHttpOnly = true,
                IdleTimeout    = TimeSpan.FromMinutes(PxConfigurationManager.PxConfig.Session.DefaultTimeoutDuration)
            });

            /* Biz session üzerinde kullanıcı IP bilgisini veriyoruz. Load Balancer'lar arkasında bulunan bir sunucuda client IP bilgisini alabilmek için
             *                 Forwarded Header'lara bakmak gerekiyor */
            app.UseForwardedHeaders(new ForwardedHeadersOptions
            {
                ForwardedHeaders = ForwardedHeaders.XForwardedFor | ForwardedHeaders.XForwardedProto
            });
            if (PxConfigurationManager.PxConfig.UseCompression)
            {
                app.UseCompression();
            }
            IPxSessionStore     iPxContextStore     = app.ApplicationServices.GetService <IPxSessionStore>();
            IPxClientInfoHelper iPxClientInfoHelper = app.ApplicationServices.GetService <IPxClientInfoHelper>();

            PxSession.Initilize(iPxContextStore, iPxClientInfoHelper);

            app.UseStaticFiles(new StaticFileOptions
            {
                OnPrepareResponse = context =>
                {
                    // Cache static file for 1 year
                    if (!string.IsNullOrEmpty(context.Context.Request.Query["v"]))
                    {
                        context.Context.Response.Headers.Add("cache-control", new[] { "public,max-age=31536000" });
                        context.Context.Response.Headers.Add("Expires", new[] { DateTime.UtcNow.AddDays(1).ToString("R") });
                    }
                }
            });

            CultureInfo culture = new CultureInfo("tr-TR");

            culture.NumberFormat.NumberDecimalSeparator   = ".";
            culture.NumberFormat.NumberGroupSeparator     = ",";
            culture.NumberFormat.CurrencyDecimalSeparator = ".";
            culture.NumberFormat.CurrencyGroupSeparator   = ",";


            CultureInfo.DefaultThreadCurrentCulture   = culture;
            CultureInfo.DefaultThreadCurrentUICulture = culture;
            Thread.CurrentThread.CurrentCulture       = culture;
            Thread.CurrentThread.CurrentUICulture     = culture;

            app.UseRequestLocalization(new RequestLocalizationOptions
            {
                DefaultRequestCulture = new RequestCulture(culture),
                SupportedCultures     = new List <CultureInfo>
                {
                    culture
                },
                SupportedUICultures = new List <CultureInfo>
                {
                    culture
                }
            });

            app.UseMvc(routes =>
            {
                routes.MapRoute(
                    name: "default",
                    template: "{controller=Home}/{action=Index}/{id?}");
            });

            PxLocalizationManager.Initialize();
            if (PxConfigurationManager.PxConfig.Schedule.Enabled)
            {
                PxTaskScheduler.Instance.Start();
            }
        }