コード例 #1
0
        private void bgwImportDictionary_DoWork(object sender, DoWorkEventArgs e)
        {
            db.EnableFastInsertMode();
            db.OpenChangeSet();
            int      count = 0, errAlreadyShownCount = 0;
            Importer importer = new DictCcImporter(openFileDialog.FileName);

            foreach (Lemma l in importer.Items())
            {
                if (l is Noun)
                {
                    nounRepo.Add((Noun)l);
                }
                if (l is Preposition)
                {
                    prepRepo.Add((Preposition)l);
                }
                ++count;
                if (count % 10000 == 0)
                {
                    db.CommitChangeSet();
                    db.OpenChangeSet();
                    bgwImportDictionary.ReportProgress(importer.ProgressPercentage,
                                                       importer.ImportErrors.GetRange(errAlreadyShownCount, importer.ImportErrors.Count - errAlreadyShownCount));
                    errAlreadyShownCount = importer.ImportErrors.Count;
                }
            }
            db.CommitChangeSet();
            bgwImportDictionary.ReportProgress(100);

            importer.Close();
        }
コード例 #2
0
 public void Add(Noun entity)
 {
     _repository.Add(entity);
 }