protected void Application_Error(Object sender, EventArgs e) { HttpApplication app = sender as HttpApplication; app.Response.Filter = null; Exception exception = Server.GetLastError(); ICommonLogger logger = new NLogLogger(); if (logger != null) logger.Exception(exception, "Unhandled exception"); }
private static void RegisterImageParts(IAppBuilder app, ContainerBuilder builder) { AmazonS3Settings amazonSettings = AmazonS3Settings.FromConfig(); ICommonLogger logger = new NLogLogger(); IFileStorage fileStorage = new AmazonFileStorage(logger, amazonSettings); var avatarImageSettings = new AvatarImageSettings() { DefaultImages = new List<string>() { "3ysYtgscfkekTqi5bS6XHw", "5eJ-trR5WUGEQZ49rzj2Kw", "cnGYOdKfX0iUKv1fmkB6KA" , "dC-HU2RSiUSEliqP_5HmwA", "EFgYkW-LTkSAxLvAE3DsvA", "Gi3Xoqq_4k2ZZy-Aa5vsyw" , "HwFfWSqQgUu5FMrrFvGiag", "Kyc0FjFlI0uQ2QyczDGvrg" , "Oh7YIBQofkubrcY7bs8RBw", "OsHpSXSr6EamPZzL0iwx0g", "pfP-ZQinnkOyZHpKzl-wBg" , "qBCQhTdEtECK559zxocntg", "QcvLm8Mdr0uLCVQv752V9g", "R0T754HITEuKho19rdnGXg" , "SiHl9pLsjUGLau9JZxEY_g", "tQ4JINIZAkq4lR2r3EVjhg", "VUqjCVsxAEmz9Yfcv24Q6A" , "vvt1gG9n30WHhiPhF2KttA", "YEVzYN1iZEKgOqi2LUsHCw", "_PIYJMjqLEShFOuWTAaCwA" }, TempDeleteAge = TimeSpan.FromDays(1), SizeLimit = 1124000, Targets = new List<ImageTargetParameters>() { new ImageTargetParameters() { TargetFormat = ImageFormat.Jpeg, ResizeType = ImageResizeType.FitAndFill, RoundCorners = false, Height = 100, Width = 100, PathCreator = new PathCreator() { UrlBase = fileStorage.GetBaseUrl(), TempRootFolder = Constants.IMAGE_TEMP_FOLDER_AVATAR, TempFolderFormat = null, TempNameFormat = "{0}{1}.jpeg", StaticRootFolder = Constants.IMAGE_STATIC_FOLDER_AVATAR, StaticFolderFormat = null, StaticNameFormat = "{0}.jpeg" } } } }; var previewImageSettings = new ImageSettings() { Name = Constants.IMAGE_SETTINGS_NAME_PREVIEW, TempDeleteAge = TimeSpan.FromDays(1), SizeLimit = 5124000, Targets = new List<ImageTargetParameters>() { new ImageTargetParameters() { TargetFormat = ImageFormat.Jpeg, ResizeType = ImageResizeType.FitAndFill, RoundCorners = false, Width = 750, Height = 420, PathCreator = new PathCreator() { UrlBase = fileStorage.GetBaseUrl(), TempRootFolder = Constants.IMAGE_TEMP_FOLDER_PREVIEW, TempFolderFormat = null, TempNameFormat = "{0}{1}.jpeg", StaticRootFolder = Constants.IMAGE_STATIC_FOLDER_PREVIEW, StaticFolderFormat = null, StaticNameFormat = "{0}.jpeg" } } } }; var contentImageSettings = new ImageSettings() { Name = Constants.IMAGE_SETTINGS_NAME_CONTENT, TempDeleteAge = TimeSpan.FromDays(1), SizeLimit = 1124000, Targets = new List<ImageTargetParameters>() { new ImageTargetParameters() { TargetFormat = ImageFormat.Jpeg, ResizeType = ImageResizeType.FitRatio, RoundCorners = false, Width = 600, Height = 600, PathCreator = new PathCreator() { UrlBase = fileStorage.GetBaseUrl(), TempRootFolder = Constants.IMAGE_TEMP_FOLDER_CONTENT, TempFolderFormat = null, TempNameFormat = "{0}{1}.jpeg", StaticRootFolder = Constants.IMAGE_STATIC_FOLDER_CONTENT, StaticFolderFormat = "{0}", StaticNameFormat = "{0}.jpeg" } } } }; var commentImageSettings = new ImageSettings() { Name = Constants.IMAGE_SETTINGS_NAME_COMMENT, TempDeleteAge = TimeSpan.FromDays(1), SizeLimit = 5124000, Targets = new List<ImageTargetParameters>() { new ImageTargetParameters() { TargetFormat = ImageFormat.Jpeg, ResizeType = ImageResizeType.FitRatio, Width = 600, Height = 600, RoundCorners = false, PathCreator = new PathCreator() { UrlBase = fileStorage.GetBaseUrl(), TempRootFolder = Constants.IMAGE_TEMP_FOLDER_COMMENT, TempFolderFormat = null, TempNameFormat = "{0}{1}.jpeg", StaticRootFolder = Constants.IMAGE_STATIC_FOLDER_COMMENT, StaticFolderFormat = "{0}", StaticNameFormat = "{0}.jpeg" } } } }; builder.RegisterInstance(fileStorage).As<IFileStorage>(); builder.RegisterType<ImageSettingsFactory>().As<IImageSettingsFactory>(); builder.RegisterInstance(avatarImageSettings).AsSelf(); builder.RegisterInstance(previewImageSettings).AsSelf(); builder.RegisterInstance(contentImageSettings).AsSelf().PreserveExistingDefaults(); builder.RegisterInstance(commentImageSettings).AsSelf().PreserveExistingDefaults(); builder.RegisterType<ContentImageQueries>().AsSelf(); builder.RegisterType<PreviewImageQueries>().AsSelf(); builder.RegisterType<AvatarImageQueries>().AsSelf(); builder.RegisterType<CommentImageQueries>().AsSelf(); }