コード例 #1
0
        public int ImportFromFile(Stream stream)
        {
            PermissionContext.VerifyPermission(PermissionToken.MikuDbImport);

            var parser   = new AlbumFileParser();
            var imported = parser.Parse(stream);

            return(HandleTransaction(session => {
                SysLog(string.Format("importing album from file with name '{0}'", imported.Title));

                var newAlbum = new MikuDbAlbum(imported);
                session.Save(newAlbum);

                return newAlbum.Id;
            }));
        }
コード例 #2
0
ファイル: MikuDbAlbumService.cs プロジェクト: AgFlore/vocadb
        private List <Album> FindAlbums(ISession session, MikuDbAlbum imported)
        {
            var webLinkMatches = session.Query <AlbumWebLink>()
                                 .Where(w => w.Url == imported.SourceUrl)
                                 .Select(w => w.Entry)
                                 .ToArray();

            var nameMatchDirect = session.Query <Album>()
                                  .Where(s => !s.Deleted &&
                                         ((s.Names.SortNames.English == imported.Title) ||
                                          (s.Names.SortNames.Romaji == imported.Title) ||
                                          (s.Names.SortNames.Japanese == imported.Title)))
                                  .ToArray();

            var nameMatchAdditional = session.Query <AlbumName>()
                                      .Where(m => !m.Album.Deleted && m.Value == imported.Title)
                                      .Select(a => a.Album)
                                      .ToArray();

            return(webLinkMatches.Union(nameMatchDirect).Union(nameMatchAdditional).ToList());
        }
コード例 #3
0
        public AlbumImportResult ImportOne(string url)
        {
            PermissionContext.VerifyPermission(PermissionToken.MikuDbImport);

            MikuDbAlbumContract[] existing = HandleQuery(session => session.Query <MikuDbAlbum>().Select(a => new MikuDbAlbumContract(a)).ToArray());

            var importer = new AlbumImporter(existing);
            var imported = importer.ImportOne(url);

            if (imported.AlbumContract == null)
            {
                return(imported);
            }

            HandleTransaction(session => {
                SysLog(string.Format("importing album from MikuDB with URL '{0}'", url));

                var newAlbum = new MikuDbAlbum(imported.AlbumContract);
                session.Save(newAlbum);
            });

            return(imported);
        }