Пример #1
0
        public async Task <HealthCheckResult> CheckHealthAsync(HealthCheckContext context, CancellationToken cancellationToken = new CancellationToken())
        {
            try
            {
                var rsClient = CreateReportService2010Client();

                ReportService2010.TrustedUserHeader trustedUserHeader = new ReportService2010.TrustedUserHeader();

                // Call to an arbitrary method
                await rsClient.ListExtensionsAsync(trustedUserHeader, "Render");
            }
            catch (Exception ex)
            {
                return(new HealthCheckResult(context.Registration.FailureStatus, exception: ex, description: "ReportService2010 is not available."));
            }

            try
            {
                var rsClient = CreateReportExecution2005Client();

                ReportExecution2005.TrustedUserHeader trustedUserHeader = new ReportExecution2005.TrustedUserHeader();

                // Call to an arbitrary method
                await rsClient.ListRenderingExtensionsAsync(trustedUserHeader);
            }
            catch (Exception ex)
            {
                return(new HealthCheckResult(context.Registration.FailureStatus, exception: ex, description: "ReportExecution2005 is not available."));
            }

            return(HealthCheckResult.Healthy());
        }
Пример #2
0
 private static void GetHeaders(string UserName, string UserPassword, ReportingService2010.ReportingService2010SoapClient rsService, ReportExecution2005.ReportExecutionServiceSoapClient rsExec, out ReportingService2010.TrustedUserHeader trusteduserHeader, out ReportExecution2005.TrustedUserHeader userHeader)
 {
     rsService.ClientCredentials.SupportInteractive                = false;
     rsService.ClientCredentials.Windows.ClientCredential          = System.Net.CredentialCache.DefaultNetworkCredentials;
     rsService.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
     System.Net.NetworkCredential clientCredentials = new System.Net.NetworkCredential(UserName, UserPassword);
     if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(UserPassword) && UserName != "@UserName" && UserPassword != "@UserPassword")
     {
         rsService.ClientCredentials.Windows.ClientCredential = clientCredentials;
         rsService.ClientCredentials.UserName.UserName        = UserName;
         rsService.ClientCredentials.UserName.UserName        = UserPassword;
     }
     trusteduserHeader          = new ReportingService2010.TrustedUserHeader();
     trusteduserHeader.UserName = clientCredentials.UserName;
     userHeader          = new ReportExecution2005.TrustedUserHeader();
     userHeader.UserName = clientCredentials.UserName;
     if (rsExec != null)
     {
         rsExec.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
         //rsExec.ClientCredentials.Windows.ClientCredential = credentials.GetCredential(new Uri(baseUrl), "NTLM");
     }
 }
        private async Task <ReportExecution2005.RenderResponse> RenderReport(string reportPath, IDictionary <string, string> parameters, string format)
        {
            var rsClient = CreateReportExecution2005Client();

            ReportExecution2005.TrustedUserHeader trustedUserHeader = new ReportExecution2005.TrustedUserHeader();

            // Load the report
            var taskLoadReport = await rsClient.LoadReportAsync(trustedUserHeader, reportPath, null);

            // Set the parameters asked for by the report
            if (parameters != null)
            {
                var reportParameters = taskLoadReport.executionInfo.Parameters.Where(x => parameters.ContainsKey(x.Name)).Select(x => new ReportExecution2005.ParameterValue {
                    Name = x.Name, Value = parameters[x.Name]
                }).ToArray();
                await rsClient.SetExecutionParametersAsync(taskLoadReport.ExecutionHeader, trustedUserHeader, reportParameters, "en-us");
            }

            // Run the report
            const string deviceInfo = @"<DeviceInfo><Toolbar>False</Toolbar></DeviceInfo>";
            var          response   = await rsClient.RenderAsync(new ReportExecution2005.RenderRequest(taskLoadReport.ExecutionHeader, trustedUserHeader, format, deviceInfo));

            return(response);
        }
Пример #4
0
 private static void GetHeaders(string UserName, string UserPassword, ReportingService2010.ReportingService2010SoapClient rsService, ReportExecution2005.ReportExecutionServiceSoapClient rsExec, out ReportingService2010.TrustedUserHeader trusteduserHeader, out ReportExecution2005.TrustedUserHeader userHeader)
 {
     rsService.ClientCredentials.SupportInteractive = false;
     rsService.ClientCredentials.Windows.ClientCredential = System.Net.CredentialCache.DefaultNetworkCredentials;
     rsService.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
     System.Net.NetworkCredential clientCredentials = new System.Net.NetworkCredential(UserName, UserPassword);
     if (!string.IsNullOrEmpty(UserName) && !string.IsNullOrEmpty(UserPassword) && UserName != "@UserName" && UserPassword != "@UserPassword")
     {
         rsService.ClientCredentials.Windows.ClientCredential = clientCredentials;
         rsService.ClientCredentials.UserName.UserName = UserName;
         rsService.ClientCredentials.UserName.UserName = UserPassword;
     }
     trusteduserHeader = new ReportingService2010.TrustedUserHeader();
     trusteduserHeader.UserName = clientCredentials.UserName;
     userHeader = new ReportExecution2005.TrustedUserHeader();
     userHeader.UserName = clientCredentials.UserName;
     if (rsExec != null)
     {
         rsExec.ClientCredentials.Windows.AllowedImpersonationLevel = TokenImpersonationLevel.Impersonation;
         //rsExec.ClientCredentials.Windows.ClientCredential = credentials.GetCredential(new Uri(baseUrl), "NTLM");
     }
 }