示例#1
0
        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);
        }
示例#2
0
        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);
        }
示例#3
0
        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();
        }