using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ZionRobot.Tasks
{
    class Queue : ZionFoundation.Threading.Thread
    {
        private Models.Process.Workflow roadmap;

        public System.Windows.Controls.Control control;

        public Queue(Models.Process.Workflow roadmap)
        {
            this.roadmap = roadmap;
            Initilize(true);
        }

        public override void Execute()
        {
            base.Execute();
            LookInsideFolders(roadmap.Folders);
        }

        private void LookInsideFolders(List<Models.Items.Folder> folders)
        {
            folders.ForEach(folder =>
            {
                LookInsideFolders(folder.Folders);
                ManageQueues(folder.Files);
            });

        }

        private void ManageQueues(List<Models.Items.File> files)
        {
            files?.ForEach(file =>
            {
                if (!roadmap.Queues.Files.Contains(file))
                    roadmap.Queues.Files.Add(file);
            });
        }
    }
}
