public ListContext(string userName, Models.StoreFront cachedStoreFront, Models.StoreFrontConfiguration cachedStoreFrontConfig, Models.UserProfile cachedUserProfile) { UserName = userName; CachedStoreFront = cachedStoreFront; CachedStoreFrontConfig = cachedStoreFrontConfig; CachedUserProfile = cachedUserProfile; CreateRepositories(); }
public IGstoreDb NewContext(string userName, Models.StoreFront cachedStoreFront, Models.StoreFrontConfiguration cachedStoreFrontConfig, Models.UserProfile cachedUserProfile) { //use same context for all lists until commit and separate contexts are coded return(new ListContext(userName, cachedStoreFront, cachedStoreFrontConfig, cachedUserProfile)); }
public GStoreErrorInfo(ErrorPage errorPage, Exception exception, RouteData routeData, string controllerName, string actionName, string ipAddress, Models.StoreFront currentstoreFrontOrNull, string rawUrl, string url) : base(exception, controllerName, actionName) { this.ErrorPage = errorPage; this.ErrorCode = (int)errorPage; this.RouteDataSource = routeData.ToSourceString(); this.IPAddress = ipAddress; this.CurrentstoreFrontOrNull = currentstoreFrontOrNull; this.RawUrl = rawUrl; this.Url = url; }
public static bool TryDisplayStaticPage(ErrorPage errorPage, int httpStatusCode, Exception ex, bool clearError, HttpContext context, BaseController controller) { string url = string.Empty; string rawUrl = string.Empty; if (context != null) { url = context.Request.Url.ToString(); rawUrl = context.Request.RawUrl; } if (controller != null && controller.CurrentStoreFrontOrNull != null) { //start with storefront error pages folder Models.StoreFront storeFront = controller.CurrentStoreFrontOrThrow; string customErrorFolder = storeFront.StoreFrontVirtualDirectoryToMap(controller.Request.ApplicationPath) + "/ErrorPages/"; string customErrorPath = customErrorFolder + errorPage.ErrorPageFileName(); bool customErrorFileExists = false; if (System.IO.File.Exists(context.Server.MapPath(customErrorPath))) { customErrorFileExists = true; } else { //if store front error page not found, look for client custom error page customErrorFolder = storeFront.Client.ClientVirtualDirectoryToMap(context.Request.ApplicationPath) + "/ErrorPages/"; customErrorPath = customErrorFolder + errorPage.ErrorPageFileName(); if (System.IO.File.Exists(context.Server.MapPath(customErrorPath))) { customErrorFileExists = true; } } if (customErrorFileExists) { try { context.Response.Clear(); context.Response.StatusCode = httpStatusCode; System.Diagnostics.Trace.WriteLine("--Displaying custom error static page: " + customErrorPath + " for ErrorPage: " + errorPage.ToString() + " Url: " + url + " RawUrl: " + rawUrl + " Original Exception: " + ex.Message); context.Server.Execute(customErrorPath); context.Response.Flush(); System.Diagnostics.Trace.WriteLine("--Success displaying custom error static page: " + customErrorPath + " for ErrorPage: " + errorPage.ToString() + " Url: " + url + " RawUrl: " + rawUrl + " Original Exception: " + ex.Message); if (clearError) { context.ClearError(); } return(true); } catch (Exception exCustomPageError) { System.Diagnostics.Trace.WriteLine("--Failure. Error displaying custom error static page: " + customErrorPath + " for ErrorPage: " + errorPage.ToString() + " Url: " + url + " RawUrl: " + rawUrl + " Exception: " + exCustomPageError.Message + " Original Exception: " + ex.Message); string error = exCustomPageError.Message; } } } //unknown client or client does not have a custom error page, show server static error page string serverErrorFolder = "~/Content/Server/ErrorPages/"; string serverErrorPath = serverErrorFolder + errorPage.ErrorPageFileName(); if (!System.IO.File.Exists(context.Server.MapPath(serverErrorPath))) { System.Diagnostics.Trace.WriteLine("--Failure. Error: Server error static page not found: " + serverErrorPath + " for ErrorPage: " + errorPage.ToString() + " Url: " + url + " RawUrl: " + rawUrl + " Original Exception: " + ex.Message); return(false); } try { context.Response.Clear(); context.Response.StatusCode = httpStatusCode; System.Diagnostics.Trace.WriteLine("--Displaying server error static page: " + serverErrorPath + " for ErrorPage: " + errorPage.ToString() + " Url: " + url + " RawUrl: " + rawUrl); context.Server.Execute(serverErrorPath); context.Response.Flush(); System.Diagnostics.Trace.WriteLine("--Success displaying server error static page: " + serverErrorPath + " for ErrorPage: " + errorPage.ToString() + " Url: " + url + " RawUrl: " + rawUrl); if (clearError) { context.Server.ClearError(); } return(true); } catch (Exception exServerPageError) { System.Diagnostics.Trace.WriteLine("--Failure. Error displaying server error static page: " + serverErrorPath + " for ErrorPage: " + errorPage.ToString() + " Url: " + url + " RawUrl: " + rawUrl + " Exception: " + exServerPageError.Message + " Original Exception: " + ex.Message); return(false); } }
/// <summary> /// Creates a new db context using specified user name, cached store front and cached user profile to pre-load cache /// </summary> /// <param name="userName"></param> /// <param name="cachedStoreFront"></param> /// <param name="cachedUserProfile"></param> /// <returns></returns> public IGstoreDb NewContext(string userName, Models.StoreFront cachedStoreFront, Models.StoreFrontConfiguration cachedStoreFrontConfig, Models.UserProfile cachedUserProfile) { return(new GStoreEFDbContext(userName, cachedStoreFront, cachedStoreFrontConfig, cachedUserProfile)); }