private IGenericObject GetGenericObject()
        {
            try
            {
                var request = JObject.FromObject(new
                {
                    qProp = new
                    {
                        qInfo = new
                        {
                            qType = "ListObject"
                        },
                        qListObjectDef = new
                        {
                            qInitialDataFetch = new List <NxPage>
                            {
                                new NxPage()
                                {
                                    qTop = 0, qHeight = 0, qLeft = 0, qWidth = 0
                                }
                            },
                            qDef = new
                            {
                                qFieldDefs = new List <string>
                                {
                                    FilterText
                                },
                                qFieldLabels = new List <string>
                                {
                                    $"Label: {FilterText}"
                                },
                                qSortCriterias = new List <SortCriteria>
                                {
                                    new SortCriteria()
                                    {
                                        qSortByState = 1
                                    }
                                }
                            },
                            qShowAlternatives = false,
                        }
                    }
                });

                return(SenseApp.CreateSessionObjectAsync(request).Result);
            }
            catch (Exception ex)
            {
                throw new Exception("Can´t create a session object", ex);
            }
        }
Example #2
0
        public async Task ClearAllSelectionsAsync()
        {
            try
            {
                await SenseApp.AbortModalAsync(false);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "The Qlik selections could not be abort.");
            }

            try
            {
                await SenseApp.ClearAllAsync(true);
            }
            catch (Exception ex)
            {
                throw new Exception("The Qlik selections could not be cleared.", ex);
            }
        }
Example #3
0
        public void ClearAllSelections()
        {
            try
            {
                SenseApp.AbortModal(false);
            }
            catch (Exception ex)
            {
                logger.Error(ex, "The Qlik selections could not be abort.");
                SenseApp.ClearAll(true);
            }

            try
            {
                SenseApp.ClearAll(true);
            }
            catch (Exception ex)
            {
                throw new Exception("The Qlik selections could not be cleared.", ex);
            }
        }
Example #4
0
        private Listbox CreateSession()
        {
            var session = SenseApp.CreateGenericSessionObject(
                new ListboxProperties()
            {
                Info = new NxInfo()
                {
                    Type = "listbox"
                },
                ListObjectDef = new ListboxListObjectDef
                {
                    InitialDataFetch = new NxPage[] { new NxPage()
                                                      {
                                                          Height = 0, Top = 0
                                                      } },
                    Def = new ListboxListObjectDimensionDef()
                    {
                        FieldDefs = new List <string>()
                        {
                            FilterText
                        },
                        FieldLabels = new List <string>()
                        {
                            Guid.NewGuid().ToString()
                        },
                        SortCriterias = new List <SortCriteria> {
                            new SortCriteria()
                            {
                                SortByState = SortDirection.Ascending
                            }
                        },
                    },
                    ShowAlternatives = false,
                },
            });

            return(session as Listbox);
        }
Example #5
0
        public async Task <SelectionObject> GetCurrentSelectionAsync()
        {
            try
            {
                var request = JObject.FromObject(new
                {
                    qProp = new
                    {
                        qInfo = new
                        {
                            qType = "CurrentSelection"
                        },
                        qSelectionObjectDef = new { }
                    }
                });

                return(await SenseApp.CreateSessionObjectAsync(request)
                       .ContinueWith((res) =>
                {
                    return res.Result.GetLayoutAsync <JObject>();
                })
                       .Unwrap()
                       .ContinueWith <SelectionObject>((res2) =>
                {
                    var ret = res2.Result as dynamic;
                    var jsonObj = ret.qSelectionObject as JObject;
                    var selectionObj = jsonObj.ToObject <SelectionObject>();
                    return selectionObj;
                }));
            }
            catch (Exception ex)
            {
                logger.Error(ex, "The filter selection could not be determined.");
                return(null);
            }
        }