Skip to content
This repository was archived by the owner on Jan 3, 2023. It is now read-only.

Commit a793a69

Browse files
author
Joe Bickley
authored
Merge pull request #2 from rvaheldendaten/master
Support for virtual proxies
2 parents 5f77fe8 + 12be5bb commit a793a69

File tree

5 files changed

+72
-63
lines changed

5 files changed

+72
-63
lines changed

.vs/CacheInitializer/v14/.suo

23.5 KB
Binary file not shown.

CacheInitializer/CacheInitializer.csproj

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -35,10 +35,10 @@
3535
<PropertyGroup />
3636
<ItemGroup>
3737
<Reference Include="Autofac">
38-
<HintPath>..\packages\Autofac.3.5.0\lib\net40\Autofac.dll</HintPath>
38+
<HintPath>..\..\..\..\..\..\LaptopData\Laptop\Benutzer\RVA\Documents\Beispiele\qliksense\cache initializer joe bickley\QlikSense.NetSDK3.0.1.0\autofac.dll</HintPath>
3939
</Reference>
4040
<Reference Include="BouncyCastle.CryptoExt">
41-
<HintPath>..\packages\QlikSense.NetSDK.2.2.3.0\lib\net452\BouncyCastle.CryptoExt.dll</HintPath>
41+
<HintPath>..\..\..\..\..\..\LaptopData\Laptop\Benutzer\RVA\Documents\Beispiele\qliksense\cache initializer joe bickley\QlikSense.NetSDK3.0.1.0\BouncyCastle.CryptoExt.dll</HintPath>
4242
</Reference>
4343
<Reference Include="CommandLine">
4444
<HintPath>..\packages\CommandLineParser.1.9.71\lib\net45\CommandLine.dll</HintPath>

CacheInitializer/ParamHandler.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Text;
@@ -20,6 +20,10 @@ class Options
2020
HelpText = "App to load")]
2121
public string appname { get; set; }
2222

23+
[Option('p', "appname", Required = false,
24+
HelpText = "Virtual Proxy to use")]
25+
public string virtualProxy { get; set; }
26+
2327
[Option('o', "objects", Required = false, DefaultValue = false,
2428
HelpText = "cycle through all sheets and objects")]
2529
public bool fetchobjects { get; set; }

CacheInitializer/Program.cs

Lines changed: 60 additions & 55 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
using System;
1+
using System;
22
using System.Collections.Generic;
33
using System.Linq;
44
using System.Threading.Tasks;
@@ -7,17 +7,17 @@
77
using Qlik.Sense.Client;
88

99
// Title: Qlik Sense Cache Initializer
10-
// Date: Feb 2015
11-
// Version: 0.1
12-
// Author: Joe Bickley
10+
// Date: 19.08.2016
11+
// Version: 0.11
12+
// Author: Joe Bickley,Roland Vecera
1313
// 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.
1414
// 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
1515
// so that it will pre calculate expressions so users get rapid performance. You can also pass in selections too.
1616
// Credits: Thanks to Øystein Kolsrud for helping with the Qlik Sense .net SDK steps
1717
// Uses the commandline.codeplex.com for processing parameters
1818

1919

20-
// Usage: cacheinitiazer.exe -s https://server.domain.com [-a appname] [-o] [-f fieldname] [-v "value 1,value 2"]
20+
// Usage: cacheinitiazer.exe -s https://server.domain.com [-a appname] [-o] [-f fieldname] [-v "value 1,value 2"] [-p virtualproxyprefix]
2121
// 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.
2222
// To swap version simply replace the .net SDK files in the BIN directory of this project, if you dont match them, it wont work!
2323

@@ -27,73 +27,78 @@ namespace CacheInitializer
2727
class Program
2828
{
2929

30-
static void Main(string[] args)
30+
static void Main(string[] args)
3131
{
3232

3333
//////Setup
34-
Options options = new Options();
35-
Uri serverURL;
36-
string appname;
37-
bool openSheets;
38-
QlikSelection mySelection = null;
34+
Options options = new Options();
35+
Uri serverURL;
36+
string appname;
37+
bool openSheets;
38+
string virtualProxy;
39+
QlikSelection mySelection = null;
3940

4041
//// process the parameters using the https://commandline.codeplex.com/
41-
if (CommandLine.Parser.Default.ParseArguments(args, options))
42-
{
43-
serverURL = new Uri(options.server);
44-
appname = options.appname;
45-
openSheets = options.fetchobjects;
46-
if(options.selectionfield != null)
47-
{
48-
mySelection = new QlikSelection();
49-
mySelection.fieldname = options.selectionfield;
50-
mySelection.fieldvalues = options.selectionvalues.Split(',');
51-
}
52-
//TODO need to validate the params ideally
53-
}
54-
else
42+
if (CommandLine.Parser.Default.ParseArguments(args, options))
43+
{
44+
serverURL = new Uri(options.server);
45+
appname = options.appname;
46+
virtualProxy = (options.virtualProxy.Length > 0) ? options.virtualProxy : "" ;
47+
openSheets = options.fetchobjects;
48+
if (options.selectionfield != null)
5549
{
56-
throw new Exception("Check parameters are correct");
50+
mySelection = new QlikSelection();
51+
mySelection.fieldname = options.selectionfield;
52+
mySelection.fieldvalues = options.selectionvalues.Split(',');
5753
}
54+
//TODO need to validate the params ideally
55+
}
56+
else
57+
{
58+
throw new Exception("Check parameters are correct");
59+
}
5860

5961

6062
////connect to the server (using windows credentials
61-
QlikConnection.Timeout = Int32.MaxValue;
62-
var d = DateTime.Now;
63-
ILocation remoteQlikSenseLocation = Qlik.Engine.Location.FromUri(serverURL);
64-
bool isHTTPs = false;
65-
if (serverURL.Scheme == Uri.UriSchemeHttps) isHTTPs = true;
66-
remoteQlikSenseLocation.AsNtlmUserViaProxy(isHTTPs);
63+
QlikConnection.Timeout = Int32.MaxValue;
64+
var d = DateTime.Now;
65+
ILocation remoteQlikSenseLocation = Qlik.Engine.Location.FromUri(serverURL);
66+
if (virtualProxy.Length > 0)
67+
{
68+
remoteQlikSenseLocation.VirtualProxyPath = virtualProxy;
69+
}
70+
bool isHTTPs = false;
71+
if (serverURL.Scheme == Uri.UriSchemeHttps) isHTTPs = true;
72+
remoteQlikSenseLocation.AsNtlmUserViaProxy(isHTTPs,null,false);
6773

6874

6975
////Start to cache the apps
70-
if (appname != null)
71-
{
72-
//Open up and cache one app
73-
IAppIdentifier appidentifier = remoteQlikSenseLocation.AppWithNameOrDefault(appname);
76+
if (appname != null)
77+
{
78+
//Open up and cache one app
79+
IAppIdentifier appidentifier = remoteQlikSenseLocation.AppWithNameOrDefault(appname);
7480

75-
LoadCache(remoteQlikSenseLocation, appidentifier, openSheets, mySelection);
76-
}
77-
else
78-
{
79-
//Get all apps, open them up and cache them
80-
remoteQlikSenseLocation.GetAppIdentifiers().ToList().ForEach(id => LoadCache(remoteQlikSenseLocation, id, openSheets, null));
81-
}
81+
LoadCache(remoteQlikSenseLocation, appidentifier, openSheets, mySelection);
82+
}
83+
else
84+
{
85+
//Get all apps, open them up and cache them
86+
remoteQlikSenseLocation.GetAppIdentifiers().ToList().ForEach(id => LoadCache(remoteQlikSenseLocation, id, openSheets, null));
87+
}
8288

8389
////Wrap it up
84-
var dt = DateTime.Now - d;
85-
Print("Cache initialization complete. Total time: {0}", dt.ToString());
90+
var dt = DateTime.Now - d;
91+
Print("Cache initialization complete. Total time: {0}", dt.ToString());
8692

87-
Console.ReadKey();
8893

8994
}
9095

91-
static void LoadCache(ILocation location, IAppIdentifier id, bool opensheets, QlikSelection Selections)
96+
static void LoadCache(ILocation location, IAppIdentifier id, bool opensheets, QlikSelection Selections)
9297
{
9398
//open up the app
94-
Print("{0}: Opening app", id.AppName);
95-
IApp app = location.App(id);
96-
Print("{0}: App open", id.AppName);
99+
Print("{0}: Opening app", id.AppName);
100+
IApp app = location.App(id);
101+
Print("{0}: App open", id.AppName);
97102

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

163168
}
164169

165-
class QlikSelection
166-
{
167-
public string fieldname { get; set; }
168-
public string[] fieldvalues { get; set;}
169-
}
170+
class QlikSelection
171+
{
172+
public string fieldname { get; set; }
173+
public string[] fieldvalues { get; set; }
174+
}
170175

171176
}

README.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,14 @@
11
# Qlik Sense Cache Initializer
2-
Date: Feb 2015
2+
Date: Aug 2016
33

4-
Version: 0.1
4+
Version: 0.11
55

6-
Author: Joe Bickley
6+
Author: Joe Bickley, Roland Vecera
77

88
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.
99

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

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

1414
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.

0 commit comments

Comments
 (0)