예제 #1
0
        private Group GetWorkspaces(string workspaceName)
        {
            if (workspaceName == PowerBIWrapperConstants.MyWorkspace)
            {
                workspace = null;
                var reportNames = reportsClient.GetReports().Value.Select(report => report.Name);
                workspaceReports = new HashSet <string>(reportNames);
                return(null);
            }
            var workspaces = groupsClient.GetGroups().Value;
            var groups     = workspaces.Where(g => (g.Name == workspaceName));

            if (groups.Count() == 1)
            {
                workspace = groups.First();
                if (workspace.IsOnDedicatedCapacity == false)
                {
                    throw new Exception($"WORKSPACE {workspaceName} IS NOT A PREMIUM WORKSPACE. Only premium workspaces can upload reports");
                }
                var reportNames = reportsClient.GetReportsInGroup(workspace.Id).Value.Select(report => report.Name);
                workspaceReports = new HashSet <string>(reportNames);
                return(workspace);
            }
            else if (groups.Count() == 0)
            {
                throw new Exception($"WORKSPACE {workspaceName} NOT FOUND.  Please make sure it is a valid workspace");
            }
            else
            {
                throw new Exception($"MULTIPLE PREMIUM WORKSPACE {workspaceName} FOUND. This should not happen, make sure you have valid workspaces");
            }
        }