コード例 #1
0
        //Конструктор класса Automation
        public Automation(IFileListener fl, IConfig config, ObservableCollection <IRecord> records, ObservableCollection <IProcFile> procFiles)
        {
            try
            {
                //Выполняем импорт библиотеки Plugin
                Import.DoImport(this);

                Records     = records;
                ProcFiles   = procFiles;
                this.FL     = fl;
                this.Config = config;

                //Создаём и инициализируем Timer
                DT       = new DispatcherTimer();
                DT.Tick += OnTick;

                //Создаём и инициализируем FileSystemWatcher
                FSW = new FileSystemWatcher
                {
                    NotifyFilter = NotifyFilters.LastWrite | NotifyFilters.LastAccess | NotifyFilters.FileName,
                    Filter       = "*.*"
                };
                FSW.Created += new FileSystemEventHandler(OnCreated);
            }
            catch
            {
                throw;
            }
        }
コード例 #2
0
ファイル: AppViewModel.cs プロジェクト: dav775/ParserRep
        //Конструктор класса AppViewModel
        public AppViewModel(IConfig config, IConfigManager configManager, IFileListener fileListener)
        {
            try
            {
                //инициализируем значения текущей конфигурации
                this.configManager = configManager;
                this.fileListener  = fileListener;
                this.config        = configManager.ReadConfig(config);

                //Инициализируем колекцию обрабатываемых данных
                Records = new ObservableCollection <IRecord>();

                //Инициализируем колекцию с перечнем обрабатываемх файлов
                ProcFiles = new ObservableCollection <IProcFile>();

                //Создаем екземпляр класса Automation
                automation = new Automation(this.fileListener, this.config, Records, ProcFiles);
            }
            catch
            {
                //Отлавливаем исключения и передаем их на верхний уровень обработки
                throw;
            }

            //Устанавливаем значения свойств
            //Инициализируем заполняя значениями массивы с перечнем допустимых для ввода значний
            //для листбоксов часы, минуты, секунды
            DataInit dataInit = new DataInit();

            HHDS = dataInit.HR;
            MSDS = dataInit.MS;
            //Устанавливаем начальные значения в листбоксах: часы, минуты, секунды,
            //заполняя их значениями из текущей конфигурации
            HHVal          = this.config.Interval.Hours;
            MMVal          = this.config.Interval.Minutes;
            SSVal          = this.config.Interval.Seconds;
            WorkDirectory  = this.config.WorkDir;
            ProcessingType = this.config.ProcessingType;
            //Задаем значение надписи на кнопке выбора типа обработки фалов в зависимости от значения свойства ProcessingType
            if (ProcessingType)
            {
                ProcessingTypeButtonContent = "Timer is tarted";
            }
            else
            {
                ProcessingTypeButtonContent = "File system watcher is started";
            }
        }