Example #1
0
    /// <summary>
    /// Load collection of steps
    /// </summary>
    /// <returns>Returns false if steps weren't loaded</returns>
    private bool LoadSteps()
    {
        // Set default values to the data control
        dataProperties.Path       = Path;
        dataProperties.ClassNames = ClassNames;

        dataProperties.OrderBy        = OrderBy;
        dataProperties.WhereCondition = WhereCondition;

        dataProperties.CultureCode = CultureCode;
        dataProperties.CombineWithDefaultCulture = CombineWithDefaultCulture;

        dataProperties.SelectedColumns     = Columns;
        dataProperties.MaxRelativeLevel    = 1;
        dataProperties.SelectTopN          = SelectTopN;
        dataProperties.FilterOutDuplicates = FilterOutDuplicates;
        dataProperties.SelectOnlyPublished = SelectOnlyPublished;

        dataProperties.CheckPermissions = CheckPermissions;

        dataProperties.CacheMinutes      = CacheMinutes;
        dataProperties.CacheItemName     = CacheItemName;
        dataProperties.CacheDependencies = CacheDependencies;

        // Resolve path
        string path        = ContextResolver.ResolvePath(Path, true);
        string currentPath = DocumentContext.OriginalAliasPath;

        // Do not process if is out of context
        if (!currentPath.StartsWith(path.TrimEnd('%'), StringComparison.InvariantCultureIgnoreCase))
        {
            StopProcessing = true;
            return(false);
        }

        // Keep site name for better performance
        string siteName = SiteContext.CurrentSiteName;

        TreeProvider tp   = new TreeProvider();
        object       data = null;

        // Load data
        dataProperties.LoadData(ref data, false);

        // Create collection of steps
        if (!DataHelper.DataSourceIsEmpty(data))
        {
            int      index = 0;
            DataView ds    = data as DataView;

            foreach (DataRowView dr in ds)
            {
                DocumentWizardStep step = new DocumentWizardStep();
                step.StepIndex = index;
                step.StepData  = dr;

                if (FirstStep == null)
                {
                    FirstStep = step;
                }

                if ((CurrentStep == null) && string.Equals(currentPath, Convert.ToString(dr["NodeAliasPath"]), StringComparison.InvariantCultureIgnoreCase))
                {
                    CurrentStep = step;
                }

                Steps.Add(step);
                LastStep = step;

                index++;
            }
        }

        // Do not process if is out of context
        if (CurrentStep == null)
        {
            StopProcessing = true;
            return(false);
        }

        // validate current step index
        if (PortalContext.ViewMode == ViewModeEnum.LiveSite)
        {
            if (RestrictStepOrder)
            {
                // For not existing confirmed step current step must be first step
                if ((LastConfirmedStepIndex == -1) && (CurrentStep.StepIndex > 0))
                {
                    string url = FirstStep.StepUrl;
                    URLHelper.Redirect(UrlResolver.ResolveUrl(url));
                }
                // Current step index cannot be higher than last confirmed step index + 1
                else if ((CurrentStep.StepIndex - 1) > LastConfirmedStepIndex)
                {
                    string url = Steps[LastConfirmedStepIndex].StepUrl;
                    URLHelper.Redirect(UrlResolver.ResolveUrl(url));
                }
            }
        }

        return(true);
    }