public void AddWatchFolder(WatchFolderSettings watchFolderSetting, TaskSettings taskSettings) { if (!IsExist(watchFolderSetting)) { if (!taskSettings.WatchFolderList.Contains(watchFolderSetting)) { taskSettings.WatchFolderList.Add(watchFolderSetting); } WatchFolder watchFolder = new WatchFolder { Settings = watchFolderSetting, TaskSettings = taskSettings }; watchFolder.FileWatcherTrigger += path => { TaskSettings taskSettingsCopy = TaskSettings.GetSafeTaskSettings(taskSettings); UploadManager.UploadFile(path, taskSettingsCopy); }; WatchFolders.Add(watchFolder); if (taskSettings.WatchFolderEnabled) { watchFolder.Enable(); } } }
public void AddWatchFolder(WatchFolderSettings watchFolderSetting, TaskSettings taskSettings) { if (!IsExist(watchFolderSetting)) { if (!taskSettings.WatchFolderList.Contains(watchFolderSetting)) { taskSettings.WatchFolderList.Add(watchFolderSetting); } WatchFolder watchFolder = new WatchFolder { Settings = watchFolderSetting, TaskSettings = taskSettings }; watchFolder.FileWatcherTrigger += origPath => { TaskSettings taskSettingsCopy = TaskSettings.GetSafeTaskSettings(taskSettings); string destPath = origPath; if (watchFolderSetting.MoveFilesToScreenshotsFolder) { destPath = Helpers.GetUniqueFilePath(Path.Combine(Program.ScreenshotsFolder, Path.GetFileName(origPath))); Helpers.CreateDirectoryFromFilePath(destPath); File.Move(origPath, destPath); } UploadManager.UploadFile(destPath, taskSettingsCopy); }; WatchFolders.Add(watchFolder); if (taskSettings.WatchFolderEnabled) { watchFolder.Enable(); } } }
public void UpdateWatchFolderState(WatchFolderSettings watchFolderSetting) { WatchFolder watchFolder = FindWatchFolder(watchFolderSetting); if (watchFolder != null) { if (watchFolder.TaskSettings.WatchFolderEnabled) { watchFolder.Enable(); } else { watchFolder.Dispose(); } } }
public void AddWatchFolder(WatchFolderSettings watchFolderSetting, TaskSettings taskSettings) { if (!IsExist(watchFolderSetting)) { if (!taskSettings.WatchFolderList.Contains(watchFolderSetting)) { taskSettings.WatchFolderList.Add(watchFolderSetting); } WatchFolder watchFolder = new WatchFolder(); watchFolder.Settings = watchFolderSetting; watchFolder.TaskSettings = taskSettings; watchFolder.FileWatcherTrigger += origPath => { TaskSettings taskSettingsCopy = TaskSettings.GetSafeTaskSettings(taskSettings); string destPath = origPath; if (watchFolderSetting.MoveFilesToScreenshotsFolder) { string screenshotsFolder = TaskHelpers.GetScreenshotsFolder(taskSettingsCopy); string fileName = Path.GetFileName(origPath); destPath = TaskHelpers.HandleExistsFile(screenshotsFolder, fileName, taskSettingsCopy); FileHelpers.CreateDirectoryFromFilePath(destPath); File.Move(origPath, destPath); } UploadManager.UploadFile(destPath, taskSettingsCopy); }; WatchFolders.Add(watchFolder); if (taskSettings.WatchFolderEnabled) { watchFolder.Enable(); } } }