示例#1
0
        private JArray GetAllowedTasks(List <ManagedTask> activeTasks, QlikRequest request)
        {
            var results = new JArray();

            try
            {
                Options.Analyser?.SetCheckPoint("GetAllowedTasks", $"Start - Find all running tasks");
                var session = Options.SessionHelper.GetSession(Options.Config.Connection, request);
                var qrsHub  = new QlikQrsHub(session.ConnectUri, session.Cookie);
                foreach (var activeTask in activeTasks)
                {
                    if (activeTask.Status == 4)
                    {
                        continue;
                    }

                    var appOwner = request.GetAppOwner(qrsHub, activeTask.Session.AppId);
                    if (appOwner != null && appOwner.ToString() == activeTask.Session.User.ToString())
                    {
                        logger.Debug($"The app owner '{appOwner}' was found.");
                        results.Add(CreateTaskResult(activeTask));
                    }
                    else
                    {
                        if (HasReadRights(qrsHub, activeTask))
                        {
                            results.Add(CreateTaskResult(activeTask));
                        }
                    }
                }
                Options.Analyser?.SetCheckPoint("GetAllowedTasks", $"End - Find all running tasks");
            }
            catch (Exception ex)
            {
                logger.Error(ex, "The list of tasks could not be determined.");
            }
            return(results);
        }