Example #1
0
        public PBIRefreshes RESTGetRefreshes(string groupId, string datasetId)
        {
            string       refreshesContent = RESTWrapper(String.Format("groups/{0}/datasets/{1}/refreshes", groupId, datasetId));
            PBIRefreshes refreshes        = JsonConvert.DeserializeObject <PBIRefreshes>(refreshesContent);

            return(refreshes);
        }
Example #2
0
        public void RESTDumpReportRefreshesToCsv()
        {
            System.IO.StreamWriter sw = new System.IO.StreamWriter(String.Format(@".\Refreshes_{0}.csv", DateTime.Now.ToString("yyyyMMddhhmmss")));
            sw.WriteLine("Workspace;DataSet;RefreshType;StartTime;EndTime;Status");

            Dictionary <PBIGroup, PBIDataSets> groupDatasets = new Dictionary <PBIGroup, PBIDataSets>();

            string groupName = null, datasetName = null;
            int    datasetCount = 0, groupCount = 0;

            try
            {
                groupName = "";
                PBIGroups groups = RESTGetGroups();

                foreach (PBIGroup group in groups.List)
                {
                    groupCount++;
                    groupName    = group.name;
                    datasetCount = 0;
                    datasetName  = "";

                    try
                    {
                        PBIDataSets datasets = RESTGetDatasets(group.id);
                        Console.WriteLine(String.Format("Group: {0} ({1} / {2})", group.name, groupCount, groups.List.Count));

                        foreach (PBIDataSet dataset in datasets.List)
                        {
                            try
                            {
                                datasetCount++;
                                datasetName = dataset.name;
                                PBIRefreshes refreshes = RESTGetRefreshes(group.id, dataset.id);

                                Console.WriteLine(String.Format("     Dataset: {0} ({1} / {2}) - {3} refreshes", dataset.name, datasetCount, datasets.List.Count, refreshes.List.Count));

                                foreach (PBIRefresh refresh in refreshes.List)
                                {
                                    datasetName = dataset.name;

                                    sw.WriteLine(String.Join(";", new String[] {
                                        group.name,
                                        dataset.name,
                                        refresh.refreshType,
                                        refresh.startTime.ToString("yyyy.MM.dd hh:mm:ss"),
                                        refresh.endTime.ToString("yyyy.MM.dd hh:mm:ss"),
                                        refresh.status
                                    }));
                                }
                            }
                            catch (Exception e)
                            {
                                Console.WriteLine("     Query error (group: " + groupName + ", dataset: " + datasetName + ")");
                                sw.WriteLine(groupName + ";" + datasetName + ";;;;");
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        Console.WriteLine("Query error (group: " + groupName + ")");
                        sw.WriteLine(groupName + ";;;;;");
                    }
                }
            }
            catch
            {
                Console.WriteLine("Query error");
            }

            sw.Close();
        }