public async Task LoadSubscriptions()
        {
            this.SubscriptionsGridView.DataSource = null;
            this.comboResourceGroup.DataSource    = null;

            PaaSController backend = new PaaSController(GetContext());

            try
            {
                string content = await backend.GetSubscriptions();

                AzureSubscriptions subscriptions = JsonConvert.DeserializeObject <AzureSubscriptions>(content);
                if (subscriptions == null || subscriptions.Value == null || subscriptions.Value.Count() == 0)
                {
                    MessageBox.Show("No subscriptions found.");
                    return;
                }
                this.SubscriptionsGridView.DataSource  = subscriptions.Value;
                this.SubscriptionsGridView.CurrentCell = this.SubscriptionsGridView[1, 0];
            }
            catch (Exception e)
            {
                MessageBox.Show($"Failed to get subscriptions: {e.Message}");
                return;
            }

            await LoadResourceGroups();
        }
Example #2
0
 private async Task <HttpResponseMessage> TryExportToFile(PaaSController controller, string workspaceId, string reportId, string filePath)
 {
     try
     {
         return((await controller.ExportToFile(workspaceId, reportId, filePath)).Response);
     }
     catch (Exception e)
     {
         MessageBox.Show(e.ToString());
         return(null);
     }
 }
Example #3
0
        private async Task AnalyzeWorkspaceCollection(AnalyzedWorkspaceCollection analyzedWorkspaceCollection)
        {
            PBIProvisioningContext localContext = new PBIProvisioningContext(MigrationPlan.Context);

            localContext.WorkspaceCollection = new PBIWorkspaceCollection {
                Name = analyzedWorkspaceCollection.WorkspaceCollectionName
            };
            PaaSController controller = new PaaSController(localContext);

            analyzedWorkspaceCollection.Workspaces = (await controller.GetWorkspaces()).Select(ws => new AnalyzedWorkspace(ws.WorkspaceId)).ToList();

            await Task.WhenAll(analyzedWorkspaceCollection.Workspaces.Select(aws => AnalyzeWorkspace(localContext, aws)).ToArray());
        }
Example #4
0
        private async Task Export(List <ReportMigrationData> selectedReports)
        {
            foreach (var report in selectedReports)
            {
                RunInUIContext(UpdateExportGrid);

                PBIProvisioningContext localContext = new PBIProvisioningContext(MigrationPlan.Context);
                localContext.WorkspaceCollection = new PBIWorkspaceCollection {
                    Name = report.PaaSWorkspaceCollectionName
                };
                PaaSController controller = new PaaSController(localContext);

                string targetFolder = Path.GetDirectoryName(report.PbixPath);

                if (!Directory.Exists(targetFolder))
                {
                    Directory.CreateDirectory(targetFolder);
                }

                report.ExportState = ExportState.InProgress;
                RunInUIContext(UpdateExportGrid);

                var response = await TryExportToFile(controller, report.PaaSWorkspaceId, report.PaaSReportId, report.PbixPath);

                if (response != null && response.StatusCode == HttpStatusCode.OK)
                {
                    if (File.Exists(report.PbixPath))
                    {
                        report.ExportState      = ExportState.Done;
                        report.LastExportStatus = "Download was successful";
                    }
                    else
                    {
                        report.ExportState      = ExportState.Failed;
                        report.LastExportStatus = Errors.Export.PBIXNotCreated;
                    }
                }
                else
                {
                    report.ExportState      = ExportState.Failed;
                    report.LastExportStatus = Errors.Export.DownloadFailed;

                    if (response != null)
                    {
                        report.LastExportStatus = response.StatusCode.ToString();
                    }
                }

                RunInUIContext(UpdateExportGrid);
            }
        }
        public async Task LoadResourceGroups()
        {
            PaaSController backend = new PaaSController(GetContext());

            string content = await backend.GetResourceGroups();

            AzureResourceGroups resourceGroups = JsonConvert.DeserializeObject <AzureResourceGroups>(content);

            if (resourceGroups == null || resourceGroups.Value == null || resourceGroups.Value.Count() == 0)
            {
                MessageBox.Show("No subscriptions found.");
                return;
            }

            this.comboResourceGroup.DataSource = resourceGroups.Value.Select(rg => rg.Name).ToList();
        }
Example #6
0
        private async Task AnalyzeResourceGroup()
        {
            try
            {
                var paaSController = new PaaSController(MigrationPlan.Context);
                var collections    = await paaSController.GetRelevantWorkspaceCollections();

                this.AnalyzedWorkspaceCollections = collections.Select(wc => new AnalyzedWorkspaceCollection(wc.Name)).ToList();

                await Task.WhenAll(this.AnalyzedWorkspaceCollections.Select(awc => AnalyzeWorkspaceCollection(awc)).ToArray());

                foreach (var analyzedWSCollection in AnalyzedWorkspaceCollections)
                {
                    foreach (var analyzedWS in analyzedWSCollection.Workspaces)
                    {
                        foreach (var reportMigrationData in analyzedWS.Reports)
                        {
                            MigrationPlan.ReportsMigrationData.Add(reportMigrationData);
                        }
                    }
                }

                RunInUIContext(() =>
                {
                    AnalyzedReportsSourceManager.FilteredReports = MigrationPlan.ReportsMigrationData;

                    UpdateActualPaaSTopologyTreeAndStatistics();
                    UpdateAnalyzeGrid();
                    UsePaaSTopologyForExport();
                    UsePaaSTopologyForImport();

                    SaveMigrationPlan();
                });
            }
            catch (Exception e)
            {
                MessageBox.Show($"Failed to analyze Resource Group. Error: { e.Message}");
            }
        }
Example #7
0
        private async Task AnalyzeWorkspace(PBIProvisioningContext context, AnalyzedWorkspace analyzedWorkspace)
        {
            PBIProvisioningContext localContext = new PBIProvisioningContext(context);

            localContext.WorkspaceId = analyzedWorkspace.WorkspaceId;

            PaaSController controller = new PaaSController(localContext);
            var            imports    = await controller.GetImports();

            var reports = await controller.GetReports();

            var datasets = await controller.GetDatasets();

            foreach (var report in reports)
            {
                var datasources = await controller.GetDatasources(report.DatasetId);

                var import = imports.Value.FirstOrDefault(i => i.Reports != null && i.Reports.Any(r => string.Equals(r.Id, report.Id, StringComparison.OrdinalIgnoreCase)));

                var dataset = datasets.FirstOrDefault(d => string.Equals(d.Id, report.DatasetId, StringComparison.OrdinalIgnoreCase));

                analyzedWorkspace.Reports.Add(new ReportMigrationData(report, import, dataset, datasources, localContext.WorkspaceCollection.Name, localContext.WorkspaceId));
            }
        }