示例#1
0
        /// <summary>
        /// Execute request for Workbook Views
        /// </summary>
        public void ExecuteRequest()
        {
            if (string.IsNullOrWhiteSpace(_userId))
            {
                OnlineSession.StatusLog.AddError("User ID required to query workbooks");
            }

            try
            {
                var urlQuery   = _onlineUrls.Url_ViewsListForWorkbook(_workbookId, OnlineSession);
                var webRequest = CreateLoggedInWebRequest(urlQuery);
                webRequest.Method = "GET";
                OnlineSession.StatusLog.AddStatus($"Web request: {urlQuery}", -10);
                var response = GetWebResponseLogErrors(webRequest, "get views list");
                var xmlDoc   = GetWebResponseAsXml(response);

                var nsManager = XmlHelper.CreateTableauXmlNamespaceManager("iwsOnline");
                var workbooks = xmlDoc.SelectNodes("//iwsOnline:view", nsManager);
                _views = new List <SiteView>();
                foreach (XmlNode itemXml in workbooks)
                {
                    try
                    {
                        var ds = new SiteView(itemXml);
                        _views.Add(ds);
                    }
                    catch
                    {
                        AppDiagnostics.Assert(false, "View parse error");
                        OnlineSession.StatusLog.AddError("Error parsing view: " + itemXml.InnerXml);
                    }
                }
            }
            catch (Exception exPageRequest)
            {
                StatusLog.AddError($"Workbooks error during page request: {exPageRequest.Message}");
            }
        }