Example #1
0
        public void Parse(string fileName)
        {
            using (StreamReader reader = new StreamReader(fileName))
            {
                int dbgLimiter = 0;

                string firstLine = reader.ReadLine();
                ColumnHeaders ch = new ColumnHeaders(firstLine);

                while (!reader.EndOfStream)
                {
                    //if (dbgLimiter > 900) break;
                    dbgLimiter++;

                    string line = reader.ReadLine();

                    Columns cm = new Columns(line);

                    AromaSet set;

                    Aroma newAroma = new Aroma(line);
                    AllAromas.Add(newAroma.Id, newAroma);

                    if (!AllAromaSets.ContainsKey(newAroma.BareTitleEng))
                    {
                        set = new AromaSet();
                        set.Add(newAroma);
                        AllAromaSets.Add(set.TitleEng, set);
                    }
                    else
                    {
                        set = AllAromaSets[newAroma.BareTitleEng];
                        set.Add(newAroma);
                    }
                }
            }

            XmlCatalogParser xmlParser = new XmlCatalogParser();
            xmlParser.SetQuantities(AllAromas);

            int adCounter = 0;
            using (StreamWriter writer = new StreamWriter("ads.txt"))
            {
                ColumnHeaders.WriteHeaderToOutput(writer);

                foreach (KeyValuePair<string, AromaSet> p in AllAromaSets)
                {
                    p.Value.BuildAds(ref adCounter, writer);
                }
            }

            Logger.Close();
        }
Example #2
0
        public void Add(Aroma aroma)
        {
            if (_allDict.Count == 0)
            {
                TitleEng = aroma.BareTitleEng;
                TitleRus = aroma.BareTitleRus;
            }

            if (aroma.BareTitleEng == this.TitleEng)
                _allList.Add(aroma);
            else
                Logger.Log("Добавляем не в ту группу ароматов: Aroma=" + aroma.BareTitleEng + ",  AromaSet="+TitleEng);
        }