Пример #1
0
        /// <summary>
        /// The create destination.
        /// </summary>
        /// <param name="job">
        /// The job.
        /// </param>
        /// <returns>
        /// The <see cref="Destination"/>.
        /// </returns>
        private static Destination CreateDestination(EncodeJob job)
        {
            Destination destination = new Destination
            {
                File       = job.OutputPath,
                Mp4Options = new Mp4Options
                {
                    IpodAtom    = job.IPod5GSupport,
                    Mp4Optimize = job.Optimize
                },
                ChapterMarkers = job.IncludeChapterMarkers,
                Mux            = HBFunctions.hb_container_get_from_name(job.ContainerName),
                ChapterList    = new List <ChapterList>()
            };

            if (job.UseDefaultChapterNames)
            {
                foreach (string item in job.CustomChapterNames)
                {
                    ChapterList chapter = new ChapterList {
                        Name = item
                    };
                    destination.ChapterList.Add(chapter);
                }
            }

            return(destination);
        }
Пример #2
0
        public async Task <bool> SetChapter(string path)
        {
            bool IsPathArchiveFile;
            bool chapterUpdated = false;

            if (Directory.Exists(path))
            {
                IsPathArchiveFile = false;
            }
            else if (PathHelper.EnsureValidArchives(path))
            {
                IsPathArchiveFile = true;
            }
            else
            {
                return(chapterUpdated);
            }

            Path        = path;
            Config.Path = Path;
            Title       = Path.Split(System.IO.Path.DirectorySeparatorChar).ToArray()[^ 1];
            ChapterList.Clear();
            var list = await collector.GetChapterListAsync(Path, IsPathArchiveFile);

            ChapterList.AddRange(list);
            chapterUpdated = true;
            return(chapterUpdated);
        }
Пример #3
0
    void FindComponent()
    {
        m_chapterList = transform.Find("ChapterList").GetComponent <ChapterList>();
        m_OADList     = transform.Find("OADList").GetComponent <LoopVerticalScrollRect>();

        btn_back        = transform.Find("BackBtn").GetComponent <Button>();
        btn_chapter     = transform.Find("ChapterBtn").GetComponent <Button>();
        btn_OAD         = transform.Find("OADBtn").GetComponent <Button>();
        text_chapterBtn = transform.Find("ChapterBtn/Title").GetComponent <Text>();
        text_OADBtn     = transform.Find("OADBtn/Title").GetComponent <Text>();
        //动画
        btn_chapter_canvasGroup = btn_chapter.GetComponent <CanvasGroup>();
        btn_OAD_canvasGroup     = btn_OAD.GetComponent <CanvasGroup>();
        diamondBtn_canvasGroup  = transform.Find("UIDiamondNav").GetComponent <CanvasGroup>();
        ZjbBtn_canvasGroup      = transform.Find("UIZjbNav").GetComponent <CanvasGroup>();
        btn_zjb  = ZjbBtn_canvasGroup.GetComponent <Button>();//点击打开快捷购买
        text_zjb = ZjbBtn_canvasGroup.transform.Find("Num").GetComponent <Text>();
        Mask     = transform.Find("Mask").gameObject;

        chapterText    = btn_chapter.transform.Find("Title").GetComponent <Text>();
        OADText        = btn_OAD.transform.Find("Title").GetComponent <Text>();
        chapterShadow  = chapterText.GetComponent <Shadow>();
        OADShadow      = OADText.GetComponent <Shadow>();
        chapterOutLine = chapterText.GetComponent <Outline>();
        OADOutLine     = OADText.GetComponent <Outline>();

        chapterRedDot = btn_chapter.transform.Find("redDot").GetComponent <Image>();
        oadRedDot     = btn_OAD.transform.Find("redDot").GetComponent <Image>();


        //获取资源
        selectBtn_sprite   = ABManager.GetAsset <Sprite>("ty_qp_tabbtn_1");
        noSelectBtn_sprite = ABManager.GetAsset <Sprite>("ty_qp_tabbtn_2");
    }
        public ActionResult ListChapter(int tutorialid)
        {
            List <ChapterList> chapterViewModel = new List <ChapterList>();
            string             constring        = ConfigurationManager.ConnectionStrings["TutorialContext"].ConnectionString;

            using (SqlConnection con = new SqlConnection(constring))
            {
                SqlCommand command = new SqlCommand();
                command.CommandText = "select * from Chapter where TutorialID=@TutorialID";
                command.Connection  = con;
                command.Parameters.AddWithValue("@TutorialID", tutorialid);
                con.Open();
                SqlDataReader reader = command.ExecuteReader();
                if (reader == null)
                {
                    return(Json(null, JsonRequestBehavior.AllowGet));
                }
                else
                {
                    while (reader.Read())
                    {
                        ChapterList c = new ChapterList();
                        {
                            //  c.TutorialID = (int)reader["TutorialID"];
                            c.ChapterID   = (int)reader["ChapterID"];
                            c.ChapterName = (string)reader["ChapterName"];
                        };
                        chapterViewModel.Add(c);
                    }
                    return(Json(chapterViewModel, JsonRequestBehavior.AllowGet));
                }
            }
        }
Пример #5
0
        /// <summary>
        /// Retrieves list of Chapter objects from SqlCommand, after database query
        /// number of rows retrieved and returned depends upon the rows field value
        /// </summary>
        /// <param name="cmd">The command object to use for query</param>
        /// <param name="rows">Number of rows to process</param>
        /// <returns>A list of Chapter objects</returns>
        private ChapterList GetList(SqlCommand cmd, long rows)
        {
            // Select multiple records
            SqlDataReader reader;
            long          result = SelectRecords(cmd, out reader);

            //Chapter list
            ChapterList list = new ChapterList();

            using ( reader )
            {
                // Read rows until end of result or number of rows specified is reached
                while (reader.Read() && rows-- != 0)
                {
                    Chapter chapterObject = new Chapter();
                    FillObject(chapterObject, reader);

                    list.Add(chapterObject);
                }

                // Close the reader in order to receive output parameters
                // Output parameters are not available until reader is closed.
                reader.Close();
            }

            return(list);
        }
Пример #6
0
        public async Task GetStandings(string chapter, int year, int yearFraction)
        {
            Standings.Clear();

            if (!ChapterList.ContainsKey(chapter))
            {
                return;
            }

            ValueColumnCaption = UnitOfMeasureList[chapter];

            var data = await CountyStandingsProvider.GetData(ChapterList[chapter], year, yearFraction);

            foreach (var item in data)
            {
                Standings.Add(item);
            }

            HasData         = data.Count > 0;
            DoesNotHaveData = !HasData;

            if (DoesNotHaveData)
            {
                var lastData = (await CountyDetailsProvider.GetData(1, ChapterList[chapter]))
                               .OrderByDescending(x => x.Year)
                               .ThenByDescending(x => x.YearFraction)
                               .FirstOrDefault();
                LastAvailableYear         = lastData.Year;
                LastAvailableYearFraction = lastData.YearFraction;
            }
        }
        private void DisplayChapters()
        {
            string  sql  = String.Format("SELECT * FROM Chapters WHERE NovelID = {0}", id);
            DataSet data = connector.query(sql);

            ChapterList.DataSource = data;
            ChapterList.DataBind();
        }
Пример #8
0
 public Epub(string title, CultureInfo culture)
 {
     _title       = title;
     _chapterList = new ChapterList();
     _chapterList.ChapterAdded += OnChapterAdded;
     _content        = new Content(_title, culture.TwoLetterISOLanguageName.ToLower());
     _mimeType       = new MimeType();
     _metaInf        = new MetaInf();
     _tableOfContent = new TableOfContent(_title);
 }
Пример #9
0
 protected void ddlChapterList_Populate(Guid storyID)
 {
     //make a new chapterlist called cl
     ChapterList cl = new ChapterList();
     // get the right chapter list by the storyID passed in
     cl = cl.GetByStoryID(storyID);
     //bind the list to ddlChapterList
     ddlChapterList.DataSource = cl.List;
     ddlChapterList.DataTextField = "Title";
     ddlChapterList.DataValueField = "ID";
     ddlChapterList.DataBind();
 }
Пример #10
0
        protected void ddlChapters_Populate(Guid storyID)
        {
            //make a new chapter list
            ChapterList cl = new ChapterList();
            //get all chapters by storyID
            cl = cl.GetByStoryID(storyID);
            //bind the list to the ddlChapter
            ddlChapterList.DataSource = cl.List;
            ddlChapterList.DataTextField = "Title";
            ddlChapterList.DataValueField = "ID";
            ddlChapterList.DataBind();

            ddlChapterList.SelectedIndex = ddlChapterList.Items.IndexOf(ddlChapterList.Items.FindByValue(chapter.Id.ToString()));
        }
Пример #11
0
        public async Task <object> GetStandings(string chapter, int year, int yearFraction)
        {
            if (!ChapterList.ContainsKey(chapter))
            {
                return(null);
            }

            var valueColumnCaption = UnitOfMeasureList[chapter];

            var data = await CountyStandingsProvider.GetData(ChapterList[chapter], year, yearFraction);

            return(new StandingsDto {
                ValueColumnCaption = valueColumnCaption, Data = data
            });
        }
 private void _loadChapter()
 {
     ChapterList.Clear();
     SqlHelper.Conn.Open();
     using (var reader = SqlHelper.Select <BookChapter>("Id, BookId, Name, Position, Url", "WHERE BookId = @id ORDER BY Position ASC, Id ASC", new SqliteParameter("@id", Book.Id)))
     {
         while (reader.Read())
         {
             if (reader.HasRows)
             {
                 ChapterList.Add(new BookChapter(reader));
             }
         }
     }
     SqlHelper.Conn.Close();
 }
Пример #13
0
        /// <summary>
        /// Retrieves all Chapter objects by PageRequest
        /// </summary>
        /// <returns>A list of Chapter objects</returns>
        public ChapterList GetPaged(PagedRequest request)
        {
            using (SqlCommand cmd = GetSPCommand(GETPAGEDCHAPTER))
            {
                AddParameter(cmd, pInt32Out("TotalRows"));
                AddParameter(cmd, pInt32("PageIndex", request.PageIndex));
                AddParameter(cmd, pInt32("RowPerPage", request.RowPerPage));
                AddParameter(cmd, pNVarChar("WhereClause", 4000, request.WhereClause));
                AddParameter(cmd, pNVarChar("SortColumn", 128, request.SortColumn));
                AddParameter(cmd, pNVarChar("SortOrder", 4, request.SortOrder));

                ChapterList _ChapterList = GetList(cmd, ALL_AVAILABLE_RECORDS);
                request.TotalRows = Convert.ToInt32(GetOutParameter(cmd, "TotalRows"));
                return(_ChapterList);
            }
        }
Пример #14
0
        public void ImportMangaInfo()
        {
            Url         = savedinfo.url;
            Name        = savedinfo.name;
            Description = savedinfo.description;
            ImageSource = savedinfo.image?.ToFreezedBitmapImage();
            IsFavourite = savedinfo.isFavourite;
            IsCompleted = savedinfo.isCompleted;

            Dispatcher dispatcher;

            if (Dispatcher.CurrentDispatcher != Application.Current.Dispatcher)
            {
                dispatcher = Application.Current.Dispatcher;
            }
            else
            {
                dispatcher = Dispatcher.CurrentDispatcher;
            }

            dispatcher.Invoke(() =>
            {
                AuthorList = savedinfo.authors;

                GenreList.Clear();
                for (int i = 0; i < savedinfo.genres.Count; i++)
                {
                    GenreList.Add(new GenreItemViewModel {
                        Text = savedinfo.genres[i]
                    });
                }

                ChapterList.Clear();
                for (int i = 0; i < savedinfo.chapters.Count; i++)
                {
                    ChapterListItemViewModel model = new ChapterListItemViewModel(this, i)
                    {
                        Name = savedinfo.chapters[i],
                        URL  = savedinfo.chapterUrls[i]
                    };

                    model.CheckIfDownloaded();

                    ChapterList.Add(model);
                }
            });
        }
Пример #15
0
        /// <summary>
        /// Retrieve list of Chapter.
        /// </summary>
        /// <param name="fillChild"></param>
        /// <returns>List of Chapter</returns>
        public ChapterList GetAll(bool fillChild)
        {
            ChapterList chapterList = new ChapterList();

            using (ChapterDataAccess data = new ChapterDataAccess(ClientContext))
            {
                chapterList = data.GetAll();
            }
            if (fillChild)
            {
                foreach (Chapter chapterObject in chapterList)
                {
                    FillChapterWithChilds(chapterObject, fillChild);
                }
            }
            return(chapterList);
        }
Пример #16
0
        protected void addNewChapter()
        {
            //make a new chapterlist (use this to get the count)
            ChapterList chapListForCount = new ChapterList();
            //make a new chapter
            chap = new Chapter();
            //get the right chapList by the storyID taken from ddlStory's selected value
            chapListForCount = chapListForCount.GetByStoryID(new Guid(this.ddlStory.SelectedValue));

            //set chap's storyID property to selected value of ddlStory
            chap.StoryID = new Guid(ddlStory.SelectedValue);
            //set chap's title property to text from txtChapTitle
            chap.Title = txtChapTitle.Text;
            //set chap's chaptercontent property to value from hidnEdit
            chap.ChapterContent = hidnEdit.Value;
            //set the chap's chapter order to the chapterlist's count + 1
            chap.ChapterOrder = chapListForCount.List.Count + 1;
        }
Пример #17
0
        public async Task GetStandings(string chapter, int year, int yearFraction)
        {
            ValueColumnCaption = "Lei";

            Standings.Clear();

            if (!ChapterList.ContainsKey(chapter))
            {
                return;
            }

            var data = await CountyStandingsProvider.GetData(ChapterList[chapter], year, yearFraction);

            foreach (var item in data)
            {
                Standings.Add(item);
            }
        }
        public async Task GetChapterData(int countyId, int countyId2, string chapter)
        {
            if (!ChapterList.ContainsKey(chapter) || countyId < 1)
            {
                return;
            }

            ValueColumnCaption = string.Format("{0} {1}", UnitOfMeasureList[chapter], CountyAbbreviations[CountyList.First(x => x.Value == countyId).Key]);

            var data = await CountyDetailsProvider.GetData(countyId, ChapterList[chapter]);

            HasData = data.Count > 0;

            if (countyId2 >= 1 && countyId != countyId2)
            {
                var data2 = await CountyDetailsProvider.GetData(countyId2, ChapterList[chapter]);

                foreach (var item2 in data2)
                {
                    var item = data.FirstOrDefault(x => x.Year == item2.Year && x.YearFraction == item2.YearFraction);
                    if (item != null)
                    {
                        item.Value2 = item2.Value;
                    }
                }

                Value2ColumnCaption = string.Format("{0} {1}", UnitOfMeasureList[chapter], CountyAbbreviations[CountyList.First(x => x.Value == countyId2).Key]);

                Value2ColumnVisibility = true;
            }
            else
            {
                Value2ColumnVisibility = false;
            }

            ChapterData.Clear();
            ChapterDataReversed.Clear();

            foreach (var item in data)
            {
                ChapterData.Add(item);
                ChapterDataReversed.Insert(0, item);
            }
        }
        public async Task GetStandings(string chapter, int year, int yearFraction)
        {
            if (!ChapterList.ContainsKey(chapter))
            {
                return;
            }

            ValueColumnCaption = UnitOfMeasureList[chapter];

            var data = await CountyStandingsProvider.GetData(ChapterList[chapter], year, yearFraction);

            //var y2015 = await CountyStandingsProvider.GetData(ChapterList[chapter], 2015, -1);
            //var y2016 = await CountyStandingsProvider.GetData(ChapterList[chapter], 2016, -1);

            //Debug.WriteLine($"Indicator: {ChapterList[chapter]}");
            //foreach(var item in y2015.OrderBy(x => x.County))
            //{
            //    var county = item.County;
            //    var value2016 = y2016.Find(x => x.County == county).Value;
            //    Debug.WriteLine($"{county}, 2015: {item.Value}, 2016: {value2016}, diferenta: {value2016 - item.Value} ({Math.Round((value2016 - item.Value) * 100.0 / item.Value, 2)}%)");
            //}

            Standings.Clear();

            foreach (var item in data)
            {
                Standings.Add(item);
            }

            HasData         = data.Count > 0;
            DoesNotHaveData = !HasData;

            if (DoesNotHaveData)
            {
                var lastData = (await CountyDetailsProvider.GetData(1, ChapterList[chapter]))
                               .OrderByDescending(x => x.Year)
                               .ThenByDescending(x => x.YearFraction)
                               .FirstOrDefault();
                LastAvailableYear         = lastData.Year;
                LastAvailableYearFraction = lastData.YearFraction;
            }
        }
Пример #20
0
        public async Task GetChapterData(int countyId, string chapter)
        {
            ValueColumnCaption = "Lei";

            ChapterData.Clear();
            ChapterDataReversed.Clear();

            if (!ChapterList.ContainsKey(chapter) || countyId < 1)
            {
                return;
            }

            var data = await CountyDetailsProvider.GetData(countyId, ChapterList[chapter]);

            foreach (var item in data)
            {
                ChapterData.Add(item);
                ChapterDataReversed.Insert(0, item);
            }
        }
Пример #21
0
 private void LoadData(Volume volume)
 {
     IsLoading     = true;
     Id            = volume.Id;
     Title         = volume.Title;
     Author        = volume.Author;
     Description   = volume.Description;
     CoverImageUri = new Uri(volume.CoverImageUri);
     ChapterList.Clear();
     foreach (var cp in volume.Chapters)
     {
         var cpvm = new ChapterPreviewModel
         {
             Id    = cp.Id,
             No    = cp.ChapterNo,
             Title = cp.Title,
         };
         ChapterList.Add(cpvm);
     }
     IsLoading = false;
 }
Пример #22
0
        public void InitData(object obj = null)
        {
            CancleHttpRequest();

            if (CurrentEntity == obj as BookEntity && ChapterList.Count != 0)
            {
                return;
            }

            PageCount      = 1;
            PageIndex      = 1;
            CurrentEntity  = (obj as BookEntity);
            CurrentPageUrl = (obj as BookEntity).UpdateCatalogUrl;
            ContentTitle   = (obj as BookEntity).BookName;

            if (this.ChapterList != null)
            {
                ChapterList.Clear();
            }
            if (!ViewModelInstance.Instance.IsLogin)
            {
                IsAddBtnShow = false;
            }
            else if (ViewModelInstance.Instance.IsLogin && ViewModelInstance.Instance.SettingPageViewModelInstance.IfAutAddToShelf)
            {
                IsAddBtnShow = false;
            }
            else if (ViewModelInstance.Instance.IsLogin && !ViewModelInstance.Instance.SettingPageViewModelInstance.IfAutAddToShelf && ViewModelInstance.Instance.MyBookShelfViewModelInstance.ShelfBookList.ToList().Find(p => p.BookID == CurrentEntity.BookID) == null)
            {
                IsAddBtnShow = true;
            }
            else
            {
                IsAddBtnShow = false;
            }
            SetData(1);
        }
Пример #23
0
    /// <summary>
    /// Loads the metadata for this file.
    /// </summary>
    public void Load()
    {
        var fileHandle = NativeMethods.MP4Read(System.Text.Encoding.UTF8.GetBytes(this.fileName), IntPtr.Zero);

        if (fileHandle == IntPtr.Zero)
        {
            // open for modify to see if that enables us to read
            fileHandle = NativeMethods.MP4Modify(System.Text.Encoding.UTF8.GetBytes(this.fileName), 0);
        }

        if (fileHandle != IntPtr.Zero)
        {
            try
            {
                this.Tags     = MetadataTags.ReadFromFile(fileHandle);
                this.Chapters = ChapterList.ReadFromFile(fileHandle);
                this.Tracks   = TrackList.ReadFromFile(fileHandle);
            }
            finally
            {
                NativeMethods.MP4Close(fileHandle);
            }
        }
    }
Пример #24
0
        /// <summary>
        /// 初始化详情界面,填充数据
        /// </summary>
        public void initData()
        {
            try
            {
                // 点击自动搜索框,数据的id
                var selectedIndex = Int32.Parse(Application.Current.Properties["SelectedIndex"].ToString());
                var bookList      = (Book[])Application.Current.Properties["SearchBookList"];
                downloadBook               = bookList[selectedIndex];
                bookTitle.Content          = bookList[selectedIndex].title;
                bookAuthor.Content         = bookList[selectedIndex].author;
                bookCat.Content            = bookList[selectedIndex].cat;
                bookWordCount.Content      = bookList[selectedIndex].wordCount + "字";
                bookLatelyFollower.Content = bookList[selectedIndex].latelyFollower + " 人";
                booklatestChapter.Content  = bookList[selectedIndex].lastChapter;
                bookRetentionRatio.Content = bookList[selectedIndex].retentionRatio + " %";
                bookShortInfo.Text         = bookList[selectedIndex].shortIntro;

                string url           = bookList[selectedIndex].cover;
                int    urlStartIndex = url.IndexOf("http:");
                if (urlStartIndex >= 0)
                {
                    url = url.Substring(urlStartIndex);
                    bookImage.Source = new BitmapImage(new Uri(url, UriKind.RelativeOrAbsolute));
                    // picturebox_cover.ImageLocation = url;
                    //MessageBox.Show(bookList[bookId].cover);
                }


                // 获取书源
                url = "http://api.zhuishushenqi.com/toc?view=summary&book=" + bookList[selectedIndex]._id + "";
                //Task<string> getValue = common.GetPage(url);
                //var json = await getValue;
                var getValue = Task.Run(() =>
                {
                    string json = common.GetPage(url);
                    //jsonArry
                    var bookSource = JArray.Parse(json);
                    if (String.IsNullOrEmpty(json))
                    {
                        MessageBox.Show("网络错误");
                        return;
                    }
                    Dictionary <string, string> sourceList = new Dictionary <string, string>();
                    List <Source> sourceDetialList         = new List <Source>();
                    foreach (var sourceItem in bookSource)
                    {
                        var info = sourceItem.ToObject <Source>();
                        sourceDetialList.Add(info);
                        // 书源的名字 书源内书的id
                        sourceList.Add(info.name, info._id);
                    }
                    // 章节列表
                    url     = "http://api.zhuishushenqi.com/toc/" + sourceList.First().Value + "?view=chapters";
                    json    = common.GetPage(url);
                    chapter = (ChapterList)common.FromJson("ChapterList", json);

                    if (String.IsNullOrEmpty(json))
                    {
                        MessageBox.Show("网络错误");
                        return;
                    }
                    if (chapter.name == "优质书源")
                    {
                        MessageBox.Show("当前电子书不支持下载");
                        this.Dispatcher.InvokeAsync(() => this.Close());

                        return;
                    }
                    Application.Current.Properties["chapterList"] = chapter;

                    ObservableCollection <ChapterList> list = new ObservableCollection <ChapterList>();

                    foreach (var item in chapter.chapters)
                    {
                        chapter      = new ChapterList();
                        chapter.name = item.title;
                        chapter.link = item.link;
                        list.Add(chapter);
                    }
                    DownloadButton.Dispatcher.InvokeAsync(() => DownloadButton.IsEnabled = true);
                    dataGrid.Dispatcher.InvokeAsync(() => dataGrid.ItemsSource           = list);
                });
            }
            catch (Exception ex)
            {
                MessageBox.Show("网络错误");
                return;
            }
        }
Пример #25
0
        public void CreateList()
        {
            ConstructorInfo ctor = typeof(ChapterList).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, Type.DefaultBinder, new Type[0], null);

            this.list = ctor.Invoke(null) as ChapterList;
        }
Пример #26
0
 void ddlChapters_Populate()
 {
     //make a new ChapterList called chapList
     ChapterList chapList = new ChapterList();
     //enable ddlChapters
     ddlChapters.Enabled = true;
     //set ddlChapters visible property to true
     ddlChapters.Visible = true;
     //get the chapters by the story ID (taken from ddlStory's selected value)
     chapList = chapList.GetByStoryID(new Guid(this.ddlStory.SelectedValue));
     //bind chapList to ddlChapters
     ddlChapters.DataSource = chapList.List;
     ddlChapters.DataTextField = "Title";
     ddlChapters.DataValueField = "ID";
     ddlChapters.DataBind();
     //set ddlChapter's selected index to the index of chapter
     ddlChapters.SelectedIndex = ddlChapters.Items.IndexOf(ddlChapters.Items.FindByValue(chap.Id.ToString()));
 }
 private IEnumerable <string> GetChapters()
 {
     return(ChapterList.Where(x => !IgnoredChapters.Contains(x.Key)).Select(x => x.Key));
 }
Пример #28
0
        // 进行下载
        private void BackgroundDownload_DoWork(object sender, DoWorkEventArgs e)
        {
            // Chapter[] chapterList = new Chapter();
            ChapterList _chapter    = (ChapterList)Application.Current.Properties["chapterList"];
            var         chapterList = _chapter.chapters;
            var         progessBar  = downloadProcess;
            var         lable       = downloadInfo;
            var         filePath    = e.Argument.ToString();
            // 章节具体信息
            List <ChapterDetial> chaperInfoList = new List <ChapterDetial>();

            for (int i = 0; i < chapterList.Length; i++)
            {
                if (backgroundDownload.CancellationPending)
                {
                    return;
                }
                var    chapter        = chapterList[i];
                double progressBarRat = (double)(i + 1) / (double)chapterList.Length;
                string info           = string.Format("正在下载:{0} {1}/{2} {3:F2}%", chapter.title, i + 1, chapterList.Length,
                                                      progressBarRat * 100);
                backgroundDownload.ReportProgress(i, info);

                while (true)
                {
                    var downloadSuccess = false;
                    var error           = "";
                    // 每个源尝试下载3次
                    for (int j = 0; j < 3; j++)
                    {
                        try
                        {
                            var charterInfo = getChapter(chapter.link);
                            if (charterInfo != null)
                            {
                                chaperInfoList.Add(charterInfo);
                                downloadSuccess = true;
                            }
                        }
                        catch (Exception ex)
                        {
                            error = ex.ToString();
                        }
                    }
                    if (!downloadSuccess)
                    {
                        var result = MessageBox.Show("取消下载?", "章节 " + chapter.title + " 下载失败", MessageBoxButton.YesNo);
                        if (result == MessageBoxResult.Yes)
                        {
                            return;
                        }
                        else
                        {
                            var emptyChaper = new ChapterDetial();
                            emptyChaper.title = chapter.title;
                            emptyChaper.body  = "本章下载失败了,失败原因:\n " + error;
                            chaperInfoList.Add(emptyChaper);
                            downloadSuccess = true;
                            break;
                        }
                    }
                    else
                    {
                        break;
                    }
                }
            }
            backgroundDownload.ReportProgress(chapterList.Length, "正在生成电子书请稍后....");
            // 获取文件拓展名
            var extName       = System.IO.Path.GetExtension(filePath);
            var selectedIndex = Int32.Parse(Application.Current.Properties["SelectedIndex"].ToString());
            var bookList      = (Book[])Application.Current.Properties["SearchBookList"];

            downloadBook = bookList[selectedIndex];
            KindleBook kindleBook = new KindleBook();

            kindleBook.name     = downloadBook.title;
            kindleBook.author   = downloadBook.author;
            kindleBook.id       = downloadBook._id;
            kindleBook.chapters = chaperInfoList.ToArray();
            if (extName.ToLower() == ".txt")
            {
                Kindlegen.book2Txt(kindleBook, filePath);
            }
            else if (extName.ToLower() == ".mobi")
            {
                Kindlegen.book2Mobi(kindleBook, filePath);
            }
            //this.Dispatcher.InvokeAsync(() => this.Close());
        }
Пример #29
0
        protected void DeleteChapters(Guid storyID)
        {
            Guid stryID = new Guid(this.ddlStory.SelectedValue);

            ChapterList chapL = new ChapterList();
            chapL = chapL.GetByStoryID(stryID);
            for (int i = 0; i <= chapL.List.Count; i++)
            {
            }

            ReviewList rvwList = new ReviewList();
        }
        public async Task <object> GetCountyDetails(int countyId, int countyId2, string chapter, bool needToProcessAllYear)
        {
            if (!ChapterList.ContainsKey(chapter) || countyId < 1)
            {
                return(null);
            }

            var countyAbbreviations = new Dictionary <string, string>()
            {
                { "Alba", "AB" },
                { "Arad", "AR" },
                { "Arges", "AG" },
                { "Bacau", "BC" },
                { "Bihor", "BH" },
                { "Bistrita-Nasaud", "BN" },
                { "Botosani", "BT" },
                { "Brasov", "BV" },
                { "Braila", "BR" },
                { "Buzau", "BZ" },
                { "Caras-Severin", "CS" },
                { "Calarasi", "CL" },
                { "Cluj", "CJ" },
                { "Constanta", "CT" },
                { "Covasna", "CV" },
                { "Dambovita", "DB" },
                { "Dolj", "DJ" },
                { "Galati", "GL" },
                { "Giurgiu", "GR" },
                { "Gorj", "GJ" },
                { "Harghita", "HR" },
                { "Hunedoara", "HD" },
                { "Ialomita", "IL" },
                { "Iasi", "IS" },
                { "Ilfov", "IF" },
                { "Maramures", "MM" },
                { "Mehedinti", "MH" },
                { "Mures", "MS" },
                { "Neamt", "NT" },
                { "Olt", "OT" },
                { "Prahova", "PH" },
                { "Satu Mare", "SM" },
                { "Salaj", "SJ" },
                { "Sibiu", "SB" },
                { "Suceava", "SV" },
                { "Teleorman", "TR" },
                { "Timis", "TM" },
                { "Tulcea", "TL" },
                { "Vaslui", "VS" },
                { "Valcea", "VL" },
                { "Vrancea", "VN" },
                { "Bucuresti", "B" },
            };

            var countyList = CountiesSeeder.GetData().ToDictionary(x => x.Name, x => x.Id);

            var valueColumnCaption = string.Format("{0} {1}", UnitOfMeasureList[chapter], countyAbbreviations[countyList.First(x => x.Value == countyId).Key]);

            var data = (await CountyDetailsProvider.GetData(countyId, ChapterList[chapter], needToProcessAllYear))
                       .OrderByDescending(x => x.Year)
                       .ThenByDescending(x => x.YearFraction)
                       .Select(x => new DataDto
            {
                Id           = x.Id,
                CountyId     = x.CountyId,
                Subchapter   = x.Subchapter,
                Year         = x.Year,
                YearFraction = x.YearFraction,
                Value        = x.Value,
                Value2       = x.Value2
            })
                       .ToList();

            string value2ColumnCaption = null;
            bool   value2ColumnVisibility;  // kept for compatibility with the mobile VM in case I ever want to merge the duplicated logic

            if (countyId2 >= 1 && countyId != countyId2)
            {
                var data2 = await CountyDetailsProvider.GetData(countyId2, ChapterList[chapter], needToProcessAllYear);

                foreach (var item2 in data2)
                {
                    var item = data.FirstOrDefault(x => x.Year == item2.Year && x.YearFraction == item2.YearFraction);
                    if (item != null)
                    {
                        item.Value2 = item2.Value;
                    }
                }

                value2ColumnCaption = string.Format("{0} {1}", UnitOfMeasureList[chapter], countyAbbreviations[countyList.First(x => x.Value == countyId2).Key]);

                value2ColumnVisibility = true;
            }
            else
            {
                value2ColumnVisibility = false;
            }

            return(new CountyDetailsDto {
                ValueColumnCaption = valueColumnCaption, Value2ColumnCaption = value2ColumnCaption, Data = data
            });
        }
Пример #31
0
        protected void loadStories(Guid storyID)
        {
            ChapterList chapList = new ChapterList();

            chapList = chapList.GetByStoryID(storyID);
        }
Пример #32
0
 public void CreateList()
 {
     ConstructorInfo ctor = typeof(ChapterList).GetConstructor(BindingFlags.NonPublic | BindingFlags.Instance, Type.DefaultBinder, new Type[0], null);
     this.list = ctor.Invoke(null) as ChapterList;
 }
Пример #33
0
 /// <summary>
 /// Loads the metadata for this file.
 /// </summary>
 public void Load()
 {
     IntPtr fileHandle = NativeMethods.MP4Read(this.fileName);
     if (fileHandle != IntPtr.Zero)
     {
         try
         {
             this.metadataTags = MetadataTags.ReadFromFile(fileHandle);
             this.chapters = ChapterList.ReadFromFile(fileHandle);
         }
         finally
         {
             NativeMethods.MP4Close(fileHandle);
         }
     }
 }