Exemplo n.º 1
0
    /// <summary>
    /// Get a page's worth of Tasks listing
    /// </summary>
    /// <param name="onlineTasks"></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 <SiteTaskExtractRefresh> onlineTasks, 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_TasksExtractRefreshesForScheduleList(_onlineSession, _scheduleId, pageSize, pageToRequest);
        var webRequest = CreateLoggedInWebRequest(urlQuery);

        webRequest.Method = "GET";

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

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

        //Get information for each of the data sources
        foreach (XmlNode itemXml in tasks)
        {
            try
            {
                var thisTask = new SiteTaskExtractRefresh(itemXml, _scheduleId);
                onlineTasks.Add(thisTask);

                SanityCheckTask(thisTask, itemXml);
            }
            catch
            {
                AppDiagnostics.Assert(false, "Task parse error");
                _onlineSession.StatusLog.AddError("Error parsing task: " + itemXml.OuterXml);
            }
        } //end: foreach

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