Ejemplo n.º 1
0
        public void TestsSetup()
        {
            //SnapshotInitialisation.ForceRestore();
            using (FullInputContext _context = new FullInputContext(""))
            {
                dnaDiagnostics = _context.dnaDiagnostics;
                readerCreator = new DnaDataReaderCreator(_context.DnaConfig.ConnectionString, dnaDiagnostics);
            }
            var bannedEmails = new BannedEmails(readerCreator, dnaDiagnostics, _emailCache, null, null);

            bannedEmails.Clear();
        }
Ejemplo n.º 2
0
        protected void Application_Start(object sender, EventArgs e)
        {
            //System.Diagnostics.Debugger.Launch();
            if (ConfigurationManager.AppSettings["MaintenanceMode"] == "1")
            {//do nothing if in maintenance
                return;
            }

            Statistics.InitialiseIfEmpty(null, false);
            dnaDiagnostics = new DnaDiagnostics(RequestIdGenerator.GetNextRequestId(), DateTime.Now);
            connectionString = ConfigurationManager.ConnectionStrings["Database"].ConnectionString;
            readerCreator = new DnaDataReaderCreator(connectionString, dnaDiagnostics);

            try
            {
                emailServerAddress = ConfigurationManager.AppSettings["EmailServer"];
            }
            catch
            {
                dnaDiagnostics.WriteWarningToLog("BBC.Dna.Services.Application_Start", "Unable to find config email server address - no emails will be sent!");
            }

            try
            {
                fileCacheFolder = ConfigurationManager.AppSettings["FileCacheFolder"];
            }
            catch
            {
                fileCacheFolder = Environment.GetEnvironmentVariable("Temp");
                dnaDiagnostics.WriteWarningToLog("BBC.Dna.Services.Application_Start", "Unable to find config file cache folder - Defaulting to the system temp folder!");
            }

            ICacheManager cacheManager = null;
            try
            {
                cacheManager = CacheFactory.GetCacheManager("Memcached");
            }
            catch (Exception error)
            {
                dnaDiagnostics.WriteWarningToLog("BBC.Dna.Services.Application_Start", "Unable to use memcached cachemanager - falling back to static inmemory");
                dnaDiagnostics.WriteExceptionToLog(error);
                cacheManager = new StaticCacheManager();
            }


            siteList = new SiteList(readerCreator, dnaDiagnostics, cacheManager, null, null);//no sending signals from here
            var bannedEmails = new BannedEmails(readerCreator, dnaDiagnostics, cacheManager, null, null);//no sending signals from here
            var userGroups = new UserGroups(readerCreator, dnaDiagnostics, cacheManager, null, null);//no sending signals from here
            var profanityFilter = new ProfanityFilter(readerCreator, dnaDiagnostics, cacheManager, null, null);//no sending signals from here
            var moderationClasses = new ModerationClassListCache(readerCreator, dnaDiagnostics, cacheManager, null, null);//no sending signals from here
            BBC.Dna.Objects.SmileyTranslator.LoadSmileys(readerCreator);
        }
Ejemplo n.º 3
0
		/// <summary>
		/// Creates an AppContext, given the root path of the app, where it can find config info
		/// </summary>
		/// <param name="rootPath">Path where app lives</param>
		public AppContext(string rootPath)
		{
			_dnaConfig = new DnaConfig(rootPath);
			//_dnaConfig.Initialise();
			_dnaAppDiagnostics = new DnaDiagnostics(-1, DateTime.Now);

			if (WebConfigurationManager.AppSettings["maxrequests"] != null)
			{
				_maximumRequestCount = Convert.ToInt32(WebConfigurationManager.AppSettings["maxrequests"]);
			}
            ReaderCreator = new DnaDataReaderCreator(_dnaConfig.ConnectionString, _dnaAppDiagnostics);
		}
Ejemplo n.º 4
0
        /// <summary>
        /// Initialises all the required objects needed for the current request 
        /// </summary>
        private void InitialiseRequest()
        {
            // Increment the request Id
			_requestId = RequestIdGenerator.GetNextRequestId();

            // Create a diagnostics object for this request
            _dnaInputDiagnostics = new DnaDiagnostics(_requestId, _dnapage.Timestamp);
            Diagnostics.WriteRequestToLog(Request);

            // Make sure that the site list exists
            if (1 == GetParamIntOrZero("_ns", "Force the framework to recache the static site list. Admin use only."))
            {
                TheSiteList.ReInitialise();
                EnsureAllowedURLsExists(true, this);
            }
           

            bool clearTemplates = (Request.Params["clear_templates"] != null);
#if DEBUG
            if (!clearTemplates)
            {
                string ripleyClearTemplates = Environment.GetEnvironmentVariable("RipleyClearTemplates");
                clearTemplates = (ripleyClearTemplates != null && ripleyClearTemplates.Equals("1"));
            }
#endif
            // Check to see if we've been told to recache the templates
            if (clearTemplates)
            {
                // Call the clear templates function
                ClearTemplates();
            }
            

            // Check to see if we've been told to recache the user groups
            if (Request.Params["_gc"] != null)
            {
                UserGroups.GetObject().ReInitialise();
            }

            // Set the pagedomain
            pageDomain = "uk";
            if (Request.DoesParamExist("hostsource", "Check the calling hostsource param"))
            {
                if (Request.GetParamStringOrEmpty("hostsource", "Check the calling hostsource param").ToLower() == "com")
                {
                    pageDomain = "com";
                }
            }

            _debugUserID = "";
#if DEBUG
            // Check to see if we're wanting to use the debug user or not
            if (Request.Params["d_identityuserid"] != null)
            {
                SetDebugUserCookie(Request.Params["d_identityuserid"]);
            }
            else if (Request.Params["d_clearidentityuserid"] != null)
            {
                ClearDebugUserCookie();
            }
            else if (GetCookie("DNADEBUGUSER") != null)
            {
                DnaCookie debuguser = GetCookie("DNADEBUGUSER");
                if (debuguser != null && debuguser.Value.Length > 0)
                {
                    _debugUserID = debuguser.Value.Substring(3);
                }
            }

            if (Request.Params["d_skinfile"] != null)
            {
                DebugSkinFile = Request.Params["d_skinfile"];
            }
#endif
            // Needs setting up before code that relies on current site is executed
            SetCurrentSiteName();

            // Create the transformer for this request
            CreateTransformer();
        }