/// <summary> /// Resolves the duplicate. /// </summary> /// <param name="itemId">The item id.</param> private void ResolveDuplicate(string itemId) { try { IMatchDuplicateProvider dupProvider = GetDuplicateProvider(itemId); if (DialogService != null) { if (dupProvider != null) { DialogService.SetSpecs(200, 200, 600, 800, "LeadSearchAndConvert", GetLocalResourceObject("Title.Resolve.Duplicate.ImportLead").ToString(), true); DialogService.DialogParameters.Add("duplicateProvider", dupProvider); DialogService.DialogParameters.Add("importHistoryItemId", itemId); DialogService.EntityType = typeof(IImportHistory); DialogService.EntityID = itemId; DialogService.ShowDialog(); chkShowDuplicates.Checked = false; } } } catch (Exception exp) { throw new ApplicationException(string.Format(GetLocalResourceObject("LoadErrorMSG").ToString(), exp.Message), exp); } }
/// <summary> /// Transforms to target object. /// </summary> /// <param name="item">The item.</param> /// <returns></returns> private IMatchDuplicateProvider GetDuplicateProvider(string itemId) { IMatchDuplicateProvider dupProvider = null; IImportHistoryItem item = Sage.Platform.EntityFactory.GetById <IImportHistoryItem>(itemId); IImportHistory importHistory = Sage.Platform.EntityFactory.GetById <IImportHistory>(item.ImportHistoryId); ImportTemplateManager templateManager = new ImportTemplateManager(importHistory.Data, Type.GetType(importHistory.EntityType)); ImportCSVOptions csvOptions = new ImportCSVOptions(); templateManager.LoadImportSourceOptions(csvOptions); StringBuilder sb = new StringBuilder(); if (csvOptions.FirstRowColHeader) { string colheader = string.Empty; int lastColIndex = templateManager.SourceProperties.Count; int index = 0; foreach (ImportSourceProperty sp in templateManager.SourceProperties) { index++; colheader = colheader + Convert.ToString(csvOptions.Qualifier) + sp.FieldName + Convert.ToString(csvOptions.Qualifier); if (lastColIndex != index) { colheader = colheader + Convert.ToString(csvOptions.Delimiter); } } sb.AppendLine(colheader); } sb.AppendLine(item.Data); ImportCSVReader sourceReader = GetCSVReader(sb.ToString()); sourceReader.Options = csvOptions; ImportTransformationManager transformationManager = new ImportTransformationManager(templateManager.EntityManager.EntityType, templateManager.ImportMaps, templateManager.TargetPropertyDefaults); //Calculated properties? transformationManager.TransformationProvider = new ImportTransformationProvider(); sourceReader.MoveToNext(); object targetEntityObj = Sage.Platform.EntityFactory.Create(templateManager.EntityManager.EntityType); transformationManager.FillEntity(sourceReader.CurrentRecord, targetEntityObj); //Need to make this more generic dupProvider = new LeadDuplicateProvider(); dupProvider.AdvancedOptions = templateManager.MatchAdvancedOptions; dupProvider.AdvancedOptions.AutoMerge = false; foreach (string filter in templateManager.MatchFilters) { dupProvider.SetActiveFilter(filter, true); } MatchEntitySource entitySource = new MatchEntitySource(templateManager.EntityManager.EntityType, targetEntityObj); dupProvider.EntitySource = entitySource; return(dupProvider); }
/// <summary> /// Saves the options. /// </summary> /// <param name="options">The options.</param> protected void SaveOptions() { MatchAdvancedOptions advancedOptions = GetOptions(); if (advancedOptions != null) { if (!String.IsNullOrEmpty(txtDuplicate_Low.Text)) { advancedOptions.DuplicateBottomThreshhold = Convert.ToInt32(txtDuplicate_Low.Text); } if (!String.IsNullOrEmpty(txtPossibleDuplicate_Low.Text)) { advancedOptions.PossibleDuplicateBottomThreshhold = Convert.ToInt32(txtPossibleDuplicate_Low.Text); } if (!String.IsNullOrEmpty(lblPossibleDuplicate_High.Text)) { advancedOptions.PossibleDuplicateTopThreshhold = Convert.ToInt32(lblPossibleDuplicate_High.Text); } if (!String.IsNullOrEmpty(lblNoDuplicate_High.Text)) { advancedOptions.NotDuplicateTopThreshhold = Convert.ToInt32(lblNoDuplicate_High.Text); } advancedOptions.IncludeStemming = chkUseStemming.Checked; advancedOptions.IncludePhonic = chkUsePhonic.Checked; advancedOptions.IncludeThesaurus = chkUseSynonym.Checked; advancedOptions.IncludeFuzzy = chkUseFuzzy.Checked; advancedOptions.FuzzyLevel = Convert.ToInt32(lbxFuzzyLevel.SelectedValue); } ImportManager importManager = Page.Session["importManager"] as ImportManager; if (importManager != null) { if (importManager.DuplicateProvider != null) { importManager.DuplicateProvider.AdvancedOptions = advancedOptions; } Page.Session["importManager"] = importManager; } IMatchDuplicateProvider dupProvider = Page.Session["duplicateProvider"] as IMatchDuplicateProvider; if (dupProvider != null) { dupProvider.AdvancedOptions = advancedOptions; Page.Session["duplicateProvider"] = dupProvider; } }
/// <summary> /// Gets the options. /// </summary> /// <returns></returns> protected MatchAdvancedOptions GetOptions() { ImportManager importManager = Page.Session["importManager"] as ImportManager; if (importManager != null && importManager.DuplicateProvider != null) { return(importManager.DuplicateProvider.AdvancedOptions); } IMatchDuplicateProvider dupProvider = Page.Session["duplicateProvider"] as IMatchDuplicateProvider; if (dupProvider != null) { return(dupProvider.AdvancedOptions); } return(DialogService.DialogParameters.ContainsKey("matchAdvancedOptions") ? DialogService.DialogParameters["matchAdvancedOptions"] as MatchAdvancedOptions : null); }
/// <summary> /// Gets the options. /// </summary> /// <returns></returns> protected MatchAdvancedOptions GetOptions() { ImportManager importManager = Page.Session["importManager"] as ImportManager; if (importManager != null && importManager.DuplicateProvider != null) { return(importManager.DuplicateProvider.AdvancedOptions); } IMatchDuplicateProvider dupProvider = Page.Session["duplicateProvider"] as IMatchDuplicateProvider; if (dupProvider != null) { return(dupProvider.AdvancedOptions); } object matchAdvancedOptions; return(DialogService.DialogParameters.TryGetValue("matchAdvancedOptions", out matchAdvancedOptions) ? matchAdvancedOptions as MatchAdvancedOptions : null); }
/// <summary> /// Resolves the duplicate. /// </summary> /// <param name="itemId">The item id.</param> private void ResolveDuplicate(string itemId) { try { IMatchDuplicateProvider dupProvider = GetDuplicateProvider(itemId); if (DialogService != null && dupProvider != null) { DialogService.SetSpecs(200, 200, 600, 800, "LeadSearchAndConvert", GetLocalResourceObject("Title.Resolve.Duplicate.ImportLead").ToString(), true); DialogService.DialogParameters.Add("duplicateProvider", dupProvider); DialogService.DialogParameters.Add("importHistoryItemId", itemId); DialogService.EntityType = typeof(IImportHistory); DialogService.EntityID = itemId; DialogService.ShowDialog(); chkShowDuplicates.Checked = false; } } catch (Exception exp) { var sSlxErrorId = ErrorHelper.GetNewLoggingId(); log.Error(ErrorHelper.AppendSlxErrorId("The call to ImportHistoryDuplicates.ResolveDuplicate() failed", sSlxErrorId), exp); throw new UserObservableApplicationException(String.Format(GetLocalResourceObject("LoadErrorMSG").ToString(), sSlxErrorId), exp); } }
/// <summary> /// Gets the options. /// </summary> /// <returns></returns> protected MatchAdvancedOptions GetOptions() { IMatchDuplicateProvider dupProvider = Page.Session["duplicateProvider"] as IMatchDuplicateProvider; return(dupProvider != null ? dupProvider.AdvancedOptions : null); }