コード例 #1
0
 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();
         }
     }
 }
コード例 #2
0
        public List<string> GetFieldValues(app app, IAppField appField2)
        {
            List<string> strValues = new List<string>();

            Uri uri = new Uri(url + ":443");
            ILocation remoteQlikSenseLocation = Qlik.Engine.Location.FromUri(uri);
            remoteQlikSenseLocation.AsNtlmUserViaProxy();

            IAppIdentifier appidentifier = remoteQlikSenseLocation.AppWithId(app.ID);
            using (var doc = remoteQlikSenseLocation.App(appidentifier))
            {
                var field = doc.GetAppField(appField2.DimensionInfo.FallbackTitle);

                var p = new List<NxPage> { new NxPage { Height = 20, Width = 1 } };
                var dataPages = field.GetData(p);
                foreach (var dataPage in dataPages)
                {
                    var matrix = dataPage.Matrix;
                    foreach (var cellRows in matrix)
                    {
                        foreach (var cellRow in cellRows)
                        {
                            strValues.Add(cellRow.Text);
                            //Console.WriteLine("## " + cellRow.Text + " - " + cellRow.State);
                        }
                    }
                }

            }
            return strValues;
        }
コード例 #3
0
        private static ILocation SetupConnection(Uri uri)
        {
            ILocation location = Qlik.Engine.Location.FromUri(uri);

            // Defines the location as NTLM via proxy. The default value for proxyUsesSsl is true. Must be set to false if the connection uses http.
            location.AsNtlmUserViaProxy(proxyUsesSsl: true);
            return(location);
        }
コード例 #4
0
 private IApp GetAppHandle(string appid)
 {
     Uri uri = new Uri(url + ":443");
     ILocation remoteQlikSenseLocation = Qlik.Engine.Location.FromUri(uri);
     remoteQlikSenseLocation.AsNtlmUserViaProxy();
     IAppIdentifier appidentifier = remoteQlikSenseLocation.AppWithId(appid);
     return remoteQlikSenseLocation.App(appidentifier);
 }
コード例 #5
0
        public static void Main(string[] args)
        {
            try
            {
                //http://stackoverflow.com/questions/9021414/dynamic-impersonation-in-asp-net
                if (Impersonation.impersonateValidUser(_user, _domain, _password))
                {
                    _qlikSenseServer = Qlik.Engine.Location.FromUri(new Uri(_serverAddress));
                    _qlikSenseServer.AsNtlmUserViaProxy();

                    Console.WriteLine("Press any key to quit.");                     // Wait for the user to quit the program.

                    SetupFileWatcherAndEnqueueExistingFiles();

                    bool doWork = true;
                    while (doWork)
                    {
                        string app;
                        if (ReloadTasks.TryDequeue(out app))
                        {
                            if (app == null)                             // Check if there is any app to reload.
                            {
                                continue;
                            }

                            var appId = _qlikSenseServer.AppWithNameOrDefault(app, noVersionCheck: true);
                            if (appId != null)
                            {
                                Task task = ReloadApplicationTask(appId); // No wait or cancelation implementet
                            }
                            File.Delete(app);                             // The file has been processed we can now delete it.
                        }
                        doWork = DoSomeIdleWorkAndKeepTheSessionAlive();
                    }                     // end while
                }
            }
            catch (Exception e)
            {
                var errMsg = e.InnerException != null ? " inner exception: " + e.InnerException.Message : string.Empty;
                Console.WriteLine("Unhandled exception " + e.Message + errMsg);
            }
        }
コード例 #6
0
        private static void DoWork(Options options)
        {
            Uri           serverURL;
            string        appname;
            string        appid;
            bool          openSheets;
            string        virtualProxy;
            QlikSelection mySelection = null;

            ILocation remoteQlikSenseLocation = null;

            try
            {
                if (options.Debug)
                {
                    DEBUG_MODE = true;
                    Print(LogLevel.Debug, "Debug logging enabled.");
                }
                Print(LogLevel.Debug, "setting parameter values in main");
                serverURL    = new Uri(options.Server);
                appname      = options.AppName;
                appid        = options.AppID;
                virtualProxy = !string.IsNullOrEmpty(options.VirtualProxy) ? options.VirtualProxy : "";
                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

                Print(LogLevel.Debug, "setting remoteQlikSenseLocation");;

                ////connect to the server (using windows credentials
                QlikConnection.Timeout = Int32.MaxValue;
                var d = DateTime.Now;

                remoteQlikSenseLocation = Qlik.Engine.Location.FromUri(serverURL);


                Print(LogLevel.Debug, "validating http(s) and virtual proxy");;
                if (virtualProxy.Length > 0)
                {
                    remoteQlikSenseLocation.VirtualProxyPath = virtualProxy;
                }
                bool isHTTPs = false;
                if (serverURL.Scheme == Uri.UriSchemeHttps)
                {
                    isHTTPs = true;
                }
                remoteQlikSenseLocation.AsNtlmUserViaProxy(isHTTPs, null, false);

                Print(LogLevel.Debug, "starting to cache applications");
                ////Start to cache the apps
                IAppIdentifier appIdentifier = null;

                if (appid != null)
                {
                    //Open up and cache one app, based on app ID
                    appIdentifier = remoteQlikSenseLocation.AppWithId(appid);
                    Print(LogLevel.Debug, "got app identifier by ID");
                    LoadCache(remoteQlikSenseLocation, appIdentifier, openSheets, mySelection);
                    Print(LogLevel.Debug, "finished caching by ID");
                }
                else
                {
                    if (appname != null)
                    {
                        //Open up and cache one app
                        appIdentifier = remoteQlikSenseLocation.AppWithNameOrDefault(appname);
                        Print(LogLevel.Debug, "got app identifier by name");
                        LoadCache(remoteQlikSenseLocation, appIdentifier, openSheets, mySelection);
                        Print(LogLevel.Debug, "finished caching by name");
                    }
                    else
                    {
                        //Get all apps, open them up and cache them
                        remoteQlikSenseLocation.GetAppIdentifiers().ToList().ForEach(id => LoadCache(remoteQlikSenseLocation, id, openSheets, null));
                        Print(LogLevel.Debug, "finished caching all applications");
                    }
                }


                ////Wrap it up
                var dt = DateTime.Now - d;
                Print(LogLevel.Info, "Cache initialization complete. Total time: {0}", dt.ToString());
                remoteQlikSenseLocation.Dispose();
                Print(LogLevel.Debug, "done");

                return;
            }
            catch (UriFormatException)
            {
                Print(LogLevel.Info, "Invalid server paramater format. Format must be http[s]://host.domain.tld.");
                return;
            }
            catch (WebSocketException webEx)
            {
                if (remoteQlikSenseLocation != null)
                {
                    Print(LogLevel.Info, "Disposing remoteQlikSenseLocation");
                    remoteQlikSenseLocation.Dispose();
                }

                Print(LogLevel.Info, "Unable to connect to establish WebSocket connection with: " + options.Server);
                Print(LogLevel.Info, "Error: " + webEx.Message);

                return;
            }
            catch (TimeoutException timeoutEx)
            {
                Print(LogLevel.Info, "Timeout Exception - Unable to connect to: " + options.Server);
                Print(LogLevel.Info, "Error: " + timeoutEx.Message);

                return;
            }
            catch (Exception ex)
            {
                if (ex.Message.Trim() == "Websocket closed unexpectedly (EndpointUnavailable):")
                {
                    Print(LogLevel.Info, "Error: licenses exhausted.");
                    return;
                }
                else
                {
                    Print(LogLevel.Info, "Unexpected error.");
                    Print(LogLevel.Info, "Message: " + ex.Message);

                    return;
                }
            }
        }
コード例 #7
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();
        }
コード例 #8
0
ファイル: Program.cs プロジェクト: steveoams/CacheInitializer
        static void Main(string[] args)
        {
            //////Setup
            Options       options = new Options();
            Uri           serverURL;
            string        appname;
            bool          openSheets;
            string        virtualProxy;
            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;
                virtualProxy = !string.IsNullOrEmpty(options.virtualProxy) ? options.virtualProxy : "";
                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");
            }


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

            if (virtualProxy.Length > 0)
            {
                remoteQlikSenseLocation.VirtualProxyPath = virtualProxy;
            }
            bool isHTTPs = false;

            if (serverURL.Scheme == Uri.UriSchemeHttps)
            {
                isHTTPs = true;
            }
            remoteQlikSenseLocation.AsNtlmUserViaProxy(isHTTPs, null, false);


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

                LoadCache(remoteQlikSenseLocation, appidentifier, openSheets, mySelection);
            }
            else
            {
                //Get all apps, open them up and cache them
                remoteQlikSenseLocation.GetAppIdentifiers().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());
        }