public static LuceneAction ToModel(this indexingQueue item) { var action = new LuceneAction { type = (LuceneIndexType)item.type, subdomainName = item.MASTERsubdomain.name, deleteOnly = item.deleteOnly, itemKey = item.itemKey }; switch (action.type) { case LuceneIndexType.CONTACTS: action.data = BaseQueueItem.Deserialize <ContactItem>(item.serializedItem); break; case LuceneIndexType.PRODUCTS: action.data = BaseQueueItem.Deserialize <ProductItem>(item.serializedItem); break; case LuceneIndexType.TRANSACTION: action.data = BaseQueueItem.Deserialize <TransactionItem>(item.serializedItem); break; default: throw new ArgumentOutOfRangeException(); } return(action); }
private LuceneAction GetLuceneAction(LuceneIndexType type, dynamic data, bool deleteOnly, long itemKey) { var action = new LuceneAction { type = type, subdomainName = subdomain.name, deleteOnly = deleteOnly, itemKey = itemKey }; if (data == null) { action.data = BaseQueueItem.Serialize(new BaseQueueItem(itemKey.ToString(), type)); } else { switch (type) { case LuceneIndexType.CONTACTS: action.data = new ContactItem(data); break; case LuceneIndexType.PRODUCTS: action.data = new ProductItem(data); break; case LuceneIndexType.TRANSACTION: action.data = new TransactionItem(data); break; default: throw new ArgumentOutOfRangeException("type"); } } return(action); }
private void AddActionToQueue(LuceneAction action) { XElement serialized; switch (action.type) { case LuceneIndexType.CONTACTS: serialized = BaseQueueItem.Serialize <ContactItem>(action.data); break; case LuceneIndexType.PRODUCTS: serialized = BaseQueueItem.Serialize <ProductItem>(action.data); break; case LuceneIndexType.TRANSACTION: serialized = BaseQueueItem.Serialize <TransactionItem>(action.data); break; default: throw new ArgumentOutOfRangeException("type"); } repository.AddActionToIndexingQueue(action.type, serialized, long.Parse(subdomain.id), action.deleteOnly, action.itemKey); repository.Save(); }