public ReportViewerParameters Parse(NameValueCollection queryString)
        {
            if (queryString == null)
            {
                throw new ArgumentNullException(nameof(queryString));
            }

            var isEncrypted = CheckEncryption(ref queryString);

            var settinsManager = new ControlSettingsManager(isEncrypted);

            var parameters = InitializeDefaults();
            ResetDefaultCredentials(queryString, parameters);
            parameters.ControlSettings = settinsManager.Deserialize(queryString);

            foreach (var key in queryString.AllKeys)
            {
                var urlParam = queryString[key];
                if (key.EqualsIgnoreCase(UriParameters.ReportPath))
                {
                    parameters.ReportPath = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                }
                else if (key.EqualsIgnoreCase(UriParameters.ControlId))
                {
                    var parameter = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                    parameters.ControlId = Guid.Parse(parameter);
                }
                else if (key.EqualsIgnoreCase(UriParameters.ProcessingMode))
                {
                    var parameter = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                    parameters.ProcessingMode = (ProcessingMode)Enum.Parse(typeof(ProcessingMode), parameter);
                }
                else if (key.EqualsIgnoreCase(UriParameters.ReportServerUrl))
                {
                    parameters.ReportServerUrl = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                }
                else if (key.EqualsIgnoreCase(UriParameters.Username))
                {
                    parameters.Username = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                }
                else if (key.EqualsIgnoreCase(UriParameters.Password))
                {
                    parameters.Password = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                }
                else if (!settinsManager.IsControlSetting(key))
                {
                    var values = queryString.GetValues(key);
                    if (values != null)
                    {
                        foreach (var value in values)
                        {
                            var realValue = isEncrypted ? SecurityUtil.Decrypt(value) : value;
                            var parsedKey = ParseKey(key);
                            var realKey = parsedKey.Item1;
                            var isVisible = parsedKey.Item2;

                            if (parameters.ReportParameters.ContainsKey(realKey))
                            {
                                parameters.ReportParameters[realKey].Values.Add(realValue);
                            }
                            else
                            {
                                var reportParameter = new ReportParameter(realKey) {Visible = isVisible};
                                reportParameter.Values.Add(realValue);
                                parameters.ReportParameters.Add(realKey, reportParameter);
                            }
                        }
                    }
                }
            }

            if (parameters.ProcessingMode == ProcessingMode.Remote
                && string.IsNullOrEmpty(parameters.ReportServerUrl))
            {
                throw new MvcReportViewerException("Report Server is not specified.");
            }

            if (string.IsNullOrEmpty(parameters.ReportPath))
            {
                throw new MvcReportViewerException("Report is not specified.");
            }

            return parameters;
        }
        public ReportViewerParameters Parse(NameValueCollection queryString)
        {
            if (queryString == null)
            {
                throw new ArgumentNullException("queryString");
            }

            var isEncrypted = CheckEncryption(ref queryString);

            var settinsManager = new ControlSettingsManager(isEncrypted);

            var parameters = InitializeDefaults();

            ResetDefaultCredentials(queryString, parameters);
            parameters.ControlSettings = settinsManager.Deserialize(queryString);

            foreach (var key in queryString.AllKeys)
            {
                var urlParam = queryString[key];
                if (key.EqualsIgnoreCase(UriParameters.ReportPath))
                {
                    parameters.ReportPath = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                }
                else if (key.EqualsIgnoreCase(UriParameters.ControlId))
                {
                    var parameter = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                    parameters.ControlId = Guid.Parse(parameter);
                }
                else if (key.EqualsIgnoreCase(UriParameters.ProcessingMode))
                {
                    var parameter = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                    parameters.ProcessingMode = (ProcessingMode)Enum.Parse(typeof(ProcessingMode), parameter);
                }
                else if (key.EqualsIgnoreCase(UriParameters.ReportServerUrl))
                {
                    parameters.ReportServerUrl = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                }
                else if (key.EqualsIgnoreCase(UriParameters.Username))
                {
                    parameters.Username = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                }
                else if (key.EqualsIgnoreCase(UriParameters.Password))
                {
                    parameters.Password = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                }
                else if (!settinsManager.IsControlSetting(key))
                {
                    var values = queryString.GetValues(key);
                    if (values != null)
                    {
                        foreach (var value in values)
                        {
                            var realValue = isEncrypted ? SecurityUtil.Decrypt(value) : value;
                            var parsedKey = ParseKey(key);
                            var realKey   = parsedKey.Item1;
                            var isVisible = parsedKey.Item2;

                            if (parameters.ReportParameters.ContainsKey(realKey))
                            {
                                parameters.ReportParameters[realKey].Values.Add(realValue);
                            }
                            else
                            {
                                var reportParameter = new ReportParameter(realKey);
                                reportParameter.Visible = isVisible;
                                reportParameter.Values.Add(realValue);
                                parameters.ReportParameters.Add(realKey, reportParameter);
                            }
                        }
                    }
                }
            }

            if (parameters.ProcessingMode == ProcessingMode.Remote &&
                string.IsNullOrEmpty(parameters.ReportServerUrl))
            {
                throw new MvcReportViewerException("Report Server is not specified.");
            }

            if (string.IsNullOrEmpty(parameters.ReportPath))
            {
                throw new MvcReportViewerException("Report is not specified.");
            }

            return(parameters);
        }
        public ReportViewerParameters Parse(NameValueCollection queryString)
        {
            if (queryString == null)
            {
                throw new ArgumentNullException("queryString");
            }

            var settinsManager = new ControlSettingsManager();

            var parameters = InitializeDefaults();
            ResetDefaultCredentials(queryString, parameters);
            parameters.ControlSettings = settinsManager.Deserialize(queryString);

            foreach (var key in queryString.AllKeys)
            {
                if (key.EqualsIgnoreCase(UriParameters.ReportPath))
                {
                    parameters.ReportPath = queryString[key];
                }
                else if (key.EqualsIgnoreCase(UriParameters.ReportServerUrl))
                {
                    parameters.ReportServerUrl = queryString[key];
                }
                else if (key.EqualsIgnoreCase(UriParameters.Username))
                {
                    parameters.Username = queryString[key];
                }
                else if (key.EqualsIgnoreCase(UriParameters.Password))
                {
                    parameters.Password = queryString[key];
                }
                else if (!settinsManager.IsControlSetting(key))
                {
                    var values = queryString.GetValues(key);
                    if (values != null)
                    {
                        foreach (var value in values)
                        {
                            if (parameters.ReportParameters.ContainsKey(key))
                            {
                                parameters.ReportParameters[key].Values.Add(value);
                            }
                            else
                            {
                                var reportParameter = new ReportParameter(key);
                                reportParameter.Values.Add(value);
                                parameters.ReportParameters.Add(key, reportParameter);
                            }
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(parameters.ReportServerUrl))
            {
                throw new MvcReportViewerException("Report Server is not specified.");
            }

            if (string.IsNullOrEmpty(parameters.ReportPath))
            {
                throw new MvcReportViewerException("Report is not specified.");
            }

            return parameters;
        }
        public ReportViewerParameters Parse(NameValueCollection queryString)
        {
            if (queryString == null)
            {
                throw new ArgumentNullException("queryString");
            }

            var isEncrypted = CheckEncryption(ref queryString);

            var settinsManager = new ControlSettingsManager(isEncrypted);

            var parameters = InitializeDefaults();
            //ResetDefaultCredentials(queryString, parameters);
            parameters.ControlSettings = settinsManager.Deserialize(queryString);

            foreach (var key in queryString.AllKeys)
            {
                var urlParam = queryString[key];

                if (key.EqualsIgnoreCase(UriParameters.ControlId))
                {
                    var parameter = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                    parameters.ControlId = Guid.Parse(parameter);
                }
                else if(key.EqualsIgnoreCase(UriParameters.ReportType))
                {
                    var parameter = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                    parameters.ReportLoaderType = int.Parse(parameter);
                }
                else if (key.EqualsIgnoreCase(UriParameters.ProcessingMode))
                {
                    var parameter = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                    parameters.ProcessingMode = (ProcessingMode)Enum.Parse(typeof(ProcessingMode), parameter);
                }
                else if (!settinsManager.IsControlSetting(key))
                {
                    if (key.StartsWith("_")) continue;

                    var values = queryString.GetValues(key);
                    if (values != null)
                    {
                        foreach (var value in values)
                        {
                            var realValue = isEncrypted ? SecurityUtil.Decrypt(value) : value;
                            var parsedKey = ParseKey(key);
                            var realKey = parsedKey.Item1;
                            var isVisible = parsedKey.Item2;

                            if (parameters.ReportParameters.ContainsKey(realKey))
                            {
                                parameters.ReportParameters[realKey].Values.Add(realValue);
                            }
                            else
                            {
                                var reportParameter = new ReportParameter(realKey);
                                reportParameter.Visible = isVisible;
                                reportParameter.Values.Add(realValue);
                                parameters.ReportParameters.Add(realKey, reportParameter);
                            }
                        }
                    }
                }
            }

            parameters.ReportLoader = ReportLoaderFactory.CreateByRequestData(parameters.ReportLoaderType, queryString, isEncrypted);

            //if (parameters.ProcessingMode == ProcessingMode.Remote
            //    && string.IsNullOrEmpty(parameters.ReportServerUrl))
            //{
            //    throw new MvcReportViewerException("Report Server is not specified.");
            //}

            //if (string.IsNullOrEmpty(parameters.MainReportResourceName) && string.IsNullOrEmpty(parameters.ReportPath))
            //{
            //    throw new MvcReportViewerException("Report is not specified.");
            //}

            return parameters;
        }
        public ReportViewerParameters Parse(NameValueCollection queryString)
        {
            if (queryString == null)
            {
                throw new ArgumentNullException("queryString");
            }

            var settinsManager = new ControlSettingsManager();

            var parameters = InitializeDefaults();

            ResetDefaultCredentials(queryString, parameters);
            parameters.ControlSettings = settinsManager.Deserialize(queryString);

            foreach (var key in queryString.AllKeys)
            {
                if (key.EqualsIgnoreCase(UriParameters.ReportPath))
                {
                    parameters.ReportPath = queryString[key];
                }
                else if (key.EqualsIgnoreCase(UriParameters.ReportServerUrl))
                {
                    parameters.ReportServerUrl = queryString[key];
                }
                else if (key.EqualsIgnoreCase(UriParameters.Username))
                {
                    parameters.Username = queryString[key];
                }
                else if (key.EqualsIgnoreCase(UriParameters.Password))
                {
                    parameters.Password = queryString[key];
                }
                else if (!settinsManager.IsControlSetting(key))
                {
                    var values = queryString.GetValues(key);
                    if (values != null)
                    {
                        foreach (var value in values)
                        {
                            if (parameters.ReportParameters.ContainsKey(key))
                            {
                                parameters.ReportParameters[key].Values.Add(value);
                            }
                            else
                            {
                                var reportParameter = new ReportParameter(key);
                                reportParameter.Values.Add(value);
                                parameters.ReportParameters.Add(key, reportParameter);
                            }
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(parameters.ReportServerUrl))
            {
                throw new MvcReportViewerException("Report Server is not specified.");
            }

            if (string.IsNullOrEmpty(parameters.ReportPath))
            {
                throw new MvcReportViewerException("Report is not specified.");
            }

            return(parameters);
        }
Exemple #6
0
        public ReportViewerParameters Parse(NameValueCollection queryString)
        {
            if (queryString == null)
            {
                throw new ArgumentNullException("queryString");
            }

            var isEncrypted = CheckEncryption(ref queryString);

            var settinsManager = new ControlSettingsManager(isEncrypted);

            var parameters = InitializeDefaults();

            ResetDefaultCredentials(queryString, parameters);
            parameters.ControlSettings = settinsManager.Deserialize(queryString);

            foreach (var key in queryString.AllKeys)
            {
                var urlParam = queryString[key];
                if (key.EqualsIgnoreCase(UriParameters.ReportPath))
                {
                    parameters.ReportPath = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                }
                else if (key.EqualsIgnoreCase(UriParameters.ReportServerUrl))
                {
                    parameters.ReportServerUrl = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                }
                else if (key.EqualsIgnoreCase(UriParameters.Username))
                {
                    parameters.Username = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                }
                else if (key.EqualsIgnoreCase(UriParameters.Password))
                {
                    parameters.Password = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                }
                else if (key.EqualsIgnoreCase(UriParameters.Local))
                {
                    var  isLocalStringValue = isEncrypted ? SecurityUtil.Decrypt(urlParam) : urlParam;
                    bool isLocalValue;
                    if (Boolean.TryParse(isLocalStringValue, out isLocalValue))
                    {
                        parameters.IsLocal = isLocalValue;
                    }
                }
                else if (!settinsManager.IsControlSetting(key))
                {
                    var values = queryString.GetValues(key);
                    if (values != null)
                    {
                        foreach (var value in values)
                        {
                            var realValue = isEncrypted ? SecurityUtil.Decrypt(value) : value;

                            if (parameters.ReportParameters.ContainsKey(key))
                            {
                                parameters.ReportParameters[key].Values.Add(realValue);
                            }
                            else
                            {
                                var reportParameter = new ReportParameter(key);
                                reportParameter.Values.Add(realValue);
                                parameters.ReportParameters.Add(key, reportParameter);
                            }
                        }
                    }
                }
            }

            if (string.IsNullOrEmpty(parameters.ReportServerUrl))
            {
                throw new MvcReportViewerException("Report Server is not specified.");
            }

            if (string.IsNullOrEmpty(parameters.ReportPath))
            {
                throw new MvcReportViewerException("Report is not specified.");
            }

            return(parameters);
        }