Beispiel #1
0
        public async void LoadDataBase(object sender, MouseButtonEventArgs e)
        {
            //加载数据库
            StackPanel stackPanel = sender as StackPanel;
            TextBox    TextBox    = stackPanel.Children[1] as TextBox;

            string name = TextBox.Text.ToLower();

            if (name == "info")
            {
                Properties.Settings.Default.DataBasePath = AppDomain.CurrentDomain.BaseDirectory + "info.sqlite";
            }
            else if (name == "新建视频库")
            {
                //重命名
                TextBox.IsEnabled  = true;
                TextBox.IsReadOnly = false;
                TextBox.Text       = "我的视频";
                TextBox.Focus();
                TextBox.SelectAll();
                TextBox.Cursor = Cursors.IBeam;
                return;
            }
            else
            {
                Properties.Settings.Default.DataBasePath = AppDomain.CurrentDomain.BaseDirectory + $"\\DataBase\\{name}.sqlite";
            }


            if (!File.Exists(Properties.Settings.Default.DataBasePath))
            {
                return;
            }

            SelectDbBorder.Visibility = Visibility.Hidden;

            if (Properties.Settings.Default.ScanGivenPath)
            {
                await Task.Run(() =>
                {
                    this.Dispatcher.BeginInvoke(new Action(() => { statusText.Text = $"扫描指定文件夹"; }), System.Windows.Threading.DispatcherPriority.Render);
                    List <string> filepaths = Scan.ScanPaths(ReadScanPathFromConfig(Properties.Settings.Default.DataBasePath.Split('\\').Last().Split('.').First()), ct);
                    DataBase cdb            = new DataBase();
                    Scan.DistinctMovieAndInsert(filepaths, ct);
                    cdb.CloseDB();
                }, cts.Token);
            }


            //启动主窗口
            Main main = new Main();

            statusText.Text = "初始化影片";
            main.InitMovie();


            main.Show();
            this.Close();
        }
Beispiel #2
0
        public static double InsertWithNfo(List <string> filepaths, CancellationToken ct, Action <string> messageCallBack = null, bool IsEurope = false)
        {
            List <string> nfopaths   = new List <string>();
            List <string> vediopaths = new List <string>();

            foreach (var item in filepaths)
            {
                if (item.ToLower().EndsWith(".nfo"))
                {
                    nfopaths.Add(item);
                }
                else
                {
                    vediopaths.Add(item);
                }
            }

            //先导入 nfo 再导入视频,避免路径覆盖
            if (nfopaths.Count > 0 && Properties.Settings.Default.ScanNfo)
            {
                Logger.LogScanInfo(Environment.NewLine + "-----【" + DateTime.Now.ToString() + "】-----");
                Logger.LogScanInfo(Environment.NewLine + $"{Jvedio.Language.Resources.ScanNFO} => {nfopaths.Count}  " + Environment.NewLine);

                double total = 0;
                //导入 nfo 文件
                nfopaths.ForEach(item =>
                {
                    if (File.Exists(item))
                    {
                        Movie movie = FileProcess.GetInfoFromNfo(item);
                        if (movie != null && !string.IsNullOrEmpty(movie.id))
                        {
                            DataBase.InsertFullMovie(movie);
                            total += 1;
                            Logger.LogScanInfo(Environment.NewLine + $"{Jvedio.Language.Resources.SuccessImportToDataBase} => {item}  ");
                        }
                    }
                });


                Logger.LogScanInfo(Environment.NewLine + $"{Jvedio.Language.Resources.ImportNFONumber}: {total}" + Environment.NewLine);
                messageCallBack?.Invoke($"{Jvedio.Language.Resources.ImportNFONumber}: {total}");
            }


            //导入视频
            if (vediopaths.Count > 0)
            {
                double _num = Scan.DistinctMovieAndInsert(vediopaths, ct, IsEurope);
                messageCallBack?.Invoke($"{Jvedio.Language.Resources.ImportVideioNumber}:{_num},详情请看日志");
                return(_num);
            }
            return(0);
        }
 public async void OpenDefaultDatabase()
 {
     if (Properties.Settings.Default.ScanGivenPath)
     {
         await Task.Run(() =>
         {
             this.Dispatcher.BeginInvoke(new Action(() => { statusText.Text = $"扫描指定文件夹"; }), System.Windows.Threading.DispatcherPriority.Render);
             List <string> filepaths = Scan.ScanPaths(ReadScanPathFromConfig(Properties.Settings.Default.DataBasePath.Split('\\').Last().Split('.').First()), ct);
             Scan.DistinctMovieAndInsert(filepaths, ct);
         }, cts.Token);
     }
 }
Beispiel #4
0
        public async void LoadDataBase(object sender, MouseButtonEventArgs e)
        {
            //加载数据库
            Border     border     = sender as Border;
            StackPanel stackPanel = border.Child as StackPanel;

            TextBlock textBlock = stackPanel.Children[1] as TextBlock;

            string name = textBlock.Text.ToLower();

            if (name == "info")
            {
                Properties.Settings.Default.DataBasePath = AppDomain.CurrentDomain.BaseDirectory + "info.sqlite";
            }
            else
            {
                Properties.Settings.Default.DataBasePath = AppDomain.CurrentDomain.BaseDirectory + $"\\DataBase\\{name}.sqlite";
            }

            SelectDbBorder.Visibility = Visibility.Hidden;

            if (Properties.Settings.Default.ScanGivenPath)
            {
                await Task.Run(() =>
                {
                    this.Dispatcher.BeginInvoke(new Action(() => { statusText.Text = $"扫描指定文件夹"; }), System.Windows.Threading.DispatcherPriority.Render);
                    List <string> filepaths = Scan.ScanPaths(ReadScanPathFromConfig(Properties.Settings.Default.DataBasePath.Split('\\').Last().Split('.').First()), ct);
                    DataBase cdb            = new DataBase();
                    Scan.DistinctMovieAndInsert(filepaths, ct);
                    cdb.CloseDB();
                }, cts.Token);
            }


            //启动主窗口
            Main main = new Main();

            statusText.Text = "初始化影片";
            main.InitMovie();


            main.Show();
            this.Close();
        }
Beispiel #5
0
        private async void Window_Loaded(object sender, RoutedEventArgs e)
        {
            //更新配置文件
            if (Properties.Settings.Default.UpgradeRequired)
            {
                Properties.Settings.Default.Upgrade();
                Properties.Settings.Default.UpgradeRequired = false;
                Properties.Settings.Default.Save();
            }


            //判断文件是否存在
            CheckFile();


            //修复设置错误
            CheckSettings();


            //Properties.Settings.Default.Reset();
            if (!Directory.Exists(Properties.Settings.Default.BasePicPath))
            {
                Properties.Settings.Default.BasePicPath = AppDomain.CurrentDomain.BaseDirectory + "Pic\\";
            }


            //创建 Log文件夹
            if (!Directory.Exists("log"))
            {
                Directory.CreateDirectory("log");
            }
            //创建 ScanLog 文件夹
            if (!Directory.Exists("log\\scanlog"))
            {
                Directory.CreateDirectory("log\\scanlog");
            }
            //创建 DataBase 文件夹
            if (!Directory.Exists("DataBase"))
            {
                Directory.CreateDirectory("DataBase");
            }

            //创建备份文件夹
            if (!Directory.Exists("BackUp"))
            {
                Directory.CreateDirectory("BackUp");
            }



            SetSkin();
            //初始化数据库
            InitDataBase();
            statusText.Text = "启动中……";



            //初始化参数
            Identify.InitFanhaoList();
            Scan.InitSearchPattern();
            StaticVariable.InitVariable();

            //创建图片文件夹
            if (!Directory.Exists(StaticVariable.BasePicPath + "ScreenShot\\"))
            {
                Directory.CreateDirectory(StaticVariable.BasePicPath + "ScreenShot\\");
            }
            if (!Directory.Exists(StaticVariable.BasePicPath + "SmallPic\\"))
            {
                Directory.CreateDirectory(StaticVariable.BasePicPath + "SmallPic\\");
            }
            if (!Directory.Exists(StaticVariable.BasePicPath + "BigPic\\"))
            {
                Directory.CreateDirectory(StaticVariable.BasePicPath + "BigPic\\");
            }
            if (!Directory.Exists(StaticVariable.BasePicPath + "ExtraPic\\"))
            {
                Directory.CreateDirectory(StaticVariable.BasePicPath + "ExtraPic\\");
            }
            if (!Directory.Exists(StaticVariable.BasePicPath + "Actresses\\"))
            {
                Directory.CreateDirectory(StaticVariable.BasePicPath + "Actresses\\");
            }



            //输入密码
            //DialogInput dialogInput = new DialogInput(this,"请输入密码", "123");
            //if (dialogInput .ShowDialog()== false) { this.Close(); } else
            //{
            //    string password = dialogInput.Text;
            //    if (password != "123")
            //    {
            //        this.Close();
            //    }
            //}



            if (Properties.Settings.Default.OpenDataBaseDefault)
            {
                if (Properties.Settings.Default.ScanGivenPath)
                {
                    await Task.Run(() =>
                    {
                        this.Dispatcher.BeginInvoke(new Action(() => { statusText.Text = $"扫描指定文件夹"; }), System.Windows.Threading.DispatcherPriority.Render);
                        List <string> filepaths = Scan.ScanPaths(ReadScanPathFromConfig(Properties.Settings.Default.DataBasePath.Split('\\').Last().Split('.').First()), ct);
                        DataBase cdb            = new DataBase();
                        Scan.DistinctMovieAndInsert(filepaths, ct);
                    }, cts.Token);
                }



                //启动主窗口
                Main main = new Main();
                statusText.Text = "初始化影片";
                main.InitMovie();


                main.Show();
                this.Close();
            }
            else
            {
                SelectDbBorder.Visibility = Visibility.Visible;
            }
        }
Beispiel #6
0
        public async void StartRun(object sender, RoutedEventArgs e)
        {
            if (Running)
            {
                new Msgbox(this, "其他任务正在进行!").ShowDialog(); return;
            }

            cts = new CancellationTokenSource();
            cts.Token.Register(() => { Console.WriteLine("取消当前下载任务"); });
            ct = cts.Token;

            var grids = MainGrid.Children.OfType <Grid>().ToList();
            int index = 0;

            for (int i = 0; i < grids.Count; i++)
            {
                if (grids[i].Visibility == Visibility.Visible)
                {
                    index = i; break;
                }
            }
            Running = true;
            switch (index)
            {
            case 0:
                //扫描
                double totalnum  = 0;   //扫描出的视频总数
                double insertnum = 0;   //导入的视频总数
                try
                {
                    //全盘扫描
                    if ((bool)ScanAll.IsChecked)
                    {
                        LoadingStackPanel.Visibility = Visibility.Visible;
                        await Task.Run(() =>
                        {
                            ct.ThrowIfCancellationRequested();

                            List <string> filepaths = Scan.ScanAllDrives();
                            totalnum  = filepaths.Count;
                            insertnum = Scan.DistinctMovieAndInsert(filepaths, ct);
                        });
                    }
                    else
                    {
                        if (vieModel.ScanPath.Count == 0)
                        {
                            break;
                        }
                        LoadingStackPanel.Visibility = Visibility.Visible;



                        await Task.Run(() =>
                        {
                            ct.ThrowIfCancellationRequested();

                            StringCollection stringCollection = new StringCollection();
                            foreach (var item in vieModel.ScanPath)
                            {
                                if (Directory.Exists(item))
                                {
                                    stringCollection.Add(item);
                                }
                            }
                            List <string> filepaths = Scan.ScanPaths(stringCollection, ct);
                            totalnum  = filepaths.Count;
                            insertnum = Scan.DistinctMovieAndInsert(filepaths, ct);
                        }, cts.Token);
                    }

                    LoadingStackPanel.Visibility = Visibility.Hidden;
                    if (!cts.IsCancellationRequested)
                    {
                        new PopupWindow(this, $"扫描出 {totalnum} 个,导入 {insertnum} 个", true).Show();
                    }
                }
                catch (OperationCanceledException ex)
                {
                    Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {ex.Message}");
                }
                finally
                {
                    cts.Dispose();
                    Running = false;
                }


                break;

            case 1:
                //Access
                LoadingStackPanel.Visibility = Visibility.Visible;
                string AccessPath = AccessPathTextBox.Text;
                if (!File.Exists(AccessPath))
                {
                    new Msgbox(this, $"不存在 :{AccessPath}").ShowDialog(); break;
                }
                try
                {
                    await Task.Run(() =>
                    {
                        DataBase cdb = new DataBase();
                        cdb.InsertFromAccess(AccessPath);
                        cdb.CloseDB();
                    });

                    LoadingStackPanel.Visibility = Visibility.Hidden;
                    if (!cts.IsCancellationRequested)
                    {
                        new PopupWindow(this, "成功!").Show();
                    }
                }
                finally
                {
                    cts.Dispose();
                    Running = false;
                }
                break;

            case 2:
                //NFO
                if ((bool)NfoRB1.IsChecked)
                {
                    if (vieModel.NFOScanPath.Count == 0)
                    {
                        new Msgbox(this, "路径为空!").ShowDialog();
                    }
                }
                else
                {
                    if (!File.Exists(NFOPathTextBox.Text))
                    {
                        new Msgbox(this, $"文件不存在{NFOPathTextBox.Text}").ShowDialog();
                    }
                }


                Running = true;

                try
                {
                    List <string> nfoFiles = new List <string>();
                    if (!(bool)NfoRB1.IsChecked)
                    {
                        nfoFiles.Add(NFOPathTextBox.Text);
                    }
                    else
                    {
                        //扫描所有nfo文件
                        await Task.Run(() =>
                        {
                            this.Dispatcher.Invoke((Action) delegate {
                                StatusTextBlock.Visibility = Visibility.Visible;
                                StatusTextBlock.Text       = "开始扫描";
                            });

                            StringCollection stringCollection = new StringCollection();
                            foreach (var item in vieModel.NFOScanPath)
                            {
                                if (Directory.Exists(item))
                                {
                                    stringCollection.Add(item);
                                }
                            }
                            nfoFiles = Scan.ScanNFO(stringCollection, ct, (filepath) => {
                                this.Dispatcher.Invoke((Action) delegate { StatusTextBlock.Text = filepath; });
                            });
                        }, cts.Token);
                    }


                    //记录日志
                    Logger.LogScanInfo("\n-----【" + DateTime.Now.ToString() + "】NFO扫描-----");
                    Logger.LogScanInfo($"\n扫描出 => {nfoFiles.Count}  个 ");


                    //导入所有 nfo 文件信息
                    double total = 0;
                    await Task.Run(() =>
                    {
                        DataBase cdb = new DataBase();

                        nfoFiles.ForEach(item =>
                        {
                            if (File.Exists(item))
                            {
                                Movie movie = GetInfoFromNfo(item);
                                if (movie != null)
                                {
                                    cdb.InsertFullMovie(movie);
                                    //复制并覆盖所有图片
                                    CopyPicToPath(movie.id, item);
                                    total += 1;
                                    Logger.LogScanInfo($"\n成功导入数据库 => {item}  ");
                                }
                            }
                        });
                        cdb.CloseDB();
                    });

                    LoadingStackPanel.Visibility = Visibility.Hidden;
                    if (!cts.IsCancellationRequested)
                    {
                        Logger.LogScanInfo($"\n成功导入 {total} 个");
                        new PopupWindow(this, "成功!").Show();
                    }
                }
                finally
                {
                    cts.Dispose();
                    Running = false;
                }


                break;

            case 3:
                //欧美扫描
                if (vieModel.ScanEuPath.Count == 0)
                {
                    break;
                }
                LoadingStackPanel.Visibility = Visibility.Visible;
                totalnum  = 0;
                insertnum = 0;

                try
                {
                    await Task.Run(() =>
                    {
                        StringCollection stringCollection = new StringCollection();
                        foreach (var item in vieModel.ScanEuPath)
                        {
                            if (Directory.Exists(item))
                            {
                                stringCollection.Add(item);
                            }
                        }
                        List <string> filepaths = Scan.ScanPaths(stringCollection, ct);
                        totalnum  = filepaths.Count;
                        insertnum = Scan.DistinctMovieAndInsert(filepaths, ct, true);
                    });

                    LoadingStackPanel.Visibility = Visibility.Hidden;
                    if (!cts.IsCancellationRequested)
                    {
                        new PopupWindow(this, $"扫描出 {totalnum} 个,导入 {insertnum} 个", true).Show();
                    }
                }
                finally

                {
                    cts.Dispose();
                    Running = false;
                }

                break;

            case 4:

                //if (IsDownLoading()) { new PopupWindow(this, "请等待下载结束!").Show(); break; }

                //if (new Msgbox(this, "删除不可逆,是否继续?").ShowDialog() == false) { break; }



                //string InfoDataBasePath = AppDomain.CurrentDomain.BaseDirectory + "Info.sqlite";
                //try
                //{

                //    //数据库管理
                //    var cb = CheckBoxStackPanel.Children.OfType<CheckBox>().ToList();

                //    if ((bool)cb[0].IsChecked)
                //    {
                //        //重置信息
                //        DataBase cdb = new DataBase();
                //        cdb.DeleteTable("movie");
                //        cdb.CreateTable(StaticVariable.SQLITETABLE_MOVIE);
                //        cdb.CloseDB();
                //    }

                //    if ((bool)cb[1].IsChecked)
                //    {
                //        //删除不存在影片
                //        DataBase cdb = new DataBase("");
                //        var movies = cdb.SelectMoviesBySql("select * from movie");
                //        movies.ForEach(movie =>
                //        {
                //            if (!File.Exists(movie.filepath))
                //            {
                //                cdb.DelInfoByType("movie", "id", movie.id);
                //            }
                //        });
                //        cdb.CloseDB();



                //    }

                //    if ((bool)cb[2].IsChecked)
                //    {
                //        //Vaccum
                //        DataBase cdb = new DataBase();
                //        cdb.Vaccum();
                //        cdb.CloseDB();
                //        cdb = new DataBase("Image");
                //        cdb.Vaccum();
                //        cdb.CloseDB();
                //    }

                //    if (!cts.IsCancellationRequested) new PopupWindow(this, "成功!").Show();
                //}
                //finally
                //{
                //    cts.Dispose();
                //    Running = false;
                //}

                //Main main = null;
                //Window window = Jvedio.GetWindow.Get("Main");
                //if (window != null) main = (Main)window;
                //main?.vieModel.Reset();

                break;

            case 5:
                //网络驱动器
                LoadingStackPanel.Visibility = Visibility.Visible;

                string path = UNCPathTextBox.Text;
                if (path == "")
                {
                    break;
                }

                bool CanScan = true;
                //检查权限
                await Task.Run(() =>
                {
                    try { var tl = Directory.GetFiles(path, "*.*", SearchOption.TopDirectoryOnly); }
                    catch { CanScan = false; }
                });

                if (!CanScan)
                {
                    LoadingStackPanel.Visibility = Visibility.Hidden; new Msgbox(this, "权限不够!").ShowDialog(); break;
                }


                bool IsEurope = (bool)ScanTypeRadioButton.IsChecked ? false : true;

                totalnum  = 0;
                insertnum = 0;
                try
                {
                    await Task.Run(() =>
                    {
                        StringCollection stringCollection = new StringCollection();
                        stringCollection.Add(path);
                        List <string> filepaths = Scan.ScanPaths(stringCollection, ct);
                        totalnum  = filepaths.Count;
                        insertnum = Scan.DistinctMovieAndInsert(filepaths, ct, IsEurope);
                    });

                    LoadingStackPanel.Visibility = Visibility.Hidden;
                    if (!cts.IsCancellationRequested)
                    {
                        new PopupWindow(this, $"扫描出 {totalnum} 个,导入 {insertnum} 个", true).Show();
                    }
                }
                finally
                {
                    cts.Dispose();
                    Running = false;
                }
                break;

            default:

                break;
            }
            Running = false;
        }
Beispiel #7
0
        public async void StartRun(object sender, RoutedEventArgs e)
        {
            if (Running)
            {
                HandyControl.Controls.Growl.Error("其他任务正在进行!", "ToolsGrowl");
                return;
            }

            cts = new CancellationTokenSource();
            cts.Token.Register(() => { HandyControl.Controls.Growl.Info("取消当前下载任务!", "ToolsGrowl"); });
            ct = cts.Token;

            var grids = MainGrid.Children.OfType <Grid>().ToList();
            int index = 0;

            for (int i = 0; i < grids.Count; i++)
            {
                if (grids[i].Visibility == Visibility.Visible)
                {
                    index = i; break;
                }
            }
            Running = true;
            switch (index)
            {
            case 0:
                //扫描
                double totalnum  = 0;   //扫描出的视频总数
                double insertnum = 0;   //导入的视频总数
                try
                {
                    //全盘扫描
                    if ((bool)ScanAll.IsChecked)
                    {
                        LoadingStackPanel.Visibility = Visibility.Visible;
                        await Task.Run(() =>
                        {
                            ct.ThrowIfCancellationRequested();

                            List <string> filepaths = Scan.ScanAllDrives();
                            totalnum  = filepaths.Count;
                            insertnum = Scan.DistinctMovieAndInsert(filepaths, ct);
                        });
                    }
                    else
                    {
                        if (vieModel.ScanPath.Count == 0)
                        {
                            break;
                        }
                        LoadingStackPanel.Visibility = Visibility.Visible;



                        await Task.Run(() =>
                        {
                            ct.ThrowIfCancellationRequested();

                            StringCollection stringCollection = new StringCollection();
                            foreach (var item in vieModel.ScanPath)
                            {
                                if (Directory.Exists(item))
                                {
                                    stringCollection.Add(item);
                                }
                            }
                            List <string> filepaths = Scan.ScanPaths(stringCollection, ct);
                            totalnum  = filepaths.Count;
                            insertnum = Scan.DistinctMovieAndInsert(filepaths, ct);
                        }, cts.Token);
                    }

                    LoadingStackPanel.Visibility = Visibility.Hidden;
                    if (!cts.IsCancellationRequested)
                    {
                        HandyControl.Controls.Growl.Info($"扫描出 {totalnum} 个,导入 {insertnum} 个", "ToolsGrowl");
                    }
                }
                catch (OperationCanceledException ex)
                {
                    Console.WriteLine($"{nameof(OperationCanceledException)} thrown with message: {ex.Message}");
                }
                finally
                {
                    cts.Dispose();
                    Running = false;
                }


                break;

            case 1:
                //Access
                LoadingStackPanel.Visibility = Visibility.Visible;
                string AccessPath = AccessPathTextBox.Text;
                if (!File.Exists(AccessPath))
                {
                    HandyControl.Controls.Growl.Error($"不存在 :{AccessPath}", "ToolsGrowl");

                    break;
                }
                try
                {
                    await Task.Run(() =>
                    {
                        DataBase.InsertFromAccess(AccessPath);
                    });

                    LoadingStackPanel.Visibility = Visibility.Hidden;
                    if (!cts.IsCancellationRequested)
                    {
                        HandyControl.Controls.Growl.Success("成功!", "ToolsGrowl");
                    }
                }
                finally
                {
                    cts.Dispose();
                    Running = false;
                }
                break;

            case 2:
                //NFO
                if ((bool)NfoRB1.IsChecked)
                {
                    if (vieModel.NFOScanPath.Count == 0)
                    {
                        HandyControl.Controls.Growl.Warning("路径为空!", "ToolsGrowl");
                    }
                }
                else
                {
                    if (!File.Exists(NFOPathTextBox.Text))
                    {
                        HandyControl.Controls.Growl.Warning($"文件不存在{NFOPathTextBox.Text}", "ToolsGrowl");
                    }
                }


                Running = true;

                try
                {
                    List <string> nfoFiles = new List <string>();
                    if (!(bool)NfoRB1.IsChecked)
                    {
                        nfoFiles.Add(NFOPathTextBox.Text);
                    }
                    else
                    {
                        //扫描所有nfo文件
                        await Task.Run(() =>
                        {
                            this.Dispatcher.Invoke((Action) delegate {
                                StatusTextBlock.Visibility = Visibility.Visible;
                                StatusTextBlock.Text       = "开始扫描";
                            });

                            StringCollection stringCollection = new StringCollection();
                            foreach (var item in vieModel.NFOScanPath)
                            {
                                if (Directory.Exists(item))
                                {
                                    stringCollection.Add(item);
                                }
                            }
                            nfoFiles = Scan.ScanNFO(stringCollection, ct, (filepath) => {
                                this.Dispatcher.Invoke((Action) delegate { StatusTextBlock.Text = filepath; });
                            });
                        }, cts.Token);
                    }


                    //记录日志
                    Logger.LogScanInfo("\n-----【" + DateTime.Now.ToString() + "】NFO扫描-----");
                    Logger.LogScanInfo($"\n扫描出 => {nfoFiles.Count}  个 ");


                    //导入所有 nfo 文件信息
                    double total     = 0;
                    bool   importpic = (bool)NFOCopyPicture.IsChecked;
                    await Task.Run(() =>
                    {
                        nfoFiles.ForEach(item =>
                        {
                            if (File.Exists(item))
                            {
                                Movie movie = GetInfoFromNfo(item);
                                if (movie != null && !string.IsNullOrEmpty(movie.id))
                                {
                                    DataBase.InsertFullMovie(movie);
                                    //复制并覆盖所有图片
                                    if (importpic)
                                    {
                                        CopyPicToPath(movie.id, item);
                                    }
                                    total += 1;
                                    Logger.LogScanInfo($"\n成功导入数据库 => {item}  ");
                                }
                            }
                        });
                    });

                    LoadingStackPanel.Visibility = Visibility.Hidden;
                    if (!cts.IsCancellationRequested)
                    {
                        Logger.LogScanInfo($"\n成功导入 {total} 个");
                        HandyControl.Controls.Growl.Success($"\n成功导入 {total} 个", "ToolsGrowl");
                    }
                }
                finally
                {
                    cts.Dispose();
                    Running = false;
                }


                break;

            case 3:
                //欧美扫描
                if (vieModel.ScanEuPath.Count == 0)
                {
                    break;
                }
                LoadingStackPanel.Visibility = Visibility.Visible;
                totalnum  = 0;
                insertnum = 0;

                try
                {
                    await Task.Run(() =>
                    {
                        StringCollection stringCollection = new StringCollection();
                        foreach (var item in vieModel.ScanEuPath)
                        {
                            if (Directory.Exists(item))
                            {
                                stringCollection.Add(item);
                            }
                        }
                        List <string> filepaths = Scan.ScanPaths(stringCollection, ct);
                        totalnum  = filepaths.Count;
                        insertnum = Scan.DistinctMovieAndInsert(filepaths, ct, true);
                    });

                    LoadingStackPanel.Visibility = Visibility.Hidden;
                    if (!cts.IsCancellationRequested)
                    {
                        HandyControl.Controls.Growl.Info($"扫描出 {totalnum} 个,导入 {insertnum} 个");
                    }
                }
                finally

                {
                    cts.Dispose();
                    Running = false;
                }

                break;

            case 4:

                break;

            case 5:
                //网络驱动器
                LoadingStackPanel.Visibility = Visibility.Visible;

                string path = UNCPathTextBox.Text;
                if (path == "")
                {
                    break;
                }

                bool CanScan = true;
                //检查权限
                await Task.Run(() =>
                {
                    try { var tl = Directory.GetFiles(path, "*.*", SearchOption.TopDirectoryOnly); }
                    catch { CanScan = false; }
                });

                if (!CanScan)
                {
                    LoadingStackPanel.Visibility = Visibility.Hidden; HandyControl.Controls.Growl.Error($"权限不够!"); break;
                }


                bool IsEurope = (bool)ScanTypeRadioButton.IsChecked ? false : true;

                totalnum  = 0;
                insertnum = 0;
                try
                {
                    await Task.Run(() =>
                    {
                        StringCollection stringCollection = new StringCollection();
                        stringCollection.Add(path);
                        List <string> filepaths = Scan.ScanPaths(stringCollection, ct);
                        totalnum  = filepaths.Count;
                        insertnum = Scan.DistinctMovieAndInsert(filepaths, ct, IsEurope);
                    });

                    LoadingStackPanel.Visibility = Visibility.Hidden;
                    if (!cts.IsCancellationRequested)
                    {
                        HandyControl.Controls.Growl.Info($"扫描出 {totalnum} 个,导入 {insertnum} 个");
                    }
                }
                finally
                {
                    cts.Dispose();
                    Running = false;
                }
                break;

            default:

                break;
            }
            Running = false;
        }