예제 #1
0
 public Livre(string titre, string pATH, char lecteur)
 {
     Titre = titre;
     PATH  = getTruePath(pATH, lecteur);
     Hash  = Hachage.FileToHashMD5(PATH);
     //Hash = Hachage.StringToHashMD5(PATH);
 }
예제 #2
0
        public bool BookKobo(string targetPath)
        {
            bool flag = true;
            // Manuel Kobo
            string   sourceFileKobo = Path.Combine(sourcePath, bookKobo), hash, id_livre, id_collect, id_editeur, id_auteur;
            FileInfo fileInfo = new FileInfo(sourceFileKobo);

            fileInfo.CopyTo(targetPath + "\\" + bookKobo);
            string destiFinal = targetPath + "\\" + bookKobo;

            hash = Hachage.FileToHashMD5(destiFinal);

            id_livre   = ClassAjout.MakeID(new Random(), "L");
            id_collect = ClassAjout.MakeID(new Random(), "C");
            id_editeur = ClassAjout.MakeID(new Random(), "A");
            id_auteur  = ClassAjout.MakeID(new Random(), "E");

            Database.Requete("INSERT INTO AUTEUR (id_auteur, nom_auteur, prenom_auteur) VALUES ('" + id_auteur + "', 'Rakuten Kobo', 'Rakuten Kobo')");
            Database.Requete("INSERT INTO LIVRE (id_livre, titre, nbpages, evaluation, datepubli, chemin_livre, description, avancement, langue, hash, id_genre, id_tomes, id_serie) VALUES ('" + id_livre + "', 'Manuel d''utilisation de Kobo Aura 2ème édition', 62, 0, '01/09/2019', '\\Manuel utilisation Kobo.epub', 'Manuel Kobo utilisateur', 0, 'fr', '" + hash + "', 44, null, null)");
            Database.Requete("INSERT INTO COLLECT (id_collect, nom_collect) VALUES ('" + id_collect + "', 'Manuel Kobo')");
            Database.Requete("INSERT INTO EDITEUR (id_editeur, nom_editeur) VALUES ('" + id_editeur + "', 'Rakuten Kobo Inc')");
            Database.Requete("INSERT INTO EDITER_LIVRE (id_editeur, id_livre, id_collect, ISBN, pays) VALUES ('" + id_editeur + "', '" + id_livre + "', '" + id_collect + "', '5215220101221', 'France')");
            Database.Requete("INSERT INTO A_ECRIT (id_livre, id_auteur) VALUES ('" + id_livre + "', '" + id_auteur + "')");

            return(flag);
        }
예제 #3
0
        public void BookNotice(string targetPath)
        {
            // Notice NumeriBook
            string   sourceFileNotice = Path.Combine(sourcePath, bookNotice), hash, id_livre, id_collect, id_editeur, id_auteur;
            FileInfo fileInfo = new FileInfo(sourceFileNotice);

            fileInfo.CopyTo(targetPath + "\\" + bookNotice);
            string destiFinal = targetPath + "\\" + bookNotice;

            hash = Hachage.FileToHashMD5(destiFinal);

            id_livre   = ClassAjout.MakeID(new Random(), "L");
            id_collect = ClassAjout.MakeID(new Random(), "C");
            id_editeur = ClassAjout.MakeID(new Random(), "A");
            id_auteur  = ClassAjout.MakeID(new Random(), "E");

            Database.Requete("INSERT INTO AUTEUR (id_auteur, nom_auteur, prenom_auteur) VALUES ('" + id_auteur + "', 'BTS SIO 2019', 'BTS SIO 2019')");
            Database.Requete("INSERT INTO LIVRE (id_livre, titre, nbpages, evaluation, datepubli, chemin_livre, description, avancement, langue, hash, id_genre, id_tomes, id_serie) VALUES ('" + id_livre + "', 'Notice d''utilisation NumeriBooK', 3, 0, '28/11/2019', '\\Notice utilisation Numeribook.epub', 'Quelle est la différence entre Windows Me et un virus  Le virus il fonctionne', 0, 'fr', '" + hash + "', 44, null, null)");
            Database.Requete("INSERT INTO COLLECT (id_collect, nom_collect) VALUES ('" + id_collect + "', 'Notice NumeriBook')");
            Database.Requete("INSERT INTO EDITEUR (id_editeur, nom_editeur) VALUES ('" + id_editeur + "', 'PPE NumeriBook')");
            Database.Requete("INSERT INTO EDITER_LIVRE (id_editeur, id_livre, id_collect, ISBN, pays) VALUES ('" + id_editeur + "', '" + id_livre + "', '" + id_collect + "', '67e0423a-de53-4903-b614-abc0b8ad97f9', 'France')");
            Database.Requete("INSERT INTO A_ECRIT (id_livre, id_auteur) VALUES ('" + id_livre + "', '" + id_auteur + "')");
            ExceptionHandler.Message("Les deux livres par défaut sont dans la base SQLite...");
        }
예제 #4
0
        public static void AjoutEpub(string PATH, string FileName, Bibliotheque biblio)
        {
            string           chemin = "\\" + FileName, id_livre = "", id_auteur = "", id_collect = "", id_editeur = "";
            Random           rng = new Random();
            SQLiteDataReader sqldr;

            try
            {
                ClassEpubRead epubRead = new ClassEpubRead(PATH);

                string hash = Hachage.FileToHashMD5(PATH);
                sqldr = biblio.Database.Extraction("SELECT id_livre FROM LIVRE WHERE hash LIKE '" + hash + "'");

                sqldr.Read();
                if (!sqldr.IsDBNull(0))
                {
                    //MessageBox.Show("Erreur le livre existe déjà dans la base " + sqldr[0].ToString(), "Erreur Ajout", MessageBoxButtons.OK, MessageBoxIcon.Error);
                }
                else
                {
                    id_livre = MakeID(rng, "L" + hash.Substring(0, 10));


                    //Détermination de l'id
                    //Détermination des auteurs
                    //MessageBox.Show(epubRead.auteur_prenom);
                    sqldr = biblio.Database.Extraction("SELECT id_auteur FROM auteur WHERE nom_auteur LIKE '" + epubRead.auteur + "'");
                    sqldr.Read();
                    if (!sqldr.IsDBNull(0))
                    {
                        id_auteur = (string)sqldr[0];
                    }
                    else
                    {
                        id_auteur = MakeID(rng, "A" + hash.Substring(0, 10));
                        biblio.Database.Requete("INSERT INTO AUTEUR (id_auteur, nom_auteur, prenom_auteur) VALUES ('" + id_auteur + "', '" + epubRead.auteur + "', ' ')");
                    }
                    //Determine si le livre existe déjà

                    // determine la collection
                    sqldr = biblio.Database.Extraction("SELECT id_collect, nom_collect FROM COLLECT WHERE nom_collect LIKE '" + epubRead.titre.Replace('\'', ' ') + "'");
                    sqldr.Read();
                    if (!sqldr.IsDBNull(0))
                    {
                        id_collect = (string)sqldr[0];
                    }
                    else
                    {
                        id_collect = MakeID(rng, "C" + hash.Substring(0, 10));
                        biblio.Database.Requete("INSERT INTO COLLECT (id_collect, nom_collect) VALUES ('" + id_collect + "', '" + epubRead.titre.Replace('\'', ' ') + "')");
                    }

                    //Determination de l'editeur
                    sqldr = biblio.Database.Extraction("SELECT id_editeur FROM EDITEUR WHERE nom_editeur LIKE '" + epubRead.editeur.Replace('\'', ' ') + "'");
                    sqldr.Read();
                    if (!sqldr.IsDBNull(0))
                    {
                        id_editeur = (string)sqldr[0];
                    }
                    else
                    {
                        id_editeur = MakeID(rng, "E" + hash.Substring(0, 10));
                        biblio.Database.Requete("INSERT INTO EDITEUR (id_editeur, nom_editeur) VALUES ('" + id_editeur + "', '" + epubRead.editeur.Replace('\'', ' ') + "')");
                    }

                    if (epubRead.date == null)
                    {
                        if (epubRead.descri == null)
                        {
                            biblio.Database.Requete("INSERT INTO LIVRE (id_livre, titre, nbpages, evaluation, datepubli, chemin_livre, description, avancement, langue, hash, id_genre, id_tomes, id_serie) VALUES ('" + id_livre + "', '" + epubRead.titre.Replace('\'', ' ') + "', 100, 0, 11111, '" + chemin + "', 'Pas de descri', 0, 'fr', '" + hash + "', 0, null, null )");
                        }
                        else
                        {
                            biblio.Database.Requete("INSERT INTO LIVRE (id_livre, titre, nbpages, evaluation, datepubli, chemin_livre, description, avancement, langue, hash, id_genre, id_tomes, id_serie) VALUES ('" + id_livre + "', '" + epubRead.titre.Replace('\'', ' ') + "', 100, 0, 11111, '" + chemin + "', '" + epubRead.descri.Replace('\'', ' ') + "', 0, 'fr', '" + hash + "', 0, null, null )");
                        }
                    }
                    else
                    {
                        if (epubRead.descri == null)
                        {
                            biblio.Database.Requete("INSERT INTO LIVRE (id_livre, titre, nbpages, evaluation, datepubli, chemin_livre, description, avancement, langue, hash, id_genre, id_tomes, id_serie) VALUES ('" + id_livre + "', '" + epubRead.titre.Replace('\'', ' ') + "', 100, 0,'" + epubRead.date.Replace('\'', ' ') + "', '" + chemin + "', 'Pas de descri', 0, 'fr', '" + hash + "', 0, null, null )");
                        }
                        else
                        {
                            biblio.Database.Requete("INSERT INTO LIVRE (id_livre, titre, nbpages, evaluation, datepubli, chemin_livre, description, avancement, langue, hash, id_genre, id_tomes, id_serie) VALUES ('" + id_livre + "', '" + epubRead.titre.Replace('\'', ' ') + "', 100, 0,'" + epubRead.date.Replace('\'', ' ') + "', '" + chemin + "', '" + epubRead.descri.Replace("'", "''") + "', 0, 'fr', '" + hash + "', 0, null, null )");
                        }
                    }

                    //MessageBox.Show(epubRead.date);
                    //MessageBox.Show("DESC " + epubRead.descri);

                    //Détermination des genres
                    //ExceptionHandler.Message("INSERT INTO LIVRE (id_livre, titre, nbpages, evaluation, datepubli, chemin_livre, description, avancement, langue, hash, id_genre, id_tomes, id_serie) VALUES ('" + id_livre + "', '" + epubRead.titre.Replace('\'', ' ') + "', 100, 0, '" + epubRead.date.Replace('\'', ' ') + "', '" + chemin + "', '" + epubRead.descri.Replace('\'', ' ') + "', 0, 'fr', '" + hash + "', 0, null, null )");
                    // revoir la requete

                    //Ajout dans la base
                    //biblio.Database.Requete("INSERT INTO LIVRE (id_livre, titre, nbpages, evaluation, datepubli, chemin_livre, description, avancement, langue, hash, id_genre, id_tomes, id_serie) VALUES ('" + id_livre + "', '" + epubRead.titre.Replace('\'', ' ') + "', 100, 0, '" + epubRead.date.Replace('\'', ' ') + "', '" + chemin + "', @'" + epubRead.descri.Replace('\'', ' ') + "', 0, 'fr', '" + hash + "', 0, null, null )");

                    biblio.Database.Requete("INSERT INTO EDITER_LIVRE (id_editeur, id_livre, id_collect, ISBN, pays) VALUES ('" + id_editeur + "', '" + id_livre + "', '" + id_collect + "', '" + epubRead.isbn + "', 'France')");
                    biblio.Database.Requete("INSERT INTO A_ECRIT (id_livre, id_auteur) VALUES ('" + id_livre + "', '" + id_auteur + "')");
                    File.Copy(PATH, biblio.CurrentPath + "\\" + FileName);
                }
            }
            catch (Exception exc)
            {
                ExceptionHandler.ExeptionCatch(exc);
                ExceptionHandler.Message(id_editeur + ", '" + id_livre + "', '" + id_collect + "', '" + id_auteur);
            }
        }