카테고리 없음

qlik sense reload c#

보미아빠 2016. 12. 8. 18:00

https://community.qlik.com/docs/DOC-8866 

 

 

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Threading;
using Qlik.Engine;

namespace qsreload
{
    class Program
    {
        static void Main(string[] args)
        {
            string app = "";
            string url = "ws://localhost";
            bool partial = false;

            foreach (string arg in args)
            {
                Console.WriteLine(arg);
                if (arg.StartsWith("-a="))
                {
                    app = arg.Substring(3);
                }

                if (arg == "-p")
                {
                    partial = true;
                }

                if (arg.StartsWith("-u="))
                {
                    url = arg.Substring(3);
                }
            }

            ILocation location;

            try
            {
                location = Qlik.Engine.Location.FromUri(new Uri(url));
                //location.AsNtlmUserViaProxy(proxyUsesSsl: false);
                location.AsDirectConnectionToPersonalEdition(); 데스크탑인 경우
                IEnumerable<IAppIdentifier> apps = location.GetAppIdentifiers();
                while (true)
                {
                    bool found = false;

                    foreach (var salmon in apps)
                    {
                        if (salmon.AppName == app)
                        {
                            Console.WriteLine("Performing " + (partial ? "PARTIAL " : "") + "reload of " + salmon.AppName + " ");
                            IApp foundApp = location.Hub().OpenApp(salmon.AppId);
                            bool ging = foundApp.DoReload(0, partial);
                            Console.WriteLine("Success: " + ging);
                            foundApp.DoSave();
                            found = true;
                        }
                    }
                    Thread.Sleep(1000 * 1);
               
               
                    if (!found)
                    {
                        Console.WriteLine("App " + app + " could not be found");
                    }
                }
            }
            catch (Exception ex)
            {
                Console.WriteLine("Connection to Qlik Sense Proxy at " + url + " failed");
                Console.WriteLine(ex.GetBaseException());
                Console.ReadKey();
            }
        }
    }
}