コード例 #1
0
        public TicketResponse GetTicket(TicketRequest request, TicketConfiguration config)
        {
            if (String.IsNullOrEmpty(request.UserId))
            {
                ErrorMessage = "No userid defined";
                return(this);
            }

            string groups = request.Groups != null && request.Groups.Length > 0 ? GetGroups(request.Groups) : "";

            string webTicketXml = string.Format("<Global method=\"GetWebTicket\"><UserId>{0}</UserId>{1}</Global>", request.UserId, groups);

            var ticket = Execute(config, webTicketXml);

            if (ticket != null && ticket.Contains("Invalid call"))
            {
                ErrorMessage = ticket;
            }

            if (!String.IsNullOrEmpty(ErrorMessage))
            {
                return(this);
            }

            Ticket = ticket;

            var backUrl = config.BackUrl != null?config.BackUrl.ToString() : "";

            if (String.IsNullOrEmpty(config.Document))
            {
                RedirectUri = string.Format("{0}QvAJAXZfc/Authenticate.aspx?type=html&webticket={1}&try={2}&back={3}", config.AccessPointUri, Ticket, Uri.EscapeUriString(config.TryUri.ToString()), Uri.EscapeUriString(backUrl));
            }
            else
            {
                if (String.IsNullOrEmpty(config.QvsHost))
                {
                    ErrorMessage = "QvsHost parameter is required";
                    return(this);
                }

                var selections = "";
                if (config.Select != null && config.Select.Count > 0)
                {
                    selections = GetSelections(config.Select);
                }

                RedirectUri = string.Format("{0}QvAJAXZfc/Authenticate.aspx?type=html&webticket={1}&try={2}&back={3}", config.AccessPointUri, Ticket, Uri.EscapeDataString(config.AccessPointUri + "QvAJAXZfc/AccessPoint.aspx?open=&id=" + config.QvsHost + "%7C" + config.Document) + selections + "&client=Ajax", backUrl);
            }

            return(this);
        }
コード例 #2
0
        public TicketResponse GetTicket(TicketRequest request, TicketConfiguration config)
        {
            if (String.IsNullOrEmpty(request.UserId))
            {
                ErrorMessage = "No userid defined";
                return this;
            }

            string groups = request.Groups != null && request.Groups.Length > 0 ? GetGroups(request.Groups) : "";

            string webTicketXml = string.Format("<Global method=\"GetWebTicket\"><UserId>{0}</UserId>{1}</Global>", request.UserId, groups);

            var ticket = Execute(config, webTicketXml);

            if (ticket != null && ticket.Contains("Invalid call"))
                ErrorMessage = ticket;

            if (!String.IsNullOrEmpty(ErrorMessage))
                return this;

            Ticket = ticket;

            var backUrl = config.BackUrl != null ? config.BackUrl.ToString() : "";

            if (String.IsNullOrEmpty(config.Document))
                RedirectUri = string.Format("{0}QvAJAXZfc/Authenticate.aspx?type=html&webticket={1}&try={2}&back={3}", config.AccessPointUri, Ticket, Uri.EscapeUriString(config.TryUri.ToString()), Uri.EscapeUriString(backUrl));
            else
            {
                if (String.IsNullOrEmpty(config.QvsHost))
                {
                    ErrorMessage = "QvsHost parameter is required";
                    return this;
                }

                var selections = "";
                if (config.Select != null && config.Select.Count > 0)
                    selections = GetSelections(config.Select);

                RedirectUri = string.Format("{0}QvAJAXZfc/Authenticate.aspx?type=html&webticket={1}&try={2}&back={3}", config.AccessPointUri, Ticket, Uri.EscapeDataString(config.AccessPointUri + "QvAJAXZfc/AccessPoint.aspx?open=&id=" + config.QvsHost + "%7C" + config.Document) + selections + "&client=Ajax", backUrl);
            }

            return this;
        }
コード例 #3
0
ファイル: Default.aspx.cs プロジェクト: braathen/qv-webticket
        protected void Page_Load(object sender, EventArgs e)
        {
            // Define some configuration options for the QlikView Server
            TicketConfiguration config = new TicketConfiguration()
            {
                GetWebTicketUri = new Uri("http://localhost/QvAJAXZfc/GetWebTicket.aspx")
            };

            // Create a ticket request with userid and groups (semicolon separated)
            TicketRequest request = new TicketRequest()
            {
                UserId = "rikard",
                Groups = new string[] { "PreSales", "Stockholm" }
            };
            
            // The response will contain the generated ticket, a redirect uri and possible error message
            TicketResponse response = new TicketResponse().GetTicket(request, config);

            if (response.ErrorMessage == null)
                Response.Redirect(response.RedirectUri, true);
            else
                Response.Write("Error: " + response.ErrorMessage);
        }