private static RedisTarget _redisTarget; // Required to ensure assembly is copied to output.
#pragma warning restore CS0169

        protected void Application_Start()
        {
            LoggingConfig.ConfigureLogging();

            TelemetryConfiguration.Active.InstrumentationKey = CloudConfigurationManager.GetSetting("InstrumentationKey");

            AreaRegistration.RegisterAllAreas();
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            ModelBinders.Binders.Add(typeof(string), new TrimStringModelBinder());

            AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;

            var container = StructuremapMvc.StructureMapDependencyScope.Container;

            FluentValidationModelValidatorProvider.Configure(x => x.ValidatorFactory = new StructureMapValidatorFactory(container));

            WebMessageBuilders.Register();
            WebMessageBuilders.UserIdClaim    = DasClaimTypes.Id;
            WebMessageBuilders.UserEmailClaim = DasClaimTypes.Email;

            AuditMessageFactory.RegisterBuilder(message =>
            {
                message.Source = new Source
                {
                    Component = "EAS-Web",
                    System    = "EAS",
                    Version   = typeof(MvcApplication).Assembly.GetName().Version.ToString()
                };
            });
        }
        protected void Application_Start()
        {
            TelemetryConfiguration.Active.InstrumentationKey = ConfigurationManager.AppSettings["InstrumentationKey"];

            MvcHandler.DisableMvcResponseHeader           = true;
            AntiForgeryConfig.SuppressXFrameOptionsHeader = true;

            LoggingConfig.ConfigureLogging();
            AreaRegistration.RegisterAllAreas();
            GlobalConfiguration.Configure(WebApiConfig.Register);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);

            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);

            WebMessageBuilders.UserIdClaim    = DasClaimTypes.Id;
            WebMessageBuilders.UserEmailClaim = DasClaimTypes.Email;
            WebMessageBuilders.Register();
            AuditMessageFactory.RegisterBuilder(message =>
            {
                var name = typeof(MvcApplication).Assembly.GetName();

                message.Source = new Audit.Types.Source
                {
                    System    = "EMPU",
                    Component = name.Name,
                    Version   = name.Version.ToString()
                };
            });
        }
        protected void Application_Start()
        {
            AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;
            AntiForgeryConfig.RequireSsl = true;
            AreaRegistration.RegisterAllAreas();
            BinderConfig.RegisterBinders(ModelBinders.Binders);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            LoggingConfig.ConfigureLogging();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            TelemetryConfiguration.Active.InstrumentationKey = ConfigurationManager.AppSettings["InstrumentationKey"];
            WebMessageBuilders.Register();
            WebMessageBuilders.UserIdClaim    = DasClaimTypes.Id;
            WebMessageBuilders.UserEmailClaim = DasClaimTypes.Email;

            AuditMessageFactory.RegisterBuilder(m =>
            {
                m.Source = new Source
                {
                    Component = "EmployerAccounts-Web",
                    System    = "EmployerAccounts",
                    Version   = typeof(MvcApplication).Assembly.GetName().Version.ToString()
                };
            });

            if (ConfigurationHelper.IsEnvironmentAnyOf(Environment.Local, Environment.At, Environment.Test))
            {
                SystemDetailsViewModel.EnvironmentName = ConfigurationHelper.CurrentEnvironment.ToString();
                SystemDetailsViewModel.VersionNumber   = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            }

            StartServiceBusEndpoint();
        }
 public static void Register()
 {
     AuditMessageFactory.RegisterBuilder(message =>
     {
         var httpContext = new HttpContextWrapper(HttpContext.Current);
         new ChangedByMessageBuilder(httpContext).Build(message);
     });
 }
Ejemplo n.º 5
0
        public void WhenAuditToStringSortOptionPropertyNameReturnExpectedResult()
        {
            // arrange
            var sut = new Customer {
                Count = -1, IsActive = true, FirstName = "Oceanware"
            };

            // act
            var result = AuditMessageFactory.AuditToString(sut, IncludeAllProperties.No, SortOption.PropertyName);

            // assert
            Assert.Equal("Count = -1, FirstName = Oceanware, IsActive = True", result);
        }
Ejemplo n.º 6
0
        public void WhenAuditToStringIncludeAllPropertiesYesIncludeErrorProperty()
        {
            // arrange
            var sut = new Customer {
                Count = -1, IsActive = true, FirstName = "Oceanware"
            };

            // act
            var result = AuditMessageFactory.AuditToString(sut, IncludeAllProperties.Yes, SortOption.AuditSequencePropertyName);

            // assert
            Assert.Equal("FirstName = Oceanware, Count = -1, IsActive = True, Error = Problem", result);
        }
Ejemplo n.º 7
0
        public void WhenAuditToStringAuditFormatNormalReturnExpectedResult()
        {
            // arrange
            var sut = new Customer {
                Count = -1, IsActive = true, FirstName = "Oceanware"
            };

            // act
            var result = AuditMessageFactory.AuditToString(sut, IncludeAllProperties.No, SortOption.AuditSequencePropertyName, auditFormat: AuditFormat.Normal);

            // assert
            Assert.Equal("First Name ( FirstName ) = Oceanware, Count ( Count ) = -1, Is Active ( IsActive ) = True", result);
        }
Ejemplo n.º 8
0
        protected void Application_Start()
        {
            AntiForgeryConfig.UniqueClaimTypeIdentifier = ClaimTypes.NameIdentifier;
            AntiForgeryConfig.RequireSsl = true;
            AreaRegistration.RegisterAllAreas();
            BinderConfig.RegisterBinders(ModelBinders.Binders);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters);
            FluentValidationModelValidatorProvider.Configure();
            LoggingConfig.ConfigureLogging();
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            TelemetryConfiguration.Active.InstrumentationKey = ConfigurationManager.AppSettings["APPINSIGHTS_INSTRUMENTATIONKEY"];
            WebMessageBuilders.Register();
            WebMessageBuilders.UserIdClaim    = DasClaimTypes.Id;
            WebMessageBuilders.UserEmailClaim = DasClaimTypes.Email;

            AuditMessageFactory.RegisterBuilder(m =>
            {
                m.Source = new Source
                {
                    Component = "EAS-Web",
                    System    = "EAS",
                    Version   = typeof(MvcApplication).Assembly.GetName().Version.ToString()
                };
            });

            var container = StructuremapMvc.StructureMapDependencyScope.Container;

            var environmentService = container.GetInstance <IEnvironmentService>();

            if (environmentService.IsCurrent(DasEnv.LOCAL))
            {
                SystemDetailsViewModel.EnvironmentName = DasEnv.LOCAL.ToString();
                SystemDetailsViewModel.VersionNumber   = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            }
            if (environmentService.IsCurrent(DasEnv.AT))
            {
                SystemDetailsViewModel.EnvironmentName = DasEnv.AT.ToString();
                SystemDetailsViewModel.VersionNumber   = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            }
            if (environmentService.IsCurrent(DasEnv.TEST))
            {
                SystemDetailsViewModel.EnvironmentName = DasEnv.TEST.ToString();
                SystemDetailsViewModel.VersionNumber   = Assembly.GetExecutingAssembly().GetName().Version.ToString();
            }

            StartServiceBusEndpoint(container);
        }
Ejemplo n.º 9
0
        public void WhenAuditToIDictionaryAuditFormatNormalReturnExpectedResult()
        {
            // arrange
            var sut = new Customer {
                Count = -1, IsActive = true, FirstName = "Oceanware"
            };
            const Int32 ExpectedDictionaryCount = 3;

            // act
            var result       = AuditMessageFactory.AuditToIDictionary(sut, IncludeAllProperties.No, SortOption.AuditSequencePropertyName, auditFormat: AuditFormat.Normal);
            var stringResult = DictionaryToString(result);

            // assert
            Assert.True(result.Count == ExpectedDictionaryCount);
            Assert.True("FirstName = Oceanware, Count = -1, IsActive = True" == stringResult);
        }
Ejemplo n.º 10
0
        public void WhenAuditToIDictionaryIncludeAllPropertiesYesIncludeErrorProperty()
        {
            // arrange
            var sut = new Customer {
                Count = -1, IsActive = true, FirstName = "Oceanware"
            };
            const Int32 ExpectedDictionaryCount = 4;

            // act
            var result       = AuditMessageFactory.AuditToIDictionary(sut, IncludeAllProperties.Yes, SortOption.AuditSequencePropertyName);
            var stringResult = DictionaryToString(result);

            // assert
            Assert.True(result.Count == ExpectedDictionaryCount);
            Assert.True("FirstName = Oceanware, Count = -1, IsActive = True, Error = Problem" == stringResult);
        }
Ejemplo n.º 11
0
        static void Main()
        {
            AuditMessageFactory.RegisterBuilder(message =>
            {
                message.Source = new Source
                {
                    Component = typeof(Program).Assembly.GetName().Name,
                    System    = "EMPU",
                    Version   = typeof(Program).Assembly.GetName().Version.ToString()
                };
            });

            var container = IoC.Initialize();

            var manager = container.GetInstance <RegistrationManager>();

            manager.RemoveExpiredRegistrations().Wait();
        }
Ejemplo n.º 12
0
 /// <summary>Builds up a String containing each property and value in the class decorated with the AuditAttribute. The String displays the property name, property friendly name and property value.</summary>
 /// <typeparam name="T">Class type.</typeparam>
 /// <param name="instance">The instance.</param>
 /// <param name="includeAllProperties">The include all properties.</param>
 /// <param name="sortOption">The sort option.</param>
 /// <param name="delimiter">The delimiter.</param>
 /// <param name="defaultValue">
 /// If no class properties are decorated with the <see cref="AuditAttribute"/> and the defaultValue is not null or an empty string, then the default value will be returned.
 /// </param>
 /// <returns>A String containing each property name, friendly name and value, separated by the delimiter and sorted by AuditAttribute.AuditSequence and then property name.</returns>
 /// <exception cref="InvalidEnumArgumentException">Thrown when enum value includeAllProperties is not defined.</exception>
 /// <exception cref="InvalidEnumArgumentException">Thrown when enum value sortOption is not defined.</exception>
 /// <exception cref="ArgumentNullEmptyWhiteSpaceException">Thrown when delimiter is null, empty, or white space.</exception>
 /// <exception cref="InvalidEnumArgumentException">Thrown when enum value auditFormat is not defined.</exception>
 public String AuditToString <T>(IncludeAllProperties includeAllProperties, SortOption sortOption, String delimiter = Constants.DefaultAuditMessageDelimiter, AuditFormat auditFormat = AuditFormat.Compact, String defaultValue = Constants.AuditDefaultValue)
 {
     return(AuditMessageFactory.AuditToString(this, includeAllProperties, sortOption, delimiter, auditFormat, defaultValue));
 }
Ejemplo n.º 13
0
 /// <summary>Populates the dictionary with property's name and value in the class for properties decorated with the <see cref="AuditAttribute"/>. If <c>IncludeAllProperties.Yes</c> then all properties will be included with or without the <c>AuditAttribute</c>.</summary>
 /// <param name="instance">The instance.</param>
 /// <param name="dictionary">Pass an IDictionary Object that needs to be populated. This could be the Data property of an exception Object that you want to populate, etc.</param>
 /// <param name="includeAllProperties">The include all properties.</param>
 /// <param name="sortOption">The sort option.</param>
 /// <param name="auditFormat">The audit format.</param>
 /// <param name="defaultValue">
 /// If no class properties are decorated with the <see cref="AuditAttribute"/> and the defaultValue is not null or an empty string, then a single entry will be added to the dictionary that is named 'DefaultValue' and will have the value of defaultValue.
 /// </param>
 /// <returns>IDictionary populated with properties and values.</returns>
 /// <exception cref="ArgumentNullException">Thrown when dictionary is null.</exception>
 /// <exception cref="InvalidEnumArgumentException">Thrown when enum value includeAllProperties is not defined.</exception>
 /// <exception cref="InvalidEnumArgumentException">Thrown when enum value sortOption is not defined.</exception>
 /// <exception cref="InvalidEnumArgumentException">Thrown when enum value auditFormat is not defined.</exception>
 public IDictionary <String, String> AuditToIDictionary(IDictionary <String, String> dictionary, IncludeAllProperties includeAllProperties, SortOption sortOption, AuditFormat auditFormat = AuditFormat.Compact, String defaultValue = Constants.AuditDefaultValue)
 {
     return(AuditMessageFactory.AuditToIDictionary(this, dictionary, includeAllProperties, sortOption, auditFormat, defaultValue));
 }