Unlock a world of possibilities! Login now and discover the exclusive benefits awaiting you.
We are trying in 2 ways.
- Using Cacheinitializer: https://github.com/eapowertools-archive/CacheInitializer
- Pre open the reload before end-user access.
cmd /c start msedge https://YourFQDNName/sense/app/AppID/sheet/SheeiID/state/analysis
Thanks Or,
So should I insert the script in the github to the end of the app's script:
using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Qlik.Engine;
using Qlik.Engine.Communication;
using Qlik.Sense.Client;
namespace AppPreload
{
class AppPreload
{
static void Main(string[] args)
{
var location = Location.FromUri(new Uri("ws://127.0.0.1:4848"));
location.AsDirectConnectionToPersonalEdition();
QlikConnection.Timeout = Int32.MaxValue;
var t = DateTime.Now;
location.GetAppIdentifiers().ToList().ForEach(id => LoadApp(location, id));
var dt = DateTime.Now - t;
Print("Cache initialization complete. Total time: {0}", dt.ToString());
}
static void LoadApp(ILocation location, IAppIdentifier id)
{
Print("{0}: Opening app", id.AppName);
// Load the app to memory.
var app = location.App(id);
Print("{0}: App opened, getting sheets", id.AppName);
var sheets = app.GetSheets().ToArray();
Print("{0}: Number of sheets - {1}, getting children", id.AppName, sheets.Count());
var allObjects = sheets.Concat(sheets.SelectMany(sheet => GetAllChildren(app, sheet))).ToArray();
Print("{0}: Number of objects - {1}, getting layouts", id.AppName, allObjects.Count());
// Trigger the engine to execute all evaluations required to display all objects included in the app.
// The evaluation results are stored in memory so that subsequent identical queries do not need
// to be recomputed.
var allLayoutTasks = allObjects.Select(o => o.GetLayoutAsync());
Task.WaitAll(allLayoutTasks.ToArray<Task>());
Print("{0}: Completed loading layouts", id.AppName);
}
// Recursively collects the entire tree of objects.
private static IEnumerable<IGenericObject> GetAllChildren(IApp app, IGenericObject obj)
{
var children = obj.GetChildInfos().Select(o => app.GetObject<GenericObject>(o.Id)).ToArray();
return children.Concat(children.SelectMany(child => GetAllChildren(app, child)));
}
private static void Print(string txt, params object[] os)
{
Console.WriteLine(DateTime.Now.ToString("hh:mm:ss") + " - " + String.Format(txt, os));
}
}
}
I concur the @Anil_Babu_Samineni , because we have implemented the same as second option, It deserve!
Hi @aheavy95 ,
Can you help me understand how it works? Can we run it automatically every day?
Thank you so much