private List <Models.Book> GetBooks(Models.Source source)
        {
            List <Models.Book>        s   = new List <Models.Book>();
            List <ReaderService.Book> tmp = new List <ReaderService.Book>();

            using (ReaderServiceSoapClient svc = new ReaderServiceSoapClient())
            {
                tmp.AddRange(svc.getBookslst(ProgramStatics.Token));
            }
            //svcClosed();

            foreach (ReaderService.Book b in tmp)
            {
                if (b.SourceID == source.SourceID)
                {
                    s.Add(SvcBooktoBook(b));
                }
            }

            foreach (Models.Book b in s)
            {
                b.BookLastChapterAddress = this.GetLastChapter(b.BookID).ChapterAddress;
                b.Chapters.AddRange(GetChapters(b));
            }
            return(s);
        }
        //public int PreviousChapterID { get; set; }


        public void SaveChapter()
        {
            if (string.IsNullOrEmpty(this.ChapterText))
            {
                return;
            }
            Models.Chapter c = new Models.Chapter();
            c.ChapterAddress = this.ChapterAddress;
            c.ChapterHTML    = Compression.CompressString(this.ChapterHtml);
            c.BookID         = this.BookID;
            c.ChapterName    = this.ChapterName;
            c.ChapterText    = Compression.CompressString(this.ChapterText);

            int itemp = 0;

            if (!string.IsNullOrEmpty(this.PreviousChapterAddress))
            {
                using (ReaderServiceSoapClient svc = new ReaderServiceSoapClient())
                {
                    itemp = svc.GetPreviousChapterID(ProgramStatics.Token, this.PreviousChapterAddress);// GetPreviousChapterID();
                }
            }
            c.PreviousChapterID = itemp;

            int id;

            using (ReaderServiceSoapClient svc = new ReaderServiceSoapClient())
            {
                id = svc.ChapterExists(ProgramStatics.Token, this.ChapterAddress);// ChapterExists();
            }

            if (id >= 0)
            {
                c.ChapterID = id;
                using (ReaderServiceSoapClient svc = new ReaderServiceSoapClient())
                {
                    svc.OverwriteChapter(ProgramStatics.Token, this.ChaptertoSvcChapter(c));// OverwriteChapter(id);
                }
            }
            else
            {
                using (ReaderServiceSoapClient svc = new ReaderServiceSoapClient())
                {
                    svc.InsertChapter(ProgramStatics.Token, this.ChaptertoSvcChapter(c));// InsertChapter();
                }
            }
        }
        private List <Models.Source> GetSources()
        {
            List <Models.Source> s = new List <Models.Source>();//SvcSourcetoSource(svc.getSourceslst(ProgramStatics.Token));

            using (ReaderServiceSoapClient svc = new ReaderServiceSoapClient())
            {
                s = ConvertSources(svc.getSourceslst(ProgramStatics.Token));
            }
            //svcClosed();

            foreach (Models.Source tmp in s)
            {
                tmp.Books.AddRange(GetBooks(tmp));
                Books.AddRange(tmp.Books);
            }

            return(s);
        }
Exemple #4
0
        public override string GetPreviousChapter()
        {
            if (string.IsNullOrEmpty(this.PreviousChapterAddress))
            {
                return("Page Not Found");
            }

            string index = "";

            using (ReaderServiceSoapClient svc = new ReaderServiceSoapClient())
            {
                index = svc.getBookIndexAddress(ProgramStatics.Token, this.BookID);
            }

            string s = index + this.PreviousChapterAddress;

            this.PreviousChapterAddress = s;
            return(s);
        }
        private List <Models.Chapter> GetChapters(Models.Book book)
        {
            List <Models.Chapter>        s   = new List <Models.Chapter>();
            List <ReaderService.Chapter> tmp = new List <ReaderService.Chapter>();

            using (ReaderServiceSoapClient svc = new ReaderServiceSoapClient())
            {
                tmp.AddRange(svc.getChapterslstByBook(ProgramStatics.Token, BooktoSvcBook(book)));
            }
            //svcClosed();

            foreach (ReaderService.Chapter b in tmp)
            {
                if (b.BookID == book.BookID)
                {
                    s.Add(SvcChaptertoChapter(b));
                }
            }
            return(s);
        }