コード例 #1
0
        public PropertyDetail FindByIgdId(string county, string igdId)
        {
            try
            {
                if (string.IsNullOrEmpty(county) || string.IsNullOrEmpty(igdId))
                {
                    throw new ArgumentNullException(igdId);
                }

                var collectionName = county.ToLower() + _current;
                IMongoCollection <PropertyDetail> collection = CollectionProvider.GetCollection <PropertyDetail>(_database, collectionName);

                var filter = Builders <PropertyDetail> .Filter.Eq("igdid", igdId.ToUpper());

                string query = filter.ToString();
                var    json  = filter.RenderToBsonDocument().ToJson();

                var doc = collection.Find <PropertyDetail>(filter).FirstOrDefault();

                return(doc ?? null);
            }
            catch (Exception ex)
            {
                throw new RepositoryException(ex.Message, ex);
            }
        }
コード例 #2
0
        public void TypeOfProviderRandom()
        {
            CollectionProvider <int> provider = new CollectionProvider <int>(TestIEnumarableInt(), ProviderType.Random);

            Assert.Equal(typeof(int), provider.TType);
            Assert.Equal(ProviderType.Random, provider.Type);
        }
コード例 #3
0
        public void TypeOfProviderSequential()
        {
            CollectionProvider <int> provider = new CollectionProvider <int>(TestIEnumarableInt());

            Assert.Equal(typeof(int), provider.TType);
            Assert.Equal(ProviderType.Sequential, provider.Type);
        }
コード例 #4
0
        public void ConstructorWithIntegerRandom()
        {
            var collection = TestIEnumarableInt();

            CollectionProvider <int> provider = new CollectionProvider <int>(collection, ProviderType.Random);

            Assert.Contains(provider.Current, collection);
        }
コード例 #5
0
        public void ConstructorWithIntegerRandomHashCode()
        {
            var collection = TestIEnumarableInt();

            CollectionProvider <int> provider = new CollectionProvider <int>(collection, ProviderType.Random);

            Assert.NotEqual(collection.GetHashCode(), provider.Collection.GetHashCode());
        }
コード例 #6
0
        public void UpdateCollectionProvider(object sender = null)
        {
            StatusBarViewModel.Instance.ProcStatus = "Loading Indexing File .....";
            collectionProvider = new CollectionProvider(settingsVM.CollectionPath, sender);
            StatusBarViewModel.Instance.ProcStatus = "Finish Loading Indexing File";

            relevantProvider = new SimpleRelevantProvider(collectionProvider);
        }
コード例 #7
0
        public void ConstructorWithSequentialSameHashCode()
        {
            var collection = TestIEnumarableInt();

            CollectionProvider <int> provider = new CollectionProvider <int>(collection);

            Assert.Equal(collection.GetHashCode(), provider.Collection.GetHashCode());
        }
コード例 #8
0
ファイル: Mapping.cs プロジェクト: lyzerk/DataSuit
        public IMapping Collection <P>(string field, IEnumerable <P> collection, ProviderType type = ProviderType.Sequential)
        {
            CollectionProvider <P> provider = new CollectionProvider <P>(collection, type);

            listOfFields.Add(field, provider);

            return(this);
        }
コード例 #9
0
        public SearchManager()
        {
            settingsVM           = SettingsViewModel.Instance;;
            luceneIndexDirectory = null;

            collectionProvider = new CollectionProvider(settingsVM.CollectionPath);
            relevantProvider   = new SimpleRelevantProvider(collectionProvider);

            trecLogger = new TrecLogger();
        }
コード例 #10
0
        /// <summary>
        /// Removes an item from the cache by it's key asynchronously.
        /// </summary>
        /// <param name="key">The key for the cache item.</param>
        /// <param name="token">The <see cref="CancellationToken"/> for the operation.</param>
        public async Task RemoveAsync(string key, CancellationToken token = new CancellationToken())
        {
            token.ThrowIfCancellationRequested();
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            var collection = await CollectionProvider.GetCollectionAsync().ConfigureAwait(false);

            await collection.RemoveAsync(key).ConfigureAwait(false);
        }
コード例 #11
0
        public IrRelevantProvider(CollectionProvider cp) : base(cp)
        {
            luceneIndexDirectory = null;
            writer   = null;
            analyzer = new Lucene.Net.Analysis.Standard.StandardAnalyzer(VERSION);  //SimpleAnalyzer();
            parser   = new QueryParser(Lucene.Net.Util.Version.LUCENE_30, TEXT_FN, analyzer);

            CreateIndex();
            AddDocuments();
            CleanUpIndexer();
            CreateSearcher();
        }
コード例 #12
0
ファイル: Mapping.cs プロジェクト: lyzerk/DataSuit
        public IMapping Collection <P>(IEnumerable <P> collection, ProviderType type = ProviderType.Sequential) where P : class
        {
            CollectionProvider <P> provider = new CollectionProvider <P>(collection, type);
            var ttype = typeof(P);

            var info = ttype.GetTypeInfo();

            foreach (var prop in info.DeclaredProperties)
            {
                listOfFields.Add(prop.Name, provider);
            }

            return(this);
        }
コード例 #13
0
        public void ConstructorWithSequentialProvider()
        {
            var list = new List <int>()
            {
                3, 5, 7
            };
            IDataProvider provider = new CollectionProvider <int>(list);
            var           settings = new JsonFieldSettings("age", provider);

            Assert.Equal("age", settings.Fields);
            Assert.Equal(typeof(int).ToString(), settings.T);
            Assert.Equal(list, settings.Value);
            Assert.Equal(ProviderType.Sequential.ToString(), settings.Type);
        }
コード例 #14
0
ファイル: Form1.cs プロジェクト: gabriel-vii/.NET-Library
        private void GetAllAndFillControls()
        {
            allListView.Items.Clear();

            var allItems = CollectionProvider.Items().ToList();

            for (var i = 0; i < allItems.Count(); i++)
            {
                AddItemTo(i, allItems[i], allListView);
            }

            AutoResizeColumnsAndHighlightChanges();
            HighlightChanges();
        }
コード例 #15
0
        public void ConstructorWithSequentialClassLoop()
        {
            var collection = TestIEnumarableData();

            CollectionProvider <TestData> provider = new CollectionProvider <TestData>(collection);

            // go over all elements, and go back to head of list
            for (int i = 0; i < collection.Count(); i++)
            {
                provider.MoveNext(null);
            }

            Assert.Equal(collection.First(), provider.Current);
        }
コード例 #16
0
        public void ConstructorWithSequentialInteger()
        {
            var collection = TestIEnumarableInt();

            CollectionProvider <int> provider = new CollectionProvider <int>(collection);
            List <int> temp = new List <int>();

            for (int i = 0; i < collection.Count(); i++)
            {
                temp.Add(provider.Current);
                provider.MoveNext(null);
            }

            Assert.Equal(temp, collection);
        }
コード例 #17
0
        /// <summary>
        /// Gets a cache item by its key asynchronously, returning null if the item does not exist within the Cache.
        /// </summary>
        /// <param name="key">The key to lookup the item.</param>
        /// <param name="token">The <see cref="CancellationToken"/> for the operation.</param>
        /// <returns>The cache item if found, otherwise null.</returns>
        public async Task <byte[]> GetAsync(string key, CancellationToken token = new CancellationToken())
        {
            token.ThrowIfCancellationRequested();
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            var collection = await CollectionProvider.GetCollectionAsync().ConfigureAwait(false);

            var result = await collection.GetAsync(key, new GetOptions().Transcoder(_transcoder))
                         .ConfigureAwait(false);

            return(result.ContentAs <byte[]>());
        }
コード例 #18
0
        public void TryGet()
        {
            var provider = new CollectionProvider(new MessagePackProvider(), MessagePackContext.Empty);

            bool result0 = provider.TryGet(typeof(int[]), out IMessagePackFormatter formatter0);
            bool result1 = provider.TryGet(typeof(List <int>), out IMessagePackFormatter formatter1);
            bool result2 = provider.TryGet(typeof(Dictionary <int, int>), out IMessagePackFormatter formatter2);

            Assert.True(result0);
            Assert.True(result1);
            Assert.True(result2);
            Assert.NotNull(formatter0);
            Assert.NotNull(formatter1);
            Assert.NotNull(formatter2);
        }
コード例 #19
0
        public HttpResponseMessage DelColletion([FromUri] int Param)
        {
            try
            {
                CollectionProvider _Provider = new CollectionProvider();
                var result = _Provider.DelColletion(Param);
                return(Request.CreateResponse(HttpStatusCode.OK, result));
            }
            catch (Exception ex)
            {
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "删除收藏", "DelColletion", ex);

                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
コード例 #20
0
        public HttpResponseMessage GetCollectionList([FromUri] int StartRow, [FromUri] int PageSize)
        {
            try
            {
                CollectionProvider _Provider = new CollectionProvider();
                var result = _Provider.GetCollectionList(StartRow, PageSize);
                return(Request.CreateResponse(HttpStatusCode.OK, result));
            }
            catch (Exception ex)
            {
                LogFactory _LogFactory = new LogFactory(this.GetType());
                _LogFactory.CreateLog(LogType.Error, "获取收藏列表", "GetCollectionList", ex);

                return(Request.CreateResponse(HttpStatusCode.InternalServerError, ex.Message));
            }
        }
コード例 #21
0
        public void ConstructorWithRandomProvider()
        {
            var list = new List <int>()
            {
                3, 5, 7
            };
            IDataProvider provider = new CollectionProvider <int>(list, ProviderType.Random);
            var           settings = new JsonFieldSettings("age", provider);

            Assert.Equal("age", settings.Fields);
            Assert.Equal(typeof(int).ToString(), settings.T);
            Assert.All(list, i =>
            {
                Assert.Contains(i, (IEnumerable <int>)settings.Value);
            });
            Assert.Equal(ProviderType.Random.ToString(), settings.Type);
        }
コード例 #22
0
ファイル: Form1.cs プロジェクト: gabriel-vii/.NET-Library
        private void AddItemTo(int?index, object item, ListView listView)
        {
            var itemContent = CollectionProvider.ItemContent(item).ToList();
            var elements    = new string[itemContent.Count() + 1];

            elements[0] = index == null
                ? string.Empty
                : (index + 1).ToString();
            itemContent.CopyTo(elements, 1);

            var listViewItem = new ListViewItem(elements)
            {
                Tag = item
            };

            listView.Items.Add(listViewItem);
        }
コード例 #23
0
        /// <summary>
        /// Sets a cache item using its key asynchronously. If the key exists, it will not be updated.
        /// </summary>
        /// <param name="key">The key for the cache item.</param>
        /// <param name="value">An array of bytes representing the item.</param>
        /// <param name="options">The <see cref="DistributedCacheEntryOptions"/> for the item; note that only sliding expiration is currently supported.</param>
        /// <param name="token">The <see cref="CancellationToken"/> for the operation.</param>
        public async Task SetAsync(string key, byte[] value, DistributedCacheEntryOptions?options,
                                   CancellationToken token = new CancellationToken())
        {
            token.ThrowIfCancellationRequested();
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }
            if (value == null)
            {
                throw new ArgumentNullException(nameof(value));
            }

            var collection = await CollectionProvider.GetCollectionAsync().ConfigureAwait(false);

            await collection.UpsertAsync(key, value, new UpsertOptions().Transcoder(_transcoder).Expiry(GetLifetime(options)))
            .ConfigureAwait(false);
        }
コード例 #24
0
ファイル: Form1.cs プロジェクト: gabriel-vii/.NET-Library
        private void GetPartAndFillControls()
        {
            var index = CurrentIndex;

            var firstPart2  = CollectionProvider.GetPartItemsAsync(index * Skip, Limit);
            var secondPart2 = CollectionProvider.GetPartItemsAsync((index + 1) * Skip, Limit);
            var thirdPart2  = CollectionProvider.GetPartItemsAsync((index + 2) * Skip, Limit);

            firstListView.Items.Clear();
            secondListView.Items.Clear();
            thirdListView.Items.Clear();

            Task.WaitAll(firstPart2.AsTask(), secondPart2.AsTask(), thirdPart2.AsTask());

            FillPartList(firstPart2.Result, firstListView);
            FillPartList(secondPart2.Result, secondListView);
            FillPartList(thirdPart2.Result, thirdListView);

            AutoResizeColumnsAndHighlightChanges();
            HighlightChanges();
        }
コード例 #25
0
        /// <summary>
        /// Gets a cache item by its key asynchronously, returning null if the item does not exist within the Cache.
        /// </summary>
        /// <param name="key">The key to lookup the item.</param>
        /// <param name="token">The <see cref="CancellationToken"/> for the operation.</param>
        /// <returns>The cache item if found, otherwise null.</returns>
        async Task <byte[]> IDistributedCache.GetAsync(string key, CancellationToken token)
        {
            token.ThrowIfCancellationRequested();
            if (key == null)
            {
                throw new ArgumentNullException(nameof(key));
            }

            var collection = await CollectionProvider.GetCollectionAsync().ConfigureAwait(false);

            try
            {
                var result = await collection.GetAsync(key, new GetOptions().Transcoder(_transcoder))
                             .ConfigureAwait(false);

                return(result.ContentAs <byte[]>());
            }
            catch (DocumentNotFoundException)
            {
                return(null);
            }
        }
コード例 #26
0
        public PropertyDetail FindByParcelId(string state, string county, string parcelId)
        {
            try
            {
                if (string.IsNullOrEmpty(state) || string.IsNullOrEmpty(county) || string.IsNullOrEmpty(parcelId))
                {
                    throw new ArgumentNullException(parcelId);
                }

                var collectionName = county.ToLower() + _current;
                IMongoCollection <PropertyDetail> collection = CollectionProvider.GetCollection <PropertyDetail>(Database, _current);

                var filter = Builders <PropertyDetail> .Filter.Eq("parcelid", parcelId);

                var doc = collection.Find(filter).FirstOrDefault();

                return(doc ?? null);
            }
            catch (Exception ex)
            {
                throw new RepositoryException(ex.Message, ex);
            }
        }
コード例 #27
0
ファイル: ProjectFeedRepository.cs プロジェクト: mridulsri/mw
 public ProjectFeedRepository()
 {
     Database    = DatabaseProvider.GetDatabase();
     _collection = CollectionProvider.GetCollection <ProjectFeed>(Database);
 }
コード例 #28
0
 public RelevantProvider(CollectionProvider cp)
 {
     collectionProvider = cp;
 }
コード例 #29
0
 public SimpleRelevantProvider(CollectionProvider cp) : base(cp)
 {
 }
コード例 #30
0
ファイル: MongoRepository.cs プロジェクト: mridulsri/mw
 public MongoRepository(IMongoDatabase database)
 {
     Collection = CollectionProvider.GetCollection <T>(database);
     Database   = database;
 }