view SSRS/SSRS.Services/ReportsService.cs @ 112:b9d5f934cb21

Initial upload
author adminsh@apollo
date Sat, 19 May 2012 16:09:07 +0100
parents
children e51a6af1c98d
line wrap: on
line source

using System.Collections.Concurrent;
using System.Linq;
using System.Security.Principal;
using System.Threading.Tasks;
using SSRS.Services.DTOs;
using SSRS.Services.ReportServiceReference;
using ServiceStack.ServiceInterface;

namespace SSRS.Services
{
    public class ReportsService : RestServiceBase<ReportsRequest>
    {
        public override object OnPost(ReportsRequest request)
        {
            var result = new ConcurrentQueue<ReportInfo>();
            var client = new ReportingService2010SoapClient();
            CatalogItem[] catalogItems;

            client.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.None;
            client.ListChildren(null, Settings.ReportPath, true, out catalogItems);

            Parallel.ForEach(catalogItems.Where(r => r.TypeName == "Report"),
                (r) =>
                {
                    ItemParameter[] parameters = null;

                    if (request.IncludeParameters)
                        client.GetItemParameters(null, r.Path, null, false, null, null, out parameters);

                    result.Enqueue(ReportInfo.Create(r.Name, Converter.Convert(parameters), r.Path));
                });

            return new ReportsResponse { Result = result.ToList() };
        }
    }
}