Skip to main content
Announcements
Join us at Qlik Connect for 3 magical days of learning, networking,and inspiration! REGISTER TODAY and save!
cancel
Showing results for 
Search instead for 
Did you mean: 
aheavy95
Creator
Creator

Open app automatically after task

Hi all
There's an app that I created that many end-users use on a daily basis, and it loads every hour. Each time after it is loaded, it takes too much time for it to open (only for the first time)

How can I achieve to open the app automatically after each load- so that when a user opens it for the first time, it opens at it's normal speed?
(I've seen an old post about a kind of similar case but didn't exactly understand the implementation -https://community.qlik.com/t5/New-to-Qlik-Sense/Automatically-reload-on-open/td-p/914365) 

 

Labels (5)
5 Replies
Anil_Babu_Samineni

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

Best Anil, When applicable please mark the correct/appropriate replies as "solution" (you can mark up to 3 "solutions". Please LIKE threads if the provided solution is helpful
aheavy95
Creator
Creator
Author

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));
}

}
}

 

rockabs
Contributor III
Contributor III

I concur the @Anil_Babu_Samineni , because we have implemented the same as second option, It deserve!

krmvacar
Creator II
Creator II

Hi @aheavy95 ,

Can you help me understand how it works? Can we run it automatically every day?

 

Thank you so much