// Connects to the Qlik Sense server with the UserID and UserDirectory provided (Qlik Sense users)
        public void QSConnectServerHeader(string UserId, string HeaderAuthName, string VirtualProxyPath = "",
                                          Boolean UseSSL = false, Boolean CheckSDKVersion = true)
        {
            QSIsConnected = false;
            string strUri = qsServer;
            Uri    uri    = new Uri(strUri);

            qsLocation = Qlik.Engine.Location.FromUri(uri);
            if (VirtualProxyPath.Trim() != "")
            {
                qsLocation.VirtualProxyPath = VirtualProxyPath;
            }

            qsLocation.AsStaticHeaderUserViaProxy(UserId, HeaderAuthName, UseSSL);

            qsLocation.IsVersionCheckActive = CheckSDKVersion;
            IHub MyHub = qsLocation.Hub();

            QSUserId         = UserId;
            QSHeaderAuthName = HeaderAuthName;

            QSIsConnected = true;

            Console.WriteLine("QSEasy connected to Qlik Sense version: " + MyHub.ProductVersion());
            Console.WriteLine("UserID: " + UserId + " - VirtualProxy: " + VirtualProxyPath);
        }
 private void connectToolStripMenuItem_Click(object sender, EventArgs e)
 {
     using (var dialog = new ConnectDialog(_connectedServer, _connectedUser, _virtualProxy))
     {
         if (dialog.ShowDialog(this) == DialogResult.OK)
         {
             _connectedServer = dialog.ConnectedServer;
             _connectedUser   = dialog.ConnectedUser;
             _virtualProxy    = dialog.VirtualProxy;
             if (string.IsNullOrEmpty(_connectedServer) || _connectedServer == "local")
             {
                 CurrentLocation = Qlik.Engine.Location.FromUri(new Uri("ws://127.0.0.1:4848"));
                 CurrentLocation.AsDirectConnectionToPersonalEdition();
             }
             else
             {
                 CurrentLocation = Qlik.Engine.Location.FromUri(new Uri(_connectedServer));
                 if (string.IsNullOrEmpty(_connectedUser))
                 {
                     CurrentLocation.AsNtlmUserViaProxy();
                 }
                 else
                 {
                     CurrentLocation.AsStaticHeaderUserViaProxy(_connectedUser);
                 }
                 CurrentLocation.VirtualProxyPath = _virtualProxy;
             }
             Notify("Connected to " + CurrentLocation.ServerUri.OriginalString + CurrentLocation.VirtualProxyPath);
             SetModeToConencted();
         }
     }
 }
Esempio n. 3
0
        private static ILocation SetupConnection(Uri uri)
        {
            ILocation location = Qlik.Engine.Location.FromUri(uri);

            // Set the prefix for the virtual proxy.
            location.VirtualProxyPath = "static";

            // Defines the location as a static header connection via proxy. The headerUserId contains the user and headerAuthenticationHeaderName contains the session cookie header name.
            location.AsStaticHeaderUserViaProxy(headerUserId: "myUser", headerAuthenticationHeaderName: "X-Qlik-HeaderAuth");

            return(location);
        }
Esempio n. 4
0
        private static void Main(string[] args)
        {
            //////Setup
            var           options = new Options();
            Uri           serverURL;
            string        appname;
            bool          openSheets;
            QlikSelection mySelection = null;

            //// process the parameters using the https://commandline.codeplex.com/
            if (CommandLine.Parser.Default.ParseArguments(args, options))
            {
                serverURL  = new Uri(options.server);
                appname    = options.appname;
                openSheets = options.fetchobjects;
                if (options.selectionfield != null)
                {
                    mySelection             = new QlikSelection();
                    mySelection.fieldname   = options.selectionfield;
                    mySelection.fieldvalues = options.selectionvalues.Split(',');
                }
                //TODO need to validate the params ideally
            }
            else
            {
                throw new Exception("Check parameters are correct");
            }
            Print($"{nameof(options.server)}:{options.server}");
            Print($"{nameof(options.appname)}:{options.appname}");
            Print($"{nameof(options.usingProxy)}:{options.usingProxy}");
            Print($"{nameof(options.User)}:{options.User}");
            Print($"{ nameof(options.fetchobjects)}:{options.fetchobjects}");

            ////connect to the server (using windows credentials
            QlikConnection.Timeout = int.MaxValue;
            var       d = DateTime.Now;
            ILocation remoteQlikSenseLocation = Qlik.Engine.Location.FromUri(serverURL);
            var       isHTTPs = serverURL.Scheme == Uri.UriSchemeHttps;

            if ((!string.IsNullOrWhiteSpace(options.User)) && (!string.IsNullOrWhiteSpace(options.staticHeader)))
            {
                remoteQlikSenseLocation.VirtualProxyPath = options.usingProxy;
                remoteQlikSenseLocation.AsStaticHeaderUserViaProxy(options.User, options.staticHeader, isHTTPs);
            }
            else if (!string.IsNullOrWhiteSpace(options.usingProxy))
            {
                remoteQlikSenseLocation.VirtualProxyPath = options.usingProxy;
                remoteQlikSenseLocation.AsNtlmUserViaProxy(isHTTPs);
            }
            else if ((!string.IsNullOrWhiteSpace(options.User)) && !string.IsNullOrWhiteSpace(options.Directory) && options.directConnection)
            {
                remoteQlikSenseLocation.AsDirectConnection(options.Directory, options.User);
            }
            else
            {
                remoteQlikSenseLocation.AsNtlmUserViaProxy(isHTTPs);
            }


            ////Start to cache the apps
            if (appname != null)
            {
                //Open up and cache one app
                IAppIdentifier appidentifier = remoteQlikSenseLocation.AppWithNameOrDefault(appname, false);

                LoadCache(remoteQlikSenseLocation, appidentifier, openSheets, mySelection);
            }
            else
            {
                //Get all apps, open them up and cache them
                remoteQlikSenseLocation.GetAppIdentifiers(true)
                .ToList()
                .ForEach(id => LoadCache(remoteQlikSenseLocation, id, openSheets, null));
            }

            ////Wrap it up
            var dt = DateTime.Now - d;

            Print("Cache initialization complete. Total time: {0}", dt.ToString());

            //Console.ReadKey();
        }