public override object ReadJson(JsonReader reader, Type objectType, object existingValue, JsonSerializer serializer)
		{
			if (reader.TokenType == JsonToken.Null) return null;

			var filter =  new SourceFilter();
			switch (reader.TokenType)
			{
				case JsonToken.Boolean:
					filter.Exclude = new[] { "*" };
					break;
				case JsonToken.String:
					filter.Include = new [] { (string)reader.Value };
					break;
				case JsonToken.StartArray:
					var include = new List<string>();
					while (reader.Read() && reader.TokenType != JsonToken.EndArray)
						include.Add((string)reader.Value);
					filter.Include = include.ToArray();
					break;
				default:
					serializer.Populate(reader, filter);
					break;
			}

			return filter;
		}
示例#2
0
        /// <summary>檢查此訊息是否需要寫入記錄檔,依照 <see cref="TraceListener.Filter"/> 設定為準</summary>
        /// <param name="source"><see cref="SourceFilter.Source"/></param>
        /// <param name="eventType"><see cref="EventTypeFilter.EventType"/></param>
        /// <returns>(True)需要寫入記錄檔 (False)不須寫入</returns>
        private bool IsNecessary(string source, TraceEventType eventType)
        {
            bool necessary = false;
            /* 判斷 Filter 是否為 EventTypeFilter */
            EventTypeFilter evnFilter = Filter as EventTypeFilter;

            if (evnFilter != null)
            {
                /* 因 SourceLevels 與 TraceEventType 兩個 Enum 數值不同,故用單一比較 */
                SourceLevels srcLv = evnFilter.EventType;
                necessary = srcLv.HasFlag(SourceLevels.All) ||
                            (srcLv.HasFlag(SourceLevels.Error) && eventType.HasFlag(TraceEventType.Error)) ||
                            (srcLv.HasFlag(SourceLevels.Information) && eventType.HasFlag(TraceEventType.Information)) ||
                            (srcLv.HasFlag(SourceLevels.Warning) && eventType.HasFlag(TraceEventType.Warning)) ||
                            (srcLv.HasFlag(SourceLevels.Critical) && eventType.HasFlag(TraceEventType.Critical)) ||
                            (srcLv.HasFlag(SourceLevels.Verbose) && eventType.HasFlag(TraceEventType.Verbose));
            }
            else
            {
                /* 檢查是否為 SourceFilter */
                SourceFilter srcFilter = Filter as SourceFilter;
                if (srcFilter != null)
                {
                    necessary = srcFilter.Source == source;
                }
            }
            return(necessary);
        }
示例#3
0
        protected CaptureGraph(FilterInfo fiSource)
        {
            try
            {
                // Fgm initialization
                fgm   = new FilgraphManagerClass();
                iFG   = (IFilterGraph)fgm;
                iGB   = (IGraphBuilder)fgm;
                rotID = FilterGraph.AddToRot(iGB);

                // Create source filter and initialize it
                source = (SourceFilter)Filter.CreateFilter(fiSource);
                iGB.AddFilter(source.BaseFilter, source.FriendlyName);
                source.AddedToGraph(fgm);

                // Pass flags to the RtpRenderer filter from the config file.
                this.rtpRendererFlags = 0;
                string setting = ConfigurationManager.AppSettings[AppConfig.MDS_RtpRendererFlags];
                if (!String.IsNullOrEmpty(setting))
                {
                    if (!byte.TryParse(setting, out rtpRendererFlags))
                    {
                        rtpRendererFlags = 0;
                    }
                }
            }
            catch (Exception)
            {
                Cleanup();
                throw;
            }
        }
示例#4
0
        protected SourceFilterViewModel Find(IReadOnlyList <string> loggerNames, SourceFilterViewModel parent, int index)
        {
            if (loggerNames.Count <= index)
            {
                return(null);
            }

            var name = loggerNames[index];
            var sourceFilterViewModel = parent.Children.FirstOrDefault(s => s.Name == name);

            if (sourceFilterViewModel == null)
            {
                var newSourceFilter = new SourceFilter(parent.sourceFilter)
                {
                    Name = name
                };
                parent.sourceFilter.Children.Add(newSourceFilter);

                sourceFilterViewModel = new SourceFilterViewModel(newSourceFilter, logPaneServices);
                parent.Children.Add(sourceFilterViewModel);
            }

            var source = Find(loggerNames, sourceFilterViewModel, index + 1);

            return(source ?? sourceFilterViewModel);
        }
示例#5
0
        /// <summary>寫入追蹤資訊、訊息、相關活動身分識別與事件資訊</summary>
        /// <param name="eventCache"><see cref="TraceEventCache"/> 物件,包含目前處理程序識別碼、執行緒識別碼與堆疊追蹤資訊</param>
        /// <param name="source">用來識別輸出的名稱,通常是產生追蹤事件的應用程式名稱</param>
        /// <param name="id">事件的數值識別項</param>
        /// <param name="message">要寫入的訊息</param>
        /// <param name="relatedActivityId"><see cref="Guid"/> 物件,辨識相關活動</param>
        public override void TraceTransfer(TraceEventCache eventCache, string source, int id, string message, Guid relatedActivityId)
        {
            SourceFilter srcFilter = Filter as SourceFilter;

            if (srcFilter != null && !srcFilter.Source.Equals(source))
            {
                return;
            }

            var traceElmt = new XElement("Transfer");

            traceElmt.Add(new XElement("GUID", relatedActivityId.ToString()));
            traceElmt.Add(new XElement("Id", id));
            traceElmt.Add(new XElement("Data", message));
            var caches = GetEventCache(eventCache);

            if (caches.Count > 0)
            {
                traceElmt.Add(new XElement("EventCache", caches));
            }
            if (this.TraceOutputOptions.HasFlag(TraceOptions.DateTime))
            {
                traceElmt.Add(new XAttribute("Time", eventCache.DateTime.ToLocalTime().ToString("HH:mm:ss.fff")));
            }
            AddXElement(traceElmt);
        }
示例#6
0
        public List <CuocThi> GetAll(List <string> ids_ignore, string[] view_fields, string nguoi_tao, bool is_admin = false)
        {
            List <QueryContainer> must_not = new List <QueryContainer>();
            List <QueryContainer> must     = new List <QueryContainer>();

            if (ids_ignore.Count > 0)
            {
                must_not.Add(new IdsQuery()
                {
                    Values = ids_ignore.Select(x => (Id)x)
                });;
            }
            if (!is_admin)
            {
                if (!string.IsNullOrEmpty(nguoi_tao))
                {
                    must.Add(new TermQuery()
                    {
                        Field = "nguoi_tao.keyword",
                        Value = nguoi_tao
                    });
                }
            }
            var query = new QueryContainer(new BoolQuery()
            {
                Must = must, MustNot = must_not
            });
            var source = new SourceFilter()
            {
                Includes = view_fields
            };
            var all = GetObjectScroll <CuocThi>(_default_index, query, source);

            return(all.Select(HitToDocument).ToList());
        }
        public override int GetHashCode()
        {
            int hashCode = -566134060;

            if (StateFilter != null)
            {
                hashCode += StateFilter.GetHashCode();
            }

            if (DateTimeFilter != null)
            {
                hashCode += DateTimeFilter.GetHashCode();
            }

            if (FulfillmentFilter != null)
            {
                hashCode += FulfillmentFilter.GetHashCode();
            }

            if (SourceFilter != null)
            {
                hashCode += SourceFilter.GetHashCode();
            }

            if (CustomerFilter != null)
            {
                hashCode += CustomerFilter.GetHashCode();
            }

            return(hashCode);
        }
示例#8
0
        protected ConcurrentDictionary <string, T> GetDicObjectScroll <T>(string _DefaultIndex, QueryContainer query, SourceFilter so) where T : class
        {
            try
            {
                ConcurrentDictionary <string, T> bag = new ConcurrentDictionary <string, T>();

                string scroll_timeout = "5m";
                int    scroll_pageize = 2000;

                if (query == null)
                {
                    query = new MatchAllQuery();
                }
                if (so == null)
                {
                    so = new SourceFilter()
                    {
                    }
                }
                ;
                try
                {
                    var searchResponse = client.Search <T>(sd => sd.Source(s => so).Index(_DefaultIndex).From(0).Take(scroll_pageize).Query(q => query).Scroll(scroll_timeout));

                    while (true)
                    {
                        if (!searchResponse.IsValid || string.IsNullOrEmpty(searchResponse.ScrollId))
                        {
                            break;
                        }

                        if (!searchResponse.Documents.Any())
                        {
                            break;
                        }

                        var tmp = searchResponse.Hits;
                        foreach (var item in tmp)
                        {
                            bag.TryAdd(item.Id, item.Source);
                        }
                        searchResponse = client.Scroll <T>(scroll_timeout, searchResponse.ScrollId);
                    }

                    client.ClearScroll(new ClearScrollRequest(searchResponse.ScrollId));
                }
                catch (Exception)
                {
                }
                finally
                {
                }
                return(bag);
            }
            catch (Exception ex)
            {
            }
            return(null);
        }
示例#9
0
 private void DisposeSource()
 {
     if (source != null)
     {
         source.Dispose();
         source = null;
     }
 }
示例#10
0
 public void SourceTest()
 {
     var filter = new SourceFilter("TestSource");
     Assert.Equal("TestSource", filter.Source);
     filter.Source = "Default";
     Assert.Equal("Default", filter.Source);
     Assert.Throws<ArgumentNullException>(() => filter.Source = null);
 }
 protected void ToString(List <string> toStringOutput)
 {
     toStringOutput.Add($"StateFilter = {(StateFilter == null ? "null" : StateFilter.ToString())}");
     toStringOutput.Add($"DateTimeFilter = {(DateTimeFilter == null ? "null" : DateTimeFilter.ToString())}");
     toStringOutput.Add($"FulfillmentFilter = {(FulfillmentFilter == null ? "null" : FulfillmentFilter.ToString())}");
     toStringOutput.Add($"SourceFilter = {(SourceFilter == null ? "null" : SourceFilter.ToString())}");
     toStringOutput.Add($"CustomerFilter = {(CustomerFilter == null ? "null" : CustomerFilter.ToString())}");
 }
示例#12
0
        public void SourceTest()
        {
            var filter = new SourceFilter("TestSource");

            Assert.Equal("TestSource", filter.Source);
            filter.Source = "Default";
            Assert.Equal("Default", filter.Source);
            Assert.Throws <ArgumentNullException>(() => filter.Source = null);
        }
示例#13
0
 public void ShouldTraceTest()
 {
     var sourceName = "TestSource";
     var cache = new TraceEventCache();
     var filter = new SourceFilter(sourceName);
     Assert.True(filter.ShouldTrace(cache, sourceName, TraceEventType.Critical, 0, null, null, null, null));
     Assert.False(filter.ShouldTrace(cache, "Default", TraceEventType.Warning, 0, null, null, null, null));
     Assert.Throws<ArgumentNullException>(() => filter.ShouldTrace(cache, null, TraceEventType.Warning, 0, null, null, null, null));
 }
示例#14
0
        public void ShouldTraceTest()
        {
            var sourceName = "TestSource";
            var cache      = new TraceEventCache();
            var filter     = new SourceFilter(sourceName);

            Assert.True(filter.ShouldTrace(cache, sourceName, TraceEventType.Critical, 0, null, null, null, null));
            Assert.False(filter.ShouldTrace(cache, "Default", TraceEventType.Warning, 0, null, null, null, null));
            Assert.Throws <ArgumentNullException>(() => filter.ShouldTrace(cache, null, TraceEventType.Warning, 0, null, null, null, null));
        }
示例#15
0
        private void AddChild(SourceFilter child)
        {
            var childViewModel = new SourceFilterViewModel(child, logPaneServices);

            Children.Add(childViewModel);

            foreach (var subChild in child.Children)
            {
                childViewModel.AddChild(subChild);
            }
        }
示例#16
0
        public List <CuocThi> SearchByPeriod(long ngay_bd, long ngay_kt, bool is_admin = false)
        {
            List <QueryContainer> must = new List <QueryContainer>();

            if (ngay_bd > 0)
            {
                var dt_ngay_thi = XMedia.XUtil.EpochToTime(ngay_bd).Date;
                must.Add(new LongRangeQuery()
                {
                    Field = "ngay_bat_dau",
                    GreaterThanOrEqualTo = XMedia.XUtil.TimeInEpoch(dt_ngay_thi)
                });
                if (ngay_kt == 0)
                {
                    var date = DateTimeOffset.MaxValue.Date;
                    must.Add(new LongRangeQuery()
                    {
                        Field             = "ngay_ket_thuc",
                        LessThanOrEqualTo = XMedia.XUtil.TimeInEpoch(date)
                    });
                }
            }

            if (ngay_kt > 0)
            {
                var dt_ngay_thi = XMedia.XUtil.EpochToTime(ngay_kt).Date.AddSeconds(86400 - 1);
                must.Add(new LongRangeQuery()
                {
                    Field             = "ngay_ket_thuc",
                    LessThanOrEqualTo = XMedia.XUtil.TimeInEpoch(dt_ngay_thi)
                });
                if (ngay_bd == 0)
                {
                    var date = DateTimeOffset.MinValue.Date;
                    must.Add(new LongRangeQuery()
                    {
                        Field = "ngay_ket_thuc",
                        GreaterThanOrEqualTo = XMedia.XUtil.TimeInEpoch(date)
                    });
                }
            }
            var query = new QueryContainer(new BoolQuery()
            {
                Must = must
            });
            var source = new SourceFilter()
            {
                Includes = null
            };
            var all = GetObjectScroll <CuocThi>(_default_index, query, source);

            return(all.Select(HitToDocument).ToList());
        }
示例#17
0
 public bool StopRemoteControlSupport()
 {
     foreach (FireDTVSourceFilterInfo SourceFilter in _sourceFilterCollection)
     {
         if (SourceFilter.RemoteRunning)
         {
             SourceFilter.StopFireDTVRemoteControlSupport();
             return(SourceFilter.RemoteRunning);
         }
     }
     return(false);
 }
示例#18
0
        /// <summary>
        /// 结构化查询
        /// </summary>
        /// <typeparam name="T">查询模型类型</typeparam>
        /// <typeparam name="TR">查询结果模型类型</typeparam>
        /// <param name="searchCondition">查询条件</param>
        /// <returns></returns>
        public IEnumerable <TR> ExactValueSearch <T, TR>(IExactValueSearchCondition <T, TR> searchCondition)
            where T : SearchEntityBase
            where TR : class
        {
            var indexMappingName = IndexNameHelper.GetIndexMappingName(SetupConfig.SetupConfig.ServiceSign, searchCondition.Index);
            var status           = this.CacheClient.GetCache <IndexOperateStatus>(indexMappingName);

            this.IndexOperate.CkeckIndexStatus <T>(status, indexMappingName);

            if (searchCondition.Selector == null)
            {
                throw new ElasticsearchException("index查询异常:未设置查询结果类型转换表达式");
            }

            var queryContainer = searchCondition.QueryPredicate == null ? new MatchAllQuery()
                 : searchCondition.QueryPredicate.GetQuery();

            var properties  = LoadFieldHelper.GetProperty(searchCondition.Selector);
            var sourefilter = new SourceFilter()
            {
                Includes = properties
            };

            var searchRequest = new SearchRequest <T>(indexMappingName);

            searchRequest.Query = new ConstantScoreQuery()
            {
                Filter = queryContainer
            };
            searchRequest.Source = new Union <bool, ISourceFilter>(sourefilter);

            if (searchCondition.Sort != null && searchCondition.Sort.Count() > 0)
            {
                searchRequest.Sort = searchCondition.Sort.Select(x => (ISort) new SortField
                {
                    Field = x.Field,
                    Order = x.isAsc ? SortOrder.Ascending : SortOrder.Descending
                }).ToList();
            }

            searchRequest.Size = searchCondition.SizeNumber;
            searchRequest.From = searchCondition.SkipNumber;

            var response = this.Client.Search <T>(searchRequest);

            if (!response.IsValid)
            {
                throw new ElasticsearchException("index查询异常:" + response.OriginalException.Message);
            }

            return(response.Hits.Select(x => x.Source).Select(searchCondition.Selector.Compile()));
        }
示例#19
0
        public async Task <ConcurrentBag <IHit <T> > > BackupAndScroll <T>(string _default_index, QueryContainer query, SourceFilter so, string scroll_timeout = "5m", int scroll_pageize = 2000) where T : class
        {
            if (query == null)
            {
                query = new MatchAllQuery();
            }
            if (so == null)
            {
                so = new SourceFilter()
                {
                }
            }
            ;
            ConcurrentBag <IHit <T> > bag = new ConcurrentBag <IHit <T> >();

            try
            {
                var searchResponse = await client.SearchAsync <T>(sd => sd.Source(s => so).Index(_default_index).From(0).Take(scroll_pageize).Query(q => query).Scroll(scroll_timeout));

                List <Task> lst_task = new List <Task>();
                while (true)
                {
                    if (!searchResponse.IsValid || string.IsNullOrEmpty(searchResponse.ScrollId))
                    {
                        break;
                    }

                    if (!searchResponse.Documents.Any())
                    {
                        break;
                    }

                    var tmp = searchResponse.Hits;
                    foreach (var item in tmp)
                    {
                        bag.Add(item);
                    }
                    searchResponse = await client.ScrollAsync <T>(scroll_timeout, searchResponse.ScrollId);
                }

                await client.ClearScrollAsync(new ClearScrollRequest(searchResponse.ScrollId));

                await Task.WhenAll(lst_task);
            }
            catch (Exception)
            {
            }
            finally
            {
            }
            return(bag);
        }
示例#20
0
        public async Task ReadDocumentsAsync(SourceFilter filter,
                                             ChannelWriter <List <ReplaceOneModel <BsonDocument> > > batchWriter,
                                             int batchSize,
                                             string[] keyFields,
                                             bool upsert,
                                             IDestinationDocumentFinder?documentFinder,
                                             CancellationToken token)
        {
            _logger.Debug("Creating a cursor to the source with batch size {Batch}", batchSize);
            using var cursor = await _collection.FindAsync(
                      filter.ToBsonDocument(), new FindOptions <BsonDocument>
            {
                BatchSize = batchSize
            }, token);

            _logger.Debug("Started reading documents from source");
            try
            {
                while (await cursor.MoveNextAsync(token))
                {
                    if (cursor.Current == null || !cursor.Current.Any())
                    {
                        continue;
                    }
                    var currentBatch = cursor.Current.ToList();

                    var destinationDocuments = new Dictionary <BsonValue, BsonDocument>();
                    if (documentFinder != null)
                    {
                        var dest = await documentFinder.GetFieldsAsync(currentBatch, keyFields, token);

                        foreach (var doc in dest)
                        {
                            destinationDocuments[doc["_id"]] = doc;
                        }
                    }

                    var replaceModels = currentBatch.Select(srcDoc => CreateReplaceModel(
                                                                destinationDocuments.TryGetValue(srcDoc["_id"], out var destDoc)
                                ? destDoc
                                : srcDoc, srcDoc, keyFields, upsert))
                                        .ToList();

                    await batchWriter.WriteAsync(replaceModels, token);
                }
            }
            finally
            {
                batchWriter.Complete();
            }
        }
        public IEnumerable <string> GetAllTrangThaiBat()
        {
            List <QueryContainer> must = new List <QueryContainer>();

            var source = new SourceFilter()
            {
                Includes = new string[] { "id" }
            };

            return(GetObjectScroll <ChienDich>(_DefaultIndex, new QueryContainer(new BoolQuery()
            {
                Must = must
            }), source).Select(x => x.id).ToList());
        }
示例#22
0
        public void Rebuild(SourceFilter rootSourceFilter)
        {
            this.sourceFilter = rootSourceFilter;

            Children.Clear();

            foreach (var child in sourceFilter.Children)
            {
                AddChild(child);
            }

            IsSelected = false;
            NotifyOfPropertyChange(nameof(IsChecked));
            NotifyOfPropertyChange(nameof(Name));
        }
        public IEnumerable <ChienDich> Overview(List <string> nguoi_tao, string[] view_fields, Dictionary <string, bool> sort_fields, int top = 10)
        {
            List <QueryContainer> must = new List <QueryContainer>();

            must.Add(new TermsQuery()
            {
                Field = "nguoi_tao",
                Terms = nguoi_tao
            });
            var source = new SourceFilter()
            {
                Includes = view_fields
            };
            QueryContainer queryFilterMultikey = new QueryContainer(new BoolQuery()
            {
                Must = must
            });

            SourceFilter soF = new SourceFilter()
            {
                Includes = view_fields
            };

            List <ISort> sort = new List <ISort>()
            {
            };

            foreach (var item in sort_fields)
            {
                sort.Add(new FieldSort()
                {
                    Field = item.Key, Order = item.Value ? SortOrder.Descending : SortOrder.Ascending
                });
            }

            SearchRequest request = new SearchRequest(Indices.Index(_DefaultIndex))
            {
                TrackTotalHits = true,
                Query          = queryFilterMultikey,
                Source         = soF,
                Sort           = sort,
                Size           = top
            };
            var re = client.Search <ChienDich>(request);

            return(re.Hits.Select(x => HitToDocument <ChienDich>(x)));
        }
示例#24
0
        /**
         * ==== Implicit conversion
         *
         * The `Union<TFirst,TSecond>` has implicit operators to convert from an instance of `TFirst` or `TSecond` to an
         * instance of `Union<TFirst,TSecond>`. This is often the easiest way of construction an instance
         */
        public void ImplicitConversion()
        {
            Union <bool, ISourceFilter> sourceFilterFalse = false;

            Union <bool, ISourceFilter> sourceFilterInterface = new SourceFilter
            {
                Includes = new [] { "foo.*" }
            };

            // hide
            sourceFilterFalse.Match(
                b => b.Should().BeFalse(),
                s => s.Should().BeNull());

            // hide
            sourceFilterInterface.Match(
                b => b.Should().BeFalse(),
                s => s.Should().NotBeNull());
        }
        public override bool Equals(object obj)
        {
            if (obj == null)
            {
                return(false);
            }

            if (obj == this)
            {
                return(true);
            }

            return(obj is SearchOrdersFilter other &&
                   ((StateFilter == null && other.StateFilter == null) || (StateFilter?.Equals(other.StateFilter) == true)) &&
                   ((DateTimeFilter == null && other.DateTimeFilter == null) || (DateTimeFilter?.Equals(other.DateTimeFilter) == true)) &&
                   ((FulfillmentFilter == null && other.FulfillmentFilter == null) || (FulfillmentFilter?.Equals(other.FulfillmentFilter) == true)) &&
                   ((SourceFilter == null && other.SourceFilter == null) || (SourceFilter?.Equals(other.SourceFilter) == true)) &&
                   ((CustomerFilter == null && other.CustomerFilter == null) || (CustomerFilter?.Equals(other.CustomerFilter) == true)));
        }
示例#26
0
        protected CaptureGraph(FilterInfo fiSource)
        {
            try
            {
                // Fgm initialization
                fgm = new FilgraphManagerClass();
                iFG = (IFilterGraph)fgm;
                iGB = (IGraphBuilder)fgm;
                rotID = FilterGraph.AddToRot(iGB);

                // Create source filter and initialize it
                source = (SourceFilter)Filter.CreateFilter(fiSource);
                iGB.AddFilter(source.BaseFilter, source.FriendlyName);
                source.AddedToGraph(fgm);
            }
            catch(Exception)
            {
                Cleanup();
                throw;
            }
        }
示例#27
0
        protected CaptureGraph(FilterInfo fiSource)
        {
            try
            {
                // Fgm initialization
                fgm   = new FilgraphManagerClass();
                iFG   = (IFilterGraph)fgm;
                iGB   = (IGraphBuilder)fgm;
                rotID = FilterGraph.AddToRot(iGB);

                // Create source filter and initialize it
                source = (SourceFilter)Filter.CreateFilter(fiSource);
                iGB.AddFilter(source.BaseFilter, source.FriendlyName);
                source.AddedToGraph(fgm);
            }
            catch (Exception)
            {
                Cleanup();
                throw;
            }
        }
示例#28
0
        public IEnumerable <User> GetAll(List <string> nguoi_tao, string[] view_fields)
        {
            List <QueryContainer> must = new List <QueryContainer>();

            must.Add(new TermsQuery()
            {
                Field = "nguoi_tao",
                Terms = nguoi_tao
            });
            var source = new SourceFilter()
            {
                Includes = view_fields
            };

            if (view_fields == null)
            {
                source = new SourceFilter();
            }
            return(GetObjectScroll <User>(_DefaultIndex, new QueryContainer(new BoolQuery()
            {
                Must = must
            }), source));
        }
示例#29
0
        public async Task <List <string> > GetListIdJobByUser(string app_id, IEnumerable <string> ids_user)
        {
            QueryContainer qc = new QueryContainer(new TermQuery()
            {
                Field = "app_id.keyword", Value = app_id
            } &&
                                                   new TermQuery()
            {
                Field = "trang_thai", Value = TrangThai.ACTIVE
            } &&
                                                   new TermsQuery()
            {
                Field = "id_user.keyword", Terms = ids_user
            }
                                                   );
            SourceFilter so = new SourceFilter();

            so.Includes = new string[] { "id_job" };

            var all = await BackupAndScroll <UserJob>(_default_index, qc, so);

            return(all.Select(x => x.Source.id_job).Distinct().ToList());
        }
示例#30
0
        public IEnumerable <TuKhoa> GetByIdChienDich(string id, string[] view_fields)
        {
            List <QueryContainer> must = new List <QueryContainer>();

            must.Add(new TermQuery()
            {
                Field = "id_chien_dich.keyword",
                Value = id
            });
            var source = new SourceFilter
            {
                Includes = view_fields
            };

            if (view_fields == null)
            {
                source = new SourceFilter();
            }
            return(GetObjectScroll <TuKhoa>(_DefaultIndex, new QueryContainer(new BoolQuery()
            {
                Must = must
            }), source));
        }
        public async Task ReadDocumentsAsync_ShouldWriteAllDocumentsIntoChannel_FilterByDate()
        {
            // Arrange
            var channel     = Channel.CreateUnbounded <List <ReplaceOneModel <BsonDocument> > >();
            var currentDate = Fixture.CreateMongoDbDate();
            await _sourceCollection.InsertManyAsync(Enumerable.Range(0, 100).Select(idx => new BsonDocument
            {
                ["Modified"] = new BsonDateTime(currentDate.AddMinutes(idx))
            }));

            var filerByDate = new SourceFilter("Modified", currentDate.AddMinutes(50));

            // Act
            await _sut.ReadDocumentsAsync(filerByDate, channel, 10, Array.Empty <string>(),
                                          false, null, CancellationToken.None);

            // Assert
            var actual = await ReadDocumentsFromChannelAsync(channel);

            var existing = _sourceCollection.Find(filerByDate.ToBsonDocument()).ToList();

            actual.Should().BeEquivalentTo(existing);
        }
示例#32
0
        public List <ChungChi> GetAll(List <string> ids_ignore, string[] view_fields)
        {
            List <QueryContainer> must_not = new List <QueryContainer>();

            if (ids_ignore.Count > 0)
            {
                must_not.Add(new IdsQuery()
                {
                    Values = ids_ignore.Select(x => (Id)x)
                });;
            }
            var query = new QueryContainer(new BoolQuery()
            {
                MustNot = must_not
            });
            var source = new SourceFilter()
            {
                Includes = view_fields
            };
            var all = GetObjectScroll <ChungChi>(_default_index, query, source);

            return(all.Select(HitToDocument).ToList());
        }
示例#33
0
        public async Task <List <string> > GetListIdCongTyByIdJob(string app_id, IEnumerable <string> ids_job)
        {
            QueryContainer qc = new QueryContainer(new TermQuery()
            {
                Field = "app_id.keyword", Value = app_id
            }

                                                   && new TermQuery()
            {
                Field = "trang_thai", Value = TrangThai.ACTIVE
            } &&
                                                   new IdsQuery()
            {
                Values = ids_job.Select(x => (Id)x)
            }
                                                   );
            SourceFilter so = new SourceFilter();

            so.Includes = new string[] { "cong_ty.id_cong_ty" };

            var all = await BackupAndScroll <Job>(_default_index, qc, so);

            return(all.Where(o => !string.IsNullOrEmpty(o.Source.cong_ty.id_cong_ty)).Select(x => x.Source.cong_ty.id_cong_ty).Distinct().ToList());
        }
示例#34
0
        public List <TuKhoa> GetTuKhoaTheoChienDich(IEnumerable <string> ids_chien_dich)
        {
            List <TuKhoa>         lst_tu_khoa = new List <TuKhoa>();
            List <QueryContainer> must        = new List <QueryContainer>();

            must.Add(new TermsQuery()
            {
                Field = "id_chien_dich.keyword",
                Terms = ids_chien_dich
            });
            must.Add(new TermQuery()
            {
                Field = "trang_thai",
                Value = TrangThaiTuKhoa.BAT
            });
            must.Add(new TermQuery()
            {
                Field = "trang_thai_quang_cao",
                Value = TrangThaiQuangCao.BAT
            });
            must.Add(new TermQuery()
            {
                Field = "trang_thai_chien_dich",
                Value = TrangThaiChienDich.BAT
            });
            var source = new SourceFilter()
            {
                Includes = new string[] { "tu_khoa", "kieu_doi_sanh", "id_chien_dich" }
            };

            lst_tu_khoa = GetObjectScroll <TuKhoa>(_DefaultIndex, new QueryContainer(new BoolQuery()
            {
                Must = must
            }), source).ToList();
            return(lst_tu_khoa);
        }
示例#35
0
        protected CaptureGraph(FilterInfo fiSource)
        {
            try
            {
                // Fgm initialization
                fgm = new FilgraphManagerClass();
                iFG = (IFilterGraph)fgm;
                iGB = (IGraphBuilder)fgm;
                rotID = FilterGraph.AddToRot(iGB);

                // Create source filter and initialize it
                source = (SourceFilter)Filter.CreateFilter(fiSource);
                iGB.AddFilter(source.BaseFilter, source.FriendlyName);
                source.AddedToGraph(fgm);

                // Pass flags to the RtpRenderer filter from the config file.
                this.rtpRendererFlags = 0;
                string setting = ConfigurationManager.AppSettings[AppConfig.MDS_RtpRendererFlags];
                if (!String.IsNullOrEmpty(setting)) {
                    if (!byte.TryParse(setting,out rtpRendererFlags)) {
                        rtpRendererFlags = 0;
                    }
                }
            }
            catch(Exception)
            {
                Cleanup();
                throw;
            }
        }
示例#36
0
 private void DisposeSource()
 {
     if(source != null)
     {
         source.Dispose();
         source = null;
     }
 }
 public void Update()
 {
     m_SourceFilter = new SourceFilter();
     var rgbInput = m_SourceFilter.Transform(x => new RgbFilter(x));
     m_Filter = Chain
         .CreateSafeFilter(rgbInput)
         .SetSize(Renderer.TargetSize)
         .Compile();
     m_Filter.Initialize();
 }
示例#38
0
 public void ConstructorTest()
 {
     var filter = new SourceFilter("TestSource");
     Assert.Equal("TestSource", filter.Source);
 }