Exemplo n.º 1
0
        protected void Application_Start()
        {
            VersionLogging.SetVersion();
            RuntimeHelper.SetRuntimeName("SFA.Apprenticeships.Web.Manage");

            AreaRegistration.RegisterAllAreas();

            var container = (IContainer)DependencyResolver.Current.GetService(typeof(IContainer));

            FilterConfig.RegisterGlobalFilters(GlobalFilters.Filters, container);
            RouteConfig.RegisterRoutes(RouteTable.Routes);
            BundleConfig.RegisterBundles(BundleTable.Bundles);
            GlobalConfiguration.Configure(WebApiConfig.Register);

            ViewEngines.Engines.Clear();
            ViewEngines.Engines.Add(new RazorViewEngine());

            ControllerBuilder.Current.SetControllerFactory(new DefaultControllerFactory());

            ModelBinders.Binders.DefaultBinder = new TrimModelBinder();
            FluentValidationModelValidatorProvider.Configure(provider =>
            {
                provider.AddImplicitRequiredValidator = false;
                provider.Add(typeof(EqualValidator),
                             (metadata, context, description, validator) =>
                             new EqualToValueFluentValidationPropertyValidator(metadata, context, description, validator));
            });

            // This header cannot be removed using web.config --> http://www.codeproject.com/Tips/785867/ASP-NET-MVC-Remove-IIS-Header-Bloat
            MvcHandler.DisableMvcResponseHeader = true;
        }
Exemplo n.º 2
0
        private void SetAbout()
        {
            var showAbout = bool.Parse(ConfigurationManager.AppSettings["ShowAbout"]);

            ViewBag.ShowAbout = showAbout;

            if (!showAbout)
            {
                return;
            }

            ViewBag.Version     = VersionLogging.GetVersion();
            ViewBag.Environment = ConfigurationManager.AppSettings["Environment"];
        }
Exemplo n.º 3
0
        private void Initialise()
        {
            VersionLogging.SetVersion();

            try
            {
                InitializeIoC();
            }
            catch (Exception ex)
            {
                if (_logger != null)
                {
                    _logger.Error(ProcessName + " failed to initialise", ex);
                }
                throw;
            }
        }
Exemplo n.º 4
0
        private void Initialise()
        {
            VersionLogging.SetVersion();

            try
            {
                InitializeIoC();
                InitialiseServiceBus();
                SubscribeServiceBusMessageBrokers();
            }
            catch (Exception ex)
            {
                if (_logger != null)
                {
                    _logger.Error(ProcessName + " failed to initialise", ex);
                }
                throw;
            }
        }
Exemplo n.º 5
0
        static void Main()
        {
            try
            {
                var container             = new Container(x => x.AddRegistry <CommonRegistry>());
                var configurationManager  = container.GetInstance <IConfigurationManager>();
                var mongoConnectionString = configurationManager.GetAppSetting <string>("ConfigurationDb");

                var mongoDbName = MongoUrl.Create(mongoConnectionString).DatabaseName;
                var database    = new MongoClient(mongoConnectionString).GetServer().GetDatabase(mongoDbName);
                var collection  = database.GetCollection("configuration");

                var json     = File.ReadAllText(@"Configs\settings.json");
                var document = BsonSerializer.Deserialize <BsonDocument>(json);

                var dateTimeUpdated = DateTime.UtcNow;
                var fileVersion     = VersionLogging.GetVersion();

                if (fileVersion == "1.0.0.0")
                {
                    // Developers use the memory cache, not Azure cache.
                    document["CacheConfiguration"]["DefaultCache"] = "MemoryCacheService";
                }

                document.InsertAt(0, new BsonElement("DateTimeUpdated", dateTimeUpdated));
                document.InsertAt(0, new BsonElement("DeploymentVersion", fileVersion));

                //Ensure there can only be one entry with this version (mostly for local)
                var query = Query.And(Query.EQ("DeploymentVersion", fileVersion), Query.NE("DateTimeUpdated", dateTimeUpdated));

                collection.Insert(document);
                collection.Remove(query);

                Console.WriteLine("Successfully deployed configuration");
                Environment.Exit(0);
            }
            catch (Exception ex)
            {
                Console.WriteLine("Failed to deploy config with exception: {0}", ex.Message);
                Environment.Exit(1);
            }
        }
Exemplo n.º 6
0
        private void Initialise()
        {
            try
            {
                VersionLogging.SetVersion();

                InitializeIoC();
            }
            catch (Exception e)
            {
                if (_logService == null)
                {
                    Trace.TraceError($"{ProcessName} failed to initialise: \"{e}\"");
                }
                else
                {
                    _logService.Error($"{ProcessName} failed to initialise");
                }

                throw;
            }
        }
Exemplo n.º 7
0
        private void Initialise()
        {
            try
            {
                ServicePointManager.DefaultConnectionLimit = 12;
                VersionLogging.SetVersion();

                InitializeIoC();
            }
            catch (Exception e)
            {
                if (_logService == null)
                {
                    Trace.TraceError("{0} failed to initialise: \"{1}\"", ProcessName, e);
                }
                else
                {
                    _logService.Error(ProcessName + " failed to initialise", e);
                }

                throw;
            }
        }