Beispiel #1
0
        private static void AddAuditLog(BackgroundTask task)
        {
            task.Logs = TaskController.GetLogs(task, task.StartDate);

            string executionLog = FormatExecutionLog(task);

            UserInfo user     = UserController.GetUserInternally(task.EffectiveUserId);
            string   username = user != null ? user.Username : null;

            AuditLog.AddAuditLogRecord(task.TaskId, task.Severity, task.EffectiveUserId,
                                       username, task.PackageId, task.ItemId,
                                       task.ItemName, task.StartDate, task.FinishDate, task.Source,
                                       task.TaskName, executionLog);
        }
Beispiel #2
0
        public static void CompleteTask()
        {
            if (TasksStack.Count == 0)
            {
                return;
            }

            // call event handler
            CallTaskEventHandler(TopTask, true);

            // finish task
            TopTask.FinishDate = DateTime.Now;
            TopTask.Completed  = true;

            // write task execution result to database
            if (TasksStack.Count == 1) // single task
            {
                // unregister task globally
                // tasks.Remove(TopTask.TaskId);

                // write to database
                string itemName = TopTask.ItemName != null?TopTask.ItemName.ToString() : null;

                string   executionLog = FormatExecutionLog(TopTask);
                UserInfo user         = UserController.GetUserInternally(TopTask.UserId);
                string   username     = user != null ? user.Username : null;

                AuditLog.AddAuditLogRecord(TopTask.TaskId, TopTask.Severity, TopTask.UserId,
                                           username, TopTask.PackageId, TopTask.ItemId,
                                           itemName, TopTask.StartDate, TopTask.FinishDate, TopTask.Source,
                                           TopTask.TaskName, executionLog);
            }

            // remove task from the stack
            TasksStack.RemoveAt(TasksStack.Count - 1);
        }