コード例 #1
0
            /// <summary>
            /// Data updating handler
            /// </summary>
            /// <remarks>This method will detect whether a duplicate exists and will mark it as such</remarks>
            private void DataUpdatingHandler(object sender, Event.DataPersistingEventArgs <TModel> e)
            {
                // Detect any duplicates
                var matches = this.m_matchingConfigurationService.Configurations.Where(o => o.AppliesTo.Contains(typeof(TModel)) && o.Metadata.State == MatchConfigurationStatus.Active).SelectMany(o => this.m_matchingService.Match <TModel>(e.Data, o.Id, this.GetIgnoredKeys(e.Data.Key.GetValueOrDefault())));

                // Clear out current duplicate markers
                this.MarkDuplicates(e.Data, matches.Where(o => o.Classification != RecordMatchClassification.NonMatch && o.Record.Key != e.Data.Key));
            }
コード例 #2
0
            /// <summary>
            /// Data inserting handler
            /// </summary>
            /// <remarks>This method will detect whether a duplicate exists and will either merge it or simply mark it as duplicate</remarks>
            private void DataInsertingHandler(object sender, Event.DataPersistingEventArgs <TModel> e)
            {
                // Detect any duplicates
                var matches = this.m_matchingConfigurationService.Configurations.Where(o => o.AppliesTo.Contains(typeof(TModel)) && o.Metadata.State == MatchConfigurationStatus.Active).SelectMany(o => this.m_matchingService.Match <TModel>(e.Data, o.Id, this.GetIgnoredKeys(e.Data.Key.GetValueOrDefault())));

                // 1. Exactly one match is found and AutoMerge so we merge
                if (matches.Count(o => o.Classification != RecordMatchClassification.Match && o.Record.Key != e.Data.Key) == 1)
                {
                    var match = matches.SingleOrDefault();
                    this.m_tracer.TraceInfo("{0} matches with {1} ({2}) and AutoMerge is true --- NEW RECORD WILL BE SET TO NULLIFIED ---", e.Data, match.Record, match.Score);
                    this.Merge(match.Record.Key.Value, new Guid[] { e.Data.Key.GetValueOrDefault() }); // Merge the data
                    (e.Data as IHasState).StatusConceptKey = StatusKeys.Nullified;
                }

                this.MarkDuplicates(e.Data, matches.Where(o => o.Classification != RecordMatchClassification.NonMatch && o.Record.Key != e.Data.Key));
            }