Ejemplo n.º 1
0
        private void FileScan(int action)
        {
            this.FileScanBusy = true;
            var setting = Setting.CurrentSetting;

            foreach (var path in setting.Paths.FindAll(p => p.IsActive == true))
            {
                Parallel.ForEach(GetFiles(path.Path), (file, a) =>
                {
                    if (!IsIgnore(file))
                    {
                        var status = LogHelper.AddFile(file);
                        if (status && action == 0)
                        {
                            var log = new ChangesLog()
                            {
                                FilePath    = file,
                                WatcherPath = "FileScan",
                                AddTime     = DateTime.Now,
                                Action      = "FileScan",
                                AddedToSync = 0
                            };
                            LogHelper.AddChangeLog(log);
                        }
                    }
                });
            }
            this.FileScanBusy = false;
        }
Ejemplo n.º 2
0
        private void Watcher_Created(object sender, FileSystemEventArgs e)
        {
            if (IsIgnore(e.FullPath))
            {
                return;
            }
            FileAttributes attr = File.GetAttributes(e.FullPath);

            if (!attr.HasFlag(FileAttributes.Directory))
            {
                var log = new ChangesLog()
                {
                    FilePath    = e.FullPath,
                    WatcherPath = ((FileSystemWatcher)sender).Path,
                    AddTime     = DateTime.Now,
                    Action      = e.ChangeType.ToString(),
                    AddedToSync = 0
                };
                LogHelper.AddChangeLog(log);
                LogHelper.AddFile(e.FullPath);
            }
        }