Example #1
0
 /// <summary>
 /// Renvoie la liste d'animes de la base de données
 /// </summary>
 /// <param name="dbFile">le fichier de base de données</param>
 /// <returns>Une instance de AnimeModel avec tous les animes de la base de données</returns>
 private static AnimeModel getAll(string dbFile)
 {
     try
     {
         SQLiteConnection cnx;
         SQLiteCommand    cmd;
         SQLiteDataReader reader;
         AnimeModel       all = new AnimeModel();
         all.file = dbFile;
         cnx      = new SQLiteConnection("Data Source=" + dbFile + "; Version=3");
         string sqlStmnt = "SELECT a.name, a.season, a.studio, r.fansubs, a.year, r.episodes, r.language, r.sub, a.synopsis, a.type, r.path FROM anime AS a JOIN release AS r ON a.name = r.name AND a.season = r.season";
         cnx.Open();
         cmd    = new SQLiteCommand(sqlStmnt, cnx);
         reader = cmd.ExecuteReader();
         while (reader.Read())
         {
             all.Add(new Anime(reader.GetString(0), reader.GetString(1), reader.GetString(2), reader.GetString(3), reader.GetInt32(4), reader.GetInt32(5), reader.GetString(6), reader.GetString(7), reader.GetString(8), reader.GetString(9), reader.GetString(10)));
         }
         reader.Close();
         cnx.Close();
         if (all.Count == 0)
         {
             all.Add((new AnimeModel()).FAKE_ANIME);
         }
         //MessageBox.Show(all.Count.ToString());
         return(all);
     }
     catch (Exception e)
     {
         Helper.ShowError(e);
         return(null);
     }
 }
Example #2
0
 public void initialisationP2()
 {
     pathStart          = getPathFromConfigFile();
     appDataErrorFolder = getErrorFolder();
     animes             = AnimeModel.getInstance(pathStart);
     loadDgrid();
     loadCboxes();
 }
Example #3
0
 private void Window_Closing(object sender, System.ComponentModel.CancelEventArgs e)
 {
     main.IsEnabled = true;
     if (main.animes[0].Equals(main.animes.FAKE_ANIME))
     {
         main.animes = AnimeModel.getInstance("");
     }
     main.loadDgrid();
     main.loadCboxes();
 }
Example #4
0
 public static void fill(DataGrid table, AnimeModel model)
 {
     table.AutoGenerateColumns = true;
     table.ItemsSource         = (from tab in model.AsStringArraysList()
                                  select new
     {
         Nom = tab[0],
         Saison = tab[1],
         Année = tab[5],
         Langue = tab[7],
         Sous__Titres = tab[8],
         Episodes = tab[6]
     });
 }
Example #5
0
        public static void fill(ComboBox cbox, int kind, AnimeModel model, bool emptyRow)
        {
            if (kind < PROP_TYPE || kind > PROP_SUB)
            {
                return;
            }
            List <string> l = new List <string>();

            if (kind == PROP_TYPE)
            {
                foreach (Anime a in model)
                {
                    foreach (string type in a.Type.Split(';'))
                    {
                        if (!l.Contains(type))
                        {
                            l.Add(type.Trim());
                        }
                    }
                }
            }
            if (kind == PROP_LANG)
            {
                foreach (Anime a in model)
                {
                    if (!l.Contains(a.Language))
                    {
                        l.Add(a.Language);
                    }
                }
            }
            if (kind == PROP_SUB)
            {
                foreach (Anime a in model)
                {
                    if (!l.Contains(a.Sub))
                    {
                        l.Add(a.Sub);
                    }
                }
            }
            cbox.ItemsSource = l;
            if (emptyRow)
            {
                l.Add("");
            }
        }
Example #6
0
        public Anime getByPrimary(string name, string season, string lang, string sub)
        {
            Anime      a        = new Anime(name, season, "", "", 0, 0, lang, sub, "", "", "");
            AnimeModel filtered = new AnimeModel();

            foreach (Anime b in this)
            {
                if (b.Name.Contains(a.Name) &&
                    b.Type.Contains(a.Type) &&
                    b.Language.Contains(a.Language) &&
                    b.Sub.Contains(a.Sub))
                {
                    return(b);
                }
            }
            return(FAKE_ANIME);
        }
Example #7
0
        /// <summary>
        /// Récuperation de toutes les données de la base de données. Si il n'existe pas de bases de données, elle sera créée.
        /// </summary>
        /// <param name="dbFolder">Le dossier de création de la base de données</param>
        /// <returns>Une liste d'animes</returns>
        public static AnimeModel getInstance(string dbFolder)
        {
            if (dbFolder == "")
            {
                AnimeModel a = new AnimeModel();
                a.Add(a.FAKE_ANIME);
                return(a);
            }
            string dbPath = Path.Combine(dbFolder, DB_FILE);

            if (!File.Exists(dbPath))
            {
                createDB(dbPath);
                // TODO : Verifier si on peut ecrire dans le dossier courant, si oui, db file = anime.sqlite sinon le appdata
                //        Faire la verification pour savoir si les fhichiers sont les memes
                //        Copier dans appdata si n'existe pas. Utiliser le local en priorite
            }
            return(getAll(dbPath));
        }
Example #8
0
        public AnimeModel get(Anime a)
        {
            AnimeModel filtered = new AnimeModel();

            foreach (Anime b in this)
            {
                if (b.Name.Contains(a.Name) && a.Name.Length != 0 ||
                    b.Type.Contains(a.Type) && a.Type.Length != 0 ||
                    b.Language.Contains(a.Language) && a.Language.Length != 0 ||
                    b.Sub.Contains(a.Sub) && a.Sub.Length != 0 ||
                    a.Name.Length == 0 && a.Type.Length == 0 && a.Language.Length == 0 && a.Sub.Length == 0)
                {
                    filtered.Add(b);
                    //MessageBox.Show(b.toString());
                }
            }
            if (filtered.Count == 0)
            {
                filtered.Add(FAKE_ANIME);
            }
            //MessageBox.Show(filtered.Count.ToString());
            return(filtered);
        }