Exemple #1
0
 public void _OpenBookFolder()
 {
     if (SelectedTableRow == null)
     {
         return;
     }
     if (File.Exists(App.LocalLibrary.AbsoluteFilePath(SelectedTableRow)))
     {
         try
         {
             System.Diagnostics.Process.Start(Path.GetDirectoryName(App.LocalLibrary.AbsoluteFilePath(SelectedTableRow)));
         }
         catch { }
     }
     else if (SelectedDevice != null)
     {
         try
         {
             System.Diagnostics.Process.Start(Path.GetDirectoryName(SelectedDevice.AbsoluteFilePath(SelectedTableRow)));
         }
         catch { }
     }
 }
Exemple #2
0
        public Unit _ReceiveBook(IList bookList)
        {
            if (bookList.Count == 0)
            {
                return(Unit.Default);
            }

            Database.BookEntry[] dbRows = new Database.BookEntry[bookList.Count];
            bookList.CopyTo(dbRows, 0);

            Task.Run(() =>
            {
                if (bookList.Count == 1)
                {
                    Database.BookEntry book = (Database.BookEntry)bookList[0];
                    try
                    {
                        book.FilePath = SelectedDevice.AbsoluteFilePath(book);
                        ImportBook(book);
                    }
                    catch (Exception e)
                    {
                        App.Current.Dispatcher.Invoke(() =>
                        {
                            var dlg = new Dialogs.Error("Error transferring book", e.Message);
                            MaterialDesignThemes.Wpf.DialogHost.Show(dlg);
                        });
                        return;
                    }
                    SnackBarQueue.Enqueue($"{book.Title} copied to library.");
                }
                else
                {
                    List <Exception> errs = new List <Exception>();

                    var prgDlg = new Dialogs.Progress("Syncing Library", false);
                    OpenBottomDrawer(prgDlg.Content);

                    int step = 100 / bookList.Count;

                    foreach (Database.BookEntry b in bookList)
                    {
                        Database.BookEntry book = new Database.BookEntry(b);
                        try
                        {
                            book.FilePath = SelectedDevice.AbsoluteFilePath(book);
                            ImportBook(book);
                        }
                        catch (Exception e)
                        {
                            e.Data["item"] = book.Title;
                            errs.Add(e);
                        }
                    }

                    if (errs.Count > 0)
                    {
                        prgDlg.Finish("Book transfer finished with errors:");
                        prgDlg.ShowError(new AggregateException(errs.ToArray()));
                    }
                    else
                    {
                        prgDlg.Close();
                        SnackBarQueue.Enqueue("Book transfer finished");
                    }
                }
            });

            return(Unit.Default);
        }