首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >使用QMS api的Qlikview文件夹列表

使用QMS api的Qlikview文件夹列表
EN

Stack Overflow用户
提问于 2015-04-01 22:01:26
回答 1查看 881关注 0票数 1

我可以使用QMS api使用以下代码成功获取qlikview文件的列表。

代码语言:javascript
复制
    string key = Client.GetTimeLimitedServiceKey();
    ServiceKeyClientMessageInspector.ServiceKey = key;
    ServiceInfo[] qvService = Client.GetServices(ServiceTypes.QlikViewServer);
    DocumentNode[] allDocs = Client.GetUserDocuments(qvService[0].ID);

但现在它只是列出了qlikview文件。那文件夹呢?有没有人可以建议我获取文件夹的代码呢?

EN

回答 1

Stack Overflow用户

发布于 2015-04-10 17:34:31

在QMS文档中的GetSourceDocumentFolders方法下有一个示例。该示例使用递归在子文件夹中导航,从而将所有文档和文件夹的名称写入控制台。

这并不完全是你所需要的,但是你可以修改它以将它们存储在数组中,等等。我已经尝试更改变量名来匹配你已经提供的代码:

代码语言:javascript
复制
List<DocumentFolder> sourceDocumentsFolders = Client.GetSourceDocumentFolders(qvService[0].ID, DocumentFolderScope.General | DocumentFolderScope.Services);
foreach (DocumentFolder sourceDocumentFolder in sourceDocumentsFolders.OrderBy(x => x.General.Path)) {
    // print the names of all source document folders, prefix with [R] for root folders
    Console.WriteLine("[R] " + sourceDocumentFolder.General.Path);

    // print all sub nodes of the current source document folder
    PrintSourceDocumentNodes(Client, sourceDocumentFolder, string.Empty, 1);
}

static void PrintSourceDocumentNodes(IQMS apiClient, DocumentFolder sourceDocumentFolder, string relativePath, int indentationDepth) {
    // retrieve all source document nodes of the given folder and under the specified relative path
        List<DocumentNode> sourceDocumentNodes = apiClient.GetSourceDocumentNodes(sourceDocumentFolder.Services.QDSID, sourceDocumentFolder.ID, relativePath);
    foreach (DocumentNode sourceDocumentNode in sourceDocumentNodes.OrderByDescending(x => x.IsSubFolder).ThenBy(x => x.Name)) {
        // print the names of all source document nodes, indent and prefix with [F] for folders and [D] for documents
        string indentation = new string(' ', indentationDepth * 3);
        string nodePrefix = (sourceDocumentNode.IsSubFolder ? "[F]" : "[D]");
        Console.WriteLine(indentation + nodePrefix + " " + sourceDocumentNode.Name);
        // print all sub nodes of the current source document node if it represents a folder
        if (sourceDocumentNode.IsSubFolder) {
            PrintSourceDocumentNodes(apiClient, sourceDocumentFolder, relativePath + "\\" + sourceDocumentNode.Name, indentationDepth + 1);
                }
        }
}
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/29392846

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档