示例#1
0
        private string PrepareViewerUri()
        {
            var query = HttpUtility.ParseQueryString(string.Empty);

            query[UriParameters.ControlId]      = ControlId.ToString();
            query[UriParameters.ProcessingMode] = _processingMode.ToString();
            if (!string.IsNullOrEmpty(_reportPath))
            {
                query[UriParameters.ReportPath] = _reportPath;
            }

            if (!string.IsNullOrEmpty(_reportServerUrl))
            {
                query[UriParameters.ReportServerUrl] = _reportServerUrl;
            }

            if (!string.IsNullOrEmpty(_username) || !string.IsNullOrEmpty(_password))
            {
                query[UriParameters.Username] = _username;
                query[UriParameters.Password] = _password;
            }

            var serializedSettings = _settingsManager.Serialize(_controlSettings);

            foreach (var setting in serializedSettings)
            {
                query[setting.Key] = setting.Value;
            }

            if (_reportParameters != null)
            {
                foreach (var parameter in _reportParameters)
                {
                    if (parameter.Value == null)
                    {
                        continue;
                    }

                    var value = parameter.Value.ToString();
                    query.Add(parameter.Key, value);
                }
            }

            string uri = _aspxViewer;

            if (query.Count == 0)
            {
                return(uri);
            }

            if (!_encryptParameters)
            {
                return(uri + "?" + query);
            }

            var encryptedQuery = UriParameters.Encrypted + "=" + SecurityUtil.Encrypt(query.ToString());

            return(uri + "?" + encryptedQuery);
        }
示例#2
0
        private string CreateHiddenField <T>(string name, T value)
        {
            var tag = new TagBuilder("input");

            tag.MergeAttribute("type", "hidden");
            tag.MergeAttribute("name", name);

            var strValue = value.ToString();

            if (_encryptParameters)
            {
                strValue = SecurityUtil.Encrypt(strValue);
            }

            tag.MergeAttribute("value", strValue);

            return(tag.ToString());
        }
        private string PrepareViewerUri()
        {
            var query = HttpUtility.ParseQueryString(string.Empty);

            query[UriParameters.ControlId]      = ControlId.ToString();
            query[UriParameters.ProcessingMode] = _processingMode.ToString();
            if (!string.IsNullOrEmpty(_reportPath))
            {
                query[UriParameters.ReportPath] = _reportPath;
            }

            if (!string.IsNullOrEmpty(_reportServerUrl))
            {
                query[UriParameters.ReportServerUrl] = _reportServerUrl;
            }

            if (!string.IsNullOrEmpty(_username) || !string.IsNullOrEmpty(_password))
            {
                query[UriParameters.Username] = _username;
                query[UriParameters.Password] = _password;
            }

            if (!string.IsNullOrEmpty(_eventsHandlerType))
            {
                query[UriParameters.EventsHandlerType] = _eventsHandlerType;
            }

            if (_dataSourceCredentials?.Length > 0)
            {
                query[UriParameters.DataSourceCredentials] = JsonConvert.SerializeObject(_dataSourceCredentials);
            }

            var frameHeight = GetFrameHeight();

            if (frameHeight != null)
            {
                if (_controlSettings == null)
                {
                    _controlSettings = new ControlSettings();
                }

                _controlSettings.FrameHeight = new Unit(frameHeight.Item1, frameHeight.Item2);
            }

            var serializedSettings = _settingsManager.Serialize(_controlSettings);

            foreach (var setting in serializedSettings)
            {
                query[setting.Key] = setting.Value;
            }

            if (_reportParameters != null)
            {
                foreach (var parameter in _reportParameters)
                {
                    if (parameter.Value == null)
                    {
                        continue;
                    }

                    var multiple = parameter.Value as IEnumerable;
                    if (parameter.Value is string || multiple == null)
                    {
                        var value = ConvertValueToString(parameter.Value);
                        query.Add(parameter.Key, value);
                    }
                    else
                    {
                        foreach (var v in multiple)
                        {
                            var value = ConvertValueToString(v);
                            query.Add(parameter.Key, value);
                        }
                    }
                }
            }

            string uri = _aspxViewer;

            if (query.Count == 0)
            {
                return(uri);
            }

            if (!_encryptParameters)
            {
                return(uri + "?" + query);
            }

            var encryptedQuery = UriParameters.Encrypted + "=" + SecurityUtil.Encrypt(query.ToString());

            return(uri + "?" + encryptedQuery);
        }