示例#1
0
        public IEnumerable <AnimeFile> GetEpisodes(Anime anime, EpisodeStatus episodeStatus)
        {
            var collection = GetEpisodes(episodeStatus)
                             .GroupBy(episode => episode.Name)
                             .Select(episode => new GroupFileDistance(episode, anime))
                             .Where(episode => episode.Distance <= 25)
                             .OrderBy(episode => episode.Distance)
                             .FirstOrDefault()
                             ?.Group
                             ?.Select(e => e);

            return(collection ?? new List <AnimeFile>());
        }
示例#2
0
 public IEnumerable <AnimeFile> GetEpisodes(EpisodeStatus episodeStatus)
 {
     try
     {
         return(GetFilesFromStatus(episodeStatus)
                .Where(filePath => FileExtensions.Any(ext => filePath.ToLower().EndsWith(ext)))
                .Select(filePath => new AnimeFile(filePath))
                .OrderBy(animeFile => animeFile.Name)
                .ThenBy(animeFile => animeFile.Episode));
     }
     catch (Exception ex) when(ex is DirectoryNotFoundException || ex is ArgumentException)
     {
         return(new List <AnimeFile>());
     }
 }
示例#3
0
        private IEnumerable <string> GetFilesFromStatus(EpisodeStatus episodeStatus)
        {
            IEnumerable <string> files;

            if (episodeStatus == EpisodeStatus.Unwatched)
            {
                files = GetDirectoryFiles(_settings.PathConfig.Unwatched, "*", SearchOption.AllDirectories);
            }
            else if (episodeStatus == EpisodeStatus.Watched)
            {
                files = GetDirectoryFiles(_settings.PathConfig.Watched, "*", SearchOption.AllDirectories);
            }
            else // (EpisodeStatus == Episode.All)
            {
                files = GetDirectoryFiles(_settings.PathConfig.Watched, "*", SearchOption.AllDirectories)
                        .Union(GetDirectoryFiles(_settings.PathConfig.Unwatched, "*", SearchOption.AllDirectories));
            }

            return(files);
        }
示例#4
0
        public async Task SeedRing0Async(ISpmsContext db, CancellationToken cancellationToken)
        {
            var game = new Game()
            {
                Name        = StaticValues.TestGame,
                Description = "USS Voyager Test SPMS Site",
                SiteTitle   = "SPMS Example Site",
                Disclaimer  =
                    "<p>Star Trek, Star Trek TAS, Star Trek: The Next Generation, Star Trek: Deep Space 9, Star Trek: Voyager, Star Trek Enterprise, and all Star Trek Movies are registered trademarks of Paramount Pictures and their respective owners; no copyright violation is intended or desired.</p><p>All material contained within this site is the property of Dan Taylor, Evan Scown &amp; Beyond the Darkness.</p>",
                SiteAnalytics = "",
                IsSpiderable  = false,
                Author        = "Dan Taylor & Evan Scown",
                RobotsText    = "User-Agent: *\n\rAllow: /"
            };

            if (!db.Game.Any(g => g.Name == StaticValues.TestGame))
            {
                await db.Game.AddAsync(game, cancellationToken);

                await db.SaveChangesAsync(cancellationToken);

                // Add Game URL's

                await db.GameUrl.AddAsync(new GameUrl()
                {
                    GameId = game.Id, Url = "localhost"
                }, cancellationToken);

                await db.GameUrl.AddAsync(new GameUrl()
                {
                    GameId = game.Id, Url = "spms0.rpg-hosting.net"
                },
                                          cancellationToken);

                await db.SaveChangesAsync(cancellationToken);
            }

            game = await db.Game.Include(x => x.Url)
                   .FirstAsync(g => g.Name == StaticValues.TestGame, cancellationToken);


            if (game.IsSpiderable.HasValue == false || game.IsSpiderable.Value)
            {
                game.IsSpiderable = false;
                await db.SaveChangesAsync(cancellationToken);
            }

            if (string.IsNullOrEmpty(game.RobotsText))
            {
                game.RobotsText = "User-Agent: *\n\rAllow: /";
                await db.SaveChangesAsync(cancellationToken);
            }

            if (string.IsNullOrEmpty(game.Author))
            {
                game.Author = "Dan Taylor & Evan Scown";
                await db.SaveChangesAsync(cancellationToken);
            }

            await SeedBiographyStatus(_db, game.Id, cancellationToken);
            await SeedBiographyState(_db, game.Id, cancellationToken);

            //await SeedPostings(_db, game.Id, cancellationToken);

            // Posting
            if (!db.Posting.Any(p => p.Name == "USS Voyager" && p.GameId == game.Id))
            {
                await db.Posting.AddAsync(new Posting()
                {
                    Name = "USS Voyager", Default = true, GameId = game.Id, IsPlayable = true
                }, cancellationToken);
            }


            await db.SaveChangesAsync(cancellationToken);

            await SeedBiographyTypes(_db, game.Id, cancellationToken);

            if (await db.Posting.AnyAsync(x => x.Name == "USS Voyager" && x.GameId == game.Id,
                                          cancellationToken: cancellationToken))
            {
                await db.Posting.AddAsync(new Posting()
                {
                    GameId  = game.Id,
                    Default = true,
                    Name    = "USS Voyager"
                }, cancellationToken);

                await db.SaveChangesAsync(cancellationToken);
            }

            var posting = await db.Posting.FirstAsync(x => x.GameId == game.Id && x.Name == "USS Voyager", cancellationToken);


            // Add Biographies

            // Character
            if (!await db.Biography.AnyAsync(b => b.Firstname == "Kathryn" && b.Surname == "Janeway", cancellationToken: cancellationToken))
            {
                await db.Biography.AddAsync(new Domain.Models.Biography()
                {
                    Firstname  = "Kathryn",
                    Surname    = "Janeway",
                    Born       = "Earth",
                    Gender     = "Female",
                    Assignment = "Starbase Gamma",
                    PostingId  = db.Posting.First(p => p.Name == "Starbase Gamma").Id,
                    Rank       = "Captain",
                    StateId    = (await db.BiographyState.FirstAsync(x => x.GameId == game.Id && x.Name == StaticValues.Published, cancellationToken)).Id,
                    StatusId   = (await db.BiographyState.FirstAsync(x => x.GameId == game.Id && x.Name == StaticValues.BioStatusAlive, cancellationToken)).Id
                }, cancellationToken);
            }


            // Series
            var series = new Series()
            {
                Title = "Series 1", GameId = game.Id, IsActive = true
            };

            if (!db.Series.Any(x => x.Title == "Series 1" && x.GameId == game.Id))
            {
                await db.Series.AddAsync(series, cancellationToken);

                await db.SaveChangesAsync(cancellationToken);
            }
            else
            {
                series = await _db.Series.FirstAsync(x => x.Title == "Series 1" && x.GameId == game.Id,
                                                     cancellationToken : cancellationToken);

                if (!series.IsActive)
                {
                    series.IsActive = true;
                    await db.SaveChangesAsync(cancellationToken);
                }
            }

            if (!await db.Episode.Include(x => x.Series).AnyAsync(x => x.Title == "Caretaker" && x.Series.GameId == game.Id, cancellationToken: cancellationToken))
            {
                EpisodeStatus episodeStatus = await db.EpisodeStatus.AsNoTracking().FirstAsync(x => x.Name == StaticValues.Published, cancellationToken: cancellationToken);

                await db.Episode.AddAsync(new Episode()
                {
                    Title    = "Caretaker",
                    SeriesId = series.Id,
                    StatusId = episodeStatus.Id
                }, cancellationToken);
            }

            await db.SaveChangesAsync(cancellationToken);
        }
示例#5
0
        public async Task SeedBeyondTheDarknessAsync(ISpmsContext db, CancellationToken cancellationToken)
        {
            var game = new Game()
            {
                Name = StaticValues.BtdGame, Description = "BtD Simulation", SiteTitle = "Beyond the Darkness a Star Trek RPG", Disclaimer = "<p>Star Trek, Star Trek TAS, Star Trek: The Next Generation, Star Trek: Deep Space 9, Star Trek: Voyager, Star Trek Enterprise, and all Star Trek Movies are registered trademarks of Paramount Pictures and their respective owners; no copyright violation is intended or desired.</p><p>All material contained within this site is the property of Dan Taylor, Evan Scown &amp; Beyond the Darkness.</p>", SiteAnalytics = @"<!-- Global site tag (gtag.js) - Google Analytics -->
<script async src='https://www.googletagmanager.com/gtag/js?id=UA-167297746-1'></script>
                <script>
                window.dataLayer = window.dataLayer || [];
                function gtag() { dataLayer.push(arguments); }
            gtag('js', new Date());

            gtag('config', 'UA-167297746-1');
                </script> "
            };

            if (!db.Game.Any(g => g.Name == StaticValues.BtdGame))
            {
                await db.Game.AddAsync(game, cancellationToken);

                await db.SaveChangesAsync(cancellationToken);

                // Add Game URL's

                await db.GameUrl.AddAsync(new GameUrl()
                {
                    GameId = game.Id, Url = "www.beyond-the-darkness.com"
                }, cancellationToken);

                //await db.GameUrl.AddAsync(new GameUrl() { GameId = game.Id, Url = "spms0.rpg-hosting.net" }, cancellationToken);
                await db.GameUrl.AddAsync(new GameUrl()
                {
                    GameId = game.Id, Url = "btd.beyond-the-darkness.com"
                }, cancellationToken);

                await db.SaveChangesAsync(cancellationToken);
            }
            else
            {
                try
                {
                    game = await db.Game.Include(x => x.Url).FirstOrDefaultAsync(g => g.Name == StaticValues.BtdGame,
                                                                                 cancellationToken: cancellationToken);


                    if (game.Url.Any(x => x.Url == "spms0.rpg-hosting.net"))
                    {
                        var urlToRemove = await db.GameUrl.FirstAsync(x => x.GameId == game.Id && x.Url == "spms0.rpg-hosting.net", cancellationToken : cancellationToken);

                        db.GameUrl.Remove(urlToRemove);
                        await db.SaveChangesAsync(cancellationToken);
                    }

                    if (game.Url.Any(x => x.Url == "localhost"))
                    {
                        var urlToRemove = await db.GameUrl.FirstAsync(x => x.GameId == game.Id && x.Url == "localhost", cancellationToken : cancellationToken);

                        db.GameUrl.Remove(urlToRemove);
                        await db.SaveChangesAsync(cancellationToken);
                    }
                }
                catch (Exception ex)
                {
                    var i = 1;
                }
            }


            await SeedBiographyStatus(_db, game.Id, cancellationToken);
            await SeedBiographyState(_db, game.Id, cancellationToken);
            await SeedPostings(_db, game.Id, cancellationToken);
            await SeedBiographyTypes(_db, game.Id, cancellationToken);


            // Add Biographies

            // Character
            if (!await db.Biography.AnyAsync(b => b.Firstname == "Marcus" && b.Surname == "Brightstar", cancellationToken: cancellationToken))
            {
                await db.Biography.AddAsync(new Domain.Models.Biography()
                {
                    Firstname   = "Marcus",
                    Surname     = "Brightstar",
                    Born        = "Earth",
                    Gender      = "Male",
                    Assignment  = "Starbase Gamma",
                    PostingId   = db.Posting.First(p => p.Name == "Starbase Gamma").Id,
                    Rank        = "Captain",
                    DateOfBirth = "Sometime in 2351",
                    StateId     = (await db.BiographyState.FirstAsync(x => x.GameId == game.Id && x.Name == StaticValues.Published, cancellationToken)).Id,
                    StatusId    = (await db.BiographyState.FirstAsync(x => x.GameId == game.Id && x.Name == StaticValues.BioStatusAlive, cancellationToken)).Id
                }, cancellationToken);
            }
            if (!db.Biography.Any(b => b.Firstname == "Jessica" && b.Surname == "Darkly"))
            {
                await db.Biography.AddAsync(new Domain.Models.Biography()
                {
                    Firstname   = "Jessica",
                    Surname     = "Darkly",
                    Born        = "Earth",
                    Gender      = "Female",
                    Assignment  = "Starbase Gamma",
                    PostingId   = db.Posting.First(p => p.Name == "Starbase Gamma").Id,
                    Rank        = "Admiral",
                    DateOfBirth = "Sometime in 2332",
                    StateId     = (await db.BiographyState.FirstAsync(x => x.GameId == game.Id && x.Name == StaticValues.Published, cancellationToken)).Id,
                    StatusId    = (await db.BiographyState.FirstAsync(x => x.GameId == game.Id && x.Name == StaticValues.BioStatusAlive, cancellationToken)).Id,
                }, cancellationToken);
            }
            if (!db.Biography.Any(b => b.Firstname == "Nigel" && b.Surname == "Adisa"))
            {
                await db.Biography.AddAsync(new Domain.Models.Biography()
                {
                    Firstname   = "Nigel",
                    Surname     = "Adisa",
                    Born        = "Earth",
                    Gender      = "Male",
                    Assignment  = "Starbase Gamma",
                    PostingId   = db.Posting.First(p => p.Name == "Starbase Gamma").Id,
                    Rank        = "Lieutenant",
                    DateOfBirth = "",
                    StateId     = (await db.BiographyState.FirstAsync(x => x.GameId == game.Id && x.Name == StaticValues.Published, cancellationToken)).Id,
                    StatusId    = (await db.BiographyState.FirstAsync(x => x.GameId == game.Id && x.Name == StaticValues.BioStatusAlive, cancellationToken)).Id,
                    History     = @"A black male of African/British decent, 6'0 in height and weighing in at 196 pounds. He has short cropped black hair and usually wears a short beard.

General Overview		Doctor Adisa, a specialist in neurology possesses a seemingly easygoing manner which he generally uses to mask his borderline OCD issues. He is very witty however his humor can sometimes become overly Sharp. His hobbies include playing various jazz instruments, long distance running, chess, and baking.



Personal History		graduated from Oxford University, attended st. George's medical University and graduated in the top 5% of his class.

Married at the age of 22, and divorced at the age of 30, the union producing one child, a daughter.

He enrolled in Starfleet directly after graduating the University against his father's wishes. who vehemently opposes Starfleet policies."
                }, cancellationToken);
            }

            if (!db.Biography.Any(b => b.Firstname == "Vars" && b.Surname == "Qiratt"))
            {
                await db.Biography.AddAsync(new Domain.Models.Biography()
                {
                    Firstname   = "Vars",
                    Surname     = "Qiratt",
                    Born        = "Bolia",
                    Species     = "Bolian",
                    Gender      = "Male",
                    Assignment  = "",
                    PostingId   = db.Posting.First(p => p.Name == "Starbase Gamma").Id,
                    Rank        = "Lieutenant Commander",
                    DateOfBirth = "",
                    PlayerId    = db.Player.First(p => p.DisplayName == "Dan Taylor").Id,
                    StateId     = (await db.BiographyState.FirstAsync(x => x.GameId == game.Id && x.Name == StaticValues.Published, cancellationToken)).Id,
                    StatusId    = (await db.BiographyState.FirstAsync(x => x.GameId == game.Id && x.Name == StaticValues.BioStatusAlive, cancellationToken)).Id,
                    History     = @"Vars is best described as carrying extra weight. A rotund Bolian Male with puffy facial features and a noticeable double chin. His height is on the slightly shorter side, coming in at around 5'9&quot;.
Vars is a vibrant individual living up to the term, 'Jolly Fat Man'.He has a distinctive laugh that can be considered quite obnoxious, not helped by his flavorful personality.Wearing his emotions like a badge on his sleeve,
Vars rarely shy's away from expressing his opinion. To the same extent, a withdrawn Vars is often the sign of an insecurity or fear.

He keeps with him a Hair piece that he wears on 'special occasions' or on Thursdays.Part of his quirky nature.

* 2383 - Current - USS Ronald Reagan - Chief of Operations(Lt Cmdr)
* 2383(Late) - USS Ronald Reagan - Acting Chief of Operations(Lt Cmdr)
* 2383(Early) - USS Ronald Reagan - Assistant Chief of Engineering / Acting Chief of Operations(Lt)
* 2380 - 2382 - USS Midway - Assistant Chief of Engineering(Lt)
* 2379 - USS Midway - Supervising Engineering Officer(Lt JG)
* 2376 - 2378 - Starbase 386 - Star Ship Maintenance Engineering Team Lead(Lt JG)
* 2374 - 2375 - USS Gettysburg - Engineering Officer / Trainee Supervisor(Lt JG)
* 2372 - 2373 - USS Melbourne - Engineering Officer(Ens / Lt JG)
* 2368 - 2371 - USS Galloway - Engineering Officer(Ens)
* 2363 - 2367 - Starfleet Academy - Officer Cadet[Engineering Stream]"
                }, cancellationToken);
            }


            // Series
            var series = new Series()
            {
                Title = "Series 1", GameId = game.Id, IsActive = true
            };

            if (!db.Series.Any(x => x.Title == "Series 1" && x.GameId == game.Id))
            {
                await db.Series.AddAsync(series, cancellationToken);

                await db.SaveChangesAsync(cancellationToken);
            }
            else
            {
                series = await _db.Series.FirstAsync(x => x.Title == "Series 1" && x.GameId == game.Id,
                                                     cancellationToken : cancellationToken);

                if (!series.IsActive)
                {
                    series.IsActive = true;
                    await db.SaveChangesAsync(cancellationToken);
                }
            }

            if (!await db.Episode.AnyAsync(x => x.Title == "Prologue", cancellationToken: cancellationToken))
            {
                EpisodeStatus episodeStatus = await db.EpisodeStatus.AsNoTracking().FirstAsync(x => x.Name == StaticValues.Published, cancellationToken: cancellationToken);

                await db.Episode.AddAsync(new Episode()
                {
                    Title    = "Prologue",
                    SeriesId = series.Id,
                    StatusId = episodeStatus.Id
                }, cancellationToken);
            }

            await db.SaveChangesAsync(cancellationToken);
        }
示例#6
0
 public async Task <IEnumerable <AnimeFile> > GetEpisodesAsync(Anime anime, EpisodeStatus episodeStatus)
 {
     return(await Task.Run(() => GetEpisodes(anime, episodeStatus)));
 }