/// <summary> /// Handles the SelectedIndexChanged event of the cboTemplates control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.EventArgs"/> instance containing the event data.</param> protected void cboTemplates_SelectedIndexChanged(object sender, EventArgs e) { ImportManager importManager = Page.Session["importManager"] as ImportManager; if (!cboTemplates.SelectedValue.ToString().Equals(GetLocalResourceObject("cboTemplates.None.Item").ToString())) { string errorMessage = String.Empty; //Owner and Lead Source values are saved into the template and we don't necessarily want to overwrite these values so we'll //reassign them after the template is done loading. ImportTargetProperty tpOwner = importManager.EntityManager.GetEntityProperty("Owner"); String ownerId = tpOwner.DefaultValue.ToString(); ImportTargetProperty tpLeadSource = importManager.EntityManager.GetEntityProperty("LeadSource"); String leadSourceId = tpLeadSource.DefaultValue.ToString(); if (!importManager.AddImportMapsFromTemplate(importManager, cboTemplates.SelectedItem.Value, out errorMessage)) { DialogService.ShowMessage(errorMessage); } else { importManager.Options.Template = cboTemplates.SelectedItem.Text; SetDefaultTargetPropertyValue("Owner", ownerId, importManager); SetDefaultTargetPropertyValue("LeadSource", leadSourceId, importManager); Page.Session["importManager"] = importManager; } } }
/// <summary> /// Sets the state of the action. /// </summary> private void SetActionState() { ImportManager importManager = GetImportManager(); Action = importManager.ActionManager.GetAction("AddResponse") as ActionAddResponse; Action.HydrateChanges(); if (Action == null) { return; } if (!Action.Initialized) { dtpResponseDate.DateTimeValue = DateTime.UtcNow; pklResponseStatus.PickListValue = GetLocalResourceObject("DefaultResponseStatus").ToString(); ImportTargetProperty tpLeadSource = importManager.EntityManager.GetEntityProperty("LeadSource"); if (tpLeadSource != null && !String.IsNullOrEmpty(tpLeadSource.DefaultValue.ToString())) { ILeadSource ls = EntityFactory.GetById <ILeadSource>(tpLeadSource.DefaultValue); if (ls != null) { lueResponseLeadSource.LookupResultValue = ls; lueResponseLeadSource.Text = ls.Description; } } txtComments.Text = Action.Response.Comments; pklResponseMethod.PickListValue = Action.Response.ResponseMethod; lueCampaign.LookupResultValue = Action.Response.Campaign; lbxStages.SelectedValue = Action.Response.Stage; pklInterest.PickListValue = Action.Response.Interest; pklInterestLevel.PickListValue = Action.Response.InterestLevel; if (Mode.Value == "") { Action.Initialized = true; Mode.Value = "ADD"; } } else { if (!String.IsNullOrEmpty(Action.Response.LeadSource)) { ILeadSource ls = EntityFactory.GetById <ILeadSource>(Action.Response.LeadSource); if (ls != null) { lueResponseLeadSource.LookupResultValue = ls; lueResponseLeadSource.Text = ls.Description; } } txtComments.Text = Action.Response.Comments; dtpResponseDate.DateTimeValue = Action.Response.ResponseDate; pklResponseStatus.PickListValue = Action.Response.Status; pklResponseMethod.PickListValue = Action.Response.ResponseMethod; lueCampaign.LookupResultValue = Action.Response.Campaign; lbxStages.SelectedValue = Action.Response.Stage; pklInterest.PickListValue = Action.Response.Interest; pklInterestLevel.PickListValue = Action.Response.InterestLevel; } }
/// <summary> /// Sets the default value for the EntityProperty specified. /// </summary> /// <param name="property">The property.</param> /// <param name="value">The value.</param> private void SetDefaultTargetPropertyValue(string property, string value, ImportManager importManager) { ImportTargetProperty prop = importManager.EntityManager.GetEntityProperty(property); if (prop != null) { prop.DefaultValue = value; Page.Session["importManager"] = importManager; } }
/// <summary> /// Sets the import source value. /// </summary> private void SetImportSourceValue() { ImportManager importManager = Page.Session["importManager"] as ImportManager; ImportTargetProperty prop = importManager.EntityManager.GetEntityProperty("ImportSource"); if (prop != null) { string importSource = Path.GetFileName(importManager.SourceFileName); if (importSource.Length > 24) { importSource = importSource.Substring(0, 24); } prop.DefaultValue = importSource; importManager.TargetPropertyDefaults.Add(prop); Page.Session["importManager"] = importManager; } }
/// <summary> /// Gets and Sets the default target properties. /// </summary> /// <param name="importManager">The import manager.</param> private void SetDefaultTargetProperties(ImportManager importManager) { if (importManager.TargetPropertyDefaults == null || importManager.TargetPropertyDefaults.Count == 0) { ImportTargetProperty tpOwner = importManager.EntityManager.GetEntityProperty("Owner"); ImportTargetProperty tpLeadSource = importManager.EntityManager.GetEntityProperty("LeadSource"); ImportTargetProperty tpImportSource = importManager.EntityManager.GetEntityProperty("ImportSource"); if (tpOwner != null) { string ownwerId = "SYST00000001"; IOwner owner = ImportRules.GetDefaultOwner(); if (owner != null) { ownwerId = owner.Id.ToString(); } tpOwner.DefaultValue = ownwerId; importManager.TargetPropertyDefaults.Add(tpOwner); ownDefaultOwner.LookupResultValue = ownwerId; } if (tpLeadSource != null) { tpLeadSource.DefaultValue = String.Empty; importManager.TargetPropertyDefaults.Add(tpLeadSource); } } else { foreach (ImportTargetProperty tp in importManager.TargetPropertyDefaults) { if (tp.PropertyId.Equals("Owner")) { ownDefaultOwner.LookupResultValue = EntityFactory.GetById <IOwner>(tp.DefaultValue); } if (tp.PropertyId.Equals("LeadSource")) { lueLeadSource.LookupResultValue = tp.DefaultValue.ToString(); } } } }