/// <summary>
    /// Rewrites the URL and performs all operations required after URL rewriting.
    /// </summary>
    /// <param name="status">Current rewriting status</param>
    /// <param name="relativePath">Relative path</param>
    /// <param name="excludedEnum">Excluded page status</param>
    /// <param name="viewMode">View mode</param>
    /// <param name="siteName">Site name</param>
    private static void RewriteUrl(URLRewritingResultEnum status, string relativePath, ExcludedSystemEnum excludedEnum, ViewModeOnDemand viewMode, SiteNameOnDemand siteName)
    {
        // Do the rewriting if status not yet determined
        if (status == URLRewritingResultEnum.Unknown)
        {
            RequestHelper.LogRequestOperation("RewriteURL", relativePath, 0);

            // Rewrite URL
            status = URLRewriter.RewriteUrl(relativePath, excludedEnum, siteName, viewMode);
        }

        // Process actions after rewriting
        URLRewriter.ProcessRewritingResult(status, excludedEnum, siteName, viewMode, relativePath);
    }
Example #2
0
    /// <summary>
    /// Attempts to run the scheduler request.
    /// </summary>
    /// <param name="status">Current status</param>
    private static void RunScheduler(URLRewritingResultEnum status)
    {
        // Scheduler is disabled
        if (!SchedulingHelper.EnableScheduler)
        {
            return;
        }

        // Ensure the rewriting status
        if (status == URLRewritingResultEnum.Unknown)
        {
            status = URLRewriter.CurrentStatus;
        }

        // Process scheduler only on content or system pages
        switch (status)
        {
            case URLRewritingResultEnum.PathRewritten:
            case URLRewritingResultEnum.MVCPage:
            case URLRewritingResultEnum.SystemPage:
            case URLRewritingResultEnum.SentFromCache:
                // Run scheduler - Do not run on first request to provide faster application start
                {
                    string siteName = SchedulingTimer.SchedulerRunImmediatelySiteName;
                    if (siteName != "")
                    {
                        if (SchedulingHelper.UseAutomaticScheduler)
                        {
                            // Ensure the active timer running in an asynchronous thread
                            SchedulingTimer timer = SchedulingTimer.EnsureTimer(siteName, true);
                            if (SchedulingTimer.RunSchedulerImmediately)
                            {
                                timer.ExecuteAsync();
                            }
                        }
                        else
                        {
                            // --- Default scheduler settings
                            // If scheduler run request acquired, run the actions
                            bool runScheduler = SchedulingTimer.RequestRun(siteName) || SchedulingTimer.RunSchedulerImmediately;
                            if (runScheduler)
                            {
                                if (SchedulingHelper.RunSchedulerWithinRequest)
                                {
                                    // --- Default scheduler settings
                                    try
                                    {
                                        try
                                        {
                                            // Flush the output
                                            HttpContext.Current.Response.Flush();
                                        }
                                        // Do not display closed host exception
                                        catch
                                        {
                                        }

                                        // Run scheduler actively within the request
                                        SchedulingExecutor.ExecuteScheduledTasks(siteName, WebSyncHelperClass.ServerName);
                                    }
                                    catch (Exception ex)
                                    {
                                        EventLogProvider.LogException("Scheduler", "ExecuteScheduledTasks", ex);
                                    }
                                }
                                else
                                {
                                    // Get passive timer and execute
                                    SchedulingTimer timer = SchedulingTimer.EnsureTimer(siteName, false);
                                    timer.ExecuteAsync();
                                }
                            }
                        }
                    }
                }
                break;
        }
    }