public Chapter(XElement chapterTag, Book book, int chapterNumber, Chapter previous) : base(chapterNumber, previous) { foreach (var verseTag in chapterTag.Descendants("VERS")) { Book = book; var prevVerse = Verses.Count > 0 ? Verses[Verses.Count - 1] : previous?.Verses[previous.Verses.Count - 1]; Verses.Add(new Verse(verseTag.Value, this, Verses.Count + 1, prevVerse)); } }
private void FinishedVerse(DataRow verse) { if (verse.Field <int>("VerseId") < User.Field <int>("NextVerseId")) { return; } if (Verses.All(p => p.Field <int>("VerseId") != verse.Field <int>("VerseId"))) { Verses.Add(verse); } }
public VerseCollection(string songText, int languageCount) { MaxVerseLinesCount = 0; var rgx = new Regex(@"[-]{3}\s*(.*?)[$]{2}\s*(.*?)(\r\n)?(?=---|$)", RegexOptions.Singleline); //Filtert Verse aus MatchCollection versesText = rgx.Matches(songText); foreach (Match verseText in versesText) { Verses.Add(new LineCollection(verseText.Groups[2].Value, verseText.Groups[1].Value, languageCount)); if (versesText.Count > MaxVerseLinesCount) { MaxVerseLinesCount = versesText.Count; } } }
private void Stop(bool manualStop) { StopTimer(); if (!HasStarted) { return; } SetupInitialState(); HandleNotReadingAnymore(); if (manualStop) { if (MessageBox.Show(@"Você leu o versículo atual até o fim?", @"Pergunta", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Verses.Add(CurrentVerse); } } if (LastVerseRead == null) { return; } var wordsPerMinute = CalculateWordsPerMinute(); var totalVerses = Verses.Count; var totalWords = Verses.AsEnumerable().Sum(p => p.Field <int>("WordCount")); try { using (var scope = TransactionScopeUtility.GetTransactionScope()) { var nextVerse = GetNextBibleVerse(LastVerseRead); if (nextVerse != null) { new User().UpdateNextVerseId(User.Field <int>("UserId"), nextVerse.Field <int>("VerseId")); } new Reading().InsertReading(StartedAt, FinishedAt, FirstVerseRead.Field <int>("VerseId"), LastVerseRead.Field <int>("VerseId"), TotalSeconds, wordsPerMinute, totalVerses, totalWords, User.Field <int>("UserId")); scope.Complete(); } } catch (Exception) { // Gravar o XML para carregar para o banco depois } LoadStartInformation(); }