Ejemplo n.º 1
0
        /// <summary>
        /// Initialise la base de données à partir du fichier init.csv
        /// </summary>
        public void Process(string filenameCsv)
        {
            //Read the contents of CSV file.
            string csvData = File.ReadAllText($@"Resources\Input\{filenameCsv}");

            //Execute a loop over the rows.
            foreach (string row in csvData.Split("\r\n"))
            {
                if (!string.IsNullOrEmpty(row))
                {
                    int    index     = row.IndexOf(';');
                    string inputItem = row.Substring(0, index);
                    string inputTags = row.Substring(index + 1);

                    // Vérification de l'existance de l'item
                    var item = ludothequeDao.GetForCreate(inputItem);

                    if (item == null)
                    {
                        // Nouvel item -> On crée de 0
                        Insert(inputItem, inputTags);
                    }
                }
            }
        }