/// <summary>
    /// This function is where the page gets to create and insert all the objects required
    /// </summary>
    public override void OnPageLoad()
    {
        Context.Items["VirtualUrl"] = "UserStatistics";

        if (!IsDnaUserAllowed())
        {
            ShowHideControls(false);
            lblError.Text = "Insufficient permissions - Editor Status Required";
            return;
        }
        if (!Page.IsPostBack)
        {
            int userId = Request.GetParamIntOrZero("userid", "UserId");

            if (userId != 0)
            {
                txtEntry.Text = userId.ToString();
            }

            int passedInShow = Request.GetParamIntOrZero("show", "show");
            if (passedInShow == 0)
            {
                _show = _basePage.GetSiteOptionValueInt("ArticleSearch", "DefaultShow");
            }
            else if (passedInShow > 200)
            {
                _show = 200;
            }
            else
            {
                _show = passedInShow;
            }

            int passedInSkip = Request.GetParamIntOrZero("skip", "skip");
            _skip = passedInSkip;

            DateTime enteredStartDate = DateTime.MinValue;
            DateTime enteredEndDate = DateTime.MinValue;

            try
            {
                if (Request.DoesParamExist("startDate", _docDnaStartDate))
                {
                    string startDateText = Request.GetParamStringOrEmpty("startDate", _docDnaStartDate);
                    string endDateText = Request.GetParamStringOrEmpty("endDate", _docDnaEndDate);

                    DateRangeValidation dateValidation = new DateRangeValidation();
                    DateRangeValidation.ValidationResult isValid;

                    DateTime tempStartDate;
                    DateTime tempEndDate;

                    isValid = UserStatistics.ParseDateParams(startDateText, endDateText, out tempStartDate, out tempEndDate);
                    isValid = dateValidation.ValidateDateRange(tempStartDate, tempEndDate, 0, false, false);

                    if (isValid == DateRangeValidation.ValidationResult.VALID)
                    {
                        enteredStartDate = dateValidation.LastStartDate;
                        enteredEndDate = dateValidation.LastEndDate;
                    }
                    else
                    {
                        lblError.Text = "Passed in Date not valid.";
                        return;
                    }
                }
                else
                {
                    enteredStartDate = DateTime.Now.AddMonths(-1);
                    if (!Request.DoesParamExist("endDate", _docDnaEndDate))
                    {
                        enteredEndDate = DateTime.Now;
                    }
                }

                if (enteredStartDate > enteredEndDate)
                {
                    enteredStartDate = enteredEndDate.AddMonths(-1);
                }

                TimeSpan timeSpan = enteredEndDate - enteredStartDate;

                if (timeSpan.Days > 180)
                {
                    enteredStartDate = enteredEndDate.AddDays(-180);
                }

                startDate.SelectedDate = enteredStartDate.Date;
                startDate.VisibleDate = enteredStartDate.Date;
                endDate.SelectedDate = enteredEndDate.Date;
                endDate.VisibleDate = enteredEndDate.Date;
            }
            catch (FormatException)
            {
                lblError.Text = "Passed in Date format incorrect. It should be dd/mm/yyyy";
                return;
            }

            if (userId != 0)
            {
                txtEntry.Text = userId.ToString();
            }

            string skin = Request.GetParamStringOrEmpty("skin", "skin");
            string skParam = Request.GetParamStringOrEmpty("_sk", "skin");
            if (skin == "purexml" || skParam == "purexml")
            {
                GetUserStatistics(true);
            }
            else
            {
                GetUserStatistics(false);
                ShowHideControls(true);
            }
        }
        else
        {
            ShowHideResultControls(false);
        }

    }
Esempio n. 2
0
        /// <summary>
        /// Gets the params for the page
        /// </summary>
        /// <param name="entryDate">Entry Date</param>
        /// <param name="emailFrom">Email from entry</param>
        /// <param name="emailTo">Email to entry</param>
        private void TryGetPageParams(ref DateTime entryDate, ref string emailFrom, ref string emailTo)
        {
            if (InputContext.DoesParamExist("date", _docDnaEntryDate))
            {
                string entryDateText = InputContext.GetParamStringOrEmpty("date", _docDnaEntryDate);

                DateRangeValidation dateValidation = new DateRangeValidation();
                DateRangeValidation.ValidationResult isValid;

                DateTime tempEntryDate;

                isValid = ParseDate(entryDateText, out tempEntryDate);
                if (isValid == DateRangeValidation.ValidationResult.VALID)
                {
                    isValid = dateValidation.ValidateDate(tempEntryDate, false);
                }
                else
                {
                    AddErrorXml("invalidparameters", "Illegal date entry (" + isValid.ToString() + ")", null);
                    return;
                }

                if (isValid == DateRangeValidation.ValidationResult.VALID)
                {
                    entryDate = dateValidation.LastStartDate;
                }
                else
                {
                    AddErrorXml("invalidparameters", "Illegal date parameters (" + isValid.ToString() + ")", null);
                    return;
                }
            }
            else
            {
                entryDate = DateTime.Now.AddDays(-1).Date;
            }
            if (InputContext.DoesParamExist("emailFrom", _docDnaEmailFrom) && InputContext.DoesParamExist("emailTo", _docDnaEmailTo))
            {
                emailFrom = InputContext.GetParamStringOrEmpty("emailFrom", _docDnaEmailFrom);
                emailTo = InputContext.GetParamStringOrEmpty("emailTo", _docDnaEmailTo);
            }
        }
Esempio n. 3
0
        /// <summary>
        /// Gets the params for the page
        /// </summary>
        /// <param name="skip">number of postings to skip</param>
        /// <param name="show">number to show</param>
        /// <param name="entryDate">Entry Date of search</param>
        /// <param name="interval">Interval of search</param>
        private void TryGetPageParams(ref int skip, ref int show, ref DateTime entryDate, ref int interval)
        {
            skip = InputContext.GetParamIntOrZero("skip", _docDnaSkip);
            show = InputContext.GetParamIntOrZero("show", _docDnaShow);

            if (show > 200)
            {
                show = 200;
            }
            else if (show < 1)
            {
                show = 25;
            }
            if (skip < 0)
            {
                skip = 0;
            }

            //find out which display mode is requested
            interval = 1;
            string intervalText = InputContext.GetParamStringOrEmpty("interval", _docDnaInterval);
            if (intervalText == "week")
            {
                interval = 2;
            }
            else if (intervalText == "month")
            {
                interval = 3;
            }
            if (InputContext.DoesParamExist("date", _docDnaEntryDate))
            {
                string entryDateText = InputContext.GetParamStringOrEmpty("date", _docDnaEntryDate);

                DateRangeValidation dateValidation = new DateRangeValidation();
                DateRangeValidation.ValidationResult isValid;

                DateTime tempEntryDate;

                isValid = ParseDate(entryDateText, out tempEntryDate);
                if (isValid == DateRangeValidation.ValidationResult.VALID)
                {
                    isValid = dateValidation.ValidateDate(tempEntryDate, false);
                }
                else
                {
                    AddErrorXml("invalidparameters", "Illegal date entry (" + isValid.ToString() + ")", null);
                    return;
                }

                if (isValid == DateRangeValidation.ValidationResult.VALID)
                {
                    entryDate = dateValidation.LastStartDate;
                }
                else
                {
                    AddErrorXml("invalidparameters", "Illegal date parameters (" + isValid.ToString() + ")", null);
                    return;
                }
            }
            else
            {
                entryDate = DateTime.Now;
            }

        }
    /// <summary>
    /// This function is where the page gets to create and insert all the objects required
    /// </summary>
    public override void OnPageLoad()
    {
        Context.Items["VirtualUrl"] = "MessageBoardStats";
        string skin = Request.GetParamStringOrEmpty("skin", "skin");

        if (!IsDnaUserAllowed())
        {
            if (skin != "purexml")
            {
                ShowHideControls(false);
                lblError.Text = "Insufficient permissions - Editor Status Required";
            }
            else
            {
                XmlDocument errorDoc = new XmlDocument();
                errorDoc.LoadXml("<ERROR TYPE='invalidcredentials' ERRORMESSAGE = 'Must be an editor or superuser to view messageboard statistics' />");

                //Replace an existing node
                if (_basePage.WholePageBaseXmlNode.SelectSingleNode("/MESSAGEBOARDSTATS") != null)
                {
                    XmlNode messageBoardStatisticsNode = _basePage.WholePageBaseXmlNode.SelectSingleNode("/MESSAGEBOARDSTATS");

                    _basePage.WholePageBaseXmlNode.ReplaceChild(messageBoardStatisticsNode, _basePage.WholePageBaseXmlNode.OwnerDocument.ImportNode(errorDoc.FirstChild, true));
                }
                else
                {
                    _basePage.WholePageBaseXmlNode.FirstChild.AppendChild(_basePage.WholePageBaseXmlNode.OwnerDocument.ImportNode(errorDoc.FirstChild, true));
                }
            }
            return;
        }
        if (!Page.IsPostBack)
        {
            DateTime enteredDate = DateTime.MinValue;

            try
            {
                if (Request.DoesParamExist("date", _docDnaDate))
                {
                    string entryDateText = Request.GetParamStringOrEmpty("date", _docDnaDate);

                    DateRangeValidation dateValidation = new DateRangeValidation();
                    DateRangeValidation.ValidationResult isValid;

                    DateTime tempDate;

                    isValid = MessageBoardStatistics.ParseDate(entryDateText, out tempDate);
                    if (isValid == DateRangeValidation.ValidationResult.VALID)
                    {
                        isValid = dateValidation.ValidateDate(tempDate, true);

                        if (isValid == DateRangeValidation.ValidationResult.FUTURE_STARTDATE)
                        {
                            lblError.Text = "Passed in Date is in the future.";
                            return;
                        }
                        else if (isValid != DateRangeValidation.ValidationResult.VALID)
                        {
                            lblError.Text = "Passed in Date not valid.";
                            return;
                        }
                        enteredDate = tempDate;
                    }
                    else
                    {
                        lblError.Text = "Passed in Date not valid.";
                        return;
                    }
                }
                else
                {
                    //Yesterday
                    enteredDate = DateTime.Now.AddDays(-1).Date;
                }

                entryDate.SelectedDate = enteredDate.Date;
                entryDate.VisibleDate = enteredDate.Date;
            }
            catch (FormatException)
            {
                lblError.Text = "Passed in Date format incorrect. It should be dd/mm/yyyy";
                return;
            }

            if (skin != "purexml")
            {
                GetMessageBoardStatistics(false);

                ShowHideControls(true);
            }
            else
            {
                GetMessageBoardStatistics(true);
            }

            string emailFrom = Request.GetParamStringOrEmpty("emailFrom", "emailFrom address");
            string emailTo = Request.GetParamStringOrEmpty("emailTo", "emailTo address");

            MessageBoardStatistics messageBoardStatistics = new MessageBoardStatistics(_basePage);
            messageBoardStatistics.SendMessageBoardStatsEmail(enteredDate, emailFrom, emailTo);
        }
        else
        {
            ShowHideResultControls(false);
        }

    }
Esempio n. 5
0
        /// <summary>
        /// Gets the params for the page
        /// </summary>
        /// <param name="asp">Class containing all the search parameters.</param>
        private bool TryGetPageParams(ref ArticleSearchParams asp)
        {
            int startDay = 0;
            int startMonth = 0;
            int startYear = 0;
            int endDay = 0;
            int endMonth = 0;
            int endYear = 0;

            string startDateText = String.Empty;
            string endDateText = String.Empty;

            //siteID = InputContext.GetParamIntOrZero("siteid", _docDnaSiteID);
            asp.SiteID = InputContext.CurrentSite.SiteID;

            int defaultShow = InputContext.GetSiteOptionValueInt("ArticleSearch", "DefaultShow");

            asp.Skip = InputContext.GetParamIntOrZero("skip", _docDnaSkip);
            asp.Show = InputContext.GetParamIntOrZero("show", _docDnaShow);
            if (asp.Show > 200)
            {
                asp.Show = 200;
            }
            else if (asp.Show < 1)
            {
                asp.Show = defaultShow;
            }

            asp.SkipPhrases = InputContext.GetParamIntOrZero("skipphrases", _docDnaSkipPhrases);
            asp.ShowPhrases = InputContext.GetParamIntOrZero("showphrases", _docDnaShowPhrases);
            if (asp.ShowPhrases > 200)
            {
                asp.ShowPhrases = 200;
            }
            else if (asp.ShowPhrases < 1)
            {
                asp.ShowPhrases = defaultShow;
            }
            if (asp.SkipPhrases < 1)
            {
                asp.SkipPhrases = 0;
            }

            asp.ContentType = InputContext.GetParamIntOrZero("contenttype", _docDnaContentType);
            asp.SortBy = InputContext.GetParamStringOrEmpty("articlesortby", _docDnaArticleSortBy);
            asp.DateSearchType = InputContext.GetParamIntOrZero("datesearchtype", _docDnaDateSearchType);

            asp.TimeInterval = InputContext.GetParamIntOrZero("timeinterval", _docDnaTimeInterval);

            startDay = InputContext.GetParamIntOrZero("startDay", _docDnaStartDay);
            startMonth = InputContext.GetParamIntOrZero("startMonth", _docDnaStartMonth);
            startYear = InputContext.GetParamIntOrZero("startYear", _docDnaStartYear);

            endDay = InputContext.GetParamIntOrZero("endDay", _docDnaEndDay);
            endMonth = InputContext.GetParamIntOrZero("endMonth", _docDnaEndMonth);
            endYear = InputContext.GetParamIntOrZero("endYear", _docDnaEndYear);

            startDateText = InputContext.GetParamStringOrEmpty("startDate", _docDnaStartDate);
            endDateText = InputContext.GetParamStringOrEmpty("endDate", _docDnaEndDate);

            asp.ArticleStatus = InputContext.GetParamIntOrZero("articlestatus", _docDnaArticleStatus);
            asp.ArticleType = InputContext.GetParamIntOrZero("articletype", _docDnaArticleType);

            int descendingOrderNum = InputContext.GetParamIntOrZero("descendingorder", _docDnaDescendingOrder);
            if (descendingOrderNum == 1)
            {
                asp.DescendingOrder = true;
            }
            else
            {
                asp.DescendingOrder = false;
            }

            DateTime startDate;
            DateTime endDate;

            if (asp.DateSearchType != 0)
            {
                DateRangeValidation dateValidation = new DateRangeValidation();
                DateRangeValidation.ValidationResult isValid;
                if (startDay == 0 && endDay == 0)
                {
                    isValid = ParseDateParams(startDateText, endDateText, out startDate, out endDate);
                }
                else
                {
                    isValid = ParseDateParams(startYear, startMonth, startDay, endYear, endMonth, endDay, out startDate, out endDate);
                }

                isValid = dateValidation.ValidateDateRange(startDate, endDate, asp.TimeInterval, false, false);

                if (isValid == DateRangeValidation.ValidationResult.VALID)
                {
                    asp.StartDate = dateValidation.LastStartDate;
                    asp.EndDate = dateValidation.LastEndDate;
                }
                else
                {
                    return AddErrorXml("invalidparameters", "Illegal date parameters (" + isValid.ToString() + ")", null);
                }
            }

            //Get Search phrases.
            if (InputContext.DoesParamExist("phrase", _docDnaPhrase))
            {
                asp.SearchPhraseList.Clear();

                string rawPhrases = String.Empty;
                for (int i = 0; i < InputContext.GetParamCountOrZero("phrase", _docDnaPhrase); i++)
                {
                    string phrase = InputContext.GetParamStringOrEmpty("phrase", i, _docDnaPhrase);
                    if (phrase.Contains(_token))
                    {
                        DnaStringParser paramParser = new DnaStringParser(phrase, _token.ToCharArray(), false, false, false);
                        ArrayList paramPhraseList = paramParser.ParseToArrayList();
                        foreach (string paramPhrase in paramPhraseList)
                        {
                            rawPhrases = rawPhrases + paramPhrase + "|";
                        }
                    }
                    else
                    {
                        rawPhrases = rawPhrases + phrase + "|";
                    }
                }

                string rawNameSpaces = String.Empty;
                for (int i = 0; i < InputContext.GetParamCountOrZero("namespace", _docDnaNameSpace); i++)
                {
                    string nameSpace = InputContext.GetParamStringOrEmpty("namespace", i, _docDnaNameSpace);
                    if (nameSpace.Contains(_token))
                    {
                        DnaStringParser paramParser = new DnaStringParser(nameSpace, _token.ToCharArray(), false, false, false);
                        ArrayList paramNameList = paramParser.ParseToArrayList();
                        foreach (string paramNameSpace in paramNameList)
                        {
                            rawNameSpaces = rawNameSpaces + paramNameSpace + "|";
                        }
                    }
                    else
                    {
                        rawNameSpaces = rawNameSpaces + nameSpace + "|";
                    }
                }

                char[] charsToTrim = new char[] { '|' };

                string parsedPhrases = String.Empty;
                //Now feed it into the DnaString Parser
                DnaStringParser phrasesParser = new DnaStringParser(rawPhrases, charsToTrim, true, true, false);
                parsedPhrases = phrasesParser.GetParsedString('|');
                ArrayList searchPhraseList = phrasesParser.ParseToArrayList();

                string parsedNameSpaces = String.Empty;
                //Now feed it into the DnaString Parser
                DnaStringParser nameSpaceParser = new DnaStringParser(rawNameSpaces, charsToTrim, true, true, false);
                parsedNameSpaces = nameSpaceParser.GetParsedString('|');
                ArrayList searchNameSpaceList = nameSpaceParser.ParseToArrayList();

                int phraseNumber = 0;
                foreach (string phraseText in searchPhraseList)
                {
                    Phrase phrase = new Phrase();
                    phrase.PhraseName = phraseText;
                    try
                    {
                        phrase.NameSpace = searchNameSpaceList[phraseNumber].ToString();
                    }
                    catch (ArgumentOutOfRangeException)
                    {
                        phrase.NameSpace = "";
                    }

                    asp.SearchPhraseList.Add(phrase);
                    phraseNumber++;
                }

                asp.Phrases = parsedPhrases.TrimEnd(charsToTrim);
                asp.NameSpaces = parsedNameSpaces.TrimEnd(charsToTrim);
            }

            //Get (Postcode or Placename or Latitude and Longitude) and Range for Search if they are there.
            if (InputContext.DoesParamExist("postcode", _docDnaPostcode) ||
                InputContext.DoesParamExist("placename", _docDnaPlacename) ||
                (InputContext.DoesParamExist("latitude", _docDnaLatitude) &&
                InputContext.DoesParamExist("longitude", _docDnaLongitude)) &&
                InputContext.DoesParamExist("range", _docDnaRange))
            {
                asp.Range = InputContext.GetParamDoubleOrZero("range", _docDnaRange);

                asp.LocationSearchType = InputContext.GetParamStringOrEmpty("locationsearchtype", _docDnaLocationSearchType);
                asp.PostCode = InputContext.GetParamStringOrEmpty("postcode", _docDnaPostcode);
                asp.Placename = InputContext.GetParamStringOrEmpty("placename", _docDnaPlacename);

                double latitude = InputContext.GetParamDoubleOrZero("latitude", _docDnaLatitude); 
                double longitude = InputContext.GetParamDoubleOrZero("longitude", _docDnaLongitude);
                if (asp.LocationSearchType == "postcode")
                {
                    GetLatLongFromPostCode(asp.PostCode, ref latitude, ref longitude);
                }
                else if (asp.LocationSearchType == "placename")
                {
                    GetLatLongFromPlacename(asp.Placename, ref latitude, ref longitude);
                }
                asp.Latitude = latitude;
                asp.Longitude = longitude;
            }

            //Get free text search condition for Search if it is there.
            if (InputContext.DoesParamExist("freetextsearch", _docDnaFreeTextSearchCondition))
            {
                asp.FreeTextSearchCondition = InputContext.GetParamStringOrEmpty("freetextsearch", _docDnaFreeTextSearchCondition);
            }

            return true;
        }
Esempio n. 6
0
        /// <summary>
        /// Gets the params for the page
        /// </summary>
        /// <param name="userID">The user of the statistics to get</param>
        /// <param name="skip">number of posts to skip</param>
        /// <param name="show">number to show</param>
        /// <param name="mode">Way the records are returned by dateposted or by forum</param>
        /// <param name="startDate">Start Date</param>
        /// <param name="endDate">End Date</param>
        private void TryGetPageParams(ref int userID, ref int skip, ref int show, ref int mode, ref DateTime startDate, ref DateTime endDate)
        {
            userID = InputContext.GetParamIntOrZero("userid", _docDnaUserID);
            skip = InputContext.GetParamIntOrZero("skip", _docDnaSkip);
            show = InputContext.GetParamIntOrZero("show", _docDnaShow);

            if (show > 200)
            {
                show = 200;
            }
            else if (show < 1)
            {
                show = 25;
            }
            if (skip < 0)
            {
                skip = 0;
            }

            //find out which display mode is requested
            mode = 1;
            string modeText = InputContext.GetParamStringOrEmpty("mode", _docDnaMode);
            if (modeText == "byforum")
            {
                mode = 0;
            }

            if (InputContext.DoesParamExist("startDate", _docDnaStartDate))
            {
                string startDateText = InputContext.GetParamStringOrEmpty("startDate", _docDnaStartDate);
                string endDateText = InputContext.GetParamStringOrEmpty("endDate", _docDnaEndDate);

                DateRangeValidation dateValidation = new DateRangeValidation();
                DateRangeValidation.ValidationResult isValid;

                DateTime tempStartDate;
                DateTime tempEndDate;

                isValid = ParseDateParams(startDateText, endDateText, out tempStartDate, out tempEndDate);
                isValid = dateValidation.ValidateDateRange(tempStartDate, tempEndDate, 0, false, false);

                if (isValid == DateRangeValidation.ValidationResult.VALID)
                {
                    startDate = dateValidation.LastStartDate;
                    endDate = dateValidation.LastEndDate;
                }
                else
                {
                    AddErrorXml("invalidparameters", "Illegal date parameters (" + isValid.ToString() + ")", null);
                    return;
                }
            }
            else
            {
                startDate = DateTime.Now.AddMonths(-1);
                if (!InputContext.DoesParamExist("endDate", _docDnaEndDate))
                {
                    endDate = DateTime.Now;
                }
            }

            if (startDate > endDate)
            {
                startDate = endDate.AddMonths(-1);
            }

            TimeSpan timeSpan = endDate - startDate;

            if (timeSpan.Days > 180)
            {
                startDate = endDate.AddDays(-180);
            }

        }
    /// <summary>
    /// This function is where the page gets to create and insert all the objects required
    /// </summary>
    public override void OnPageLoad()
    {
        Context.Items["VirtualUrl"] = "StatisticsReport";
        string skin = Request.GetParamStringOrEmpty("skin", "skin");
        string skParam = Request.GetParamStringOrEmpty("_sk", "skin");

        if (!IsDnaUserAllowed())
        {
            ShowHideControls(false);
            DisplayError("PermissionsError", "Insufficient permissions - Editor Status Required");
            return;
        }
        if (!Page.IsPostBack)
        {
            int passedInShow = Request.GetParamIntOrZero("show", "show");
            if (passedInShow == 0)
            {
                _show = _basePage.GetSiteOptionValueInt("ArticleSearch", "DefaultShow");
            }
            else if (passedInShow > 200)
            {
                _show = 200;
            }
            else
            {
                _show = passedInShow;
            }

            int passedInSkip = Request.GetParamIntOrZero("skip", "skip");
            _skip = passedInSkip;

            DateTime enteredDate = DateTime.MinValue;

            try
            {
                if (Request.DoesParamExist("date", _docDnaDate))
                {
                    string entryDateText = Request.GetParamStringOrEmpty("date", _docDnaDate);

                    DateRangeValidation dateValidation = new DateRangeValidation();
                    DateRangeValidation.ValidationResult isValid;

                    DateTime tempDate;

                    isValid = StatisticsReport.ParseDate(entryDateText, out tempDate);
                    if (isValid == DateRangeValidation.ValidationResult.VALID)
                    {
                        isValid = dateValidation.ValidateDate(tempDate, true);

                        if (isValid == DateRangeValidation.ValidationResult.FUTURE_STARTDATE)
                        {
                            DisplayError("DateError", "Passed in Date is in the future.");
                            return;
                        }
                        else if (isValid != DateRangeValidation.ValidationResult.VALID)
                        {
                            DisplayError("DateError", "Passed in Date not valid.");
                            return;
                        }
                        enteredDate = tempDate;
                    }
                    else
                    {
                        DisplayError("DateError", "Passed in Date not valid.");
                        return;
                    }
                }
                else
                {
                    enteredDate = DateTime.Now;
                }

                entryDate.SelectedDate = enteredDate.Date;
                entryDate.VisibleDate = enteredDate.Date;
            }
            catch (FormatException)
            {
                DisplayError("DateError", "Passed in Date format incorrect. It should be yyyy/mm/dd");
                return;
            }
            interval.SelectedValue = "1";
            if (Request.DoesParamExist("interval", _docDnaInterval))
            {
                string intervalText = Request.GetParamStringOrEmpty("interval", _docDnaInterval);
                if (intervalText == "week")
                {
                    interval.SelectedValue = "2";
                }
                else if (intervalText == "month")
                {
                    interval.SelectedValue = "3";
                }

            }

            if (skin == "purexml" || skParam == "purexml")
            {
                GetStatisticsReport(true);
            }
            else
            {
                GetStatisticsReport(false);
                ShowHideControls(true);
            }
        }
        else
        {
            ShowHideResultControls(false);
        }

    }
Esempio n. 8
0
        /// <summary>
        /// Used to process the current request.
        /// </summary>
        public override void ProcessRequest()
        {
            //Clean any existing XML.
            RootElement.RemoveAll();

            XmlNode summaryXML = AddElementTag(RootElement, "SITESUMMARY");

            if (InputContext.ViewingUser == null || !InputContext.ViewingUser.IsSuperUser)
            {
                AddErrorXml("Invalid Permissions", "Superuser permissions required", RootElement);
                return;
            }

            int siteId = InputContext.GetParamIntOrZero("siteid","SiteId");
            if (siteId > 0)
            {
                //Add XML for selected site.
                ISite site = InputContext.TheSiteList.GetSite(siteId);
                SiteXmlBuilder siteXmlBuilder = new SiteXmlBuilder(InputContext);
                XmlNode siteXML = siteXmlBuilder.GenerateXml(null, site);
                siteXML = ImportNode(siteXML);
                summaryXML.AppendChild(siteXML);
            }

            bool recalculateReport = InputContext.GetParamIntOrZero("recalculate", "Recalculate Report") == 1;

            //Require Dates to produce site summary report.
            if (InputContext.DoesParamExist("startdate", "Start Date") && InputContext.DoesParamExist("enddate", "End Date"))
            {
                DateTime startDate;
                DateTime endDate;
                try
                {
                    startDate = DateTime.Parse(InputContext.GetParamStringOrEmpty("startdate", "StartDate"));
                    endDate = DateTime.Parse(InputContext.GetParamStringOrEmpty("enddate", "EndDate"));
                }
                catch(FormatException fe)
                {
                    this.AddErrorXml("Bad Format",fe.Message,RootElement);
                    return;
                }

                DateRangeValidation dateValidate = new DateRangeValidation();
                DateRangeValidation.ValidationResult result = dateValidate.ValidateDateRange(startDate, endDate, 1, false, true);
                if (result != DateRangeValidation.ValidationResult.VALID)
                {
                    XmlElement errorXML = dateValidate.GetLastValidationResultAsXmlElement(RootElement.OwnerDocument);
                    RootElement.AppendChild(errorXML);
                    return;
                }

                AddDateXml(startDate, summaryXML, "STARTDATE");
                AddDateXml(endDate, summaryXML, "ENDDATE");

                GenerateStatsXML(summaryXML, siteId, startDate, endDate, recalculateReport);
            }
            SiteXmlBuilder siteXml = new SiteXmlBuilder(InputContext);
            siteXml.GenerateAllSitesXml(InputContext.TheSiteList);
            AddInside(RootElement, siteXml);
       
        }