TableauServerUrls.Url_DatasourcesList C# (CSharp) Method

Url_DatasourcesList() public method

URL for the Datasources list
public Url_DatasourcesList ( TableauServerSignIn, session, int pageSize, int pageNumber = 1 ) : string
session TableauServerSignIn,
pageSize int
pageNumber int
return string
    public string Url_DatasourcesList(TableauServerSignIn session, int pageSize, int pageNumber = 1)
    {
        string workingText = _urlListDatasourcesTemplate;
        workingText = workingText.Replace("{{iwsSiteId}}", session.SiteId);
        workingText = workingText.Replace("{{iwsPageSize}}", pageSize.ToString());
        workingText = workingText.Replace("{{iwsPageNumber}}", pageNumber.ToString());
        ValidateTemplateReplaceComplete(workingText);

        return workingText;
    }

Usage Example

Beispiel #1
0
    /// <summary>
    /// Get a page's worth of Data Sources
    /// </summary>
    /// <param name="onlineDatasources"></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 <SiteDatasource> onlineDatasources, 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_DatasourcesList(_onlineSession, pageSize, pageToRequest);

        _onlineSession.StatusLog.AddStatus("Web request: " + urlQuery, -10);
        var xmlDoc = ResourceSafe_PerformWebRequest_GetXmlDocument(urlQuery, "get datasources list");

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

        //Get information for each of the data sources
        foreach (XmlNode itemXml in datasources)
        {
            try
            {
                var ds = new SiteDatasource(itemXml);
                onlineDatasources.Add(ds);
            }
            catch
            {
                AppDiagnostics.Assert(false, "Datasource parse error");
                _onlineSession.StatusLog.AddError("Error parsing datasource: " + itemXml.InnerXml);
            }
        } //end: foreach

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