Ejemplo n.º 1
0
        private void StopManagedTask(ManagedTask task)
        {
            task.InternalStatus = InternalTaskStatus.STOPSTART;
            var stopRequest = new QlikRequest
            {
                ManagedTaskId = task.Id.ToString()
            };
            var stopFunction = new StopFunction(runtimeOptions);

            stopFunction.StopReportJobs(stopRequest, true);
        }
Ejemplo n.º 2
0
        private void CleanUp(ManagedTask task)
        {
            try
            {
                if (task.Status > 2 || task.Status == -1)
                {
                    task.InternalStatus = InternalTaskStatus.CLEANUP;
                    task.Endtime        = DateTime.Now;

                    Task.Delay(runtimeOptions.Config.CleanupTimeout * 1000)
                    .ContinueWith((_) =>
                    {
                        try
                        {
                            logger.Debug($"Run clean up process...");
                            runtimeOptions.Analyser?.SetCheckPoint("CleanUp", "Start - Cleanup");

                            if (ManagedTasks.TryRemove(task.Id, out var taskResult))
                            {
                                logger.Debug($"Managed task '{task.Id}' was successfully removed from the managed pool.");
                            }
                            else
                            {
                                logger.Debug($"Managed task '{task.Id}' could not be removed from the pool.");
                            }

                            runtimeOptions.SessionHelper.Manager.MakeSocketFree(task?.Session ?? null);

                            var deleteResult = runtimeOptions.RestClient.Delete(task.Id);
                            if (deleteResult)
                            {
                                logger.Debug($"The directory for the task '{task.Id}' was successfully deleted.");
                            }
                            else
                            {
                                logger.Warn($"The directory for the task '{task.Id}' could not be deleted.");
                            }

                            foreach (var guidItem in task.FileUploadIds)
                            {
                                deleteResult = runtimeOptions.RestClient.Delete(guidItem);
                                if (deleteResult)
                                {
                                    logger.Debug($"The upload directory '{guidItem}' of the task was successfully deleted.");
                                }
                                else
                                {
                                    logger.Warn($"The upload directory '{guidItem}' of the task could not be deleted.");
                                }
                            }

                            runtimeOptions.Analyser?.SetCheckPoint("CleanUp", "End - Cleanup");
                            logger.Debug($"Cleanup of the task '{task.Id}' has been completed.");
                        }
                        catch (Exception ex)
                        {
                            logger.Error(ex, $"Cleaning up the task '{task.Id}' failed.");
                        }
                    });
                }
            }
            catch (Exception ex)
            {
                logger.Error(ex, "The cleanup has an unknown error.");
            }
        }