public static ReportService.ReportParameter[] GetReportParameters(ReportViewerModel model, bool forRendering = false)
        {
            var url = model.ServerUrl + ((model.ServerUrl.ToSafeString().EndsWith("/")) ? "" : "/") + "ReportService2005.asmx";

            var basicHttpBinding = _initializeHttpBinding(url, model);
            var service          = new ReportService.ReportingService2005SoapClient(basicHttpBinding, new System.ServiceModel.EndpointAddress(url));

            service.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
            service.ClientCredentials.Windows.ClientCredential          = (System.Net.NetworkCredential)(model.Credentials ?? System.Net.CredentialCache.DefaultCredentials);

            var cred = model.Credentials?.GetCredential(new Uri(url), "Basic");

            service.ClientCredentials.UserName.UserName = cred?.UserName;
            service.ClientCredentials.UserName.Password = cred?.Password;

            string historyID = null;

            ReportService.ParameterValue[]        values        = null;
            ReportService.DataSourceCredentials[] rsCredentials = null;

            var parameters = service.GetReportParametersAsync(model.ReportPath, historyID, false, values, rsCredentials).Result;                //set it to load the not for rendering so that it's hopefully quicker than the whole regular call

            if (model != null && model.Parameters != null && model.Parameters.Any())
            {
                var tempParameters = new List <ReportService.ParameterValue>();
                foreach (var parameter in parameters)
                {
                    if (model.Parameters.ContainsKey(parameter.Name))
                    {
                        var providedParameter = model.Parameters[parameter.Name];
                        if (providedParameter != null)
                        {
                            foreach (var value in providedParameter.Where(x => !String.IsNullOrEmpty(x)))
                            {
                                tempParameters.Add(new ReportService.ParameterValue()
                                {
                                    Label = parameter.Name,
                                    Name  = parameter.Name,
                                    Value = value
                                });
                            }
                        }
                    }
                }

                values = tempParameters.ToArray();
            }

            parameters = service.GetReportParametersAsync(model.ReportPath, historyID, forRendering, values, rsCredentials).Result;

            return(parameters);
        }
        public static ReportService.ReportParameter[] GetReportParameters(ReportViewerModel model, bool forRendering = false)
        {
            var url = model.ServerUrl + ((model.ServerUrl.ToSafeString().EndsWith("/")) ? "" : "/") + "ReportService2005.asmx";

            var basicHttpBinding = _initializeHttpBinding();
            var service          = new ReportService.ReportingService2005SoapClient(basicHttpBinding, new System.ServiceModel.EndpointAddress(url));

            service.ClientCredentials.Windows.AllowedImpersonationLevel = System.Security.Principal.TokenImpersonationLevel.Impersonation;
            service.ClientCredentials.Windows.ClientCredential          = (System.Net.NetworkCredential)(model.Credentials ?? System.Net.CredentialCache.DefaultCredentials);

            string historyID = null;

            ReportService.ParameterValue[]        values        = null;
            ReportService.DataSourceCredentials[] rsCredentials = null;

            var parameters = service.GetReportParametersAsync(model.ReportPath, historyID, forRendering, values, rsCredentials).Result;

            return(parameters);
        }