/// <summary> /// Creates a task to be run /// </summary> /// <param name="bs"> /// A <see cref="BackupSet"/> /// </param> /// <param name="operation"> /// A <see cref="TaskOperation"/> /// </param> /// <param name="type"> /// A <see cref="TaskType"/> /// </param> public Task(BackupSet bs, /*TaskOperation operation,*/ TaskStartupType type) : this() { this.BackupSet = bs; this.BackupSetId = bs.Id; this.Operation = bs.Operation; this.Type = type; this.LogEntries = new List <TaskLogEntry>(); //new List<Tuple<DateTime, int, string, string>>(); this.Percent = 0; this.IndexSize = 0; this.IndexName = String.Empty; this.IndexSum = String.Empty; this.Priority = TaskPriority.High; this.Status = TaskStatus.Ok; this.OriginalSize = 0; this.FinalSize = 0; this.TotalItems = 0; StorageBudget = 0; }
private Task CreateTask(BackupSet bs, TaskStartupType taskType, User u, BackupLevel?overridenLevel) { if (TasksQueueExists(bs)) { return(null); } Task newBackup = new Task(bs, taskType); newBackup.Operation = bs.Operation; newBackup.NodeId = bs.NodeId; newBackup.CurrentAction = "Initializing"; newBackup.RunStatus = TaskRunningStatus.PendingStart; newBackup.StartDate = DateTime.Now; if (overridenLevel.HasValue) { newBackup.Level = overridenLevel.Value; } else if (bs.ScheduleTimes.Count == 1) { newBackup.Level = bs.ScheduleTimes[0].Level; } else { newBackup.Level = BackupLevel.Refresh; } if (u != null) { newBackup.UserId = u.Id; Logger.Append("HUBRN", Severity.DEBUG, "User " + u.Id + " (" + u.Name + ") started new task for backupset " + bs.Id + " with level " + newBackup.Level + " (client #" + bs.NodeId + ")"); } // set an encryption key newBackup.EncryptionKey = Convert.ToBase64String(Guid.NewGuid().ToByteArray()); newBackup = new DAL.TaskDAO().Save(newBackup); TasksQueue.Add((Task)newBackup); Logger.Append("RUN", Severity.TRIVIA, "Created new task for scheduled backupset " + bs.ToString()); TaskPublisher.Instance().Notify(newBackup); return(newBackup); }