Exemple #1
0
        public void ImportFromExcelFile(string path)
        {
            var excelRepository = new ExcelRepository();

            var data = excelRepository.GetAllDataFrom(path, "DEF.xls", "Sheet1");

            var list = new List<DEF>();

            foreach (DataRow row in data.Rows)
            {
                var def = new DEF();

                foreach (DataColumn column in data.Columns)
                {
                    switch (column.Caption)
                    {
                        case "PRINCÍPIO ATIVO":
                            def.ActivePrinciple = (string)row[column];
                            break;
                        case "PRODUTO":
                            def.Description = (string)row[column];
                            break;
                    }
                }

                list.Add(def);
            }

            var defs = new DEFRepository();

            defs.SaveList(list);
        }
Exemple #2
0
 public static DefModel MapDefModelFrom(DEF def)
 {
     Mapper.CreateMap<DEF, DefModel>();
     var defModel = Mapper.Map<DEF, DefModel>(def);
     defModel.Code = def.Id;
     return defModel;
 }
Exemple #3
0
 private void AddFields(DEF def, Document doc)
 {
     doc.Add(new Field("Id", def.Id.ToString(CultureInfo.InvariantCulture), Field.Store.YES, Field.Index.ANALYZED));
     doc.Add(new Field("Description", def.Description.ToString(CultureInfo.InvariantCulture).ToLower(), Field.Store.YES, Field.Index.ANALYZED));
 }
Exemple #4
0
 public void UpdateIndex(DEF patients)
 {
     UpdateIndex(new List<DEF> { patients });
     Optimize();
 }
Exemple #5
0
        private DEF _mapLuceneDocumentToData(Document doc)
        {
            var def = new DEF
                          {
                              Id = short.Parse(doc.Get("Id")),
                              Description = doc.Get("Description"),
                          };

            return def;
        }
Exemple #6
0
 private void _addToLuceneIndex(DEF def, IndexWriter writer)
 {
     //Não precisa remover o tratamento, pois existem varios tratamentos com o id igual.
     // RemoveIndex(treatment, writer);
     var doc = new Document();
     AddFields(def, doc);
     writer.AddDocument(doc);
 }
Exemple #7
0
 private void RemoveIndex(DEF def, IndexWriter writer)
 {
     var searchQuery = new TermQuery(new Term("Id", def.Id.ToString(CultureInfo.InvariantCulture)));
     writer.DeleteDocuments(searchQuery);
 }