예제 #1
0
    /// <summary>
    /// Attempt to remove a tag from a set of datasources
    /// </summary>
    /// <param name="onlineLogin"></param>
    /// <param name="contentSet"></param>
    /// <param name="removeTag"></param>
    private void Execute_DeleteTagFromDatasources(
        TableauServerSignIn onlineLogin,
        ICollection <SiteDatasource> contentSet,
        string removeTag)
    {
        if (string.IsNullOrWhiteSpace(removeTag))
        {
            throw new ArgumentException("Tag to remove is blank");
        }

        //Nothing to do?
        if (contentSet == null)
        {
            return;
        }

        var onlineUrls = _onlineUrls;

        _statusLog.AddStatusHeader("Deleting tag '" + removeTag + "' from " + contentSet.Count.ToString() + " datasources");
        //Make the delete tag request for each datasource
        foreach (var contentItem in contentSet)
        {
            try
            {
                var tagDelete = new SendDeleteDatasourceTag(onlineUrls, onlineLogin, contentItem.Id, removeTag);
                tagDelete.ExecuteRequest();
            }
            catch (Exception exDeleteTag)
            {
                _statusLog.AddError(
                    "Error attempting to delete tag from datasource " +
                    contentItem.Id + "/" + removeTag
                    + ", " + exDeleteTag.Message);
            }
        }//end: foreach
    }
예제 #2
0
    /// <summary>
    /// Attempt to remove a tag from a set of datasources
    /// </summary>
    /// <param name="onlineLogin"></param>
    /// <param name="contentSet"></param>
    /// <param name="removeTag"></param>
    private void Execute_DeleteTagFromDatasources(
        TableauServerSignIn onlineLogin,
        ICollection<SiteDatasource> contentSet,
        string removeTag)
    {
        if (string.IsNullOrWhiteSpace(removeTag))
        {
            throw new ArgumentException("Tag to remove is blank");
        }

        //Nothing to do?
        if (contentSet == null)
        {
            return;
        }

        var onlineUrls = _onlineUrls;
        _statusLog.AddStatusHeader("Deleting tag '" + removeTag + "' from " + contentSet.Count.ToString() + " datasources");
        //Make the delete tag request for each datasource
        foreach (var contentItem in contentSet)
        {
            try
            {
                var tagDelete = new SendDeleteDatasourceTag(onlineUrls, onlineLogin, contentItem.Id, removeTag);
                tagDelete.ExecuteRequest();
            }
            catch (Exception exDeleteTag)
            {
                _statusLog.AddError(
                    "Error attempting to delete tag from datasource " +
                    contentItem.Id + "/" + removeTag
                    + ", " + exDeleteTag.Message);
            }
        }//end: foreach
    }