private async void OnChanged(object source, FileSystemEventArgs e)
        {
            if (e.ChangeType == WatcherChangeTypes.Created && e.Name.StartsWith("WOH"))
            {
                using (FileImportService service = new FileImportService())
                {
                    var succeeded = await service.CreateAsync(new FileImport
                    {
                        FileName = e.Name
                    }, _source.Token);
                }
            }
            else if (e.ChangeType == WatcherChangeTypes.Deleted && e.Name.StartsWith("WOH"))
            {
                using (FileImportService service = new FileImportService())
                {
                    var found = await service.GetByFileNameAsync(e.Name);

                    if (found != null)
                    {
                        found.DateDeleted = DateTime.Now;
                        var succeeded = await service.UpdateAsync(found, _source.Token);
                    }
                }
            }
        }
        private async void CheckImportStatusAsync(object state)
        {
            var config = GetConfig();

            if (config == null)
            {
                return;
            }

            using (FileImportService service = new FileImportService())
            {
                var list = await service.GetReadyToCheckImports(config.WaitInSeconds);

                foreach (var file in list)
                {
                    file.DateChecked = DateTime.Now;

                    string sumfile = Path.Combine(config.SummaryFolder, Path.GetFileNameWithoutExtension(file.FileName) + ".sum");

                    if (File.Exists(sumfile) && IsImportSucceeded(sumfile))
                    {
                        file.Result = "Imported";
                    }
                    else
                    {
                        file.Result = "Failed";

                        string body = GetAllErrors(file.FileName, config.ErrorFolder, config.SummaryFolder);

                        if (config.DefaultMail == "DbMail")
                        {
                            await service.SendDbMail(config.DbMail, config.EmailTos, "",
                                                     string.Format("Import Error - {0}", file.FileName), body);
                        }
                        else
                        {
                            await service.SendSmtpEmailAsync(config.SmtpMail, config.EmailTos,
                                                             string.Format("Import Error - {0}", file.FileName), body);
                        }
                    }
                    await service.UpdateAsync(file, _source.Token);
                }
            }
        }