【问题标题】:Qlikview folder list using QMS api使用 QMS api 的 Qlikview 文件夹列表
【发布时间】:2015-04-01 14:01:26
【问题描述】:

我能够使用以下代码和 QMS api 成功获取 qlikview 文件列表。

    string key = Client.GetTimeLimitedServiceKey();
    ServiceKeyClientMessageInspector.ServiceKey = key;
    ServiceInfo[] qvService = Client.GetServices(ServiceTypes.QlikViewServer);
    DocumentNode[] allDocs = Client.GetUserDocuments(qvService[0].ID);

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

【问题讨论】:

    标签: qlikview


    【解决方案1】:

    QMS API 文档中有一个示例,位于GetSourceDocumentFolders 方法下。该示例通过使用递归浏览子文件夹将所有文档和文件夹的名称写入控制台。

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

    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);
                    }
            }
    }
    

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2017-10-30
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多