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); }
public static DefModel MapDefModelFrom(DEF def) { Mapper.CreateMap<DEF, DefModel>(); var defModel = Mapper.Map<DEF, DefModel>(def); defModel.Code = def.Id; return defModel; }
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)); }
public void UpdateIndex(DEF patients) { UpdateIndex(new List<DEF> { patients }); Optimize(); }
private DEF _mapLuceneDocumentToData(Document doc) { var def = new DEF { Id = short.Parse(doc.Get("Id")), Description = doc.Get("Description"), }; return def; }
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); }
private void RemoveIndex(DEF def, IndexWriter writer) { var searchQuery = new TermQuery(new Term("Id", def.Id.ToString(CultureInfo.InvariantCulture))); writer.DeleteDocuments(searchQuery); }