示例#1
0
        public void SaveMeasure(string AppId, string title, string description, List <string> tags, string definition)
        {
            var appIdentifier = location.AppWithIdOrDefault(AppId);

            var measure = new NxLibraryMeasureDef()
            {
                Def = definition, Label = title
            };

            var properties = new Qlik.Sense.Client.MeasureProperties()
            {
                Title       = title,
                Description = description,
                Tags        = tags,
                Info        = new NxInfo()
                {
                    Type = "GenericMeasure"
                },
                Measure = measure
            };

            using (IApp app = location.App(appIdentifier))
            {
                app.CreateMeasure(null, properties);
            }
        }
示例#2
0
        private void listSheets(string appName)
        {
            IAppIdentifier foundAppIdentifier = _location.AppWithNameOrDefault(appName);
            IApp           application        = _location.App(foundAppIdentifier);
            ISheetList     sheetList          = application.GetSheetList();

            foreach (ISheetObjectViewListContainer item in sheetList.Items)
            {
                dropDown2.Items.Add(CreateRibbonDropDownItem());
                dropDown2.Items.Last().Label = item.Data.Title;
            }
        }
示例#3
0
 internal QlikAppSession(ILocation location, IAppIdentifier appIdentifier, bool createDefaultSession)
 {
     Id = Guid.NewGuid();
     if (createDefaultSession)
     {
         CurrentApp = location.App(appIdentifier, Session.WithApp(appIdentifier, SessionType.Default), true, false);
     }
     else
     {
         CurrentApp = location.App(appIdentifier, Session.Random, true, false);
     }
     SessionId  = location.SessionCookie?.Split('=').ElementAtOrDefault(1) ?? null;
     Selections = new QlikSelections(CurrentApp);
     IsFree     = false;
 }
        public List<string> GetFieldValues(app app, IAppField appField2)
        {
            List<string> strValues = new List<string>();

            Uri uri = new Uri(url + ":443");
            ILocation remoteQlikSenseLocation = Qlik.Engine.Location.FromUri(uri);
            remoteQlikSenseLocation.AsNtlmUserViaProxy();

            IAppIdentifier appidentifier = remoteQlikSenseLocation.AppWithId(app.ID);
            using (var doc = remoteQlikSenseLocation.App(appidentifier))
            {
                var field = doc.GetAppField(appField2.DimensionInfo.FallbackTitle);

                var p = new List<NxPage> { new NxPage { Height = 20, Width = 1 } };
                var dataPages = field.GetData(p);
                foreach (var dataPage in dataPages)
                {
                    var matrix = dataPage.Matrix;
                    foreach (var cellRows in matrix)
                    {
                        foreach (var cellRow in cellRows)
                        {
                            strValues.Add(cellRow.Text);
                            //Console.WriteLine("## " + cellRow.Text + " - " + cellRow.State);
                        }
                    }
                }

            }
            return strValues;
        }
示例#5
0
        /// <summary>
        /// Write app resource and load with correct session to enable synchronization with other clients.
        /// </summary>
        /// <param name="location"></param>
        /// <returns>The custom desktop app.</returns>
        private static IApp PrepareApp(ILocation location)
        {
            File.WriteAllBytes(DesktopAppPath, Resources.CustomDesktopApp);
            var appIdentifier = location.AppWithNameOrDefault(CustomDesktopAppName);

            return(location.App(appIdentifier));
        }
示例#6
0
        static void Main()
        {
            ILocation location = Qlik.Engine.Location.FromUri(new Uri("ws://127.0.0.1:4848")); // url do Qlik Sense Desktop

            location.AsDirectConnectionToPersonalEdition();
            var appIdentifier = location.AppWithNameOrDefault("TesteAutoReload.qvf"); // !!!! IMPORTANTE: ESPECIFICAR O QVF AQUI!!

            if (appIdentifier == null)
            {
                Console.WriteLine(@"The app does not exist."); // caso o app não for encontrado
            }
            else
            {
                var app            = location.App(appIdentifier);
                var reloadSucceded = app.DoReload();
                if (reloadSucceded)
                {
                    app.DoSave();
                    Console.WriteLine(@"The app is reloaded and saved."); // reload OK
                    //Console.WriteLine("Time: " + appIdentifier.LastReloadTime);
                }
                else
                {
                    Console.WriteLine(@"Reload failed."); // reload Falha
                }
            }
        }
 private IApp GetAppHandle(string appid)
 {
     Uri uri = new Uri(url + ":443");
     ILocation remoteQlikSenseLocation = Qlik.Engine.Location.FromUri(uri);
     remoteQlikSenseLocation.AsNtlmUserViaProxy();
     IAppIdentifier appidentifier = remoteQlikSenseLocation.AppWithId(appid);
     return remoteQlikSenseLocation.App(appidentifier);
 }
 private static IApp GetApp(ILocation location, IAppIdentifier appId, bool noData)
 {
     try
     {
         return(location.App(appId, Session.Random, noData: noData));
     }
     catch
     {
         return(null);
     }
 }
示例#9
0
        private static void GetEngineObjects(string centralNodeHostname, TelemetryMetadata metadata, int engineRequestTimeoutMS)
        {
            TelemetryDashboardMain.Logger.Log(string.Format("Engine request timeout set to: {0} ms (default is: 30000 ms)", engineRequestTimeoutMS.ToString()), LogLevel.Info);

            Qlik.Sense.JsonRpc.RpcConnection.Timeout = engineRequestTimeoutMS;

            string    wssPath  = "https://" + centralNodeHostname + ":4747";
            ILocation location = Location.FromUri(new Uri(wssPath));

            X509Certificate2Collection certificateCollection = new X509Certificate2Collection(CertificateConfigHelpers.Certificate);

            // Defining the location as a direct connection to Qlik Sense Server
            location.AsDirectConnection("INTERNAL", "sa_api", certificateCollection: certificateCollection);

            int totalApps  = metadata.Apps.Count;
            int currentApp = 0;

            TelemetryDashboardMain.Logger.Log("Will start to fetch all app objects from the engine.", LogLevel.Info);

            foreach (KeyValuePair <Guid, QRSApp> appTuple in metadata.Apps)
            {
                currentApp++;
                TelemetryDashboardMain.Logger.Log(string.Format("App {0} of {1} - Checking to see if visualaizations fetch is needed for app '{2}' with ID '{3}' ", currentApp, totalApps, appTuple.Value.Name, appTuple.Key.ToString()), LogLevel.Debug);

                if (appTuple.Value.VisualizationUpdateNeeded)
                {
                    TelemetryDashboardMain.Logger.Log(string.Format("Getting visualizations for app '{0}' with ID '{1}' ", appTuple.Value.Name, appTuple.Key.ToString()), LogLevel.Info);
                    try
                    {
                        IAppIdentifier appIdentifier = new AppIdentifier()
                        {
                            AppId = appTuple.Key.ToString()
                        };
                        using (IApp app = location.App(appIdentifier, null, true))
                        {
                            IEnumerable <ISheet> sheetList = app.GetSheets();
                            foreach (ISheet sheet in sheetList)
                            {
                                ISheetLayout          sheetObject = (SheetLayout)sheet.GetLayout();
                                IList <Visualization> vizs        = new List <Visualization>();
                                sheetObject.Cells.ToList().ForEach(c => vizs.Add(new Visualization(c.Name, c.Type)));
                                metadata.Apps[appTuple.Key].Sheets.FirstOrDefault(s => s.Value.EngineObjectID == sheetObject.Info.Id).Value.SetSheetsList(vizs);
                            }
                        }
                    }
                    catch (Exception e)
                    {
                        TelemetryDashboardMain.Logger.Log("Failed to get engine objects from App: " + appTuple.Key.ToString() + ". Message: " + e.Message, LogLevel.Error);
                        TelemetryDashboardMain.Logger.Log("Skipping app: " + appTuple.Key.ToString(), LogLevel.Error);
                    }
                }
            }
            TelemetryDashboardMain.Logger.Log("Done getting all app objects from the engine.", LogLevel.Info);
        }
 private static IEnumerable <IApp> OpenAllApps(ILocation location)
 {
     try
     {
         return(location.GetAppIdentifiers().Select(x => location.App(x)));
     }
     catch (CommunicationErrorException e)
     {
         Console.WriteLine("Communication error exception, no Qlik Sense instance found! " + e.Message);
         return(new IApp[] { });
     }
 }
示例#11
0
        static void LoadCache(ILocation location, IAppIdentifier id, bool opensheets, QlikSelection Selections)
        {
            IApp app = null;

            try
            {
                //open up the app
                Print(LogLevel.Info, "{0}: Opening app", id.AppName);
                app = location.App(id);
                Print(LogLevel.Info, "{0}: App open", id.AppName);

                //see if we are going to open the sheets too
                if (opensheets)
                {
                    //see of we are going to make some selections too
                    if (Selections != null)
                    {
                        for (int i = 0; i < Selections.fieldvalues.Length; i++)
                        {
                            //clear any existing selections
                            Print(LogLevel.Info, "{0}: Clearing Selections", id.AppName);
                            app.ClearAll(true);
                            //apply the new selections
                            Print(LogLevel.Info, "{0}: Applying Selection: {1} = {2}", id.AppName, Selections.fieldname, Selections.fieldvalues[i]);
                            app.GetField(Selections.fieldname).Select(Selections.fieldvalues[i]);
                            //cache the results
                            cacheObjects(app, location, id);
                        }
                    }
                    else
                    {
                        //clear any selections
                        Print(LogLevel.Info, "{0}: Clearing Selections", id.AppName);
                        app.ClearAll(true);
                        //cache the results
                        cacheObjects(app, location, id);
                    }
                }

                Print(LogLevel.Info, "{0}: App cache completed", id.AppName);
                app.Dispose();
            }
            catch (Exception ex)
            {
                if (app != null)
                {
                    app.Dispose();
                }
                throw ex;
            }
        }
        // Open a Qlik Sense app with the properties defined in this class
        public void QSOpenApp()
        {
            QSAppIsOpen = false;

            try
            {
                CheckConnection();

                IAppIdentifier MyAppId;
                if (qsAppId != "" && qsAppId != null)
                {
                    MyAppId = qsLocation.AppWithIdOrDefault(qsAppId);
                }
                else
                {
                    MyAppId = qsLocation.AppWithNameOrDefault(qsAppName);
                }

                qsAppId   = MyAppId.AppId;
                qsAppName = MyAppId.AppName;

                qsApp             = qsLocation.App(MyAppId);
                qsAppThumbnailUrl = qsApp.GetAppProperties().Thumbnail.Url;

                // Later
                //QSReadFields();
                QSReadMasterItems();
                QSReadSheets();
                //QSReadStories();
                //GetAlternativeApps(qsAlternativeStreams); // Refresh the alternatives every time I open an app

                QSAppIsOpen = true;

                Console.WriteLine("QSEasy opened App " + (qsAppId != "" ? qsAppId : qsAppName) + " with handle: " + qsApp.Handle);
            }
            catch (Exception e)
            {
                Console.WriteLine(e.ToString());
                QSAppIsOpen = false;
            }
        }
        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);
        }
示例#14
0
 private static void ListApps(ILocation location)
 {
     foreach (var appIdentifier in location.GetAppIdentifiers())
     {
         try
         {
             using (var app = location.App(appIdentifier))
             {
                 Traversing.Traverse(app);
             }
         }
         catch (MethodInvocationException e)
         {
             TextHelper.WriteLine("Could not open app: " + appIdentifier.AppName + Environment.NewLine +
                                  TextHelper.Indent() +
                                  e.InvocationError.Message);
         }
         catch (TimeoutException e)
         {
             TextHelper.WriteLine("Timeout for: " + appIdentifier.AppName + Environment.NewLine +
                                  TextHelper.Indent() + e.Message);
         }
     }
 }
示例#15
0
        private static void listApps(ILocation loc)
        {
            ILocation location = loc;

            foreach (var appIdentifier in location.GetAppIdentifiers())
            {
                try
                {
                    using (var app = location.App(appIdentifier))// Location specified in Accessing
                    {
                        var layout = app.GetAppLayout();
                        Console.Write(layout.Title + " [" + app.Type + "]");
                    }
                }
                catch (MethodInvocationException e)
                {
                    Console.WriteLine("Could not open app: " + appIdentifier.AppName + Environment.NewLine + e.InvocationError.Message);
                }
                catch (TimeoutException e)
                {
                    Console.WriteLine("Timeout for: " + appIdentifier.AppName + Environment.NewLine + e.Message);
                }
            }
        }