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

namespace BodyshopPartner.Models
{
    public class Monitor : DTO_Base
    {
        private static NLog.Logger logger = NLog.LogManager.GetCurrentClassLogger();

        public Monitor()
        {

        }

        private SourceSystem _source;
        public SourceSystem Source
        {
            get { return _source; }
            set { SetProperty(ref _source, value); }
        }

        private string _filePath;
        public string FilePath
        {
            get { return _filePath; }
            set { SetProperty(ref _filePath, value); }
        }

        private string _status;
        public string Status
        {
            get { return _status; }
            set { SetProperty(ref _status, value); }
        }

        private Utils.CIECAMonitor _folderMonitor;
        public Utils.CIECAMonitor FolderMonitor
        {
            get { return _folderMonitor; }
            set { SetProperty(ref _folderMonitor, value); }
        }

        public void StartMonitor()
        {
            logger.Debug("Starting folder monitor for path {0}", FilePath);
            System.IO.Directory.CreateDirectory(FilePath);
            FolderMonitor = new Utils.CIECAMonitor(FilePath);
            OnPropertyChanged( nameof(FolderMonitor));
        }

        public void StopMonitor()
        {
            logger.Debug("Stopping folder monitor for path {0}", FilePath);
            FolderMonitor?.Dispose();
            OnPropertyChanged(nameof(FolderMonitor));
        }
    }
}
