Beispiel #1
0
        public IList <Route> MapRoute(string moduleFolderName, string url, object defaults, object constraints, string[] namespaces)
        {
            if (namespaces == null || namespaces.Length == 0 || String.IsNullOrEmpty(namespaces[0]))
            {
                throw new ArgumentException("At least one namespace must be specified.");
            }

            if (String.IsNullOrEmpty(moduleFolderName))
            {
                throw new ArgumentNullException("moduleFolderName");
            }

            url = url.Trim(new[] { '/', '\\' });

            var prefixes = GetRoutePrefixes();
            var routes   = new List <Route>();

            string formattedRouteName = GetFormattedRouteName(moduleFolderName);

            int i = 0;

            foreach (var prefix in prefixes)
            {
                var routeName = string.Format(formattedRouteName, i);
                var routeUrl  = string.Format("{0}DesktopModules/{1}/API/{2}", prefix, moduleFolderName, url);
                var route     = _routes.MapRoute(routeName, routeUrl, defaults, constraints, namespaces);
                route.DataTokens["Name"] = routeName;
                routes.Add(route);
                DnnLog.Trace("Mapping route: " + routeName + " @ " + routeUrl);

                i++;
            }

            return(routes);
        }
Beispiel #2
0
        public void TryIt()
        {
            var currentDelay    = (int)Delay.TotalMilliseconds;
            int retrysRemaining = MaxRetries;

            do
            {
                try
                {
                    Action();
                    DnnLog.Trace("Action succeeded - {0}", Description);
                    return;
                }
                catch (Exception)
                {
                    if (retrysRemaining <= 0)
                    {
                        DnnLog.Warn("All retries of action failed - {0}", Description);
                        throw;
                    }

                    DnnLog.Trace("Retrying action {0} - {1}", retrysRemaining, Description);
                    SleepAction.Invoke(currentDelay);

                    const double epsilon = 0.0001;
                    if (Math.Abs(DelayMultiplier - 1) > epsilon)
                    {
                        currentDelay = (int)(currentDelay * DelayMultiplier);
                    }
                }
                retrysRemaining--;
            } while (true);
        }
Beispiel #3
0
        public static void RunSchedule(HttpRequest request)
        {
            DnnLog.MethodEntry();

            //First check if we are upgrading/installing
            if (request.Url.LocalPath.ToLower().EndsWith("install.aspx") ||
                request.Url.LocalPath.ToLower().EndsWith("upgradewizard.aspx") ||
                request.Url.LocalPath.ToLower().EndsWith("installwizard.aspx"))
            {
                return;
            }
            try
            {
                if (SchedulingProvider.SchedulerMode == SchedulerMode.REQUEST_METHOD && SchedulingProvider.ReadyForPoll)
                {
                    DnnLog.Trace("Running Schedule " + (SchedulingProvider.SchedulerMode));
                    SchedulingProvider scheduler = SchedulingProvider.Instance();
                    var requestScheduleThread    = new Thread(scheduler.ExecuteTasks);
                    requestScheduleThread.IsBackground = true;
                    requestScheduleThread.Start();
                    SchedulingProvider.ScheduleLastPolled = DateTime.Now;
                }
            }
            catch (Exception exc)
            {
                Exceptions.LogException(exc);
            }
        }
Beispiel #4
0
 public void RegisterRoutes()
 {
     using (_routes.GetWriteLock())
     {
         _routes.Clear();
         LocateServicesAndMapRoutes();
     }
     DnnLog.Trace("Registered a total of {0} routes", _routes.Count);
 }
Beispiel #5
0
        private static string InitializeApp(HttpApplication app)
        {
            DnnLog.MethodEntry();
            HttpRequest request  = app.Request;
            string      redirect = Null.NullString;

            DnnLog.Trace("Request " + request.Url.LocalPath);

            //Don't process some of the AppStart methods if we are installing
            if (!request.Url.LocalPath.ToLower().EndsWith("installwizard.aspx") &&
                !request.Url.LocalPath.ToLower().EndsWith("upgradewizard.aspx") &&
                !request.Url.LocalPath.ToLower().EndsWith("install.aspx"))
            {
                //Check whether the current App Version is the same as the DB Version
                redirect = CheckVersion(app);
                if (string.IsNullOrEmpty(redirect))
                {
                    DnnLog.Info("Application Initializing");

                    //Cache Mapped Directory(s)
                    CacheMappedDirectory();
                    //Set globals
                    Globals.IISAppName             = request.ServerVariables["APPL_MD_PATH"];
                    Globals.OperatingSystemVersion = Environment.OSVersion.Version;
                    Globals.NETFrameworkVersion    = GetNETFrameworkVersion();
                    Globals.DatabaseEngineVersion  = GetDatabaseEngineVersion();
                    //Try and Upgrade to Current Framewok
                    Upgrade.TryUpgradeNETFramework();

                    //Start Scheduler
                    StartScheduler();
                    //Log Application Start
                    LogStart();
                    //Process any messages in the EventQueue for the Application_Start event
                    EventQueueController.ProcessMessages("Application_Start");

                    ServicesRoutingManager.RegisterServiceRoutes();

                    //Set Flag so we can determine the first Page Request after Application Start
                    app.Context.Items.Add("FirstRequest", true);

                    //Log Server information
                    ServerController.UpdateServerActivity(new ServerInfo());
                    DnnLog.Info("Application Initialized");
                }
            }
            else
            {
                //NET Framework version is neeed by Upgrade
                Globals.NETFrameworkVersion = GetNETFrameworkVersion();
            }
            return(redirect);
        }
Beispiel #6
0
        /// -----------------------------------------------------------------------------
        /// <summary>
        /// StartScheduler starts the Scheduler
        /// </summary>
        /// <remarks>
        /// </remarks>
        /// <history>
        ///     [cnurse]    1/27/2005   Moved back to App_Start from Scheduling Module
        /// </history>
        /// -----------------------------------------------------------------------------
        public static void StartScheduler()
        {
            DnnLog.MethodEntry();

            //instantiate APPLICATION_START scheduled jobs
            if (SchedulingProvider.SchedulerMode == SchedulerMode.TIMER_METHOD)
            {
                DnnLog.Trace("Running Schedule " + (SchedulingProvider.SchedulerMode));
                SchedulingProvider scheduler = SchedulingProvider.Instance();
                scheduler.RunEventSchedule(EventName.APPLICATION_START);
                var newThread = new Thread(SchedulingProvider.Instance().Start);
                newThread.IsBackground = true;
                newThread.Start();
            }
        }
        void Application_Error(object sender, EventArgs e)
        {
            // Code that runs when an unhandled error occurs

            // Get the exception object.
            DnnLog.Trace("Dumping all Application Errors");
            if (HttpContext.Current != null)
            {
                foreach (Exception exc in HttpContext.Current.AllErrors)
                {
                    DnnLog.Fatal(exc);
                }
            }
            DnnLog.Trace("End Dumping all Application Errors");
        }
        private void Application_End(object Sender, EventArgs E)
        {
            DnnLog.MethodEntry();
            DnnLog.Info("Application Ending");
            Initialize.LogEnd();
            Initialize.StopScheduler();

            DnnLog.Trace("Dumping all Application Errors");
            if (HttpContext.Current != null)
            {
                foreach (Exception exc in HttpContext.Current.AllErrors)
                {
                    DnnLog.Fatal(exc);
                }
            }
            DnnLog.Trace("End Dumping all Application Errors");
            DnnLog.Info("Application Ended");
        }
 internal void ItemRemovedCallback(string key, object value, CacheItemRemovedReason removedReason)
 {
     try
     {
         if (Globals.Status == Globals.UpgradeStatus.None)
         {
             // track data removed from cache to synchonize UrlRule cache
             string[] CacheKeys = UrlRuleConfiguration.GetCacheKeys();
             if (CacheKeys != null)
             {
                 foreach (string CacheKey in CacheKeys)
                 {
                     if (key.Contains(CacheKey))
                     {
                         if (DotNetNuke.Entities.Portals.PortalSettings.Current != null)
                         {
                             int PortalId = DotNetNuke.Entities.Portals.PortalSettings.Current.PortalId;
                             Remove(GetCacheKey("UrlRuleConfig" + PortalId));
                             DnnLog.Trace("Clear cache " + key + " portal " + PortalId + " raison " + removedReason.ToString());
                         }
                         else
                         {
                             // DnnLog.Trace("Clear cache not executed " + key + " raison " + removedReason.ToString());
                         }
                     }
                 }
             }
             if (key.StartsWith("UrlRuleConfig"))
             {
                 DnnLog.Trace("cache " + key + "claired : " + removedReason.ToString());
             }
         }
     }
     catch (Exception exc)
     {
         //Swallow exception
         DnnLog.Error(exc);
     }
 }