Beispiel #1
0
        private FictionBook ReadFictionBook(TextReader stream)
        {
            SgmlReader reader = new SgmlReader();

            reader.InputStream = stream;

            if (this.fb2Dtd == null)
            {
                reader.SystemLiteral = "fb2.dtd";
                this.fb2Dtd          = reader.Dtd;
            }
            else
            {
                reader.Dtd = this.fb2Dtd;
            }

            FictionBook fictionBook = ReadFictionBook(reader);

            if (reader.MarkupErrorsCount > 0)
            {
                fictionBook.ModificationType = ModificationType.Body;
            }

            return(fictionBook);
        }
        /// <summary>
        /// Заполнение хеш таблицы данными о fb2-книгах в контексте Авторов
        /// </summary>
        /// <param name="fb2">объект класса FictionBook</param>
        /// <param name="ZipPath">путь к zip-архиву. Если книга - не запакована в zip, то ZipPath = null</param>
        /// <param name="SrcPath">путь к fb2-файлу</param>
        /// <param name="Encoding">кодировка текщего файла в fb2</param>
        /// <param name="sAuthor">Фамилия и 1-я буква Имени текущего автора</param>
        /// <param name="htFB2ForAuthorFIO">Хеш Таблица с книгами одинаковых Авторов</param>
        private void FB2AuthorFIOSetHashTable(FictionBook fb2, string ZipPath, string SrcPath, string Encoding,
                                              string sAuthor, ref HashtableClass htFB2ForAuthorFIO)
        {
            // данные о книге
            BookData fb2BookData = new BookData(
                fb2.TIBookTitle, fb2.TIAuthors, fb2.TIGenres, fb2.TILang, fb2.DIID, fb2.DIVersion, fb2.DIAuthors, SrcPath, Encoding
                );

            if (ZipPath != null)
            {
                fb2BookData.Path = ZipPath;
            }

            if (!htFB2ForAuthorFIO.ContainsKey(sAuthor))
            {
                // этого Автора sAuthor в Группе еще нет
                FB2FilesDataInGroup fb2f = new FB2FilesDataInGroup(fb2BookData, sAuthor);
                fb2f.Group = sAuthor;
                htFB2ForAuthorFIO.Add(sAuthor, fb2f);
            }
            else
            {
                // этот Автор sAuthor в Группе уже есть
                FB2FilesDataInGroup fb2f = (FB2FilesDataInGroup)htFB2ForAuthorFIO[sAuthor];
                fb2f.Add(fb2BookData);
                //htFB2ForBT[sAuthor] = fb2f; //ИЗБЫТОЧНЫЙ КОД
            }
        }
Beispiel #3
0
        private IList <XmlNode> makeAuthorNode(Enums.AuthorEnum AuthorType, ref FictionBook fb2, ListView lv)
        {
            FB2DescriptionCorrector fB2Corrector = new FB2DescriptionCorrector(fb2);
            IList <XmlNode>         Authors      = null;
            XmlNode xmlAuthor = null;

            if (lv.Items.Count > 0)
            {
                Authors = new List <XmlNode>(lv.Items.Count);
                foreach (ListViewItem item in lv.Items)
                {
                    string         HPs     = StringProcessing.trimLastTemplateSymbol(item.SubItems[4].Text.Trim(), new Char [] { ',', ';' });
                    IList <string> lHPs    = HPs.Split(new Char [] { ',', ';' });
                    string         Emails  = StringProcessing.trimLastTemplateSymbol(item.SubItems[5].Text.Trim(), new Char [] { ',', ';' });
                    IList <string> lEmails = Emails.Split(new Char [] { ',', ';' });
                    xmlAuthor = fB2Corrector.makeAuthorNode(
                        AuthorType,
                        item.SubItems[1].Text, item.SubItems[2].Text, item.Text, item.SubItems[3].Text,
                        lHPs, lEmails, item.SubItems[6].Text
                        );
                    Authors.Add(xmlAuthor);
                }
            }
            else
            {
                if (AuthorType == Enums.AuthorEnum.AuthorOfBook)
                {
                    Authors   = new List <XmlNode>();
                    xmlAuthor = fB2Corrector.makeAuthorNode(AuthorType, null, null, null, null, null, null, null);
                    Authors.Add(xmlAuthor);
                }
            }
            return(Authors);
        }
Beispiel #4
0
        public static void _gebugTestIsSameBookData(bool CompareAndMiddleName)
        {
            FictionBook fb2_1 = new FictionBook("1.fb2");
            FictionBook fb2_2 = new FictionBook("2.fb2");

            BookData bd1 = new BookData(
                fb2_1.TIBookTitle, fb2_1.TIAuthors, fb2_1.TIGenres, fb2_1.TILang, fb2_1.DIID, fb2_1.DIVersion,
                fb2_1.DIAuthors, fb2_1.getFilePath(), fb2_1.getEncoding()
                );
            BookData bd2 = new BookData(
                fb2_2.TIBookTitle, fb2_2.TIAuthors, fb2_2.TIGenres, fb2_2.TILang, fb2_2.DIID, fb2_2.DIVersion,
                fb2_2.DIAuthors, fb2_2.getFilePath(), fb2_2.getEncoding()
                );

            if (bd1.isSameBook(bd2, CompareAndMiddleName, false))
            {
                MessageBox.Show("Одинаковые:\n" + "bd1: " + bd1.BookTitle.Value + "\n" + "bd2: " + bd2.BookTitle.Value,
                                "Test - BookData", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
            else
            {
                MessageBox.Show("Нет:\n" + "bd1: " + bd1.BookTitle.Value + "\n" + "bd2: " + bd2.BookTitle.Value,
                                "Test - BookData", MessageBoxButtons.OK, MessageBoxIcon.Information);
            }
        }
        private IList <XmlNode> makeGenreNode(ref FictionBook fb2, ListView lv)
        {
            IList <XmlNode> Genres   = null;
            XmlNode         xmlGenre = null;

            if (lv.Items.Count > 0)
            {
                Genres = new List <XmlNode>(lv.Items.Count);
                FB2DescriptionCorrector fB2Corrector = new FB2DescriptionCorrector(fb2);
                if (lv.Items.Count > 0)
                {
                    foreach (ListViewItem item in lv.Items)
                    {
                        string code = item.Text.Substring(item.Text.IndexOf('(') + 1);
                        xmlGenre = fB2Corrector.makeGenreNode(code.Substring(0, code.Length - 1), item.SubItems[1].Text);
                        Genres.Add(xmlGenre);
                    }
                }
                else
                {
                    xmlGenre = fB2Corrector.makeGenreNode("other", null);
                    Genres.Add(xmlGenre);
                }
            }
            return(Genres);
        }
Beispiel #6
0
 private void ChangeDocumentVersion(FictionBook fictionBook)
 {
     if ((fictionBook.ModificationType & ModificationType.DocumentInfo) == ModificationType.DocumentInfo)
     {
         fictionBook.Version = 1.0f;
         return;
     }
 }
Beispiel #7
0
        /// <summary>
        /// Заполнение хеш таблицы данными о fb2-книгах в контексте их md5
        /// </summary>
        /// <param name="ZipPath">путь к zip-архиву. Если книга - не запакована в zip, то ZipPath = null</param>
        /// <param name="SrcPath">путь к fb2-файлу;</param>
        /// <param name="htFB2ForMd5">Хеш Таблица с книгами с одинаковыми значениями Md5</param>
        private void MakeFB2Md5HashTable(string ZipPath, string SrcPath, ref HashtableClass htFB2ForMd5)
        {
            string md5 = ComputeMD5Checksum(SrcPath);

            FictionBook fb2 = null;

            try {
                fb2 = new FictionBook(SrcPath);
            } catch (Exception ex) {
                Debug.DebugMessage(
                    SrcPath, ex, "Дубликатор.CompareForm.MakeFB2Md5HashTable(): Заполнение хеш таблицы данными о fb2-книгах в контексте их md5."
                    );
                _nonOpenedFileList = _compComm.collectBadFB2(!string.IsNullOrEmpty(ZipPath) ? ZipPath : SrcPath);
                return;
            }

            string Encoding = fb2.getEncoding();

            if (string.IsNullOrWhiteSpace(Encoding))
            {
                Encoding = "?";
            }
            string ID = fb2.DIID;

            if (ID == null)
            {
                return;
            }

            if (ID.Trim().Length == 0)
            {
                ID = "Тег <id> в этих книгах \"пустой\"";
            }

            // данные о книге
            BookData fb2BookData = new BookData(
                fb2.TIBookTitle, fb2.TIAuthors, fb2.TIGenres, fb2.TILang, ID, fb2.DIVersion, fb2.DIAuthors, SrcPath, Encoding
                );

            if (ZipPath != null)
            {
                fb2BookData.Path = ZipPath;
            }

            if (!htFB2ForMd5.ContainsKey(md5))
            {
                // такой книги в числе дублей еще нет
                FB2FilesDataInGroup fb2f = new FB2FilesDataInGroup(fb2BookData, md5);
                htFB2ForMd5.Add(md5, fb2f);
            }
            else
            {
                // такая книга в числе дублей уже есть
                FB2FilesDataInGroup fb2f = (FB2FilesDataInGroup)htFB2ForMd5[md5];
                fb2f.Add(fb2BookData);
                //htFB2ForMd5[md5] = fb2f; //ИЗБЫТОЧНЫЙ КОД
            }
        }
        /// <summary>
        /// Заполнение хеш таблицы данными о fb2-книгах в контексте Авторов с одинаковой Фамилией и инициалами
        /// </summary>
        /// <param name="ZipPath">путь к zip-архиву. Если книга - не запакована в zip, то ZipPath = null</param>
        /// <param name="SrcPath">путь к fb2-файлу</param>
        /// <param name="htFB2ForAuthorFIO">Хеш Таблица с книгами одинаковых Авторов</param>
        /// <param name="WithMiddleName">Учитывать ли отчество Авторов (true) или нет (false) при поиске</param>
        private void MakeFB2AuthorFIOHashTable(string ZipPath, string SrcPath, ref HashtableClass htFB2ForAuthorFIO, bool WithMiddleName)
        {
            FictionBook fb2 = null;

            try {
                fb2 = new FictionBook(SrcPath);
            } catch (Exception ex) {
                Debug.DebugMessage(
                    SrcPath, ex, "Дубликатор.CompareForm.MakeFB2AuthorFIOHashTable(): Заполнение хеш таблицы данными о fb2-книгах в контексте Авторов с одинаковой Фамилией и инициалами."
                    );
                _nonOpenedFileList = _compComm.collectBadFB2(!string.IsNullOrEmpty(ZipPath) ? ZipPath : SrcPath);
                return;
            }

            string Encoding = fb2.getEncoding();

            if (string.IsNullOrWhiteSpace(Encoding))
            {
                Encoding = "?";
            }

            IList <Author> AuthorsList = fb2.TIAuthors;
            string         sAuthor     = "<Автор книги отсутствует>";

            if (AuthorsList != null)
            {
                foreach (Author a in AuthorsList)
                {
                    if (a.LastName != null && !string.IsNullOrEmpty(a.LastName.Value))
                    {
                        sAuthor = a.LastName.Value;
                    }
                    if (a.FirstName != null && !string.IsNullOrEmpty(a.FirstName.Value))
                    {
                        sAuthor += " " + a.FirstName.Value.Substring(0, 1);
                    }
                    if (WithMiddleName)
                    {
                        if (a.MiddleName != null && !string.IsNullOrEmpty(a.MiddleName.Value))
                        {
                            sAuthor += " " + a.MiddleName.Value.Substring(0, 1);
                        }
                    }
                    if (a.NickName != null && !string.IsNullOrWhiteSpace(a.NickName.Value))
                    {
                        sAuthor += a.NickName.Value;
                    }
                    sAuthor = sAuthor.Trim();
                    // Заполнение хеш таблицы данными о fb2-книгах в контексте Авторов
                    FB2AuthorFIOSetHashTable(fb2, ZipPath, SrcPath, Encoding, sAuthor, ref htFB2ForAuthorFIO);
                }
            }
            else
            {
                // Заполнение хеш таблицы данными о fb2-книгах в контексте Авторов
                FB2AuthorFIOSetHashTable(fb2, ZipPath, SrcPath, Encoding, sAuthor, ref htFB2ForAuthorFIO);
            }
        }
 public FictionDetailsTabViewModel(MainModel mainModel, IWindowContext parentWindowContext, FictionBook book, bool isInModalWindow)
     : base(mainModel, parentWindowContext, book.Title)
 {
     this.book           = book;
     IsInModalWindow     = isInModalWindow;
     DownloadBookCommand = new Command(DownloadBook);
     CloseCommand        = new Command(CloseTab);
     Initialize();
 }
Beispiel #10
0
 public FB2ItemInfo(ListViewItem FB2ListViewItem, string FilePathSource,
                    string FilePathIfFromZip, bool IsFromZip)
 {
     m_FB2ListViewItem   = FB2ListViewItem;
     m_FilePathSource    = FilePathSource.Replace(@"\\", @"\");
     m_FilePathIfFromZip = FilePathIfFromZip.Replace(@"\\", @"\");
     m_IsFromZip         = IsFromZip;
     m_fb2 = IsFromZip ? new FictionBook(FilePathIfFromZip) : new FictionBook(FilePathSource);
 }
Beispiel #11
0
        private void PostProcessDocument(FictionBook fictionBook)
        {
            List <XmlElement> invalidNodes;

            if (fictionBook == null)
            {
                throw new ArgumentNullException("fictionBook");
            }

            XmlDocument document = fictionBook.Document;

            invalidNodes = new List <XmlElement>(64);
            ProcessElement(fictionBook, document.DocumentElement, invalidNodes);

            //foreach (XmlElement node in invalidNodes)
            //{
            //    if(node == null)
            //    {
            //        continue;
            //    }

            //    XmlElement parent = node.ParentNode as XmlElement;
            //    if (parent != null && parent.NodeType == XmlNodeType.Element)
            //    {
            //        XmlComment comment = parent.OwnerDocument.CreateComment(node.OuterXml);
            //        parent.ReplaceChild(comment, node);
            //    }
            //}

            XmlNodeList       nodes          = document.SelectNodes("//FictionBook/descendant::p");
            List <XmlElement> paragraphNodes = new List <XmlElement>(nodes.Count);

            foreach (XmlNode node in nodes)
            {
                XmlElement paragraph = node as XmlElement;
                if (paragraph != null)
                {
                    paragraphNodes.Add(paragraph);
                }
            }

            for (int index = paragraphNodes.Count - 1; index >= 0; index--)
            {
                XmlElement paragraphElement = paragraphNodes[index];
                XmlElement parentElement    = paragraphElement.ParentNode as XmlElement;
                if (parentElement != null && String.Compare(parentElement.LocalName, "p") == 0)
                {
                    XmlElement precedingElement = parentElement.ParentNode as XmlElement;
                    if (precedingElement != null)
                    {
                        parentElement.RemoveChild(paragraphElement);
                        precedingElement.InsertAfter(paragraphElement, parentElement);
                        fictionBook.ModificationType = ModificationType.Body;
                    }
                }
            }
        }
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            FB2DescriptionCorrector fB2Corrector = null;

            foreach (FB2ItemInfo Info in m_KeywordsFB2InfoList)
            {
                FictionBook fb2 = Info.FictionBook;
                if (fb2 != null)
                {
                    fB2Corrector = new FB2DescriptionCorrector(fb2);
                    fB2Corrector.recoveryDescriptionNode();

                    XmlNode xmlTI = fb2.getTitleInfoNode(TitleInfoEnum.TitleInfo);
                    if (xmlTI != null)
                    {
                        string kw    = string.Empty;
                        string kwOld = fb2.getKeywordsNode(TitleInfoEnum.TitleInfo).InnerText;
                        if (AddRadioButton.Checked)
                        {
                            // добавить новые ключевые слова к существующим
                            kw = !string.IsNullOrWhiteSpace(kwOld) ?
                                 (kwOld + "," + KeywordsTextBox.Text.Trim())
                                                        : KeywordsTextBox.Text.Trim();
                        }
                        else
                        {
                            // заменить существующие ключевые слова на новые
                            kw = KeywordsTextBox.Text.Trim();
                        }
                        xmlTI.ReplaceChild(
                            fB2Corrector.makeKeywordsNode(kw),
                            fb2.getKeywordsNode(TitleInfoEnum.TitleInfo)
                            );

                        // сохранение fb2 файла
                        if (!Directory.Exists(m_TempDir))
                        {
                            Directory.CreateDirectory(m_TempDir);
                        }
                        string NewPath = Info.IsFromZip ? Info.FilePathIfFromZip : Info.FilePathSource;
                        fb2.saveToFB2File(NewPath, false);
                        if (Info.IsFromZip)
                        {
                            WorksWithBooks.zipMoveTempFB2FileTo(m_sharpZipLib, NewPath, Info.FilePathSource);
                        }
                        if (Info.IsFromZip && File.Exists(NewPath))
                        {
                            File.Delete(NewPath);
                        }
                    }
                }
                m_bw.ReportProgress(1);
                ProgressBar.Update();
            }
            Cursor.Current = Cursors.Default;
        }
Beispiel #13
0
 static void Main(string[] args)
 {
     Book x = new Book();
     x.show_type(); //вывод book
     FictionBook w = new FictionBook();
     w.show_type(); //вывод fiction
     Book h = new FictionBook();
     h.show_type(); //во время выполнения программы свяжется с методом класса FictionBook, вывод fiction
     Console.WriteLine();
 }
Beispiel #14
0
        private void SaveFictionBook(string directory, string filename, FictionBook fictionBook, Encoding encoding)
        {
            string      outputFilename = String.Empty;
            XmlDocument document       = fictionBook.Document;

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

            try
            {
                outputFilename = GetOutputFileName(directory, filename, ".fb2");

                using (Fb2TextWriter writer = new Fb2TextWriter(outputFilename, encoding))
                {
                    writer.WriteStartDocument();

                    document.WriteTo(writer);
                    writer.Flush();
                }

                if (!String.IsNullOrEmpty(outputFilename))
                {
                    DateTime dt = fictionBook.ContainerDateTime;

                    if (!dt.IsDaylightSavingTime())
                    {
                        dt = dt.AddHours(-1);
                    }

                    File.SetCreationTime(outputFilename, dt);
                    File.SetLastAccessTime(outputFilename, dt);
                    File.SetLastWriteTime(outputFilename, dt);
                }
            }
            catch (Exception)
            {
                if (!String.IsNullOrEmpty(outputFilename))
                {
                    if (File.Exists(outputFilename))
                    {
                        try
                        {
                            File.Delete(outputFilename);
                        }
                        catch (Exception exp)
                        {
                            ApplicationLogger.WriteStringToLog(exp.Message);
                        }
                    }
                }
                throw;
            }
        }
Beispiel #15
0
 public FictionDetailsWindowViewModel(MainModel mainModel, FictionBook book, bool modalWindow)
 {
     this.mainModel      = mainModel;
     this.book           = book;
     this.modalWindow    = modalWindow;
     tabViewModel        = null;
     WindowTitle         = book.Title;
     WindowWidth         = mainModel.AppSettings.Fiction.DetailsWindow.Width;
     WindowHeight        = mainModel.AppSettings.Fiction.DetailsWindow.Height;
     WindowClosedCommand = new Command(WindowClosed);
 }
        /// <summary>
        /// Заполнение хеш таблицы данными о fb2-книгах в контексте их Названия
        /// </summary>
        /// <param name="ZipPath">путь к zip-архиву. Если книга - не запакована в zip, то ZipPath = null</param>
        /// <param name="SrcPath">путь к fb2-файлу;</param>
        /// <param name="htFB2ForBT">Хеш Таблица с книгами с одинаковыми Названиями</param>
        private void MakeFB2BTHashTable(string ZipPath, string SrcPath, HashtableClass htFB2ForBT)
        {
            FictionBook fb2 = null;

            try {
                fb2 = new FictionBook(SrcPath);
            }
            catch (Exception ex) {
                Debug.DebugMessage(
                    SrcPath, ex, "Дубликатор.CompareForm.MakeFB2BTHashTable(): Заполнение хеш таблицы данными о fb2-книгах в контексте их Названия."
                    );
                _nonOpenedFileList = _compComm.collectBadFB2(!string.IsNullOrEmpty(ZipPath) ? ZipPath : SrcPath);
                return;
            }

            string Encoding = fb2.getEncoding();

            if (string.IsNullOrWhiteSpace(Encoding))
            {
                Encoding = "?";
            }

            BookTitle bookTitle = fb2.TIBookTitle;
            string    BT        = "<Название книги отсутствует>";

            if (bookTitle != null && !string.IsNullOrWhiteSpace(bookTitle.Value))
            {
                BT = bookTitle.Value.Trim();
            }

            // данные о книге
            BookData fb2BookData = new BookData(
                bookTitle, fb2.TIAuthors, fb2.TIGenres, fb2.TILang, fb2.DIID, fb2.DIVersion, fb2.DIAuthors, SrcPath, Encoding
                );

            if (ZipPath != null)
            {
                fb2BookData.Path = ZipPath;
            }

            if (!htFB2ForBT.ContainsKey(BT))
            {
                // такой книги в числе дублей еще нет
                FB2FilesDataInGroup fb2f = new FB2FilesDataInGroup(fb2BookData, BT);
                htFB2ForBT.Add(BT, fb2f);
            }
            else
            {
                // такая книга в числе дублей уже есть
                FB2FilesDataInGroup fb2f = (FB2FilesDataInGroup)htFB2ForBT[BT];
                fb2f.Add(fb2BookData);
                //htFB2ForBT[sBT] = fb2f; //ИЗБЫТОЧНЫЙ КОД
            }
        }
Beispiel #17
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            FB2DescriptionCorrector fB2Corrector = null;

            foreach (FB2ItemInfo Info in m_SequencesFB2InfoList)
            {
                FictionBook fb2 = Info.FictionBook;
                if (fb2 != null)
                {
                    fB2Corrector = new FB2DescriptionCorrector(fb2);
                    fB2Corrector.recoveryDescriptionNode();

                    XmlNode xmlTI = fb2.getTitleInfoNode(TitleInfoEnum.TitleInfo);
                    if (xmlTI != null)
                    {
                        if (RemoveRadioButton.Checked || ReplaceRadioButton.Checked)
                        {
                            // удаление всех Серий
                            foreach (XmlNode node in fb2.getSequencesNode(TitleInfoEnum.TitleInfo))
                            {
                                xmlTI.RemoveChild(node);
                            }
                        }
                        if (AddRadioButton.Checked || ReplaceRadioButton.Checked)
                        {
                            // добавление новой Серии
                            xmlTI.AppendChild(
                                fB2Corrector.makeSequenceNode(SequencesTextBox.Text.Trim(), NumberTextBox.Text.Trim())
                                );
                        }
                        // сохранение fb2 файла
                        if (!Directory.Exists(m_TempDir))
                        {
                            Directory.CreateDirectory(m_TempDir);
                        }
                        string NewPath = Info.IsFromZip ? Info.FilePathIfFromZip : Info.FilePathSource;
                        fb2.saveToFB2File(NewPath, false);
                        if (Info.IsFromZip)
                        {
                            WorksWithBooks.zipMoveTempFB2FileTo(m_sharpZipLib, NewPath, Info.FilePathSource);
                        }
                        if (Info.IsFromZip && File.Exists(NewPath))
                        {
                            File.Delete(NewPath);
                        }
                    }
                }
                m_bw.ReportProgress(1);
                ProgressBar.Update();
            }
            Cursor.Current = Cursors.Default;
        }
Beispiel #18
0
        /// <summary>
        /// Заполнение хеш таблицы данными о fb2-книгах в контексте их ID
        /// </summary>
        /// <param name="ZipPath">путь к zip-архиву. Если книга - не запакована в zip, то ZipPath = null</param>
        /// <param name="SrcPath">путь к fb2-файлу;</param>
        /// <param name="htFB2ForID">Хеш Таблица с книгами с одинаковыми ID</param>
        private void MakeFB2IDHashTable(string ZipPath, string SrcPath, ref HashtableClass htFB2ForID)
        {
            FictionBook fb2 = null;

            try {
                fb2 = new FictionBook(SrcPath);
            }
            catch (Exception ex) {
                Debug.DebugMessage(
                    SrcPath, ex, "Дубликатор.CompareForm.MakeFB2IDHashTable(): Заполнение хеш таблицы данными о fb2-книгах в контексте их ID."
                    );
                _nonOpenedFileList = _compComm.collectBadFB2(!string.IsNullOrEmpty(ZipPath) ? ZipPath : SrcPath);
                return;
            }

            string Encoding = fb2.getEncoding();

            if (string.IsNullOrWhiteSpace(Encoding))
            {
                Encoding = "?";
            }
            string ID = fb2.DIID;

            if (string.IsNullOrEmpty(ID) || string.IsNullOrWhiteSpace(ID))
            {
                ID = _compComm.NoOrEmptyBookIDString;
            }

            // данные о книге
            BookData fb2BookData = new BookData(
                fb2.TIBookTitle, fb2.TIAuthors, fb2.TIGenres, fb2.TILang, ID, fb2.DIVersion, fb2.DIAuthors, SrcPath, Encoding
                );

            if (ZipPath != null)
            {
                fb2BookData.Path = ZipPath;
            }

            if (!htFB2ForID.ContainsKey(ID))
            {
                // такой книги в числе дублей еще нет
                FB2FilesDataInGroup fb2f = new FB2FilesDataInGroup(fb2BookData, ID);
                htFB2ForID.Add(ID, fb2f);
            }
            else
            {
                // такая книга в числе дублей уже есть
                FB2FilesDataInGroup fb2f = (FB2FilesDataInGroup)htFB2ForID[ID];
                fb2f.Add(fb2BookData);
                //htFB2ForID[sID] = fb2f; //ИЗБЫТОЧНЫЙ КОД
            }
        }
        private Book ToBook(FictionBook fictionBook)
        {
            var title  = fictionBook.Description.TitleInfo.BookTitle.Text;
            var author = fictionBook.Description.TitleInfo.Author[0].Items.Select(x => x.Text).Aggregate((current, next) => current + " " + next);

            var book = new Book
            {
                Id             = Guid.NewGuid(),
                Author         = author,
                Title          = title,
                LastOpenedTime = DateTime.Now,
                IsImported     = true,
                Type           = BookType.FictionBook
            };

            return(book);
        }
Beispiel #20
0
        private void Load([In] XElement root, Fb2LoadingOptions?loadingOptions = null)
        {
            if (root == null)
            {
                throw new ArgumentNullException(nameof(root));
            }

            var options = loadingOptions ?? new Fb2LoadingOptions();

            var loadUnsafeElements     = options.LoadUnsafeElements;
            var loadNamespanceMetadata = options.LoadNamespaceMetadata;

            Book = new FictionBook();
            Book.Load(root, loadUnsafe: loadUnsafeElements, loadNamespaceMetadata: loadNamespanceMetadata);

            IsLoaded = true;
        }
Beispiel #21
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            FB2DescriptionCorrector fB2Corrector = null;

            foreach (FB2ItemInfo Info in m_LangFB2InfoList)
            {
                FictionBook fb2 = Info.FictionBook;
                if (fb2 != null)
                {
                    fB2Corrector = new FB2DescriptionCorrector(fb2);
                    fB2Corrector.recoveryDescriptionNode();

                    XmlNode xmlTI = fb2.getTitleInfoNode(TitleInfoEnum.TitleInfo);
                    if (xmlTI != null)
                    {
                        xmlTI.ReplaceChild(
                            fB2Corrector.makeLangNode(LangComboBox.Text.Substring(LangComboBox.Text.IndexOf('(') + 1, 2)),
                            fb2.getLangNode(TitleInfoEnum.TitleInfo)
                            );

                        // сохранение fb2 файла
                        if (!Directory.Exists(m_TempDir))
                        {
                            Directory.CreateDirectory(m_TempDir);
                        }
                        string NewPath = Info.IsFromZip ? Info.FilePathIfFromZip : Info.FilePathSource;
                        fb2.saveToFB2File(NewPath, false);
                        if (Info.IsFromZip)
                        {
                            WorksWithBooks.zipMoveTempFB2FileTo(m_sharpZipLib, NewPath, Info.FilePathSource);
                        }
                        if (Info.IsFromZip && File.Exists(NewPath))
                        {
                            File.Delete(NewPath);
                        }
                    }
                }
                m_bw.ReportProgress(1);
                ProgressBar.Update();
            }
            Cursor.Current = Cursors.Default;
        }
Beispiel #22
0
        private FictionBook ReadFictionBook(XmlReader reader)
        {
            XmlDocument document = new XmlDocument();

            document.Load(reader);

            FictionBook fictionBook = new FictionBook(document);

            if (fictionBook.DocumentStatus == Fb2FixStatus.Passed)
            {
                return(fictionBook);
            }

            fictionBook.CheckDocumentHeader();

            PostProcessDocument(fictionBook);

            fictionBook.DocumentStatus = Fb2FixStatus.Passed;

            return(fictionBook);
        }
Beispiel #23
0
        private void ProcessElement(FictionBook fictionBook, XmlNode node, List <XmlElement> invalidNodes)
        {
            foreach (XmlNode childNode in node.ChildNodes)
            {
                ProcessElement(fictionBook, childNode, invalidNodes);
            }

            switch (node.NodeType)
            {
            case XmlNodeType.Text:
                string text = node.InnerText;

                text = bullets.Replace(text, new MatchEvaluator(delegate(Match match)
                {
                    fictionBook.ModificationType = ModificationType.Text;
                    return("-");
                }));

                text = invalidChars.Replace(text, new MatchEvaluator(delegate(Match match)
                {
                    fictionBook.ModificationType = ModificationType.Text;
                    return(" ");
                }));

                node.InnerText = text;

                //node.InnerText = invalidChars.Replace(bullets.Replace(node.InnerText, "-"), " ");
                break;

            case XmlNodeType.Element:
                ElementDecl elementDecl = this.fb2Dtd.FindElement(node.LocalName);
                if (elementDecl == null)
                {
                    invalidNodes.Add(node as XmlElement);
                }
                break;
            }
        }
Beispiel #24
0
        void CreateEnvyXml(FictionBook book, ref ISXMLElement pXML)
        {
            EnvyBook sbook  = new EnvyBook(book);
            Books    sBooks = new Books();

            sBooks.books[0] = sbook;

            MemoryStream ms       = null;
            XmlWriter    writer   = null;
            string       finalXml = String.Empty;

            try {
                XmlSerializer s = new XmlSerializer(typeof(Books));
                s.UnknownNode      += new XmlNodeEventHandler(OnUnknownNode);
                s.UnknownAttribute += new XmlAttributeEventHandler(OnUnknownAttribute);

                ms = new MemoryStream();

                UTF8Encoding utf8 = new UTF8Encoding(false, false);
                writer = new XmlTextWriter(ms, utf8);

                XmlSerializerNamespaces xsn = new XmlSerializerNamespaces();
                // Don't add any prefixes
                xsn.Add("xsi", "http://www.w3.org/2001/XMLSchema-instance");
                s.Serialize(writer, sBooks, xsn);

                // Start modifying the resulting XML
                XmlDocument doc = new XmlDocument();
                ms.Position = 0;
                doc.Load(ms);
                XmlAttribute schema = doc.CreateAttribute("xsi", "noNamespaceSchemaLocation",
                                                          "http://www.w3.org/2001/XMLSchema-instance");
                schema.Value = Books.URI;
                doc.DocumentElement.SetAttributeNode(schema);
                // Truncate the serialization result and overwrite it with our modified XML
                ms.SetLength(0);
                ms.Position = 0;
                writer      = new XmlTextWriter(ms, utf8);
                doc.Save(writer);

                char[] buffer = Encoding.UTF8.GetChars(ms.ToArray());
                finalXml = new string(buffer);
            } catch (Exception e) {
                Trace.WriteLine(e.Message);
                Exception inner = e.InnerException;
                while (inner != null)
                {
                    Trace.WriteLine(inner.Message);
                    inner = inner.InnerException;
                }
            } finally {
                if (writer != null)
                {
                    writer.Close();
                }
                if (ms != null)
                {
                    ms.Close();
                }
            }
            if (!String.IsNullOrEmpty(finalXml))
            {
                Trace.WriteLine(finalXml);
                ISXMLElement newXML = pXML.FromString(finalXml);
                if (newXML != null)
                {
                    pXML.Elements.Attach(newXML);
                }
            }
        }
Beispiel #25
0
        private void ProcessDocument(Stream stream, string filename, DateTime lastModifiedTime)
        {
            Encoding    encoding = null;
            FictionBook document = null;

            ApplicationLogger.WriteStringToLog(string.Format("Processing fb2 document '{0}'.", filename));

            try
            {
                using (HtmlStream htmlStream = new HtmlStream(stream, Encoding.Default))
                {
                    encoding = htmlStream.Encoding;
                    document = ReadFictionBook(htmlStream);

                    ChangeDocumentVersion(document);

                    if (document.ModificationType == ModificationType.None)
                    {
                        document.ContainerDateTime = lastModifiedTime;
                    }
                }
            }
            catch (InvalidOperationException)
            {
                throw new Exception("InvalidFictionBookFormatException(exp.Message, exp)");
            }
            catch (XmlException)
            {
                throw new Exception("InvalidFictionBookFormatException(exp.Message, exp)");
            }

            try
            {
                if (encoding == null)
                {
                    throw new Exception("Can't detect a character encoding.");
                }

                long threshold = (long)(document.Document.InnerText.Length * 0.25);

                if (this.preferedCodepage != null)
                {
                    encoding = Encoding.GetEncoding((int)this.preferedCodepage, new EncoderCharEntityFallback(threshold), new DecoderExceptionFallback());
                }
                else if (encoding.IsSingleByte)
                {
                    encoding = Encoding.GetEncoding(encoding.CodePage, new EncoderCharEntityFallback(threshold), new DecoderExceptionFallback());
                }

                bool done       = false;
                int  retryCount = 0;

                do
                {
                    try
                    {
                        if (++retryCount > 2)
                        {
                            break;
                        }

                        if (encoding != null && document != null)
                        {
                            string outputFullPath  = GetFilename(this.outputDirectoryGood, filename, document);
                            string outputDirectory = "Temp";
                            string outputFilename  = Path.GetFileName(outputFullPath).Trim();

                            SaveFictionBook(outputDirectory, outputFilename, document, encoding);
                        }

                        done = true;
                    }
                    catch (EncoderFallbackException)
                    {
                        if (encoding != null)
                        {
                            ApplicationLogger.WriteStringToError(string.Format("Invalid document encoding ({0}) detected, utf-8 is used instead.", encoding.WebName));
                        }

                        encoding = Encoding.UTF8;
                    }
                }while (!done);
            }
            catch (IOException exp)
            {
                ApplicationLogger.WriteStringToError(exp.Message);
                Environment.Exit(1);
            }
            catch (UnauthorizedAccessException exp)
            {
                ApplicationLogger.WriteStringToError(exp.Message);
            }
        }
Beispiel #26
0
        private string GetFilename(string directory, string filename, FictionBook fictionBook)
        {
            filename = filename.ToLowerInvariant();

            return(filename);
        }
Beispiel #27
0
        public void Process(IntPtr hFile, string sFile, ISXMLElement pXML)
        {
            bool success = true;

            try {
                success = (Path.GetExtension(sFile) == @".fb2") && hFile != IntPtr.Zero;
            } catch { }
            if (!success)
            {
                Marshal.ThrowExceptionForHR(Hresults.E_INVALIDARG);
            }

            XmlReader   reader = null;
            FictionBook book   = null;
            Stream      fs     = null;

            try {
                XmlSerializer s = new XmlSerializer(typeof(FictionBook));
                s.UnknownNode      += new XmlNodeEventHandler(OnUnknownNode);
                s.UnknownAttribute += new XmlAttributeEventHandler(OnUnknownAttribute);
                fs     = new FileStream(sFile, FileMode.Open, FileAccess.Read);
                reader = new XmlTextReader(fs);
                book   = (FictionBook)s.Deserialize(reader);
            } catch (Exception e) {
                Trace.WriteLine(e.Message);
                Exception inner = e.InnerException;
                while (inner != null)
                {
                    Trace.WriteLine(inner.Message);
                    inner = inner.InnerException;
                }
            } finally {
                if (reader != null)
                {
                    reader.Close();
                }
                if (fs != null)
                {
                    fs.Close();
                }
            }

            if (book == null)
            {
                Marshal.ThrowExceptionForHR(Hresults.E_FAIL);
            }

            int result = Hresults.S_OK;

            try {
                CreateEnvyXml(book, ref pXML);
            } catch (Exception e) {
                Trace.WriteLine(e.Message);
                Exception inner = e.InnerException;
                while (inner != null)
                {
                    Trace.WriteLine(inner.Message);
                    inner = inner.InnerException;
                }
                result = Marshal.GetHRForException(e);
            }

            if (result != 0)
            {
                Trace.WriteLine("Error HRESULT=" + result.ToString());
                Marshal.ThrowExceptionForHR(result);
            }
        }
Beispiel #28
0
        private void bw_DoWork(object sender, DoWorkEventArgs e)
        {
            Cursor.Current = Cursors.WaitCursor;
            FB2DescriptionCorrector fB2Corrector = null;

            foreach (FB2ItemInfo Info in m_AuthorFB2InfoList)
            {
                FictionBook fb2 = Info.FictionBook;
                if (fb2 != null)
                {
                    // восстанавление раздела description до структуры с необходимыми элементами для валидности
                    fB2Corrector = new FB2DescriptionCorrector(fb2);
                    fB2Corrector.recoveryDescriptionNode();

                    IList <XmlNode> xmlNewAuthors = makeAuthorNode(Enums.AuthorEnum.AuthorOfBook, ref fb2, AuthorsListView);
                    if (xmlNewAuthors != null)
                    {
                        XmlNodeList xmlAuthorList = fb2.getAuthorNodes(TitleInfoEnum.TitleInfo);
                        if (xmlAuthorList != null)
                        {
                            XmlNode xmlBookTitleNode = fb2.getBookTitleNode(TitleInfoEnum.TitleInfo);
                            if (xmlBookTitleNode != null)
                            {
                                XmlNode xmlTINode = fb2.getTitleInfoNode(TitleInfoEnum.TitleInfo);
                                if (xmlTINode != null)
                                {
                                    // удаление старых данных Авторов
                                    foreach (XmlNode Author in xmlAuthorList)
                                    {
                                        xmlTINode.RemoveChild(Author);
                                    }
                                    // добавление новых данных Авторов
                                    foreach (XmlNode Author in xmlNewAuthors)
                                    {
                                        xmlTINode.InsertBefore(Author, xmlBookTitleNode);
                                    }

                                    // сохранение fb2 файла
                                    if (!Directory.Exists(m_TempDir))
                                    {
                                        Directory.CreateDirectory(m_TempDir);
                                    }
                                    string NewPath = Info.IsFromZip ? Info.FilePathIfFromZip : Info.FilePathSource;
                                    fb2.saveToFB2File(NewPath, false);
                                    if (Info.IsFromZip)
                                    {
                                        WorksWithBooks.zipMoveTempFB2FileTo(m_sharpZipLib, NewPath, Info.FilePathSource);
                                    }
                                    if (Info.IsFromZip && File.Exists(NewPath))
                                    {
                                        File.Delete(NewPath);
                                    }
                                }
                            }
                        }
                    }
                }
                m_bw.ReportProgress(1);
                ProgressBar.Update();
            }
            Cursor.Current = Cursors.Default;
        }
Beispiel #29
0
 public static string GetFictionCoverUrl(Mirrors.MirrorConfiguration mirror, FictionBook book)
 {
     return(Replace(mirror.FictionCoverUrl, fictionTransformations, book));
 }
        /// <summary>
        /// Проверка, соответствует ли текущий файл критерия поиска для Избранной Сортировки
        /// </summary>
        /// <param name="sFromFilePath">Рассматриваемый файл на предмет соответствия критериям сортировки</param>
        /// <param name="lSSQCList">Список экземпляров класса  SortQueryCriteria</param>
        /// <param name="IsNotRead">out параметр: true - книга не открывается; false - книгу удалось открыть</param>
        /// <returns>null, если книга не соответствует ни одному критерию поиска; или найденный критерий SelectedSortQueryCriteria</returns>
        public static SortQueryCriteria isConformity(string sFromFilePath, List <SortQueryCriteria> lSSQCList, out bool IsNotRead)
        {
            SortQueryCriteria currentCriteria = null;

            IsNotRead = false;
            FictionBook fb2 = null;
            TitleInfo   ti  = null;

            try {
                fb2 = new FictionBook(sFromFilePath);
                ti  = fb2.getTitleInfo();
                if (ti == null)
                {
                    return(null);
                }
            } catch (Exception ex) {
                Debug.DebugMessage(
                    sFromFilePath, ex, "Сортировщик.SortQueryCriteria: Проверка, соответствует ли текущий файл критерия поиска для Избранной Сортировки."
                    );
                IsNotRead = true;
                return(null);
            }

            LatinToRus latinToRus = new LatinToRus();

            string        sFB2Lang     = ti.Lang;
            BookTitle     FB2BookTitle = ti.BookTitle;
            IList <Genre> lFB2Genres   = ti.Genres;
            // Замена 1-го латинского символа в ФИО Авторов на соответствующий кирилический
            IList <Author>   lFB2Authors = latinToRus.replaceFirstCharLatinToRusForAuthors(ti.Authors);
            IList <Sequence> lFB2Sequences = ti.Sequences;
            string           sLang, sFirstName, sGenre, sMiddleName, sLastName, sNickName, sSequence, sBookTitle;
            bool             bExactFit;
            Regex            re = null;

            foreach (SortQueryCriteria ssqc in lSSQCList)
            {
                sLang       = ssqc.Lang;
                sGenre      = ssqc.Genre;
                sFirstName  = ssqc.FirstName;
                sMiddleName = ssqc.MiddleName;
                sLastName   = ssqc.LastName;
                sNickName   = ssqc.NickName;
                sSequence   = ssqc.Sequence;
                sBookTitle  = ssqc.BookTitle;
                bExactFit   = ssqc.ExactFit;

                /* Проверка условиям критерия */
                // проверка языка книги
                if (!string.IsNullOrWhiteSpace(sFB2Lang))
                {
                    if (!string.IsNullOrWhiteSpace(sLang))
                    {
                        if (sFB2Lang != sLang)
                        {
                            continue;
                        }
                    }
                }
                else
                {
                    // в книге тега языка нет
                    if (!string.IsNullOrWhiteSpace(sLang))
                    {
                        continue;
                    }
                }
                // проверка жанра книги
                bool b = false;
                if (lFB2Genres != null)
                {
                    if (!string.IsNullOrWhiteSpace(sGenre))
                    {
                        foreach (Genre gfb2 in lFB2Genres)
                        {
                            if (!string.IsNullOrWhiteSpace(gfb2.Name))
                            {
                                if (gfb2.Name == sGenre)
                                {
                                    b = true; break;
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                        if (!b)
                        {
                            continue;
                        }
                    }
                }
                else
                {
                    // в книге тега жанра нет
                    if (!string.IsNullOrWhiteSpace(sGenre))
                    {
                        continue;
                    }
                }
                // проверка серии книги
                b = false;
                if (lFB2Sequences != null)
                {
                    if (!string.IsNullOrWhiteSpace(sSequence))
                    {
                        foreach (Sequence sfb2 in lFB2Sequences)
                        {
                            if (!string.IsNullOrWhiteSpace(sfb2.Name))
                            {
                                if (bExactFit)
                                {
                                    // точное соответствие
                                    if (sfb2.Name == sSequence)
                                    {
                                        b = true; break;
                                    }
                                }
                                else
                                {
                                    re = new Regex(sSequence, RegexOptions.IgnoreCase);
                                    try {
                                        if (re.IsMatch(sfb2.Name))
                                        {
                                            b = true; break;
                                        }
                                    } catch (Exception ex) {
                                        Debug.DebugMessage(
                                            sFromFilePath, ex, "Сортировщик.SortQueryCriteria: Проверка серии книги."
                                            );
//										MessageBox.Show("sfb2.Name  \r\n"+e.Message+"\r\n\r\n"+sFromFilePath);
                                    }
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                        if (!b)
                        {
                            continue;
                        }
                    }
                }
                else
                {
                    // в книге тега серии нет
                    if (!string.IsNullOrWhiteSpace(sSequence))
                    {
                        continue;
                    }
                }
                // проверка автора книги
                if (lFB2Authors != null)
                {
                    b = false;
                    if (sFirstName.Length != 0)
                    {
                        foreach (Author afb2 in lFB2Authors)
                        {
                            if (afb2.FirstName != null)
                            {
                                if (bExactFit)
                                {
                                    // точное соответствие
                                    if (afb2.FirstName.Value == sFirstName)
                                    {
                                        b = true; break;
                                    }
                                }
                                else
                                {
                                    re = new Regex(sFirstName, RegexOptions.IgnoreCase);
                                    try {
                                        if (re.IsMatch(afb2.FirstName.Value))
                                        {
                                            b = true; break;
                                        }
                                    } catch (Exception ex) {
                                        Debug.DebugMessage(
                                            sFromFilePath, ex, "Сортировщик.SortQueryCriteria: Проверка автора книги (FirstName)."
                                            );
//										MessageBox.Show("afb2.FirstName.Value \r\n"+e.Message+"\r\n\r\n"+sFromFilePath);
                                    }
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                        if (!b)
                        {
                            continue;
                        }
                    }
                    b = false;
                    if (sMiddleName.Length != 0)
                    {
                        foreach (Author afb2 in lFB2Authors)
                        {
                            if (afb2.MiddleName != null)
                            {
                                if (bExactFit)
                                {
                                    // точное соответствие
                                    if (afb2.MiddleName.Value == sMiddleName)
                                    {
                                        b = true; break;
                                    }
                                }
                                else
                                {
                                    re = new Regex(sMiddleName, RegexOptions.IgnoreCase);
                                    try {
                                        if (re.IsMatch(afb2.MiddleName.Value))
                                        {
                                            b = true; break;
                                        }
                                    } catch (Exception ex) {
                                        Debug.DebugMessage(
                                            sFromFilePath, ex, "Сортировщик.SortQueryCriteria: Проверка автора книги (MiddleName)."
                                            );
//										MessageBox.Show("afb2.MiddleName.Value \r\n"+e.Message+"\r\n\r\n"+sFromFilePath);
                                    }
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                        if (!b)
                        {
                            continue;
                        }
                    }
                    b = false;
                    if (sLastName.Length != 0)
                    {
                        foreach (Author afb2 in lFB2Authors)
                        {
                            if (afb2.LastName != null)
                            {
                                if (bExactFit)
                                {
                                    // точное соответствие
                                    if (afb2.LastName.Value == sLastName)
                                    {
                                        b = true; break;
                                    }
                                }
                                else
                                {
                                    re = new Regex(sLastName, RegexOptions.IgnoreCase);
                                    try {
                                        if (re.IsMatch(afb2.LastName.Value))
                                        {
                                            b = true; break;
                                        }
                                    } catch (Exception ex) {
                                        Debug.DebugMessage(
                                            sFromFilePath, ex, "Сортировщик.SortQueryCriteria: Проверка автора книги (LastName)."
                                            );
//										MessageBox.Show("afb2.LastName.Value \r\n"+e.Message+"\r\n\r\n"+sFromFilePath);
                                    }
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                        if (!b)
                        {
                            continue;
                        }
                    }
                    b = false;
                    if (sNickName.Length != 0)
                    {
                        foreach (Author afb2 in lFB2Authors)
                        {
                            if (afb2.NickName != null)
                            {
                                if (bExactFit)
                                {
                                    // точное соответствие
                                    if (afb2.NickName.Value == sNickName)
                                    {
                                        b = true; break;
                                    }
                                }
                                else
                                {
                                    re = new Regex(sNickName, RegexOptions.IgnoreCase);
                                    try {
                                        if (re.IsMatch(afb2.NickName.Value))
                                        {
                                            b = true; break;
                                        }
                                    } catch (Exception ex) {
                                        Debug.DebugMessage(
                                            sFromFilePath, ex, "Сортировщик.SortQueryCriteria: Проверка автора книги (NickName)."
                                            );
//										MessageBox.Show("afb2.NickName.Value \r\n"+e.Message+"\r\n\r\n"+sFromFilePath);
                                    }
                                }
                            }
                            else
                            {
                                continue;
                            }
                        }
                        if (!b)
                        {
                            continue;
                        }
                    }
                }
                else
                {
                    // в книге тегов автора нет
                    if (!string.IsNullOrWhiteSpace(sFirstName) || !string.IsNullOrWhiteSpace(sMiddleName) ||
                        !string.IsNullOrWhiteSpace(sNickName) || !string.IsNullOrWhiteSpace(sNickName))
                    {
                        continue;
                    }
                }
                // проверка названия книги
                if (FB2BookTitle != null)
                {
                    if (!string.IsNullOrWhiteSpace(sBookTitle))
                    {
                        if (!string.IsNullOrWhiteSpace(FB2BookTitle.Value))
                        {
                            if (bExactFit)
                            {
                                // точное соответствие
                                if (FB2BookTitle.Value != sBookTitle)
                                {
                                    continue;
                                }
                            }
                            else
                            {
                                re = new Regex(sBookTitle, RegexOptions.IgnoreCase);
                                try {
                                    if (!re.IsMatch(FB2BookTitle.Value))
                                    {
                                        continue;
                                    }
                                } catch (Exception ex) {
                                    Debug.DebugMessage(
                                        sFromFilePath, ex, "Сортировщик.SortQueryCriteria: Проверка названия книги."
                                        );
//									MessageBox.Show("FB2BookTitle.Value \r\n"+e.Message+"\r\n\r\n"+sFromFilePath);
                                }
                            }
                        }
                        else
                        {
                            continue;                             // пустой тэг <book-title>
                        }
                    }
                }
                else
                {
                    // в книге тега названия нет
                    if (!string.IsNullOrWhiteSpace(sBookTitle))
                    {
                        continue;
                    }
                }
                currentCriteria = ssqc;
                break;
            }
            return(currentCriteria);
        }