예제 #1
0
    /// <summary>
    /// Gets the import manager.
    /// </summary>we
    /// <returns></returns>
    private ImportManager GetImportManager()
    {
        ImportManager importManager = Page.Session["importManager"] as ImportManager;

        if (importManager != null)
        {
            if (importProcessId.Value != importManager.ToString() && String.IsNullOrEmpty(txtImportFile.Value))
            {
                lblFileRequired.Visible = false;
                lblRequiredMsg.Visible  = false;
                importManager           = null;
            }
        }
        if (importManager == null)
        {
            try
            {
                LeadDuplicateProvider duplicateProvider = new LeadDuplicateProvider();
                txtCreateGroupName.Text = DateTime.Now.ToString();
                ImportService importService = new ImportService();
                importManager = importService.CreateImportManager(typeof(ILead));
                importManager.DuplicateProvider = duplicateProvider;
                importManager.MergeProvider     = new ImportLeadMergeProvider();
                importManager.ActionManager     = GetActionManager();
            }
            catch (Exception e)
            {
                divError.Style.Add(HtmlTextWriterStyle.Display, "inline");
                divMainContent.Style.Add(HtmlTextWriterStyle.Display, "none");
                lblError.Text = (e.Message);
                (Parent.Parent.FindControl("StartNavigationTemplateContainerID").FindControl("cmdStartButton")).Visible = false;
            }
        }
        return(importManager);
    }
    /// <summary>
    /// Transforms to target object.
    /// </summary>
    /// <param name="itemId">The item</param>
    /// <returns></returns>
    private IMatchDuplicateProvider GetDuplicateProvider(string itemId)
    {
        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
        IMatchDuplicateProvider 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);
    }
예제 #3
0
    /// <summary>
    /// Assigns the match filters.
    /// </summary>
    public void AssignMatchFilters()
    {
        ImportManager importManager = Page.Session["importManager"] as ImportManager;

        if (importManager != null)
        {
            if (Mode.Value == "")
            {
                Mode.Value = "Initialized";
                chkFindDupsInFile.Checked = importManager.Configuration.AdvancedOptions.IndexAfterInsert;
            }
            else
            {
                importManager.Configuration.AdvancedOptions.IndexAfterInsert = chkFindDupsInFile.Checked;
            }

            if (importManager.DuplicateProvider == null)
            {
                importManager.DuplicateProvider = new LeadDuplicateProvider();
            }
            LeadDuplicateProvider duplicateProvider = (LeadDuplicateProvider)importManager.DuplicateProvider;

            foreach (ListItem item in chklstFilters.Items)
            {
                if ((item.Selected) && (item.Enabled))
                {
                    duplicateProvider.SetActiveFilter(item.Value, true);
                }
                else
                {
                    duplicateProvider.SetActiveFilter(item.Value, false);
                }
            }
            duplicateProvider.AdvancedOptions.AutoMerge = chkAutoMergeDups.Checked;
            duplicateProvider.SearchAccount             = false;
            duplicateProvider.SearchContact             = (chkContacts.Checked);
            duplicateProvider.SearchLead = (chkLeads.Checked);

            if (lbxConflicts.SelectedIndex == 0)
            {
                importManager.MergeProvider.RecordOverwrite = MergeOverwrite.targetWins;
            }
            else
            {
                importManager.MergeProvider.RecordOverwrite = MergeOverwrite.sourceWins;
            }
            importManager.DuplicateProvider          = duplicateProvider;
            importManager.Options.CheckForDuplicates = chkCheckForDups.Checked;

            Page.Session["importManager"] = importManager;
        }
    }
예제 #4
0
    /// <summary>
    /// Gets the import manager.
    /// </summary>we
    /// <returns></returns>
    private ImportManager GetImportManager()
    {
        ImportManager importManager = Page.Session["importManager"] as ImportManager;

        if (importManager != null)
        {
            if (importProcessId.Value != importManager.ToString() && String.IsNullOrEmpty(txtImportFile.Value))
            {
                lblFileRequired.Visible = false;
                lblRequiredMsg.Visible  = false;
                importManager           = null;
            }
        }
        if (importManager == null)
        {
            try
            {
                LeadDuplicateProvider duplicateProvider = new LeadDuplicateProvider();
                txtCreateGroupName.Text = DateTime.Now.ToString();
                ImportService importService = new ImportService();
                importManager                   = importService.CreateImportManager(typeof(ILead));
                importProcessId.Value           = importManager.ToString();
                importManager.DuplicateProvider = duplicateProvider;
                importManager.MergeProvider     = new ImportLeadMergeProvider();
                importManager.ActionManager     = GetActionManager();
            }
            catch (Exception ex)
            {
                string sSlxErrorId = null;
                var    sMsg        = ErrorHelper.GetClientErrorHtmlMessage(ex, ref sSlxErrorId);
                if (!string.IsNullOrEmpty(sSlxErrorId))
                {
                    log.Error(
                        ErrorHelper.AppendSlxErrorId("The call to StepSelectFile.GetImportManager() failed", sSlxErrorId),
                        ex);
                }
                divError.Style.Add(HtmlTextWriterStyle.Display, "inline");
                divMainContent.Style.Add(HtmlTextWriterStyle.Display, "none");
                lblError.Text = sMsg;
                (Parent.Parent.FindControl("StartNavigationTemplateContainerID").FindControl("cmdStartButton")).Visible = false;
            }
        }
        return(importManager);
    }
    /// <summary>
    /// Transforms to target object.
    /// </summary>
    /// <param name="itemId">The item</param>
    /// <returns></returns>
    private IMatchDuplicateProvider GetDuplicateProvider(string itemId)
    {
        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
        IMatchDuplicateProvider 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;
    }
예제 #6
0
 /// <summary>
 /// Gets the import manager.
 /// </summary>we
 /// <returns></returns>
 private ImportManager GetImportManager()
 {
     ImportManager importManager = Page.Session["importManager"] as ImportManager;
     if (importManager != null)
     {
         if (importProcessId.Value != importManager.ToString() && String.IsNullOrEmpty(txtImportFile.Value))
         {
             lblFileRequired.Visible = false;
             lblRequiredMsg.Visible = false;
             importManager = null;
         }
     }
     if (importManager == null)
     {
         try
         {
             LeadDuplicateProvider duplicateProvider = new LeadDuplicateProvider();
             txtCreateGroupName.Text = DateTime.Now.ToString();
             ImportService importService = new ImportService();
             importManager = importService.CreateImportManager(typeof(ILead));
             importManager.DuplicateProvider = duplicateProvider;
             importManager.MergeProvider = new ImportLeadMergeProvider();
             importManager.ActionManager = GetActionManager();
         }
         catch (Exception e)
         {
             divError.Style.Add(HtmlTextWriterStyle.Display, "inline");
             divMainContent.Style.Add(HtmlTextWriterStyle.Display, "none");
             lblError.Text = (e.Message);
             (Parent.Parent.FindControl("StartNavigationTemplateContainerID").FindControl("cmdStartButton")).Visible = false;
         }
     }
     return importManager;
 }
    private void InitializeView()
    {
        ImportManager importManager = Page.Session["importManager"] as ImportManager;

        if (importManager == null)
        {
            return;
        }
        importManager.Options.CheckForDuplicates = chkCheckForDups.Checked;
        if (Mode.Value == "")
        {
            Mode.Value = "Initialized";
            chkFindDupsInFile.Checked = importManager.Configuration.AdvancedOptions.IndexAfterInsert;
        }
        else
        {
            importManager.Configuration.AdvancedOptions.IndexAfterInsert = chkFindDupsInFile.Checked;
        }

        if (chklstFilters.Items.Count <= 0)
        {
            if (importManager.DuplicateProvider == null)
            {
                importManager.DuplicateProvider = new LeadDuplicateProvider();
            }
            LeadDuplicateProvider duplicateProvider = (LeadDuplicateProvider)importManager.DuplicateProvider;
            foreach (MatchPropertyFilterMap propertyFilter in duplicateProvider.GetFilters())
            {
                ListItem item = new ListItem();
                //If resource does not exist then use the xml value. Item is prefixed with "Filter" to better identify resource items
                item.Text = GetLocalResourceObject("Filter." + propertyFilter.PropertyName) != null &&
                            GetLocalResourceObject("Filter." + propertyFilter.PropertyName).ToString() != ""
                                ? GetLocalResourceObject("Filter." + propertyFilter.PropertyName).ToString()
                                : propertyFilter.DisplayName;

                item.Value    = propertyFilter.PropertyName;
                item.Selected = propertyFilter.Enabled;
                item.Enabled  = IsFilterMapped(importManager, propertyFilter.PropertyName);
                chklstFilters.Items.Add(item);
            }
        }
        else
        {
            LeadDuplicateProvider duplicateProvider = (LeadDuplicateProvider)importManager.DuplicateProvider;
            if (duplicateProvider != null)
            {
                foreach (ListItem item in chklstFilters.Items)
                {
                    item.Enabled = IsFilterMapped(importManager, item.Value);
                    MatchPropertyFilterMap propertyFilter = duplicateProvider.GetPropertyFilter(item.Value);
                    if (propertyFilter != null && ((!item.Enabled) || (!propertyFilter.Enabled)))
                    {
                        item.Selected = false;
                    }
                }
            }
            else
            {
                foreach (ListItem item in chklstFilters.Items)
                {
                    item.Enabled = false;
                }
            }
        }
    }
예제 #8
0
 /// <summary>
 /// Gets the import manager.
 /// </summary>we
 /// <returns></returns>
 private ImportManager GetImportManager()
 {
     ImportManager importManager = Page.Session["importManager"] as ImportManager;
     if (importManager != null)
     {
         if (importProcessId.Value != importManager.ToString() && String.IsNullOrEmpty(txtImportFile.Value))
         {
             lblFileRequired.Visible = false;
             lblRequiredMsg.Visible = false;
             importManager = null;
         }
     }
     if (importManager == null)
     {
         try
         {
             LeadDuplicateProvider duplicateProvider = new LeadDuplicateProvider();
             txtCreateGroupName.Text = DateTime.Now.ToString();
             ImportService importService = new ImportService();
             importManager = importService.CreateImportManager(typeof(ILead));
             importProcessId.Value = importManager.ToString();
             importManager.DuplicateProvider = duplicateProvider;
             importManager.MergeProvider = new ImportLeadMergeProvider();
             importManager.ActionManager = GetActionManager();
         }
         catch (Exception ex)
         {
             string sSlxErrorId = null;
             var sMsg = ErrorHelper.GetClientErrorHtmlMessage(ex, ref sSlxErrorId);
             if (!string.IsNullOrEmpty(sSlxErrorId))
             {
                 log.Error(
                     ErrorHelper.AppendSlxErrorId("The call to StepSelectFile.GetImportManager() failed", sSlxErrorId),
                     ex);
             }
             divError.Style.Add(HtmlTextWriterStyle.Display, "inline");
             divMainContent.Style.Add(HtmlTextWriterStyle.Display, "none");
             lblError.Text = sMsg;
             (Parent.Parent.FindControl("StartNavigationTemplateContainerID").FindControl("cmdStartButton")).Visible = false;
         }
     }
     return importManager;
 }