public async void GetLatest_OnlyGrabsTheSpecifiedNumber()
        {
            var database = IntegrationDatabase.CreateBlankDatabase();
            using (var context = database.CreateContext())
            {
                DateTime startDate = new DateTime(2015, 5, 1);
                for (int i = 1; i <= 15; i++)
                {
                    var comic = new Comic()
                    {
                        ComicNumber = i,
                        ComicType = ComicType.Explosm,
                        ImageSrc = $"http://www.example.com/images/{i}.png",
                        PublishedDate = startDate.AddDays(i).Date
                    };

                    context.Comics.Add(comic);
                }

                await context.SaveChangesAsync();

                var repo = new ComicsRepository(context);
                var recent = repo.GetLatestComics(ComicType.Explosm);

                Check.That(recent).HasSize(10);
            }
        }
        public void UsesRegistryToGetNewComics()
        {
            var mocker = new AutoMoqer();

            var lastExplosmComic = new Comic();
            var newExplosmComic1 = new Comic();
            var newExplosmComic2 = new Comic();

            var explosm = new Mock<IComicDownloader>();
            explosm.Setup(m => m.GetNewComicsSince(lastExplosmComic))
                .Returns(new[] { newExplosmComic1, newExplosmComic2 });

            mocker.GetMock<IComicsRepository>()
                .Setup(m => m.GetLastImportedComic(ComicType.Explosm))
                .Returns(lastExplosmComic)
                .Verifiable();

            var registry = new ComicConfigRegistry();
            registry.Add(new ComicConfig(ComicType.Explosm, explosm.Object));

            // ReSharper disable once RedundantTypeArgumentsOfMethod
            mocker.SetInstance<ComicConfigRegistry>(registry);

            mocker.Create<ImportProcess>()
                .Run();

            mocker.GetMock<IComicsRepository>().VerifyAll();
            mocker.GetMock<IComicsRepository>()
                .Verify(m => m.InsertComic(newExplosmComic1), Times.Once);
            mocker.GetMock<IComicsRepository>()
                .Verify(m => m.InsertComic(newExplosmComic2), Times.Once);
        }
        public void ReportsComicsImported()
        {
            var mocker = new AutoMoqer();

            var lastExplosmComic = new Comic();
            var newExplosmComic1 = new Comic();
            var newExplosmComic2 = new Comic();

            var explosm = new Mock<IComicDownloader>();
            explosm.Setup(m => m.GetNewComicsSince(lastExplosmComic))
                .Returns(new[] { newExplosmComic1, newExplosmComic2 });

            mocker.GetMock<IComicsRepository>()
                .Setup(m => m.GetLastImportedComic(ComicType.Explosm))
                .Returns(lastExplosmComic)
                .Verifiable();

            var registry = new ComicConfigRegistry();
            registry.Add(new ComicConfig(ComicType.Explosm, explosm.Object));

            // ReSharper disable once RedundantTypeArgumentsOfMethod
            mocker.SetInstance<ComicConfigRegistry>(registry);

            var process = mocker.Create<ImportProcess>();
            process.Run();

            Check.That(process.ImportedComics.Count).IsEqualTo(2);
        }
Beispiel #4
0
 private SyndicationItem MapComicToItem(Comic c)
 {
     var content = $"<img src='{c.ImageSrc}' />";
     return new SyndicationItem(
         c.PublishedDate.ToString("yyyy-MM-dd"),
         content,
         new Uri(c.Permalink));
 }
        public void DownloadsWhileThereIsAValidNextLink()
        {
            var downloader = _mocker.Create<ExplosmDownloader>();

            var lastComic = new Comic { ComicNumber = 4124 };
            var comics = downloader.GetNewComicsSince(lastComic);

            Check.That(comics.Single().ComicNumber).IsEqualTo(4125);
        }
        public void ItSetsTheComicTypeToExplosm()
        {
            var downloader = _mocker.Create<ExplosmDownloader>();

            var lastComic = new Comic { ComicNumber = 4124 };
            var comic = downloader.GetNewComicsSince(lastComic).Single();

            Check.That(comic.ComicType).IsEqualTo(ComicType.Explosm);
        }
        public void ItSetsTheImageSrc()
        {
            var downloader = _mocker.Create<ExplosmDownloader>();

            var lastComic = new Comic { ComicNumber = 4124 };
            var comic = downloader.GetNewComicsSince(lastComic).Single();

            Check.That(comic.ImageSrc).IsEqualTo("http://files.explosm.net/comics/Kris/knowingis.png");
        }
        public void ItSetsTheComicTypeToDilbert()
        {
            var downloader = _mocker.Create<DilbertDownloader>();
            downloader.Today = new DateTime(2015, 11, 23);

            var lastComic = new Comic() { PublishedDate = new DateTime(2015, 11, 22) };
            var comic = downloader.GetNewComicsSince(lastComic).Single();

            Check.That(comic.ComicType).IsEqualTo(ComicType.Dilbert);
        }
        public HomeControllerTests()
        {
            _mocker = new AutoMoqer();

            _registry = new ComicConfigRegistry();
            _mocker.SetInstance(_registry);

            _latestDilbert = RegisterComic(ComicType.Dilbert);
            _latestExplosm = RegisterComic(ComicType.Explosm);
        }
        public void ItSetsTheImageSrc()
        {
            var downloader = _mocker.Create<DilbertDownloader>();
            downloader.Today = new DateTime(2015, 11, 23);

            var lastComic = new Comic() { PublishedDate = new DateTime(2015, 11, 22) };
            var comic = downloader.GetNewComicsSince(lastComic).Single();

            Check.That(comic.ImageSrc).IsEqualTo("http://assets.amuniversal.com/041159a06560013319a6005056a9545d");
        }
Beispiel #11
0
        private static void ParseTrash()
        {
            var comic = new Comic()
            {
                Name = "Trash",
                Source = "http://www.mangareader.net/trash/"
            };

            using (var client = new WebClient())
            {
                for (int issueID = 1; issueID <= 26; issueID++)
                {
                    Issue issue = new Issue()
                    {
                        Name = "Trash #" + issueID,
                    };

                    int stripCount = 0;

                    // Gather issue information
                    {
                        string data = client.DownloadString(string.Format("http://www.mangareader.net/trash/{0}/", issueID));
                        var doc = new HtmlDocument();
                        doc.LoadHtml(data);

                        var node = doc.DocumentNode.SelectSingleNode("//div[@id=\"selectpage\"]");
                        issue.Cover = doc.DocumentNode.SelectSingleNode("//img[@id=\"img\"]")?.GetAttributeValue("src", null);

                        var text = Regex.Match(node.InnerText, "of (?<num>\\d+)$");
                        stripCount = int.Parse(text.Groups["num"].Value);
                    }

                    for (int stripID = 1; stripID <= stripCount; stripID++)
                    {
                        string url = string.Format("http://www.mangareader.net/trash/{0}/{1}", issueID, stripID);
                        Console.WriteLine(url);
                        string data = client.DownloadString(url);
                        var doc = new HtmlDocument();
                        doc.LoadHtml(data);

                        var strip = new Strip();
                        strip.Title = "Trash #" + issueID + " Page #" + stripID;

                        strip.Url = doc.DocumentNode.SelectSingleNode("//img[@id=\"img\"]")?.GetAttributeValue("src", null);
                        issue.Strips.Add(strip);
                    }

                    comic.Issues.Add(issue);
                }
            }
            using (var fs = File.Open("trash.xml", FileMode.Create, FileAccess.Write))
            {
                comic.Save(fs);
            }
        }
Beispiel #12
0
        public bool ExportCompressFile(Comic comic, string originalPath)
        {
            try
            {
                string subPath = string.Empty;

                var imageExtension = string.Empty;

                string path = originalPath + @"\" + comic.Title;

                this.CreateFolder(path); // create comic folder
                
                foreach (var chapter in comic.Chapters)
                {
                    subPath = path + @"\data" + @"\" + chapter.Title + chapter.Index;
                    this.CreateFolder(subPath); // create chapter folder

                    foreach (var page in chapter.Pages)
                    {
                        imageExtension = Path.GetExtension(page.ImgPath);
                        CopyFiles(page.ImgPath, subPath + @"\" + page.Index + imageExtension);
                    }
                }

                this.CopyFiles(comic.CoverPath, path + @"\" + "cover" + Path.GetExtension(comic.CoverPath)); // create cover

                ConvertJson(comic, AppDomain.CurrentDomain.BaseDirectory, DateTime.Now.ToString("dMMyyyy"), "tmp");

                ConvertJson(ResetImagePath(CloneComic(comic)), path, "meta", "manga"); // convert meta data file and save to comic folder

                if (!Directory.Exists(originalPath))
                {
                    Directory.CreateDirectory(originalPath);
                }

                FileStream fsOut = File.Create(path + ".zip");

                var zipStream = new ZipOutputStream(fsOut);

                int folderOffset = path.Length  + (originalPath.EndsWith("\\") ? 0 : 1);

                CompressFolder(path, zipStream, folderOffset);

                zipStream.IsStreamOwner = true;

                zipStream.Close();

                return true;
            }
            catch (Exception)
            {
                return false;
            }
           
        }
        private Comic RegisterComic(ComicType type)
        {
            var comic = new Comic() { ComicType = type };
            _mocker.GetMock<IComicsRepository>()
                 .Setup(m => m.GetLastImportedComic(type))
                 .Returns(comic);

            _registry.Add(new ComicConfig(type, null));

            return comic;
        }
Beispiel #14
0
        private void MenuSave_Click(object sender, RoutedEventArgs e)
        {
            var page1 = new Page {Caption = "test", ImgPath = @"C:\image\1.jpg", PageIndex = 1};
            var page2 = new Page { Caption = "test1", ImgPath = @"C:\image\2.jpg", PageIndex = 2 };

            var listPage = new List<Page> {page1, page2};

            var chapter1 = new Chapter {Title = "Chapter1", Pages = listPage, Index = 1};

            var listChapter = new List<Chapter> {chapter1};

            var comic = new Comic
            {
                Author = "Le Minh Tu",
                Chapters = listChapter,
                Description = "1 nua ranma",
                Id = 1,
                Title = "1_nua_ranma"
            };

            var path = @"C:\" + comic.Title;

            CreateFolder(comic, path); // create parent folder

            foreach (var chap in comic.Chapters)
            {
                CreateFolder(comic, path + @"\" + chap.Title); // create sub folder

                foreach (var page in chap.Pages)
                {
                    CopyFiles(page.ImgPath, path + @"\" + chap.Title + @"\" + page.PageIndex + ".jpg");
                }
            }

            ConvertJson(comic, path); // create meta data

            if (!Directory.Exists(@"C:\zip"))
            {
                Directory.CreateDirectory(@"C:\zip");
            }

            FileStream fsOut = File.Create(@"C:\zip" + @"\manga.zip");

            ZipOutputStream zipStream = new ZipOutputStream(fsOut);

            CompressFolder(path, zipStream, 1);

            zipStream.IsStreamOwner = true;

            zipStream.Close();
            

        }
Beispiel #15
0
 /// <summary>
 /// method for deleteCommand
 /// </summary>
 public void DeleteExecute()
 {
     if (_selectedGridRow != null)
     {
         Comic toDelete = Mapper.ViewComicMapper(_selectedGridRow.Comic);
         controller.RemoveComic(toDelete);
         _comicList = new List <ViewComic>(Mapper.ComicsMapper(controller.GetCatalogue().Comics));
         FilterExecute();
     }
     else
     {
         throw new PresentationException("Gelieve iets te selecteren a.u.b.");
     }
 }
Beispiel #16
0
 public IActionResult Add(AddComicViewModel comicViewModel)
 {
     if (ModelState.IsValid)
     {
         Comic comic = new Comic(comicViewModel.Title, comicViewModel.IssueNumber);
         comic.Grade = ComicsData.GetGradeById(comicViewModel.GradeId.Value);
         ComicsData.Add(comic);
         //return RedirectToAction("Index", new { name = "blake" });
         return(Redirect("/Comics"));
     }
     // Bad news, stuff is not right
     // Stay, so the user can finish form
     return(View(comicViewModel));
 }
Beispiel #17
0
        public Comic GetComic(int id)
        {
            Comic comicToReturn = null;

            foreach (var comic in _comics)
            {
                if (comic.Id == id)
                {
                    comicToReturn = comic;
                    break;
                }
            }
            return(comicToReturn);
        }
Beispiel #18
0
        private bool HasSameSize(FileInfo fileDownloadInfo, Comic comic)
        {
            string sizeWeb  = string.Format("{0:n1}", float.Parse(comic.SizeWeb.Replace(".", ",")));
            string sizeDisk = string.Format("{0:n1}", float.Parse(Functions.FormatSize(fileDownloadInfo.Length)));

            if (sizeWeb.Equals(sizeDisk))
            {
                return(true);
            }
            else
            {
                return(false);
            }
        }
Beispiel #19
0
        /// <summary>
        /// Gets a comic by ID
        /// </summary>
        /// <param name="id">Comic ID</param>
        /// <returns>Requested comic</returns>
        public static Comic GetComic(int id)
        {
            Comic comic = XkcdDatabase.GetComic(id);

            if (comic != null)
            {
                return(comic);
            }
            if (ComicDictionary.Keys.Contains(id))
            {
                return(GetComic(ComicDictionary[id]));
            }
            return(null);
        }
        public void RemoveAuthorDoestExistShouldThrowException()
        {
            Comic  comic   = new Comic();
            Author author1 = new Author("author1");
            Author author2 = new Author("author2");

            comic.AddAuthor(author1);
            Action act1 = () => comic.RemoveAuthor(author1);

            act1.Should().NotThrow <DomainException>();
            Action act2 = () => comic.RemoveAuthor(author2);

            act2.Should().Throw <DomainException>().WithMessage("Author bestaat niet.");
        }
Beispiel #21
0
        public async Task ExecuteAsync(CancellationToken cancellationToken)
        {
            WebClient getNew              = new WebClient();
            var       newComic            = getNew.DownloadString("http://xkcd.com/info.0.json");
            Comic     deserializeNewComic = JsonConvert.DeserializeObject <Comic>(newComic);

            var newestComicInDb = _context.Comics.Max(n => n.Num);

            if (deserializeNewComic.Num > newestComicInDb)
            {
                AddNewComic(deserializeNewComic);
            }
            await _context.SaveChangesAsync(cancellationToken);
        }
Beispiel #22
0
        // GET: Comic/Details/5
        public ActionResult Details(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Comic comic = db.Comics.Find(id);

            if (comic == null)
            {
                return(HttpNotFound());
            }
            return(View(comic));
        }
Beispiel #23
0
        /// <summary>
        /// Gets a comic from a comic archive entry
        /// </summary>
        /// <param name="comicArchiveEntry">Comic archive entry</param>
        /// <returns>Comic object</returns>
        public static Comic GetComic(ComicArchiveEntry comicArchiveEntry)
        {
            Comic comic = XkcdDatabase.GetComic(comicArchiveEntry.Id);

            if (comic != null)
            {
                return(comic);
            }
            var          permaLink = $"https://xkcd.com/{comicArchiveEntry.Id}/";
            var          web       = new HtmlWeb();
            HtmlDocument doc       = web.Load(permaLink);

            return(GetComic(comicArchiveEntry, permaLink, doc));
        }
Beispiel #24
0
        private void FrmTest_Load(object sender, EventArgs e)
        {
            Biografia p1 = (Biografia)"Life (Keith Richards)";
            Biografia p2 = new Biografia("White line fever (Lemmy)", 5);
            Biografia p3 = new Biografia("Commando (Johnny Ramone)", 2, 5000);
            Comic     p4 = new Comic("La Muerte de Superman (Superman)", true, 1, 1850);
            Comic     p5 = new Comic("Año Uno (Batman)", false, 3, 1270);

            this.lstStock.Items.Add(p1);
            this.lstStock.Items.Add(p2);
            this.lstStock.Items.Add(p3);
            this.lstStock.Items.Add(p4);
            this.lstStock.Items.Add(p5);
        }
Beispiel #25
0
        public void DownloadUri(bool addNewOnly, Uri uri, string comicName, bool skipMarumaru)
        {
            lock (this.Queue)
            {
                if (this.CheckExisted(uri))
                {
                    var comicItem = Comic.CreateForSearch(addNewOnly, uri, comicName, skipMarumaru);
                    comicItem.PropertyChanged += this.Item_PropertyChanged;
                    this.Queue.Add(comicItem);
                }

                Monitor.PulseAll(this.Queue);
            }
        }
Beispiel #26
0
        public async Task <IActionResult> Create([Bind("ComicId,Title,ArtistID,WriterID,Year,Rating,PublisherID")] Comic comic)
        {
            if (ModelState.IsValid)
            {
                _context.Add(comic);
                await _context.SaveChangesAsync();

                return(RedirectToAction(nameof(Index)));
            }
            ViewData["WriterID"]    = new SelectList(_context.Writers, "WriterID", "WriterName", comic.WriterID);
            ViewData["ArtistId"]    = new SelectList(_context.Artists, "ArtistID", "ArtistName", comic.ArtistID);
            ViewData["PublisherID"] = new SelectList(_context.Publishers, "PublisherID", "PublisherName", comic.PublisherID);
            return(View(comic));
        }
Beispiel #27
0
        static void ParsePomcomic()
        {
            var comic = new Comic()
            {
                Name = "Piece Of Me",
                Source = "http://www.pomcomic.com/"
            };
            var issue = new Issue()
            {
                Name = "Web Comic",
                Cover = "http://www.pomcomic.com/comics/292-bus-stop.jpg"
            };
            comic.Issues.Add(issue);

            string init = "http://www.pomcomic.com/comic-1";
            using (var client = new WebClient())
            {
                string next = init;
                while (next != null)
                {
                    Console.WriteLine("Downloading {0}...", next);
                    string data = client.DownloadString(next);
                    var doc = new HtmlDocument();
                    doc.LoadHtml(data);

                    var strip = new Strip();

                    strip.Title = doc.DocumentNode.SelectSingleNode("//h1[@id=\"comic-name\"]")?.InnerText;
                    strip.Url = "http://www.pomcomic.com/" + doc.DocumentNode.SelectSingleNode("//div[@class=\"comic\"]/a/img")?.GetAttributeValue("src", null);

                    if (strip.Title != null)
                    {
                        strip.Title = HttpUtility.HtmlDecode(strip.Title.Trim());
                    }

                    issue.Strips.Add(strip);

                    var nextref = doc.DocumentNode.SelectSingleNode("//a[@id=\"next\"]")?.GetAttributeValue("href", null);

                    next = null;
                    if (nextref != null)
                        next = "http://www.pomcomic.com/" + nextref;
                }
            }

            using (var fs = File.Open("pomcomic.xml", FileMode.Create, FileAccess.Write))
            {
                comic.Save(fs);
            }
        }
        /*----------------METHODS-------------------*/

        public int CreateComic(int userId, int collectionId, string author, string title, DateTime publishDate, string description, string publisher, HashSet <string> characters)
        {
            Comic comic = new Comic();


            string sqlCommandInsert = "INSERT INTO comic (author_id, title, publish_date, publisher_id, description) VALUES " +
                                      "(@authorId, @title, @publishDate, @publisherId, @description); " +
                                      "SELECT comic_id FROM comic ORDER BY comic_id DESC";

            int authorId    = CreateAuthor(author);
            int publisherId = CreatePublisher(publisher);


            try
            {
                using (SqlConnection conn = new SqlConnection(connectionString))
                {
                    conn.Open();
                    SqlCommand cmd = new SqlCommand(sqlCommandInsert, conn);
                    cmd.Parameters.AddWithValue("@authorId", authorId);
                    cmd.Parameters.AddWithValue("@title", title);
                    cmd.Parameters.AddWithValue("@publishDate", publishDate);
                    cmd.Parameters.AddWithValue("@publisherId", publisherId);
                    cmd.Parameters.AddWithValue("@description", description);


                    comic.ComicId = Convert.ToInt32(cmd.ExecuteScalar());
                }
            }
            catch (SqlException ex)
            {
                throw ex;
            }



            foreach (string item in characters)
            {
                if (item != null)
                {
                    int characterId = CreateCharacter(item, publisherId);
                    AddCharacterToComic(characterId, comic.ComicId);
                }
            }

            AddComicToCollection(collectionId, comic.ComicId);

            return(comic.ComicId);
        }
Beispiel #29
0
        protected void btnAdd_Click(object sender, EventArgs e)
        {
            int          randomId;
            Random       random   = new Random();
            bool         repeatId = false;
            string       email    = HttpContext.Current.User.Identity.Name;
            ComicCreator f        = db.ComicCreators.SingleOrDefault(x => x.CC_email.ToString() == email);
            int          id       = f.CC_Id;

            if (Page.IsValid)
            {
                do
                {
                    randomId = random.Next(100000, 99999999);
                    var b = db.Comics.SingleOrDefault(
                        cc => cc.C_Id == randomId);
                    if (b == null)
                    {
                        repeatId = true;
                    }
                } while (repeatId == false);

                string p      = "~/pic/comic/" + randomId + "/";
                var    folder = Server.MapPath(p);
                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }
                var img = new SimpleImage(fuImage.FileContent);
                img.SaveAs(folder + randomId + ".jpg");

                Comic c = new Comic
                {
                    C_Id           = randomId,
                    C_Title        = txtTitle.Text,
                    C_Description  = txtDescription.Text,
                    C_Price        = decimal.Parse(txtPrice.Text),
                    C_Publish_Date = DateTime.Now,
                    C_Status       = 'U',
                    C_category     = ddlCategory.SelectedValue,
                    C_AgeRestrict  = int.Parse(ddlAgeRestrt.SelectedValue),
                    C_IsForVip     = bool.Parse(rblVipView.SelectedValue),
                    CC_Id          = id
                };
                db.Comics.InsertOnSubmit(c);
                db.SubmitChanges();
                Response.Redirect("~/Comic.aspx");
            }
        }
        public JsonResult bookInfoResult(int source, string bookId)
        {
            BookInfoResult   bir = new BookInfoResult();
            IQuery <Comic>   q   = dbcontext.Query <Comic>();
            IQuery <Chapter> cq  = dbcontext.Query <Chapter>();
            var token            = Request.Headers["X-AuthToken"];

            if (bookstoretoken != token)
            {
                bir.code    = 403;
                bir.message = "无数据访问权限";
                return(Json(bir, JsonRequestBehavior.AllowGet));
            }
            try
            {
                Comic          comic      = q.Where(x => x.source == (Source)source && x.comicid == bookId).FirstOrDefault();
                List <Chapter> chapterlst = cq.Where(x => x.source == (Source)source && x.comicid == bookId).ToList();
                var            cplst2     = chapterlst.Where(x => x.downstatus != DownChapter.完图片).OrderBy(x => x.sort).FirstOrDefault();
                if (cplst2 != null)
                {
                    chapterlst = chapterlst.Where(x => x.sort < cplst2.sort).ToList();
                }
                bir.result = new BookInfo()
                {
                    bookname     = comic.comicname,
                    alias        = comic.comicname,
                    authorname   = comic.authorname,
                    category     = comic.theme,
                    intro        = comic.comicdesc,
                    bookpic      = comic.comiccoverlocal,
                    maxfreecount = 0,
                    cartoontype  = 0,
                    fullflag     = comic.isfinished == "连载中" ? 0 : 1,
                    chaptercount = chapterlst.Count,
                    region       = 5,
                    iswhole      = 0,
                    price        = 0,
                    bookid       = comic.comicid
                };
                bir.code    = 200;
                bir.message = "漫画详情获取成功";
            }
            catch (Exception ex)
            {
                bir.code    = 500;
                bir.message = "漫画详情获取失败";
            }
            return(Json(bir, JsonRequestBehavior.AllowGet));
        }
        public void TestMethod1()
        {
            try
            {
                APIClient cliente     = new APIClient();
                int       comicNumber = 405;
                Comic     comic       = cliente.GetComic(comicNumber);

                // Obtaining a given comic
                Assert.IsNotNull(comic);
            }
            catch (Exception ex)
            {
            }
        }
        public void TestMethod1()
        {
            try
            {
                APIClient cliente          = new APIClient();
                int       indexOutOfBounds = 9000;
                Comic     comic            = cliente.GetComic(indexOutOfBounds);

                // If we set a index greater than the max index of comics, then it would go back to the first comic
                Assert.AreEqual(comic.Num, 1);
            }
            catch (Exception ex)
            {
            }
        }
        public async Task <IActionResult> AddComic(ComicDetailsDto comicDetailsDto)
        {
            var comicToCreate = new Comic
            {
                Name        = comicDetailsDto.Name,
                Description = comicDetailsDto.Description,
                WriterName  = comicDetailsDto.WriterName,
                Published   = comicDetailsDto.Published,
                PhotoUrl    = comicDetailsDto.PhotoUrl
            };

            await _repo.AddComic(comicToCreate);

            return(StatusCode(201));
        }
Beispiel #34
0
        private void Worker_Download()
        {
            Comic comic = null;

            using (var hc = new HttpClientEx())
            {
                while (true)
                {
                    if (this.GetComicFromQueue(ref comic, MaruComicState.Working_2_WaitDownload, MaruComicState.Working_3_Downloading))
                    {
                        comic.StartDownload(hc);
                    }
                }
            }
        }
Beispiel #35
0
        private void Worker_Infomation()
        {
            Comic comic = null;

            using (var hc = new HttpClientEx())
            {
                while (true)
                {
                    if (this.GetComicFromQueue(ref comic, MaruComicState.Wait, MaruComicState.Working_1_GetInfomation))
                    {
                        comic.GetInfomation(hc);
                    }
                }
            }
        }
Beispiel #36
0
 public ComicViewModel(Comic comic)
 {
     if (comic != null)
     {
         this.Id                = comic.Id;
         this.Name              = comic.Name;
         this.Description       = comic.Description;
         this.Category          = comic.Category;
         this.AvailableCount    = comic.AvailableCount;
         this.ImageUrl          = comic.ImageUrl;
         this.Price             = comic.Price;
         this.OrderedItemsCount = comic.OrderedItemsCount;
         this.Orders            = new List <Order>(comic.Orders);
     }
 }
Beispiel #37
0
 public void MapToViewModel(Comic comic, ComicViewModel viewModel)
 {
     viewModel.Id               = comic.Id;
     viewModel.Name             = comic.Name;
     viewModel.DownloadedStrips = comic.DownloadedStrips;
     viewModel.Status           = MapStatus(comic);
     if (comic.CurrentPage != null)
     {
         viewModel.CurrentPage = comic.CurrentPage.AbsoluteUri;
     }
     else
     {
         viewModel.CurrentPage = comic.Definition.StartAt;
     }
 }
        public ComicPageViewModel()
        {
            _comicMaxNo = DataService.GetLatesComicAsync().Num;

            if (Comic == null)
            {
                ComicNo = rnd.Next(1, ComicMaxNo);
                Comic   = new Comic();
                Comic   = DataService.GetComicAsync(ComicNo);
            }

            GetRandomComicCommand  = new Command(GetRandomComic);
            SaveToFavoritesCommand = new Command(SaveToFavorites);
            //ComicClickedCommand = new Command(ComicClicked);
        }
        public void TestMethod1()
        {
            try
            {
                APIClient cliente     = new APIClient();
                int       comicNumber = 404; //comic number 404 is empty
                Comic     comic       = cliente.GetComic(comicNumber);

                // The resultant Comic should be the next existing Comic, in this case 405
                Assert.Equals(comic.Num, 505);
            }
            catch (Exception ex)
            {
            }
        }
        private async Task CreateComicCreator(IList <Creator> creators, Comic comic)
        {
            IList <ComicCreator> comicCreators = new List <ComicCreator>();

            foreach (var item in creators)
            {
                ComicCreator comicCreatorItem = new ComicCreator();
                comicCreatorItem.Comic   = comic;
                comicCreatorItem.Creator = item;

                comicCreators.Add(comicCreatorItem);
            }

            await _unitOfWOrk.ComicCreatorRepository.Add(comicCreators);
        }
        public ActionResult Edit(int?id)
        {
            if (id == null)
            {
                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest));
            }
            Comic comic = db.Comics.Find(id);

            if (comic == null)
            {
                return(HttpNotFound());
            }
            ViewBag.UserID = new SelectList(db.Administrators, "UserID", "Username", comic.UserID);
            return(View(comic));
        }
Beispiel #42
0
        public void ThrowWhenArgumentComicHasNullValue()
        {
            //Arrange
            var   mockedDataProvider = new Mock <IEfComicShopDataProvider <Comic> >();
            Comic nullComic          = null;

            //Act
            var actualComicService =
                new ComicShop.Data.Services.ComicService(mockedDataProvider.Object);

            //Assert
            Assert.That(
                () => actualComicService.UpdateComic(nullComic),
                Throws.InstanceOf <ArgumentNullException>());
        }
Beispiel #43
0
        private static async Task <StorageFile?> TryGetThumbnailSourceAsync(Comic comic)
        {
            if (comic.ThumbnailSource is { } path)
            {
                try {
                    return(await StorageFile.GetFileFromPathAsync(path));
                } catch (UnauthorizedAccessException) {
                    // weird shit happens with windows and file permissions. just ignore this
                } catch (FileNotFoundException) {
                    // we pretend the ThumbnailSource isn't set
                }
            }

            return(await TryGetFirstValidThumbnailFileAsync(comic.Path));
        }
        public void RemoveComic(Comic comic)
        {
            var dComic = Mapper.ToDComic(comic);


            using (var command = context.CreateCommand())
            {
                command.CommandText = "UPDATE Comics " +
                                      "SET IsInCatalogue = 0 " +
                                      "WHERE Comics.Title = @Title AND Comics.SeriesNr = @SeriesNr; ";
                command.AddParameter("Title", dComic.Title);
                command.AddParameter("SeriesNr", dComic.SeriesNumber);
                command.ExecuteNonQuery();
            }
        }
Beispiel #45
0
 private void comic_update(object sender, EventArgs e, Comic comic, ComicSource source)
 {
     currentcomic = new CurrentComicInfo(comic, source);
     date.ResetBindings();
     date.Checked = true;
     //i keep getting argumentoutofrangeexceptions. lets try this
     date.MaxDate = DateTimePicker.MaximumDateTime;
     date.MinDate = DateTimePicker.MinimumDateTime;
     //reset mindate and maxdate values then set it again
     date.MaxDate     = source.getMaxDate(comic);
     date.MinDate     = source.getMinDate(comic);
     date.Value       = date.Value;
     statuscomic.Text = String.Format("({0}) {1}", currentcomic.source.name, currentcomic.comic.name);
     strip_update(null, null);
 }
Beispiel #46
0
        public void ConvertJson(Comic comic, string path,string fileName = null, string extension = null)
        {
            path = (path.EndsWith(@"\")) ? path.Substring(0, path.Length - 1) : path;

            string fullPath = (fileName != null && extension != null) ? path + @"\" + fileName + "." + extension : path;

            JsonConvert.DefaultSettings = () => new JsonSerializerSettings
            {
                Formatting = Formatting.Indented,
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            };

            var serializeObject = JsonConvert.SerializeObject(comic, Formatting.Indented, new JsonSerializerSettings
            {
                Formatting = Formatting.Indented,
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            });

            File.WriteAllText(fullPath, serializeObject);
        }
 static void downloadComic(Comic comic, string downloadDirectory)
 {
     string filename = getBaseName(comic.img);
     string consoleMessage = String.Format("[#{0}] {1} - Downloading as {2}...", comic.num, comic.title, filename);
     if (File.Exists(downloadDirectory + "\\" + filename) && (new FileInfo(downloadDirectory + "\\" + filename)).Length > 0)
     {
         consoleMessage += " already exists";
     }
     else
     {
         WebClient webclient = new WebClient();
         int tries = 0;
         TryAgain:
         try
         {
             webclient.DownloadFile(comic.img, downloadDirectory + "\\" + filename);
         }
         catch (WebException e)
         {
             if (e.Status == WebExceptionStatus.Timeout)
             {
                 if (tries < 3)
                 {
                     tries++;
                     goto TryAgain;
                 }
                 else
                 {
                     consoleMessage += " timed out";
                 }
             }
         }
         consoleMessage += " done";
     }
     Console.WriteLine(consoleMessage);
 }
Beispiel #48
0
        private Comic ResetImagePath(Comic comic)
        {
            var coverExtension = Path.GetExtension(comic.CoverPath);
            comic.CoverPath = @"cover" + coverExtension;

            foreach (var chapter in comic.Chapters)
            {
                foreach (var page in chapter.Pages)
                {
                    string extension = Path.GetExtension(page.ImgPath);

                    page.ImgPath = @"data/" + chapter.Title + chapter.Index + @"/" + page.Index + extension;
                }
            }

            return comic;
        }
        public void ItSetsThePublishedDate()
        {
            var downloader = _mocker.Create<ExplosmDownloader>();

            var lastComic = new Comic { ComicNumber = 4124 };
            var comic = downloader.GetNewComicsSince(lastComic).Single();

            Check.That(comic.PublishedDate).IsEqualTo(new DateTime(2015, 11, 22));
        }
        public void ItSetsThePermalink()
        {
            var downloader = _mocker.Create<ExplosmDownloader>();

            var lastComic = new Comic { ComicNumber = 4124 };
            var comic = downloader.GetNewComicsSince(lastComic).Single();

            Check.That(comic.Permalink).IsEqualTo("http://explosm.net/comics/4125/");
        }
Beispiel #51
0
 private void ConvertJson(Comic comic, string path)
 {
    var test = Newtonsoft.Json.JsonConvert.SerializeObject(comic);
    System.IO.File.WriteAllText(path + @"\meta.manga", test);
 }
Beispiel #52
0
 public void InsertComic(Comic comic)
 {
     _context.Comics.Add(comic);
     _context.SaveChanges();
 }
        public async void GetLatest_ComicsAreInReverseChronologicalOrder()
        {
            var database = IntegrationDatabase.CreateBlankDatabase();
            using (var context = database.CreateContext())
            {
                DateTime startDate = new DateTime(2015, 5, 1);
                for (int i = 0; i < 15; i++)
                {
                    var comic = new Comic()
                    {
                        ComicNumber = i+1,
                        ComicType = ComicType.Explosm,
                        ImageSrc = $"http://www.example.com/images/{i}.png",
                        PublishedDate = startDate.AddDays(i).Date
                    };

                    context.Comics.Add(comic);
                }

                await context.SaveChangesAsync();

                var repo = new ComicsRepository(context);
                var recent = repo.GetLatestComics(ComicType.Explosm);

                Check.That(recent.First().PublishedDate).IsEqualTo(new DateTime(2015, 5, 15));
                Check.That(recent.Last().PublishedDate).IsEqualTo(new DateTime(2015, 5, 6));
            }
        }
        public void ItSkipsFailedComics()
        {
            var mocker = new AutoMoqer();
            var result20151123 = new ComicDownloadResult(
                Fixture.Load("dilbert-2015-11-23"),
                20151123,
                new Uri("http://dilbert.com/strip/2015-11-23"));

            mocker.GetMock<IDilbertWebClient>()
                .Setup(m => m.GetComicHtml(new DateTime(2015, 11, 23)))
                .Returns(result20151123);
            mocker.GetMock<IDilbertWebClient>()
                .Setup(m => m.GetComicHtml(new DateTime(2015, 11, 24)))
                .Throws(new ComicNotFoundException(new Uri("http://dilbert.com/strip/2015-11-24")));

            var downloader = mocker.Create<DilbertDownloader>();
            downloader.Today = new DateTime(2015,11,24);

            var lastComic = new Comic() { PublishedDate = new DateTime(2015, 11, 22) };
            var comic = downloader.GetNewComicsSince(lastComic).Single();

            Check.That(comic.PublishedDate).IsEqualTo(new DateTime(2015, 11, 23));
        }
        /// <summary>
        /// Hooks up this with the specified comic.
        /// </summary>
        /// <param name="comic">The comic.</param>
        public void HookUp(Comic comic)
        {
            if (comic != null)
            {
                this.SetTextToDisplay(this.Title, comic.Title);
                this.SetTextToDisplay(this.Description, comic.CleanDescription);
                this.SetTextToDisplay(this.DiamondCode, comic.DiamondCode, this.DiamondCode.transform.parent.gameObject);
                this.SetTextToDisplay(this.DigitalId, comic.DigitalId > 0 ? comic.DigitalId.ToString() : null, this.DigitalId.transform.parent.gameObject);
                this.SetTextToDisplay(this.Ean, comic.Ean, this.Ean.transform.parent.gameObject);
                this.SetTextToDisplay(this.Format, comic.Format, this.Format.transform.parent.gameObject);
                this.SetTextToDisplay(this.Isbn, comic.Isbn, this.Isbn.transform.parent.gameObject);
                this.SetTextToDisplay(this.Issn, comic.Issn, this.Issn.transform.parent.gameObject);
                this.SetTextToDisplay(this.IssueNumber, comic.IssueNumber > 0 ? comic.IssueNumber.ToString() : null, this.IssueNumber.transform.parent.gameObject);
                this.SetTextToDisplay(this.PageCount, comic.PageCount > 0 ? comic.PageCount.ToString() : null, this.PageCount.transform.parent.gameObject);
                this.SetTextToDisplay(this.Upc, comic.Upc, this.Upc.transform.parent.gameObject);
                this.SetTextToDisplay(this.VariantDescription, comic.VariantDescription);

                this.SetListItems(this.ComicPriceListView, comic.Prices != null ? comic.Prices.OrderBy(p => p.DisplayType) : null);
                this.SetListItems(this.ComicDateListView, comic.Dates != null ? comic.Dates.Where(c => c.HasData).OrderBy(d => d.DisplayType) : null);
                this.SetListItems(this.UrlListView, comic.Urls != null ? comic.Urls.OrderBy(u => u.DisplayType) : null);
            }
        }
        public void LoadsNewComicsUpToToday()
        {
            var downloader = _mocker.Create<DilbertDownloader>();
            downloader.Today = new DateTime(2015, 11, 23); // mock Today

            var lastComic = new Comic() { PublishedDate = new DateTime(2015, 11, 22) };
            var comic = downloader.GetNewComicsSince(lastComic).Single();

            Check.That(comic.PublishedDate).IsEqualTo(new DateTime(2015, 11, 23));
        }
Beispiel #57
0
        /// <summary>
        /// Display information for the specified comic.
        /// </summary>
        /// <param name="comic">The comic.</param>
        private void DisplayInformation(Comic comic)
        {
            this.Reset();

            this.ComicDetailsPanel.gameObject.SetActive(true);

            this.SetImage(comic.Thumbnail);

            this.ComicDetailsPanel.HookUp(comic);
        }
Beispiel #58
0
        private Comic CloneComic(Comic comic)
        {
            var serializeObject = JsonConvert.SerializeObject(comic, Formatting.Indented, new JsonSerializerSettings
            {
                Formatting = Formatting.Indented,
                ContractResolver = new CamelCasePropertyNamesContractResolver()
            });

            return JsonConvert.DeserializeObject<Comic>(serializeObject);
        }
Beispiel #59
0
 private void CreateFolder(Comic comic, string path)
 {
     if (!Directory.Exists(path))
     {
         Directory.CreateDirectory(path);
     }
 }
        public void ItSetsThePermalink()
        {
            var downloader = _mocker.Create<DilbertDownloader>();
            downloader.Today = new DateTime(2015, 11, 23);

            var lastComic = new Comic() { PublishedDate = new DateTime(2015, 11, 22) };
            var comic = downloader.GetNewComicsSince(lastComic).Single();

            Check.That(comic.Permalink).IsEqualTo("http://dilbert.com/strip/2015-11-23");
        }