Example #1
0
 private void _Edit(dynamic o)
 {
     if (Selected != null)
     {
         var vm = new VM新番();
         vm.Anime    = Selected;
         vm.EditMode = true;
         var window = new View.W新番(vm);
         window.Owner = o;
         window.ShowDialog();
     }
 }
Example #2
0
        public ObservableCollection <资源> CreateList(dynamic sender)
        {
            try
            {
                string[] strs = Settings.Default.路径格式.Split('|');
                var      dirs = (new DirectoryInfo(strs[0])).GetDirectories().Where(
                    d => Regex.IsMatch(d.Name, strs[1])
                    ).ToArray();
                文件夹整理(dirs);
                string 扩展名 = Settings.Default.扩展名;

                var aniList = new List <资源>();

                foreach (var dir in dirs)
                {
                    var bgmDirs = dir.GetDirectories();
                    foreach (var bgm in bgmDirs)
                    {
                        var name  = string分割(bgm.Name);
                        var mark  = $"{dir}-{name[1]}";
                        var anime = DbModel.资源.SingleOrDefault(rs => rs.标识 == mark);
                        if (anime == null)
                        {
                            anime = new 资源()
                            {
                                字幕组 = name[0],
                                标识  = mark,
                                目录  = bgm.FullName
                            };

                            var vm = new VM新番()
                            {
                                Anime    = anime,
                                EditMode = false
                            };
                            sender.Dispatcher.Invoke(new Action(() =>
                            {
                                var window = new View.W新番(vm);
                                window.ShowDialog();
                            }));
                            if (!vm.DialogResult)
                            {
                                continue;
                            }
                        }
                        if (anime.完结)
                        {
                            continue;
                        }
                        if (anime.目录 != bgm.FullName)
                        {
                            anime.目录 = bgm.FullName;
                            DbModel.SaveChanges();
                        }
                        anime.计数 = -1;
                        var    files = bgm.GetFiles().OrderBy(f => f.CreationTime);
                        double temp  = 0;
                        foreach (var file in files)
                        {
                            if (file.Extension == ".torrent")
                            {
                                file.Delete();
                                continue;
                            }
                            if (!扩展名.Contains(file.Extension.ToLower()))
                            {
                                continue;
                            }
                            var info = string分割(file.Name);
                            if (info.Length < 3)
                            {
                                continue;
                            }
                            var macth = Regex.Match(info[2], @"\d{1,3}(\.5)?");
                            if (!macth.Success && info.Length > 3)
                            {
                                macth = Regex.Match(info[3], @"\d{1,3}(\.5)?");
                            }
                            if (macth.Success)
                            {
                                temp = double.Parse(macth.Value);
                                if (temp > anime.计数)
                                {
                                    anime.计数   = temp;
                                    anime.完成时间 = file.CreationTime;
                                    anime.路径   = file.FullName;
                                }
                            }
                        }
                        aniList.Add(anime);
                    }
                }

                var online = DbModel.资源.Where(a => !a.完结 && a.在线).ToList();
                if (online.Count > 0)
                {
                    aniList.AddRange(online.Select(a => 在线更新(a)));
                }
                aniList.AddRange(onlineBgms());
                DbModel.SaveChanges();

                return(new ObservableCollection <资源>(aniList.OrderByDescending(a => a.完成时间)));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return(null);
            }
        }
Example #3
0
 private void _EditAnime(dynamic o)
 {
     if (SelectedAnime != null)
     {
         var vm = new VM新番();
         vm.Anime = SelectedAnime;
         vm.EditMode = true;
         var win = new View.W新番(vm);
         win.Owner = o;
         win.ShowDialog();
     }
 }
Example #4
0
        public ObservableCollection<资源> CreateList(dynamic sender)
        {
            try
            {
                string[] strs = Settings.Default.路径格式.Split('|');
                var dirs = (new DirectoryInfo(strs[0])).GetDirectories().Where(
                    d => Regex.IsMatch(d.Name, strs[1])
                    ).ToArray();
                文件夹整理(dirs);
                string 扩展名 = Settings.Default.扩展名;

                var aniList = new List<资源>();

                foreach (var dir in dirs)
                {
                    var bgmDirs = dir.GetDirectories();
                    foreach (var bgm in bgmDirs)
                    {
                        var name = string分割(bgm.Name);
                        var mark = $"{dir}-{name[1]}";
                        var anime = DbModel.资源.SingleOrDefault(rs => rs.标识 == mark);
                        if (anime == null)
                        {
                            anime = new 资源()
                            {
                                字幕组 = name[0],
                                标识 = mark,
                                目录 = bgm.FullName
                            };

                            var vm = new VM新番()
                            {
                                Anime = anime,
                                EditMode = false
                            };
                            sender.Dispatcher.Invoke(new Action(() =>
                            {
                                var window = new View.W新番(vm);
                                window.ShowDialog();
                            }));
                            if (!vm.DialogResult)
                                continue;
                        }
                        if (anime.完结)
                            continue;
                        if (anime.目录 != bgm.FullName)
                        {
                            anime.目录 = bgm.FullName;
                            DbModel.SaveChanges();
                        }
                        anime.计数 = -1;
                        var files = bgm.GetFiles().OrderBy(f => f.CreationTime);
                        double temp = 0;
                        foreach (var file in files)
                        {
                            if (file.Extension == ".torrent")
                            {
                                file.Delete();
                                continue;
                            }
                            if (!扩展名.Contains(file.Extension.ToLower()))
                                continue;
                            var info = string分割(file.Name);
                            if (info.Length < 3)
                                continue;
                            var macth = Regex.Match(info[2], @"\d{1,3}(\.5)?");
                            if (!macth.Success && info.Length > 3)
                                macth = Regex.Match(info[3], @"\d{1,3}(\.5)?");
                            if (macth.Success)
                            {
                                temp = double.Parse(macth.Value);
                                if (temp > anime.计数)
                                {
                                    anime.计数 = temp;
                                    anime.完成时间 = file.CreationTime;
                                    anime.路径 = file.FullName;
                                }
                            }
                        }
                        aniList.Add(anime);
                    }
                }

                var online = DbModel.资源.Where(a => !a.完结 && a.在线).ToList();
                if (online.Count > 0)
                    aniList.AddRange(online.Select(a => 在线更新(a)));
                aniList.AddRange(onlineBgms());
                DbModel.SaveChanges();

                return new ObservableCollection<资源>(aniList.OrderByDescending(a => a.完成时间));
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex);
                return null;
            }
        }