Esempio n. 1
0
    /// <summary>
    /// Get a page's worth of Views listing
    /// </summary>
    /// <param name="onlineViews"></param>
    /// <param name="pageToRequest">Page # we are requesting (1 based)</param>
    /// <param name="totalNumberPages">Total # of pages of data that Server can return us</param>
    private void ExecuteRequest_ForPage(List <SiteView> onlineViews, int pageToRequest, out int totalNumberPages)
    {
        int pageSize = _onlineUrls.PageSize;
        //Create a web request, in including the users logged-in auth information in the request headers
        var urlQuery   = _onlineUrls.Url_ViewsList(_onlineSession, pageSize, pageToRequest);
        var webRequest = CreateLoggedInWebRequest(urlQuery);

        webRequest.Method = "GET";

        _onlineSession.StatusLog.AddStatus("Web request: " + urlQuery, -10);
        var response = GetWebReponseLogErrors(webRequest, "get views list");
        var xmlDoc   = GetWebResponseAsXml(response);

        //Get all the view nodes
        var nsManager = XmlHelper.CreateTableauXmlNamespaceManager("iwsOnline");
        var views     = xmlDoc.SelectNodes("//iwsOnline:view", nsManager);

        //Get information for each of the data sources
        foreach (XmlNode itemXml in views)
        {
            try
            {
                var thisView = new SiteView(itemXml);
                onlineViews.Add(thisView);

                SanityCheckView(thisView, itemXml);
            }
            catch
            {
                AppDiagnostics.Assert(false, "View parse error");
                _onlineSession.StatusLog.AddError("Error parsing view: " + itemXml.OuterXml);
            }
        } //end: foreach

        //-------------------------------------------------------------------
        //Get the updated page-count
        //-------------------------------------------------------------------
        totalNumberPages = DownloadPaginationHelper.GetNumberOfPagesFromPagination(
            xmlDoc.SelectSingleNode("//iwsOnline:pagination", nsManager),
            pageSize);
    }