Ejemplo n.º 1
0
        public async Task Refresh()
        {
            if (_internalLoadingArchives)
            {
                return;
            }
            _internalLoadingArchives = true;
            RefreshOnErrorButton     = false;
            ArchiveList.Clear();
            LoadingArchives = true;
            foreach (var b in Settings.Profile.Bookmarks)
            {
                var archive = Archives.GetArchive(b.archiveID);
                if (archive != null)
                {
                    Tabs.CloseTabWithId(archive.title);
                }
            }
            await Archives.ReloadArchives();

            LoadBookmarks();
            Page                     = 0;
            LoadingArchives          = false;
            _internalLoadingArchives = false;
        }
Ejemplo n.º 2
0
 public void LoadBookmarks()
 {
     SortBy.Clear();
     foreach (var n in Archives.Namespaces)
     {
         SortBy.Add(n);
     }
     SortByIndex = SortBy.IndexOf(Settings.SortByDefault);
     OrderBy     = Settings.OrderByDefault;
     if (Settings.OpenBookmarksStart && Archives.Archives.Count > 0)
     {
         foreach (var b in Settings.Profile.Bookmarks)
         {
             var archive = Archives.GetArchive(b.archiveID);
             if (archive != null)
             {
                 Archives.OpenTab(archive, false);
             }
             else
             {
                 WeakReferenceMessenger.Default.Send(new ShowNotification("Bookmarked Archive with ID[" + b.archiveID + "] not found.", ""));
             }
         }
     }
     Settings.Profile.MarkedAsNonDuplicated.RemoveAll(hit => !(Archives.HasArchive(hit.Left) && Archives.HasArchive(hit.Right)));
 }
Ejemplo n.º 3
0
        void worker_DoWork(object sender, System.ComponentModel.DoWorkEventArgs e)
        {
            MonitorFile file;

            while (!worker.CancellationPending)
            {
                NotifyPropertyChanged("Active");
                NotifyPropertyChanged("Status");
                if (QueueCount == 0)
                {
                    // No new files? Take a nap.
                    try {
                        Thread.Sleep(100);
                    } catch (Exception ex) {
                        TranslatingMessageHandler.SendException(ex);
                    }
                    continue;
                }

                lock (FileQueue) {
                    file = FileQueue.Dequeue();
                }

                if (!file.Path.Game.IsMonitored)
                {
                    continue;
                }

                FileInfo fi   = new FileInfo(Path.Combine(file.root, file.path));
                GameID   game = file.Path.Game.id;
                switch (file.change_type)
                {
                case System.IO.WatcherChangeTypes.Changed:
                case System.IO.WatcherChangeTypes.Created:
                case System.IO.WatcherChangeTypes.Renamed:
                    if (!fi.Exists)
                    {
                        continue;
                    }
                    List <DetectedFile> these_files = file.Path.Game.GetSavesMatching(file.full_path);
                    if (these_files.Count == 0)
                    {
                        continue;
                    }
                    foreach (DetectedFile this_file in these_files)
                    {
                        _status = game.Name + " updating " + Path.Combine(this_file.Path, this_file.Name);
                        NotifyPropertyChanged("Status");

                        if (this_file.FullDirPath == null)
                        {
                            continue;
                        }

                        Archive archive = Archives.GetArchive(game, this_file);

                        try {
                            if (archive == null)
                            {
                                if (this_file.owner == null)
                                {
                                    archive = new Archive(Core.settings.backup_path, new ArchiveID(game, this_file));
                                }
                                else
                                {
                                    archive = new Archive(Core.settings.backup_path, new ArchiveID(game, this_file));
                                }
                                Archives.Add(archive);
                            }
                            //monitorNotifier.ShowBalloonTip(10, "Safety Will Robinson", "Trying to archive " + file.path, ToolTipIcon.Info);
                            MessageHandler.suppress_messages = true;
                            List <DetectedFile> temp_list = new List <DetectedFile>();
                            temp_list.Add(this_file);
                            archive.backup(temp_list, false, true);
                        } catch {
                            //monitorNotifier.ShowBalloonTip(10,"Danger Will Robinson","Error while trying to archive " + file.path,ToolTipIcon.Error);
                            // If something goes wrong during backup, it's probable the file copy.
                            // Reinsert the file to the end of the queue, then move on to the next one.
                            if (!FileQueue.Contains(file))
                            {
                                FileQueue.Enqueue(file);
                            }
                        } finally {
                            MessageHandler.suppress_messages = false;
                        }
                    }
                    break;
                }
                if (worker.CancellationPending)
                {
                    e.Cancel = true;
                }

                _status = null;
            }
            NotifyPropertyChanged("Status");
            NotifyPropertyChanged("Active");
        }