Esempio n. 1
0
        /// <summary>
        /// Takes a folder of reports, convert them and upload them to PBI workspace.
        /// </summary>
        /// <param name="urlEndPoint">the end point of report server.</param>
        /// <param name="inputPath">The Path of input Folder.</param>
        /// <param name="workspaceName">The name of requesting workspace.</param>
        /// <param name="clientID">The clientID of the App registered with permissions of Reading/Writing dataset, report and Reading Workspaces.</param>
        public void ConvertFolder(string urlEndPoint, string inputPath, string workspaceName, string clientID)
        {
            Trace("Starting the log-in window");
            PowerBIClientWrapper powerBIPortal = new PowerBIClientWrapper(workspaceName, clientID);

            Trace("Log-in successfully, retrieving the reports...");

            RdlFileIO rdlFileIO = new RdlFileIO(urlEndPoint);

            Trace($"Starting conversion and uploading the reports {DateTime.UtcNow.ToString()}");

            if (!Directory.Exists("output"))
            {
                Directory.CreateDirectory("output");
            }

            if (!rdlFileIO.IsFolder(inputPath))
            {
                ConvertAndUploadReport(
                    powerBIPortal,
                    rdlFileIO,
                    inputPath);
            }
            else
            {
                var reportPaths = rdlFileIO.GetReportsInFolder(inputPath);

                Console.WriteLine($"Found {reportPaths.Length} reports to convert");
                Parallel.ForEach(reportPaths, reportPath => ConvertAndUploadReport(
                                     powerBIPortal,
                                     rdlFileIO,
                                     reportPath));
            }
        }
Esempio n. 2
0
        /// <summary>
        /// Takes a folder of reports, convert them and upload them to PBI workspace.
        /// </summary>
        /// <param name="urlEndPoint">the end point of report server.</param>
        /// <param name="inputPath">The Path of input Folder.</param>
        /// <param name="workspaceName">The name of requesting workspace.</param>
        /// <param name="clientID">The clientID of the App registered with permissions of Reading/Writing dataset, report and Reading Workspaces.</param>
        public void ConvertFolder(string urlEndPoint, string inputPath, string workspaceName, string clientID)
        {
            Trace("Starting the log-in window");
            PowerBIClientWrapper powerBIClient = new PowerBIClientWrapper(workspaceName, clientID);

            Trace("Log-in successfully, retrieving the reports...");

            rdlFileIO = new RdlFileIO(urlEndPoint);

            Trace($"Starting conversion and uploading the reports {DateTime.UtcNow.ToString()}");

            if (!Directory.Exists("output"))
            {
                Directory.CreateDirectory("output");
            }

            if (!rdlFileIO.IsFolder(inputPath))
            {
                rootFolder = Path.GetDirectoryName(inputPath).Replace("\\", "/");
                var reportName = Path.GetFileName(inputPath);
                reportNameMap.TryAdd(reportName, 1);
                reportPaths.Enqueue(inputPath);
            }
            else
            {
                rootFolder = inputPath;
                var rootReports = rdlFileIO.GetReportsInFolder(inputPath);
                Console.WriteLine($"Found {rootReports.Length} reports to convert");
                foreach (string reportPath in reportPaths)
                {
                    var reportName = Path.GetFileName(reportPath);
                    reportNameMap.TryAdd(reportName, 1);
                }
                rootReports.ToList().ForEach(reportPaths.Enqueue);
            }
            while (reportPaths.Count > 0)
            {
                string reportPath = reportPaths.Dequeue();
                ConvertAndUploadReport(
                    powerBIClient,
                    rdlFileIO,
                    reportPath);
            }
        }