Exemple #1
0
        public List <string[]> Listing(string reportPath)
        {
            if (string.IsNullOrEmpty(reportPath))
            {
                throw new Exception("Missing required reportPath parameter");
            }

            List <string[]> listing = new List <string[]>();

            ReportService.ListChildrenResponse listChildrenResponse = null;
            listChildrenResponse = RSServiceClient.ListChildrenAsync(reportPath, false).Result;
            CatalogItem[] output = listChildrenResponse.CatalogItems;

            if (listChildrenResponse.CatalogItems.Length > 0)
            {
                foreach (CatalogItem item in listChildrenResponse.CatalogItems)
                {
                    string[] reportItem = new string[4];
                    reportItem[0] = item.Name ?? string.Empty;
                    reportItem[1] = item.Description ?? string.Empty;
                    reportItem[2] = item.Path ?? string.Empty;

                    if (item.Type == ItemTypeEnum.Report)
                    {
                        ReportService.ParameterValue[]        values      = null;
                        ReportService.DataSourceCredentials[] credentials = null;
                        var reportParameters = RSServiceClient.GetReportParametersAsync(
                            item.Path,
                            HistoryId,
                            true,
                            values,
                            credentials

                            );

                        reportParameters.Wait();

                        if (reportParameters.IsCompletedSuccessfully)
                        {
                            List <string> parameters = new List <string>();
                            foreach (ReportService.ReportParameter paranmeter in reportParameters.Result.Parameters)
                            {
                                parameters.Add(paranmeter.Name);
                            }

                            StringBuilder builder = new StringBuilder();
                            foreach (string parameter in parameters)
                            {
                                builder.Append(parameter).Append(',');
                            }

                            reportItem[3] = builder.ToString().Trim(',');
                        }
                    }
                    else
                    {
                        reportItem[3] = string.Empty;
                    }

                    listing.Add(reportItem);
                }
            }

            return(listing);
        }