Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Binary file added .vs/CacheInitializer/v14/.suo
Binary file not shown.
4 changes: 2 additions & 2 deletions CacheInitializer/CacheInitializer.csproj
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,10 @@
<PropertyGroup />
<ItemGroup>
<Reference Include="Autofac">
<HintPath>..\packages\Autofac.3.5.0\lib\net40\Autofac.dll</HintPath>
<HintPath>..\..\..\..\..\..\LaptopData\Laptop\Benutzer\RVA\Documents\Beispiele\qliksense\cache initializer joe bickley\QlikSense.NetSDK3.0.1.0\autofac.dll</HintPath>
</Reference>
<Reference Include="BouncyCastle.CryptoExt">
<HintPath>..\packages\QlikSense.NetSDK.2.2.3.0\lib\net452\BouncyCastle.CryptoExt.dll</HintPath>
<HintPath>..\..\..\..\..\..\LaptopData\Laptop\Benutzer\RVA\Documents\Beispiele\qliksense\cache initializer joe bickley\QlikSense.NetSDK3.0.1.0\BouncyCastle.CryptoExt.dll</HintPath>
</Reference>
<Reference Include="CommandLine">
<HintPath>..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll</HintPath>
Expand Down
6 changes: 5 additions & 1 deletion CacheInitializer/ParamHandler.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
Expand All @@ -20,6 +20,10 @@ class Options
HelpText = "App to load")]
public string appname { get; set; }

[Option('p', "appname", Required = false,
HelpText = "Virtual Proxy to use")]
public string virtualProxy { get; set; }

[Option('o', "objects", Required = false, DefaultValue = false,
HelpText = "cycle through all sheets and objects")]
public bool fetchobjects { get; set; }
Expand Down
115 changes: 60 additions & 55 deletions CacheInitializer/Program.cs
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
using System;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
Expand All @@ -7,17 +7,17 @@
using Qlik.Sense.Client;

// Title: Qlik Sense Cache Initializer
// Date: Feb 2015
// Version: 0.1
// Author: Joe Bickley
// Date: 19.08.2016
// Version: 0.11
// Author: Joe Bickley,Roland Vecera
// Summary: This tool will "warm" the cache of a Qlik Sense server so that when using large apps the users get good performance right away.
// You can use it to load all apps, a single app, and you can get it to just open the app to RAM or cycle through all the objects
// so that it will pre calculate expressions so users get rapid performance. You can also pass in selections too.
// Credits: Thanks to Øystein Kolsrud for helping with the Qlik Sense .net SDK steps
// Uses the commandline.codeplex.com for processing parameters


// Usage: cacheinitiazer.exe -s https://server.domain.com [-a appname] [-o] [-f fieldname] [-v "value 1,value 2"]
// Usage: cacheinitiazer.exe -s https://server.domain.com [-a appname] [-o] [-f fieldname] [-v "value 1,value 2"] [-p virtualproxyprefix]
// Notes: This projects use the Qlik Sense .net SDK, you must use the right version of the SDK to match the server you are connecting too.
// To swap version simply replace the .net SDK files in the BIN directory of this project, if you dont match them, it wont work!

Expand All @@ -27,73 +27,78 @@ namespace CacheInitializer
class Program
{

static void Main(string[] args)
static void Main(string[] args)
{

//////Setup
Options options = new Options();
Uri serverURL;
string appname;
bool openSheets;
QlikSelection mySelection = null;
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;
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
if (CommandLine.Parser.Default.ParseArguments(args, options))
{
serverURL = new Uri(options.server);
appname = options.appname;
virtualProxy = (options.virtualProxy.Length > 0) ? options.virtualProxy : "" ;
openSheets = options.fetchobjects;
if (options.selectionfield != null)
{
throw new Exception("Check parameters are correct");
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);
bool isHTTPs = false;
if (serverURL.Scheme == Uri.UriSchemeHttps) isHTTPs = true;
remoteQlikSenseLocation.AsNtlmUserViaProxy(isHTTPs);
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);
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));
}
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());
var dt = DateTime.Now - d;
Print("Cache initialization complete. Total time: {0}", dt.ToString());

Console.ReadKey();

}

static void LoadCache(ILocation location, IAppIdentifier id, bool opensheets, QlikSelection Selections)
static void LoadCache(ILocation location, IAppIdentifier id, bool opensheets, QlikSelection Selections)
{
//open up the app
Print("{0}: Opening app", id.AppName);
IApp app = location.App(id);
Print("{0}: App open", id.AppName);
Print("{0}: Opening app", id.AppName);
IApp app = location.App(id);
Print("{0}: App open", id.AppName);

//see if we are going to open the sheets too
if (opensheets)
Expand Down Expand Up @@ -162,10 +167,10 @@ private static void Print(string txt, params object[] os)

}

class QlikSelection
{
public string fieldname { get; set; }
public string[] fieldvalues { get; set;}
}
class QlikSelection
{
public string fieldname { get; set; }
public string[] fieldvalues { get; set; }
}

}
10 changes: 5 additions & 5 deletions README.md
Original file line number Diff line number Diff line change
@@ -1,14 +1,14 @@
# Qlik Sense Cache Initializer
Date: Feb 2015
Date: Aug 2016

Version: 0.1
Version: 0.11

Author: Joe Bickley
Author: Joe Bickley, Roland Vecera

Summary: This tool will "warm" the cache of a Qlik Sense server so that when using large apps the users get good performance right away. You can use it to load all apps, a single app, and you can get it to just open the app to RAM or cycle through all the objects so that it will pre calculate expressions so users get rapid performance. You can also pass in selections too.

Credits: Thanks to �ystein Kolsrud for helping with the Qlik Sense .net SDK steps. Uses the commandline.codeplex.com for processing parameters
Credits: Thanks to Øystein Kolsrud for helping with the Qlik Sense .net SDK steps. Uses the commandline.codeplex.com for processing parameters

Usage: cacheinitiazer.exe -s https://server.domain.com [-a appname] [-o] [-f fieldname] [-v "value 1,value 2"]
Usage: cacheinitiazer.exe -s https://server.domain.com [-a appname] [-o] [-f fieldname] [-v "value 1,value 2"] [-p virtualproxyprefix]

Notes: This projects use the Qlik Sense .net SDK, you must use the right version of the SDK to match the server you are connecting too. To swap version simply replace the .net SDK files in the BIN directory of this project, if you dont match them, it wont work.