Example #1
0
        private static void CheckConnection(QSApp TheQS)
        {   // Connects a QSApp object with the default values
            TheQS.qsAppName            = cntqsAppName;
            TheQS.qsAppId              = cntqsAppId;
            TheQS.qsServer             = cntqsServer;
            TheQS.qsSingleServer       = cntqsSingleServer;
            TheQS.qsSingleApp          = cntqsSingleApp;
            TheQS.qsAlternativeStreams = cntqsAlternativeStreams;

            try
            {
                // Create or use the Telegram UserID as the Qlik Sense UserID
                // With the bot virtual proxy and user directory
                // The Virtual Proxy has to be created as "Header authentication static user directory"
                // The user directory is defined in the Virtual Proxy, in "Header authentication static user directory"
                // For this example:
                //
                // Qlik Sense Virtual Proxy
                // ------------------------
                //
                // Description: Telegram
                // Prefix: telegram
                // Timeout: 30
                // Session cookie header name: X-Qlik-Session-telegram
                // Anonymous access mode: No anonymous user
                // Authentication method: Header authentication static user directory
                // Header authentication header name: X-Qlik-HeaderAuthTelegram
                // Header authentication static user directory: TELEGRAM
                //
                // PD.- Do not forget to add the server node, link the proxy and include the server name in the white list

                TheQS.QSConnectServerHeader("User1", "Qlik Sense Header Auth is Here", cntqsServerVirtualProxy, cntqsServerSSL, true);


                if (TheQS.IsConnected)
                {
                    TheQS.QSOpenApp();
                    if (TheQS.AppIsOpen)
                    {
                        Console.WriteLine(string.Format("Opened the Qlik Sense app: {0} for user {1} ({2})", cntqsAppId, "User1", cntqsServerVirtualProxy));

                        string Val = TheQS.GetExpression("Sum([Sales Amount])");
                        Console.WriteLine("Value: " + Val);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(string.Format("Error opening the Qlik Sense app: {0} for user {1} ({2}): {3}", cntqsAppId, "User1", cntqsServerVirtualProxy, e));
            }
        }
Example #2
0
        public TelegramBot(string BotToken, QSApp TemplateApp)
        {
            // Save the template
            QSTemplateApp = TemplateApp;

            // Users
            QlikUsers.ReadFromCSV(cntQlikUsersCSV);
            Console.WriteLine("Users read");

            // The Telegram Bot object
            Bot = new TelegramBotClient(BotToken);

            // Set the calls that will receive the bot events
            SetBotCalls();

            // Start the Bot
            Bot.StartReceiving();
        }
Example #3
0
        private static void Connect(QSApp TheQS, string UserId, string VirtualProxyPath = "", bool UseSSL = true)
        {   // Connects a QSApp object
            try
            {
                // Create or use the Telegram UserID as the Qlik Sense UserID
                // With the bot virtual proxy and user directory
                // The Virtual Proxy has to be created as "Header authentication static user directory"
                // The user directory is defined in the Virtual Proxy, in "Header authentication static user directory"
                // For this example:
                //
                // Qlik Sense Virtual Proxy
                // ------------------------
                //
                // Description: Telegram
                // Prefix: telegram
                // Timeout: 30
                // Session cookie header name: X-Qlik-Session-telegram
                // Anonymous access mode: No anonymous user
                // Authentication method: Header authentication static user directory
                // Header authentication header name: X-Qlik-HeaderAuthTelegram
                // Header authentication static user directory: TELEGRAM
                //
                // PD.- Do not forget to add the server node, link the proxy and include the server name in the white list

                TheQS.QSConnectServerHeader(UserId, "X-Qlik-HeaderAuthTelegram", VirtualProxyPath, UseSSL, true);


                if (TheQS.IsConnected)
                {
                    TheQS.QSOpenApp();
                    if (TheQS.AppIsOpen)
                    {
                        Console.WriteLine(string.Format("Opened the Qlik Sense app: {0} for user {1} ({2})", TheQS.qsAppId, UserId, VirtualProxyPath));

                        //string Val = TheQS.GetExpression("Sum([Sales Amount])");
                        //Console.WriteLine("Value: " + Val);
                    }
                }
            }
            catch (Exception e)
            {
                Console.WriteLine(string.Format("Error opening the Qlik Sense app: {0} for user {1} ({2}): {3}", TheQS.qsAppId, UserId, VirtualProxyPath, e));
            }
        }
Example #4
0
        static void Main(string[] args)
        {
            // The QS object to connect to Qlik Sense at the begining, to check the connection
            // This QS object will also be used as a template for new objects for every user session
            QSApp InitQS = new QSApp();

            CheckConnection(InitQS);

            if (InitQS.IsConnected)
            {
                Console.WriteLine("Qlik Sense seems to be working :-)");
            }
            else
            {
                Console.WriteLine("Something went wrong with Qlik Sense :-(.\nPress a key to exit.");
                Console.ReadKey();
                return;
            }

            // Telegram
            MyBot = new TelegramBot(cntBotToken, InitQS);

            Console.WriteLine("Telegram seems to be working :-)");

            // Wait forever (or until someone writes close)
            // During this time, the Bot functions will be receiving the messages
            bool go = true;

            while (go)
            {
                string   c    = Console.ReadLine();
                string[] parm = c.Split(' ');

                if (c.ToLower() == "close")
                {
                    go = false;
                }
            }

            // The End
            Console.WriteLine("Everything stopped. Bye.");
            MyBot.CloseBot();
        }
Example #5
0
        protected void InitializeQSServer()
        {
            QSApp QS = new QSApp();

            QS.qsAppName = AppSettings.DemoQsAppName;
            QS.qsAppId   = AppSettings.DemoQsAppId;
            QS.qsServer  = AppSettings.DemoQsServer;
            if (ConfigurationManager.AppSettings["DemoqsServerSSL"] != null &&
                ConfigurationManager.AppSettings["DemoqsServerSSL"].ToLower().StartsWith("y"))
            {
                cntqsServerSSL = true;
            }
            cntqsServerVirtualProxy = ConfigurationManager.AppSettings["DemoqsServerVirtualProxy"];
            if (cntqsServerVirtualProxy == null)
            {
                cntqsServerVirtualProxy = "";
            }
            QS.qsSingleServer       = AppSettings.DemoQsSingleServer;
            QS.qsSingleApp          = AppSettings.DemoQsSingleApp;
            QS.qsAlternativeStreams = AppSettings.QsAlternativeStreams;
        }