Exemplo n.º 1
0
 public void AddEntryToQueue(Entry entry)
 {
     lock (_syncObj)
     {
         _queue.Enqueue(entry);
         Monitor.Pulse(_syncObj);
     }
 }
Exemplo n.º 2
0
        public void Scan()
        {
            try
            {
                _treeWrittingThread = new Thread(_treeEntryService.Write);
                _xmlWrittingThread = new Thread(_xmlEntryService.Write);
                _treeWrittingThread.Start();
                _xmlWrittingThread.Start();

                var root = new Entry { IsRoot = true };
                GetEntry(root);
                FinishScanning();
            }
            catch (Exception ex)
            {
                Helpers.WriteToLog(Resources.Error_message, ex.Message);
            }
        }
Exemplo n.º 3
0
        public void Write()
        {
            Working = true;
            Monitor.Enter(_syncObj);
            while (Working)
            {
                lock (_syncObj)
                {
                    if (_queue.Count == 0)
                        Monitor.Wait(_syncObj);

                    CurrentEntry = _queue.Dequeue();
                    WriteEntry();
                }
            }

            Monitor.Exit(_syncObj);
        }
Exemplo n.º 4
0
        private void GetEntry(Entry info)
        {
            if (!Directory.Exists(Path) && !File.Exists(Path) || info == null)
                return;
            var entry = new Entry { Info = Helpers.GetEntryInfo(Path) };

            if (!info.IsRoot)
            {
                info.Children.Add(entry);
                entry.Parent = info;
            }
            PassEntry(entry);

            //if entry is directory - get files and subdirectories for it and recursively call this method for each of them
            if (!Helpers.IsDirectory(Path))
            {
                return;
            }

            var directoryInfo = new DirectoryInfo(Path);
            try
            {
                var fileSystemInfos = directoryInfo.GetFileSystemInfos();
                foreach (var fileSystemInfo in fileSystemInfos)
                {
                    Path = fileSystemInfo.FullName;
                    GetEntry(entry);
                }
            }
            catch (Exception ex)
            {
                Helpers.WriteToLog(Resources.Error_message, ex.Message);
            }
        }
Exemplo n.º 5
0
 private void PassEntryToServices(Entry entry)
 {
     try
     {
         _treeEntryService.AddEntryToQueue(entry);
         _xmlEntryService.AddEntryToQueue(entry);
     }
     catch (ThreadStateException ex)
     {
         Helpers.WriteToLog(Resources.Error_message, ex.Message);
     }
 }
Exemplo n.º 6
0
 private void PassEntry(Entry entry)
 {
     PassEntryToServices(entry);
     _statusUpdater.UpdateProgress(entry.Info.FullName);
 }