Exemplo n.º 1
0
        public void ConvertBase(string inPath, string outIngredientsPath, string outCategoriesPath)
        {
            FileInfo existingFile = new FileInfo(inPath);

            ListeCategories  categories  = new ListeCategories();
            ListeIngredients ingredients = new ListeIngredients();

            int indexCategorie = 1, indexIngredient = 1;

            Categorie currentCat = null;

            using (StreamWriter databaseFileXML = new StreamWriter(outIngredientsPath))
            {
                using (ExcelPackage package = new ExcelPackage(existingFile))
                {
                    for (int worksheetIndex = 1; worksheetIndex <= 8; worksheetIndex++)
                    {
                        ExcelWorksheet worksheet = package.Workbook.Worksheets[worksheetIndex];

                        Scan(worksheet, 1, databaseFileXML, ref currentCat, ingredients, categories, ref indexCategorie, ref indexIngredient);
                        Scan(worksheet, 3, databaseFileXML, ref currentCat, ingredients, categories, ref indexCategorie, ref indexIngredient);
                    }
                }
            }

            XMLPersistIngredients IngredientsXMLPersister = new XMLPersistIngredients();

            IngredientsXMLPersister.Save(ingredients, outIngredientsPath);

            XMLPersistCategories categoriesXMLPersister = new XMLPersistCategories();

            categoriesXMLPersister.Save(categories, outCategoriesPath);
        }
Exemplo n.º 2
0
        public void ChargerBase(string inIngredientsPath)
        {
            ListeIngredients      ingredients             = new ListeIngredients();
            XMLPersistIngredients IngredientsXMLPersister = new XMLPersistIngredients();

            IngredientsBase       = IngredientsXMLPersister.Load(ingredients, inIngredientsPath).Ingredients.OrderBy(x => x.Nom).ToList();
            IngredientsBaseFiltre = IngredientsBase;
        }