Exemplo n.º 1
0
        public string Generate()
        {
            var sb = new StringBuilder();

            sb.AppendLine("*Current*:");

            foreach (var task in CurrentTasks)
            {
                sb.AppendLine(task.GetLine());
            }

            if (!CurrentTasks.Any())
            {
                sb.AppendLine("none");
            }

            sb.AppendLine();
            sb.AppendLine("*Done*:");

            foreach (var task in DoneTasks)
            {
                sb.AppendLine(task.GetLine());
            }

            if (!DoneTasks.Any())
            {
                sb.AppendLine("none");
            }

            sb.AppendLine();
            sb.AppendLine("*Blocked*:");

            foreach (var task in BlockedTasks)
            {
                sb.AppendLine(task.GetLine());
            }

            if (!BlockedTasks.Any())
            {
                sb.AppendLine("none");
            }

            sb.AppendLine();
            sb.Append($"*{PreviousDayLabel}*: ");
            sb.AppendLine(string.IsNullOrWhiteSpace(PreviousDaySummary) ? "none" : PreviousDaySummary);
            sb.AppendLine();
            sb.Append("*Today*: ");
            sb.AppendLine(string.IsNullOrWhiteSpace(TodaySummary) ? "none" : TodaySummary);
            sb.AppendLine();
            sb.Append("*Impediments*: ");
            sb.Append(string.IsNullOrWhiteSpace(BlockedSummary) ? "none" : BlockedSummary);

            return(sb.ToString());
        }
Exemplo n.º 2
0
        /// <summary>
        /// Runs the tasks.
        /// </summary>
        private void RunTasks()
        {
            if (completed.Count == Tasks.Count)
            {
                TasksCompleted.RaiseEvent(this);
                return;
            }
            lock (CurrentTasks)
            {
                IEnumerable <TaskWorker> available = Dependancies.GetAvailable(Tasks, Completed);
                available = available.Except(CurrentTasks.Keys);

                foreach (TaskWorker worker in available)
                {
                    List <TaskWorker> ensureNotRunning = new List <TaskWorker>();
                    //Check if we have a key saying that this cannot be run at the same time as...
                    if (PreventSimultaneousRunning.Dependancies.ContainsKey(worker))
                    {
                        ensureNotRunning = PreventSimultaneousRunning.Dependancies[worker].DependsOn.ToList();
                    }

                    //Then see if anything says x is not allowed to be run at the same time as this
                    IEnumerable <Dependacy <TaskWorker> > dependancies = PreventSimultaneousRunning.Dependancies.Where(d => d.Value.DependsOn.Contains(worker)).Select(kvp => kvp.Value);
                    ensureNotRunning.AddRange(dependancies.Select(depend =>
                    {
                        List <TaskWorker> items = new List <TaskWorker>();
                        items.Add(depend.Item);
                        return(items);
                    }).SelectMany(i => i));

                    if (CurrentTasks.Any(t => ensureNotRunning.Contains(t.Value)))
                    {
                        continue;
                    }

                    CurrentTasks.TryAdd(worker, worker);
                    TaskWorkerManager mgr = new TaskWorkerManager(worker);
                    mgr.AutoTryRecover  = AutoTryRecover;
                    mgr.TasksCancelled += mgr_TasksCancelled;
                    mgr.TasksCompleted += mgr_TasksCompleted;
                    mgr.TasksFailed    += mgr_TasksFailed;
                    managers.TryAdd(mgr, mgr);
                    mgr.Start();
                }
            }
        }