//Map Button kV to Data-Transfer-Object (DTO) with logic. public CardCriterion CriteriaMaker() { //Where key=(hardcoded)"ButtonName", Value=Button.CardEdition var cardCriterion = new CardCriterion(); foreach (KeyValuePair <string, object> entry in _dict) { if (entry.Key.Equals("cbTerritory")) { cardCriterion.Territory = ((string)entry.Value == "Все") ? "" : entry.Value.ToString(); //Button.CardEdition } if (entry.Key.Equals("cbKindNpa")) { cardCriterion.CardKind = ((string)entry.Value == "Все") ? "" : entry.Value.ToString(); //Ternary without else } if (entry.Key.Equals("cbAdoptionKindSubject")) { cardCriterion.CardAdoptionKindSubject = ((string)entry.Value == "Все") ? "" : entry.Value.ToString(); } if (entry.Key.Equals("cbAdoptionSubject")) { cardCriterion.CardAdoptionSubject = ((string)entry.Value == "Все") ? "" : entry.Value.ToString(); } if (entry.Key.Equals("tbFindAll")) //[tbFindAll, { //_cardCriterion.CardName = ((string) entry.Value == "Все") ? "" : entry.Value.ToString();SHIT! cardCriterion.FindAll = ((string)entry.Value == "Все") ? "" : entry.Value.ToString(); } if (entry.Key.Equals("tbCardAdoptionNumber")) //[tbFindAll, { //_cardCriterion.CardName = ((string) entry.Value == "Все") ? "" : entry.Value.ToString();SHIT! cardCriterion.CardAdoptionNumber = ((string)entry.Value == "Все") ? "" : entry.Value.ToString(); } //if (entry.Key.Equals("tbCardEdition")) //{ // _cardCriterion.CardEdition = ((string) entry.Value == "Все") // ? "" // : entry.Value.ToString(); //} if (entry.Key.Equals("dtpMin")) { //_cardCriterion.CardAdoptionDateMin = (DateTime) entry.Value;//dont work? cardCriterion.CardAdoptionDateMin = (DateTime)entry.Value; } if (entry.Key.Equals("dtpMax")) { cardCriterion.CardAdoptionDateMax = (DateTime)entry.Value; } } return(cardCriterion); }
private static void _addToLuceneIndex(CardCriterion cardCriterion, IndexWriter writer) { //Add Tikafields from CardCriteriaRepository maybe here later to avoid RAM-haevy traffic? // remove older index entry TermQuery searchQuery = new TermQuery(new Term("EditionId", Convert.ToString(cardCriterion.EditionId))); writer.DeleteDocuments(searchQuery); // add new index entry Document doc = new Document(); // add lucene fields mapped to db fields doc.Add(new Field("EditionId", Convert.ToString(cardCriterion.EditionId), Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field("CardId", Convert.ToString(cardCriterion.CardId), Field.Store.YES, Field.Index.NOT_ANALYZED)); //doc.Add(new NumericField("CardId").SetIntValue(cardCriterion.CardId)); doc.Add(new Field("CardName", cardCriterion.CardName, Field.Store.YES, Field.Index.ANALYZED)); //doc.Add(new Field("CardName", cardCriterion.CardName, Field.Store.NO, // Field.Index.ANALYZED)); doc.Add(new Field("CardKind", cardCriterion.CardKind, Field.Store.YES, Field.Index.NOT_ANALYZED)); //Changed from analyzed doc.Add(new Field("FileExt", cardCriterion.FileExt, Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field("CardEdition", cardCriterion.CardEdition, Field.Store.YES, Field.Index.ANALYZED)); doc.Add(new Field("CardAdoptionKindSubject", cardCriterion.CardAdoptionKindSubject, Field.Store.YES, Field.Index.NOT_ANALYZED)); //Changed from analyzed doc.Add(new Field("CardAdoptionSubject", cardCriterion.CardAdoptionSubject, Field.Store.YES, Field.Index.NOT_ANALYZED)); //Changed from analyzed doc.Add(new Field("Territory", cardCriterion.Territory, Field.Store.YES, Field.Index.NOT_ANALYZED)); //doc.Add(new Field("CardEdition", cardCriterion.CardEdition, Field.Store.NO, // Field.Index.ANALYZED)); doc.Add(new Field("CardAdoptionNumber", cardCriterion.CardAdoptionNumber, Field.Store.YES, Field.Index.NOT_ANALYZED)); doc.Add(new Field("CardAdoptionDate", DateTools.DateToString(cardCriterion.CardAdoptionDate, DateTools.Resolution.DAY), Field.Store.YES, Field.Index.NOT_ANALYZED)); #region Index Metadata //doc.Add(new Field("ContentType", cardCriterion.ContentType, Field.Store.YES, // Field.Index.ANALYZED)); No need to index contentype so far //foreach (var kvp in cardCriterion.ContentMetadataDict) //{ // doc.Add(new Field(kvp.Key, kvp.Value, Field.Store.YES, Field.Index.NOT_ANALYZED)); //} //Add later if metadata indexing is needed #endregion // add entry to index writer.AddDocument(doc); }
private static CardCriterion _extractRowToCriterion(IDataRecord record) { CardCriterion criterion = new CardCriterion(); var textExtractionResult = new TextExtractor().Extract((byte[])record[5]); criterion.EditionId = Convert.ToUInt32(record[0]); criterion.CardId = Convert.ToUInt32(record[1]); criterion.Territory = Convert.ToString(record[2]); criterion.CardKind = Convert.ToString(record[3]); criterion.CardName = Convert.ToString(record[4]); criterion.CardEdition = textExtractionResult.Text; criterion.ContentMetadataDict = textExtractionResult.Metadata; criterion.FileExt = Convert.ToString(record[6]); criterion.CardAdoptionKindSubject = Convert.ToString(record[7]); criterion.CardAdoptionSubject = Convert.ToString(record[8]); criterion.CardAdoptionDate = Convert.ToDateTime(record[9]); criterion.CardAdoptionNumber = Convert.ToString(record[10]); return(criterion); }
// add/update/clear search index data public static void AddUpdateLuceneIndex(CardCriterion cardCriterion) { AddUpdateLuceneIndex(new List <CardCriterion> { cardCriterion }); }