/// <summary> /// Adds the contact to account. /// </summary> /// <param name="sourceLead">The source lead.</param> private void AddContactToAccount(ILead sourceLead, string accountID) { if (accountID != null) { IList <IAccount> selectedAccount = EntityFactory.GetRepository <IAccount>().FindByProperty("Id", accountID); if (selectedAccount != null) { foreach (IAccount account in selectedAccount) { IContact newContact = EntityFactory.Create <IContact>(); sourceLead.ConvertLeadToContact(newContact, account, "Add Contact to this Account"); sourceLead.ConvertLeadAddressToContactAddress(newContact); sourceLead.ConvertLeadAddressToAccountAddress(account); sourceLead.MergeLeadWithAccount(account, "ACCOUNTWINS", newContact); account.Save(); newContact.Save(); Response.Redirect(string.Format("Contact.aspx?entityId={0}", (newContact.Id))); } } } }
/// <summary> /// Handles the CheckedChanged event of the chkQualificationSelected* controls, used to update the corresponding LeadQualification entity. /// </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 ChkQualificationSelectedCheckedChanged(object sender, EventArgs e) { CheckBox cb = sender as CheckBox; if (cb != null) { string Id = cb.Attributes[cQualificationId]; if (!string.IsNullOrEmpty(Id)) { IQualification qualification = EntityFactory.GetById <IQualification>(Id); if (qualification != null) { ILead lead = GetCurrentLead(); if (lead != null) { ILeadQualification lead_qual = GetLeadQualification(lead, qualification); if (lead_qual != null) { lead_qual.Checked = cb.Checked; lead_qual.Save(); } else { ILeadQualification new_qual = EntityFactory.Create <ILeadQualification>(); new_qual.Lead = lead; new_qual.Qualification = qualification; new_qual.Checked = cb.Checked; new_qual.Save(); } } } } } }
/// <summary> /// Handles the TextChanged event of the txtQualificationDescription* controls, used to update the corresponding LeadQualification entity. /// </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 txtQualificationDescription_TextChanged(object sender, EventArgs e) { TextBox tb = sender as TextBox; if (tb != null) { string Id = tb.Attributes[cQualificationId]; if (!string.IsNullOrEmpty(Id)) { IQualification qualification = EntityFactory.GetById <IQualification>(Id); if (qualification != null) { ILead lead = GetCurrentLead(); if (lead != null) { ILeadQualification lead_qual = GetLeadQualification(lead, qualification); if (lead_qual != null) { lead_qual.Notes = tb.Text; lead_qual.Save(); } else { ILeadQualification new_qual = EntityFactory.Create <ILeadQualification>(); new_qual.Lead = lead; new_qual.Qualification = qualification; new_qual.Notes = tb.Text; new_qual.Save(); } } } } } }
// Example of target method signature public static void MyConvertLeadToAccount(ILead lead, IAccount account) { //=============================================================== // This code doesn't work.... added it directly to LeadsearchandConvert //========================================================================== //foreach (ILeadWebsite tmpWebsite in lead.LeadWebsites) //{ // // Create Account Additional Website Record // Sage.Entity.Interfaces.IAccountWebsite Acctwebsite = Sage.Platform.EntityFactory.Create<Sage.Entity.Interfaces.IAccountWebsite >(); // Acctwebsite.Account = account; // Acctwebsite.Notes = tmpWebsite.Notes ; // Acctwebsite.WebAddress = tmpWebsite.WebAddress; // try // { // Acctwebsite.Save(); // } // catch (Exception) // { // //Exception But Continue // } //} }
private void UpdateContactOrLeadInfo(bool selectedContact) { if (selectedContact) { Activity.LeadId = null; } else { Activity.ContactId = null; Activity.OpportunityId = null; Activity.TicketId = null; Activity.AccountId = null; } if (!string.IsNullOrEmpty(Activity.LeadId)) { ILead lead = EntityFactory.GetById <ILead>(Activity.LeadId); if (lead != null) { if (string.IsNullOrEmpty(Activity.AccountName)) { Activity.AccountName = lead.Company; } Activity.ContactName = lead.LeadNameLastFirst; } } }
public static void SLXSocial_OnLeadCreate(ILead lead) { var appCtx = Sage.Platform.Application.ApplicationContext.Current.Services.Get <Sage.Platform.Application.IContextService>(); if (appCtx.HasContext("NewEntityParameters")) { var entityParams = appCtx["NewEntityParameters"] as System.Collections.Generic.Dictionary <String, String>; if (entityParams != null && entityParams.ContainsKey("LeadNotes")) { lead.Notes = (String)entityParams["LeadNotes"]; lead.BusinessDescription = (String)entityParams["LeadBusinessDescription"]; lead.WebAddress = (String)entityParams["LeadUrl"]; String name = (String)entityParams["LeadName"]; String[] nameParts = name.Split(new char[] { ' ' }, 2); if (nameParts.Length == 2) { lead.FirstName = nameParts[0]; lead.LastName = nameParts[1]; } else { lead.LastName = name; } lead.Company = name; } appCtx.RemoveContext("NewEntityParameters"); } }
private void SetTACODefaultsFromParameters() { Activity.AccountId = GetParam("aid"); if (GetParam("cid") != null) { Activity.ContactId = GetParam("cid"); } if (GetParam("oid") != null) { Activity.OpportunityId = GetParam("oid"); } if (GetParam("tid") != null) { Activity.TicketId = GetParam("tid"); } if (GetParam("lid") != null) { Activity.LeadId = GetParam("lid"); ILead lead = EntityFactory.GetById <ILead>(Activity.LeadId); if (lead != null) { Activity.AccountName = lead.Company; } SetDivVisible(VisibleDiv.Lead); } }
public void insert(ILead newLead) { var lead = newLead.getLeadDto(); using (IDbConnection db = new SqlConnection(ConfigurationManager.ConnectionStrings["SqlServerConnString"].ConnectionString)) { string sqlQuery = @"Insert INTO Lead (Firstname, Surname, TitleId, IdentityNo , ContactNo, EmailAddress) Values(@FirstName, @Surname, @TitleId, @IdentityNo, @ContactNo, @EmailAddress); SELECT CAST(SCOPE_IDENTITY() as bigint)"; var id = db.ExecuteScalar(sqlQuery, new { FirstName = lead.firstName, Surname = lead.surname, TitleId = lead.title, IdentityNo = lead.identityNo, EmailAddress = lead.emailAddress, ContactNo = lead.contactNo }); lead.id = long.Parse(id.ToString()); //save lead comsmethod opt-ins insertLeadComs(lead.id, lead); } }
// Example of target method signature public static void MyConvertLeadToAccount(ILead lead, IAccount account) { //=============================================================== // This code doesn't work.... added it directly to LeadsearchandConvert //========================================================================== //foreach (ILeadWebsite tmpWebsite in lead.LeadWebsites) //{ // // Create Account Additional Website Record // Sage.Entity.Interfaces.IAccountWebsite Acctwebsite = Sage.Platform.EntityFactory.Create<Sage.Entity.Interfaces.IAccountWebsite >(); // Acctwebsite.Account = account; // Acctwebsite.Notes = tmpWebsite.Notes ; // Acctwebsite.WebAddress = tmpWebsite.WebAddress; // try // { // Acctwebsite.Save(); // } // catch (Exception) // { // //Exception But Continue // } //} }
protected void btnConvert_Click(object sender, EventArgs e) { IContact newContact = EntityFactory.Create <IContact>(); ILeadHistory newHistory = EntityFactory.Create <ILeadHistory>(); ILeadAddressHistory newAddressHistory = EntityFactory.Create <ILeadAddressHistory>(); newAddressHistory.LeadHistory = newHistory; newHistory.Addresses.Add(newAddressHistory); ILead curLead = BindingSource.Current as ILead; if (curLead == null) { return; } accountID = ((IAccount)dtsAccounts.Current).Id.ToString(); if (accountID != null) { var account = EntityFactory.GetById <IAccount>(accountID); if (account != null) { curLead.ConvertLeadToContact(newContact, account, GetLocalResourceObject("chkAddContacts.Text").ToString()); curLead.ConvertLeadAddressToContactAddress(newContact); curLead.ConvertLeadAddressToAccountAddress(account); curLead.MergeLeadWithAccount(account, GetLocalResourceObject("ExistingAccountwins.Text").ToString(), newContact); account.Save(); Response.Redirect(string.Format("Contact.aspx?entityId={0}", (newContact.Id))); } } }
public void SendLeadSyncShouldSendAPostToConversions() { _httpClient.PostAsJsonAsync("conversions", Arg.Any <HttpContent>()).ReturnsForAnyArgs(new HttpResponseMessage(HttpStatusCode.OK)); ILead lead = _lead; _sut.SendLeadSync(lead); _httpClient.Received().SendAsync(Arg.Is <HttpRequestMessage>(h => h.RequestUri.ToString() == RdStationApiClient.CONVERSION_URL), Arg.Any <CancellationToken>()); }
/// <summary> /// Loads the marketing. /// </summary> private void LoadResponses() { ILead lead = EntityFactory.GetRepository <ILead>().Get(EntityContext.EntityID); if (lead != null) { IList <ITargetResponse> responses = EntityFactory.GetRepository <ITargetResponse>().FindByProperty("Lead.Id", lead.Id); grdLeadResponses.DataSource = responses; grdLeadResponses.DataBind(); } }
/// <summary> /// Gets the current Lead entity. /// </summary> /// <returns></returns> protected ILead GetCurrentLead() { ILead lead = null; object obj = BindingSource.Current; if (obj != null) { lead = (obj as ILead); } return(lead); }
public static void CanSendLeadToBD(ILead lead, out Boolean result) { Boolean blnValidFlag = true; //============================ // http://screencast.com/t/FJAORdM4 // Requirements from Kevin //======================================= if (lead.FirstName == null || lead.FirstName == "") { blnValidFlag = false; } //================================================ if (lead.LastName == null || lead.LastName == "") { blnValidFlag = false; } //================================================ if (lead.Company == null || lead.Company == "") { blnValidFlag = false; } //================================================ if (lead.WorkPhone == null || lead.WorkPhone == "") { blnValidFlag = false; } //================================================ // Lead Status //================================================ if (lead.CfxLeadQualityCode == null || lead.CfxLeadQualityCode == "") { blnValidFlag = false; } //================================================ if (lead.CfxCompetitor == null || lead.CfxCompetitor == "") { blnValidFlag = false; } //================================================ if (lead.CFXBuy != null || lead.CfxSell != null) { } else { blnValidFlag = false; } result = blnValidFlag; }
protected void LoadLeadGrid() { ILead curLead = BindingSource.Current as ILead; if (curLead != null) { List <ILead> leadlist = new List <ILead>(); leadlist.Add(curLead); dtsLeads.setCustomData(leadlist); } }
private static void StoreLeadInLocalCache(ILead lead) { if (lead.Id <= 0) { return; } var cacheKey = String.Format(LeadCacheKeyTempl, lead.Id); LocalCache.Put(cacheKey, lead, LocalCacheLeadSecsToLive); }
/// <summary> /// Adds the lead entity to data source. /// </summary> private void AddLeadEntityToDataSource(DataTable dataTable, MatchResultItem resultItem, string type) { try { ILead lead = resultItem.Data as ILead; dataTable.Rows.Add(lead.Id.ToString(), "Lead", resultItem.Score, type, lead.Company, lead.FirstName, lead.LastName, lead.Title, lead.Email, lead.Address.LeadCtyStZip, lead.WorkPhone); } catch { } }
/// <summary> /// Handles the SelectedIndexChanged event of the cboQualifications 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 cboQualifications_SelectedIndexChanged(object sender, EventArgs e) { ListItem item = cboQualifications.SelectedItem; if (item != null) { using (NHibernate.ISession session = new SessionScopeWrapper()) { ILead lead = GetCurrentLead(); if (lead != null) { IQualificationCategory currentCategory = lead.QualificationCategory; if (currentCategory != null) { IList <IQualification> qualifications = GetQualifications(currentCategory); if (qualifications != null) { IList <ILeadQualification> lead_qualifications = GetLeadQualifications(currentCategory, qualifications, lead); if (lead_qualifications != null) { if (lead_qualifications.Count > 0) { string confirmation = htxtConfirmation.Value; if (!string.IsNullOrEmpty(confirmation)) { const string cFalse = "false"; if (confirmation.ToLower() == cFalse) { cboQualifications.SelectedValue = currentCategory.Id.ToString(); return; } } foreach (ILeadQualification lead_qual in lead_qualifications) { lead_qual.Delete(); } lead_qualifications.Clear(); } } } } IQualificationCategory category = EntityFactory.GetById <IQualificationCategory>(item.Value); if (category != null) { lead.QualificationCategory = category; session.Update(lead); } } } } }
private bool ValuesSet(EntityHistory hist) { switch (hist.EntityType.Name) { case "IAccount": IAccount account = EntityFactory.GetById <IAccount>(hist.EntityId.ToString()); Account.LookupResultValue = account; Contact.LookupResultValue = GetPrimaryContact(account.Contacts); return(true); case "IContact": IContact contact = EntityFactory.GetById <IContact>(hist.EntityId.ToString()); Contact.LookupResultValue = contact; Account.LookupResultValue = contact.Account; return(true); case "IOpportunity": IOpportunity opportunity = EntityFactory.GetById <IOpportunity>(hist.EntityId.ToString()); Opportunity.LookupResultValue = opportunity; Account.LookupResultValue = opportunity.Account; foreach (IOpportunityContact oppContact in opportunity.Contacts) { if (oppContact.IsPrimary.HasValue) { if ((bool)oppContact.IsPrimary) { Contact.LookupResultValue = oppContact.Contact; break; } } } return(true); case "ITicket": ITicket ticket = EntityFactory.GetById <ITicket>(hist.EntityId.ToString()); Ticket.LookupResultValue = ticket; Account.LookupResultValue = ticket.Account; Contact.LookupResultValue = ticket.Contact; return(true); case "ILead": SetDivVisible(VisibleDiv.Lead); ILead lead = EntityFactory.GetById <ILead>(hist.EntityId.ToString()); LeadId.LookupResultValue = lead; Company.Text = lead.Company; return(true); } return(false); }
void LeadId_LookupResultValueChanged(object sender, EventArgs e) { string leadID = LeadId.LookupResultValue.ToString(); ILead lead = EntityFactory.GetById <ILead>(leadID); if (lead != null) { Activity.ContactId = null; Activity.OpportunityId = null; Activity.TicketId = null; Activity.AccountId = null; Activity.LeadName = lead.LeadNameLastFirst; Activity.ContactName = lead.LeadNameLastFirst; Activity.AccountName = lead.Company; } }
/// <summary> /// Gets the LeadQualification entity based on the parameters. /// </summary> /// <param name="lead">The Lead.</param> /// <param name="qualification">The Qualification.</param> /// <returns></returns> protected static ILeadQualification GetLeadQualification(ILead lead, IQualification qualification) { using (new SessionScopeWrapper()) { IRepository <ILeadQualification> rep = EntityFactory.GetRepository <ILeadQualification>(); IQueryable qry = (IQueryable)rep; IExpressionFactory ep = qry.GetExpressionFactory(); ICriteria crt = qry.CreateCriteria(); IJunction all = ep.Conjunction(); all.Add(ep.Eq("Lead", lead)); all.Add(ep.Eq("Qualification", qualification)); crt.Add(all); ILeadQualification result = crt.UniqueResult <ILeadQualification>(); return(result); } }
/// <summary> /// Loads the source snapshot. /// </summary> private void LoadSourceSnapshot() { if (BindingSource.Current != null) { ILead lead = BindingSource.Current as ILead; lblLead.Text = !String.IsNullOrEmpty(lead.LastName) ? String.Format("{0}, {1}", lead.LastName, lead.FirstName) : lead.FirstName; lblValueCompany.Text = lead.Company; if (lead.Address != null) { lblAddress.Text = lead.Address.FormatFullLeadAddress(); } lblValueEmail.Text = lead.Email; lblValueTitle.Text = lead.Title; phnWorkPhone.Text = lead.WorkPhone; lblValueWeb.Text = lead.WebAddress; } }
/// <summary> /// Handles the OnRowCommand event of the grdAccountMatches control. /// </summary> /// <param name="sender">The source of the event.</param> /// <param name="e">The <see cref="System.Web.UI.WebControls.GridViewCommandEventArgs"/> instance containing the event data.</param> protected void grdAccountMatches_OnRowCommand(object sender, GridViewCommandEventArgs e) { if (e.CommandName.Equals("Add Contact")) { int rowIndex = Convert.ToInt32(e.CommandArgument); string entityId = grdAccountMatches.DataKeys[rowIndex].Values[0].ToString(); if (entityId != null) { if (DuplicateProvider.EntitySource.EntityData != null) { ILead sourceLead = DuplicateProvider.EntitySource.EntityData as ILead; AddContactToAccount(sourceLead, entityId); } } } }
/// <summary> /// Loads the collection of QualificationCategory entities and assigns the collection to the cboQualifications control. /// </summary> protected void LoadQualificationCategories() { ILead lead = GetCurrentLead(); if (Visible && !IsPostBack) { cboQualifications.Items.Clear(); cboQualifications.AppendDataBoundItems = true; IList <IQualificationCategory> list = GetQualificationCategories(); bool isSelected; ListItem listItem = new ListItem { Text = GetLocalResourceObject("qualification_Category_None").ToString(), Value = String.Empty, Selected = lead.QualificationCategory == null }; cboQualifications.Items.Add(listItem); foreach (IQualificationCategory qualificationCategory in list) { isSelected = lead.QualificationCategory != null && (lead.QualificationCategory.Id.ToString() == qualificationCategory.Id.ToString()); listItem = new ListItem { Text = qualificationCategory.CategoryName, Value = qualificationCategory.Id.ToString(), Selected = isSelected }; cboQualifications.Items.Add(listItem); } } else if (Visible) { if (lead.QualificationCategory != null) { ListItem item = cboQualifications.Items.FindByValue(lead.QualificationCategory.Id.ToString()); if (item != null) { cboQualifications.SelectedValue = item.Value; } } else { cboQualifications.SelectedValue = String.Empty; } } }
/// <summary> /// Adds the contact to account. /// </summary> /// <param name="sourceLead">The source lead.</param> /// <param name="accountID">The account ID.</param> private void AddContactToAccount(ILead sourceLead, string accountID) { if (accountID != null) { var account = EntityFactory.GetById <IAccount>(accountID); if (account != null) { IContact newContact = EntityFactory.Create <IContact>(); sourceLead.ConvertLeadToContact(newContact, account, "Add Contact to this Account"); sourceLead.ConvertLeadAddressToContactAddress(newContact); sourceLead.ConvertLeadAddressToAccountAddress(account); sourceLead.MergeLeadWithAccount(account, "ACCOUNTWINS", newContact); account.Contacts.Add(newContact); account.Save(); Response.Redirect(String.Format("Contact.aspx?entityId={0}", (newContact.Id))); } } }
private async Task <int> UpsertLeadAsync(ILead lead) { using (var conn = StoneAgeDbConn()) { const string returnPropName = "ReturnVal"; var arguments = new DynamicParameters(lead); arguments.Add(returnPropName, dbType: DbType.Int32, direction: ParameterDirection.Output); await conn.ExecuteAsync("FCCWeb.UpsertStagedLead", arguments, commandType : CommandType.StoredProcedure) .ConfigureAwait(false); return(arguments.Get <int>(returnPropName)); } }
public async Task <ILead> SaveAsync(ILead lead) { var currentLead = RetrieveCurrentLead(lead.Id); if (currentLead != null) { // Sync-up server-side maintained state props ((ILeadState)lead) .SetSuccessfulPlacementCheck(currentLead.SuccessfulPlacementCheck) .SetSuccessfulLeadSubmission((currentLead.SuccessfulLeadSubmission)) .SetIpAddress(currentLead.IpAddress); } var id = await UpsertLeadAsync(lead).ConfigureAwait(false); // Set the Id on this lead and then store it in local cache StoreLeadInLocalCache(lead.SetId(id)); return(lead); }
protected void LeadId_LookupResultValueChanged(object sender, EventArgs e) { string leadID = LeadId.LookupResultValue.ToString(); ILead lead = EntityFactory.GetById <ILead>(leadID); if (lead != null) { Activity.ContactId = null; Activity.OpportunityId = null; Activity.TicketId = null; Activity.AccountId = null; Activity.LeadName = lead.LeadNameLastFirst; Activity.AccountName = lead.Company; Activity.PhoneNumber = (lead.WorkPhone ?? lead.TollFree); } else { //lead was blanked Activity.LeadName = null; Activity.AccountName = null; } }
public static void SLXSocial_OnLeadCreate( ILead lead) { var appCtx = Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Application.IContextService>(); if(appCtx.HasContext("NewEntityParameters")){ var entityParams = appCtx["NewEntityParameters"] as System.Collections.Generic.Dictionary<String,String>; if(entityParams != null && entityParams.ContainsKey("LeadNotes")) { lead.Notes = (String)entityParams["LeadNotes"]; lead.BusinessDescription = (String)entityParams["LeadBusinessDescription"]; lead.WebAddress = (String)entityParams["LeadUrl"]; String name = (String)entityParams["LeadName"]; String[] nameParts = name.Split(new char[] { ' ' }, 2); if(nameParts.Length == 2) { lead.FirstName = nameParts[0]; lead.LastName = nameParts[1]; } else { lead.LastName = name; } lead.Company = name; } appCtx.RemoveContext("NewEntityParameters"); } }
private void LoadContactGrid() { bool conditionMet = false; string company = String.Empty; string firstName = String.Empty; string lastName = String.Empty; string title = String.Empty; string email = String.Empty; string cityStatePostal = String.Empty; string workPhone = String.Empty; string webAddress = String.Empty; ILead lead = BindingSource.Current as ILead; if (lead != null) { company = lead.Company; firstName = lead.FirstName; lastName = lead.LastName; title = lead.Title; email = lead.Email; cityStatePostal = lead.Address.LeadCtyStZip; workPhone = lead.WorkPhone; webAddress = lead.WebAddress; } IRepository <IContact> contactList = EntityFactory.GetRepository <IContact>(); IQueryable qryContact = (IQueryable)contactList; IExpressionFactory exp = qryContact.GetExpressionFactory(); ICriteria criteria = qryContact.CreateCriteria(); criteria.CreateAlias("Address", "ad"); IList <IExpression> expression = new List <IExpression>(); if (chkCompany.Checked && company != null) { expression.Add(GetExpression(exp, "AccountName", company)); conditionMet = true; } if (chkFirstName.Checked && firstName != null) { expression.Add(GetExpression(exp, "FirstName", firstName)); conditionMet = true; } if (chkLastName.Checked && lastName != null) { expression.Add(GetExpression(exp, "LastName", lastName)); conditionMet = true; } if (chkTitle.Checked && title != null) { expression.Add(GetExpression(exp, "Title", title)); conditionMet = true; } if (chkEmail.Checked && email != null) { expression.Add(GetExpression(exp, "Email", email)); conditionMet = true; } if (chkCityStatePostal.Checked && cityStatePostal != null) { expression.Add(GetExpression(exp, "ad.CityStateZip", cityStatePostal)); conditionMet = true; } if (chkWorkPhone.Checked && workPhone != null) { expression.Add(GetExpression(exp, "WorkPhone", workPhone)); conditionMet = true; } if (chkWebAddress.Checked && webAddress != null) { expression.Add(GetExpression(exp, "WebAddress", webAddress)); conditionMet = true; } IJunction junction = rdbMatchAll.Checked ? exp.Conjunction() : exp.Disjunction(); foreach (IExpression e in expression) { junction.Add(e); } criteria.Add(junction); if (conditionMet.Equals(true)) { IList list = criteria.List(); dtsContacts.setCustomData(list); lblContactMatches.Text = String.Format(GetLocalResourceObject("PotentialContactMatches_rsc").ToString(), list.Count); } }
public static void cfxGetLatestDupeAuditStatus(ILead lead, out String result) { string strResult = string.Empty; string LastStatus = GetField<string>("STATUS", "CFXDUPECHECKAUDIT", "LEADID ='" + lead.Id.ToString() + "' order by CREATEDATE desc"); if (LastStatus == null) { strResult = "None"; } else { strResult = LastStatus; } result = strResult; }
public void CreateContactLeadSource(ILead lead, IContact contact) { if (lead.LeadSource != null) { var contactLeadSource = EntityFactory.Create<IContactLeadSource>(); contactLeadSource.Contact = contact; contactLeadSource.LeadSource = lead.LeadSource; contactLeadSource.LeadDate = DateTime.UtcNow; contact.LeadSources.Add(contactLeadSource); } }
/// <summary> /// Converts the lead to new account and contact. /// </summary> /// <param name="lead">The lead.</param> /// <param name="createOpportunity">if set to <c>true</c> [create opportunity].</param> /// <param name="options">The options.</param> private void ConvertLeadToNewAccountAndContact(ILead lead, bool createOpportunity, string options) { if (lead.LegalName != null) { string qry = "select LegalCompanyName from LegalMaster where LegalCompanyName ='" + lead.LegalName + "'"; Sage.Platform.Data.IDataService service1 = Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Data.IDataService>(); System.Data.OleDb.OleDbConnection conObj = new System.Data.OleDb.OleDbConnection(service1.GetConnectionString()); System.Data.OleDb.OleDbDataAdapter dataAdapterObj = new System.Data.OleDb.OleDbDataAdapter(qry, conObj); System.Data.DataTable dt = new System.Data.DataTable(); dataAdapterObj.Fill(dt); if (dt.Rows.Count > 0) { lblmsg.Text = lead.LegalName + ": legal Name is already exists"; return; } } //if (ddLSalesProcess.SelectedIndex > 0 || chkCreateOpportunity.Checked == false) //{ var keyGen = new SalesLogixEntityKeyGenerator(); string key = keyGen.GenerateIds(typeof(IContact), 1).FirstOrDefault(); IContact contact = EntityFactory.Create<IContact>(); ((IAssignableId)contact).Id = key; IAccount account = EntityFactory.Create<IAccount>(); account.Type = "LEAD"; lead.ConvertLeadToContact(contact, account, options); lead.ConvertLeadToAccount(account); lead.ConvertLeadAddressToAccountAddress(account); lead.ConvertLeadAddressToContactAddress(contact); contact.SaveContactAccount(account); IOpportunity opportunity = CreateOpportunity(createOpportunity, contact, lead); IUser usr = lead.AccountManager; IOwner own = lead.Owner; if (lkpBranchManager.LookupResultValue != null) { usr = (IUser)lkpBranchManager.LookupResultValue;//Sage.Platform.EntityFactory.GetById<IUser>(lkpBranchManager.LookupResultValue.ToString()); Sage.Platform.Data.IDataService service1 = Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Data.IDataService>(); System.Data.OleDb.OleDbConnection conObj = new System.Data.OleDb.OleDbConnection(service1.GetConnectionString()); System.Data.OleDb.OleDbDataAdapter dataAdapterObj3 = new System.Data.OleDb.OleDbDataAdapter("Select Optionvalue as DEFAULTSECCODEID from UserOptions where userid = '" + usr.Id.ToString() + "' and name ='InsertSecCodeID'", conObj); System.Data.DataTable dt3 = new System.Data.DataTable(); dataAdapterObj3.Fill(dt3); if (dt3.Rows.Count > 0) { Sage.Entity.Interfaces.IOwner objowner2 = Sage.Platform.EntityFactory.GetById<Sage.Entity.Interfaces.IOwner>((object)dt3.Rows[0][0].ToString()); own = objowner2; } } AddAttachmentsToLead(lead, account, contact, opportunity); lead.AddHistoryAndQualificationRecords(contact, account, opportunity, false); lead.AddActivities(contact, account, opportunity); if(chkCreateOpportunity.Checked == true) account.Type = "Prospect"; else account.Type = "LEAD"; account.LegalName = lead.LegalName; Sage.Platform.Data.IDataService service2 = Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Data.IDataService>(); System.Data.OleDb.OleDbConnection conOb2 = new System.Data.OleDb.OleDbConnection(service2.GetConnectionString()); System.Data.OleDb.OleDbDataAdapter dataAdapterObj1 = new System.Data.OleDb.OleDbDataAdapter("Select INDSGMSTID From INDSGMST where CINDSGDESC = '" +lead.Industry+"' and CMKTSGDESC = '" +lead.MKTSegment +"'", conOb2); System.Data.DataTable dt1 = new System.Data.DataTable(); dataAdapterObj1.Fill(dt1); if (dt1.Rows.Count > 0) { account.SegmentmstID = dt1.Rows[0][0].ToString(); } //account.Industry = lead.Industry; //account.MktSegment = lead.MKTSegment; account.AccountManager = usr; account.Owner = own; contact.Owner = own; contact.AccountManager = usr; account.Status = "Active"; contact.Save(); account.Save(); IList<ICampaignTarget> campaignTargets = EntityFactory.GetRepository<ICampaignTarget>().FindByProperty("EntityId", lead.Id.ToString()); foreach (ICampaignTarget campaignTarget in campaignTargets) lead.ChangeCampaignTargetEntityID(contact, campaignTarget); ILeadHistory leadHistory = EntityFactory.GetById<ILeadHistory>(lead.SaveLeadHistory()); if (leadHistory != null) { leadHistory.ContactId = contact.Id.ToString(); leadHistory.AccountId = account.Id.ToString(); leadHistory.Save(); } //lead.Delete(); Sage.Entity.Interfaces.IOwner objowner = Sage.Platform.EntityFactory.GetById<Sage.Entity.Interfaces.IOwner>((object)"SYST00000002"); lead.Owner = objowner; lead.Status = "Converted"; lead.Save(); string url; if (opportunity != null) { opportunity.Status = "Active"; opportunity.BusinessPotential = lead.BussinessPortential; opportunity.AccountManager = usr; opportunity.Owner = own; opportunity.Save(); url = string.Format("Opportunity.aspx?entityid={0}", opportunity.Id); } else url = string.Format("Contact.aspx?entityId={0}", contact.Id); cmdConvert.Click += DialogService.CloseEventHappened; //Page.ClientScript.RegisterClientScriptBlock(GetType(), "sas", "<script>window.close();if (window.opener && !window.opener.closed) { window.opener.location='" + url + "'; }</script>", false); Response.Redirect( opportunity != null ? string.Format("Opportunity.aspx?entityid={0}", opportunity.Id) : string.Format("Contact.aspx?entityId={0}", contact.Id), false); /*} else { lblmsg.Text = "Please Select SalesProcess,Then Continue Convert Opportunity"; //throw new Sage.Platform.Application.ValidationException("The call to LeadSearchAndConvert.cmdConvert_Click() failed"); }*/ }
/// <summary> /// Adds the attachments to lead. /// </summary> /// <param name="sourceLead">The source lead.</param> /// <param name="account">The account.</param> /// <param name="contact">The contact.</param> private void AddAttachmentsToLead(ILead sourceLead, IAccount account, IContact contact, IOpportunity opportunity) { IList<IAttachment> attachments = EntityFactory.GetRepository<IAttachment>().FindByProperty("LeadId", sourceLead.Id.ToString()); foreach (IAttachment attachment in attachments) sourceLead.AddAttachmentsContactID(contact, account, opportunity, attachment); }
/// <summary> /// Adds the contact to account. /// </summary> /// <param name="sourceLead">The source lead.</param> private void AddContactToAccount(ILead sourceLead, string accountID) { if (accountID != null) { IList<IAccount> selectedAccount = EntityFactory.GetRepository<IAccount>().FindByProperty("Id", accountID); if (selectedAccount != null) { foreach (IAccount account in selectedAccount) { IContact newContact = EntityFactory.Create<IContact>(); sourceLead.ConvertLeadToContact(newContact, account, "Add Contact to this Account"); sourceLead.ConvertLeadAddressToContactAddress(newContact); sourceLead.ConvertLeadAddressToAccountAddress(account); sourceLead.MergeLeadWithAccount(account, "ACCOUNTWINS", newContact); account.Save(); newContact.Save(); Response.Redirect(string.Format("Contact.aspx?entityId={0}", (newContact.Id))); } } } }
// Example of target method signature public static void CFXLeadOnBeforeUpdate(ILead Lead, ISession session) { ////TAC Code here// Sage.Platform.Security.IRoleSecurityService _roleSecurityService; _roleSecurityService = Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Security.IRoleSecurityService>(true); IChangedState state = Lead as IChangedState; if (state != null) { //============================================== // Stage Change //============================================== // Removed September 30, 2011 No longer Lead Stage for Notifications //PropertyChange chgType = state.GetChangedState().FindPropertyChange("CfxLeadScore"); //if (chgType != null) //{ // //DateTime oldValue = (DateTime)chgDueDate.OldValue; // //DateTime newValue = (DateTime)chgDueDate.NewValue; // if (chgType.NewValue.ToString() == "4- Dupe Check") // { // SendEmail(Lead); // } //} //======================================= // Owner Change //======================================= EntityPropertyChange chgType2 = state.GetChangedState().FindMemberChange<EntityPropertyChange>("Owner"); if (chgType2 != null) { // Do Something //Get Current user Sage.SalesLogix.Security.SLXUserService usersvc = (Sage.SalesLogix.Security.SLXUserService)Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Security.IUserService>(); Sage.Entity.Interfaces.IUser currentuser = usersvc.GetUser(); string Mapid = GetField<string>("CFXTEAMUSERMAPID", "CFXTEAMUSERMAP", "TEAMID = '" + chgType2.NewEntity.EntityId.ToString() + "'"); if (Mapid != null) { ICFXTeamUserMap cfxTeamUserMap = Sage.Platform.EntityFactory.GetById<ICFXTeamUserMap>(Mapid) as ICFXTeamUserMap; Lead.AccountManager = cfxTeamUserMap.MarketerUser; Lead.BDAccountManager = cfxTeamUserMap.BDUser; Lead.CfxNewAssignment = "Assigned To:" + cfxTeamUserMap.MarketerUser.UserInfo.FirstName + " By: " + currentuser.UserInfo.FirstName; // July 31, 2012 change to New Assignment } } } }
/// <summary> /// Send Lead to RdStation Async /// </summary> /// <param name="lead">Lead to be Sent</param> /// <returns>true if sent</returns> public async Task<bool> SendLead(ILead lead) { var response = await _httpClient.PostAsJsonAsync(CONVERSION_URL, lead); return response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Created; }
/// <summary> /// Send Lead to RdStation Sync /// </summary> /// <param name="lead">Lead to be Sent</param> /// <returns>true if sent</returns> public bool SendLeadSync(ILead lead) { var response = _httpClient.PostAsJsonAsync(CONVERSION_URL, lead).Result; return response.StatusCode == HttpStatusCode.OK || response.StatusCode == HttpStatusCode.Created; }
/// <summary> /// Called when the smartpart has been bound. Derived components should override this method to run code that depends on entity context being set and it not changing. /// </summary> protected override void OnFormBound() { base.OnFormBound(); _parentEntity = GetParentEntity() as IPersistentEntity; ILeadAddress curAdd = this.BindingSource.Current as ILeadAddress; _parentEntityReference = _parentEntity as IComponentReference; ClientBindingMgr.RegisterDialogCancelButton(btnCancel); if (_parentEntityReference is ILead) { ViewState["parentEntityID"] = _parentEntityReference.Id; _Objlead = _parentEntity as ILead; } string script_FormatNumber = ""; //script_FormatNumber += " function only_required(Address1,pincode,Latitude,Logitute,description,isprimary,addtype,add2,add3,city,state,country,attn) "; script_FormatNumber += " function only_required(Address1,pincode,Latitude,Logitute,add2,add3,city,state,country) "; script_FormatNumber += " {"; script_FormatNumber += " var df = true;"; script_FormatNumber += " if(Address1 == '') { df = false; }"; script_FormatNumber += " if(pincode == '') {df = false; }"; //script_FormatNumber += " if(Latitude == '') {df = false; }"; //script_FormatNumber += " if(Logitute == '') {df = false; }"; script_FormatNumber += " if(!df) {"; script_FormatNumber += " alert('Please Fill Required fields');"; script_FormatNumber += " return df;} else {"; script_FormatNumber += " var add = Address1 + ', ' + add2 + ', ' + add3 + ', ' + city + ', ' + state + ', ' + country + ', ' + pincode;"; script_FormatNumber += " document.getElementById('MainContent_InsertLead_txtAccountAddress').value = add;"; script_FormatNumber += " return df;"; // script_FormatNumber += " { document.getElementById('MainContent_InsertContact_txtAccountAddress').value = Address1 + pincode + Latitude + Logitute;"; script_FormatNumber += " }}"; ScriptManager.RegisterStartupScript(Page, Page.GetType(), "Validate", script_FormatNumber, true); // btnSave.Attributes.Add("onclick", "return only_required(document.getElementById('" + txtAddress1.ClientID + "').value,document.getElementById('" + txtPostalCode.ClientID + "').value,document.getElementById('" + txtLatitude.ClientID + "').value,document.getElementById('" + txtLogitute.ClientID + "').value,document.getElementById('" + txtAddress2.ClientID + "').value,document.getElementById('" + txtAddress3.ClientID + "').value,document.getElementById('" + pklCity.ClientID + "').value,document.getElementById('" + pklState.ClientID + "').value,document.getElementById('" + pklCountry.ClientID + "').value);"); btnSave.Attributes.Add("onclick", "return only_required(document.getElementById('" + txtAddress1.ClientID + "').value,document.getElementById('" + txtPostalCode.ClientID + "').value,document.getElementById('" + txtLatitude.ClientID + "').value,document.getElementById('" + txtLogitute.ClientID + "').value,document.getElementById('" + txtAddress2.ClientID + "').value,document.getElementById('" + txtAddress3.ClientID + "').value,document.getElementById('" + pklCity.ClientID + "_Text').value,document.getElementById('" + pklState.ClientID + "_Text').value,document.getElementById('"+ pklCountry.ClientID + "_Text').value);"); if (Session["LeadAddressid"] != null && curAdd.Address1 == null) { Sage.Entity.Interfaces.ILeadAddress objadd = Sage.Platform.EntityFactory.GetById<Sage.Entity.Interfaces.ILeadAddress>(Session["LeadAddressid"].ToString()); if (objadd != null ) { curAdd.Address1 = objadd.Address1; curAdd.Address2 = objadd.Address2; curAdd.Address3 = objadd.Address3; curAdd.City = objadd.City; curAdd.Country = objadd.Country; curAdd.IsPrimary = objadd.IsPrimary; curAdd.Latitude = objadd.Latitude != null ? objadd.Latitude : "0"; curAdd.Logitude = objadd.Logitude != null ? objadd.Logitude : "0"; curAdd.PostalCode = objadd.PostalCode; curAdd.Salutation = objadd.Salutation; curAdd.State = objadd.State; curAdd.Description = objadd.Description; //curAdd = objadd; } } string _Entityid = ""; if (ViewState["parentEntityID"] != null) { //Sage.Entity.Interfaces.ILead objlead = Sage.Platform.EntityFactory.GetById<Sage.Entity.Interfaces.ILead>(ViewState["parentEntityID"].ToString()); //if (objlead != null) //{ // _Entityid = objlead.Address.Id.ToString(); //} ILeadAddress curAdd2 = this.BindingSource.Current as ILeadAddress; Sage.Entity.Interfaces.ILeadAddress objadd2 = Sage.Platform.EntityFactory.GetById<Sage.Entity.Interfaces.ILeadAddress>(curAdd2.Id.ToString()); if (objadd2 != null && curAdd2.Address1 != null) { curAdd2.Address1 = objadd2.Address1; curAdd2.Address2 = objadd2.Address2; curAdd2.Address3 = objadd2.Address3; curAdd2.City = objadd2.City; curAdd2.Country = objadd2.Country; curAdd2.IsPrimary = objadd2.IsPrimary; curAdd2.Latitude = objadd2.Latitude != null ? objadd2.Latitude : "0"; curAdd2.Logitude = objadd2.Logitude != null ? objadd2.Logitude : "0"; curAdd2.PostalCode = objadd2.PostalCode; curAdd2.Salutation = objadd2.Salutation; curAdd2.State = objadd2.State; curAdd2.Description = objadd2.Description; } curAdd2.LeadId = ViewState["parentEntityID"].ToString(); } }
public override ISmartPartInfo GetSmartPartInfo(Type smartPartInfoType) { ToolsSmartPartInfo tinfo = new ToolsSmartPartInfo(); if (BindingSource != null) { if (BindingSource.Current != null) { ILeadAddress address = (ILeadAddress)BindingSource.Current; txtEntityId.Value = "";// _parentEntityReference.Id.ToString(); if (address.Id != null) { cbxIsPrimary.Enabled = (address.IsPrimary != true); cbxIsShipping.Enabled = (address.IsMailing != true); Mode.Value = "UPDATE"; } else { Mode.Value = "ADD"; // pklDecription.PickListValue = GetLocalResourceObject("DefaultDescription").ToString(); } if (_parentEntityReference is ILead) { ViewState["parentEntityID"] = _parentEntityReference.Id; _Objlead = _parentEntity as ILead; } if (!(_parentEntityReference is IAccount || _parentEntityReference is IContact)) { // tinfo.Title = Mode.Value == "ADD" // ? GetLocalResourceObject("DialogTitleAdd").ToString() // : GetLocalResourceObject("DialogTitleEdit").ToString(); } } else { if (!Page.IsPostBack) { if (Request.QueryString["Type"] != null) { string _addid = Request.QueryString["id"].ToString(); Sage.Entity.Interfaces.ILeadAddress objadd = Sage.Platform.EntityFactory.GetById<Sage.Entity.Interfaces.ILeadAddress>(_addid); if (objadd != null) { pklDecription.PickListValue = objadd.Description; txtAddress1.Text = objadd.Address1; txtAddress2.Text = objadd.Address2; txtAddress3.Text = objadd.Address3; //pklAddressType.PickListValue = objadd.AddressType; pklCity.PickListValue = objadd.City; pklState.PickListValue = objadd.State; pklCountry.PickListValue = objadd.Country; cbxPrimaryAddr.Checked = objadd.IsPrimary == true ? true : false; cbxIsShipping.Checked = objadd.IsMailing == true ? true : false; //cbxIsPrimary.Checked = objadd.PrimaryAddress == true ? true : false; txtLatitude.Text = Convert.ToString(objadd.Latitude); txtLogitute.Text = Convert.ToString(objadd.Logitude); txtPostalCode.Text = objadd.PostalCode; txtSalutation.Text = objadd.Salutation; } } } } } foreach (Control c in AddressForm_LTools.Controls) tinfo.LeftTools.Add(c); foreach (Control c in AddressForm_CTools.Controls) tinfo.CenterTools.Add(c); foreach (Control c in AddressForm_RTools.Controls) tinfo.RightTools.Add(c); return tinfo; }
public Opportunity(ILead lead) : base((IContact)lead) { }
public static void GetCfxNumCompletedCallsStep(ILead lead, out System.Int32 result) { // TODO: Complete business rule implementation System.Collections.Generic.IList<Sage.Entity.Interfaces.IHistory> myresult; IRepository<IHistory> repository = EntityFactory.GetRepository<IHistory>(); IQueryable qry = (IQueryable)repository; IExpressionFactory ef = qry.GetExpressionFactory(); Sage.Platform.Repository.ICriteria criteria = qry.CreateCriteria(); criteria.Add(ef.Eq("LeadId", lead.Id)); myresult = criteria.List<IHistory>(); int iReturnVal = 0; //Intialize. foreach (IHistory tmpHistory in myresult) { if (tmpHistory.Type == HistoryType.atPhoneCall) { iReturnVal += 1; } } result = iReturnVal; }
/// <summary> /// Converts the lead to new account and contact. /// </summary> /// <param name="lead">The lead.</param> /// <param name="createOpportunity">if set to <c>true</c> [create opportunity].</param> /// <param name="options">The options.</param> private void ConvertLeadToNewAccountAndContact(ILead lead, bool createOpportunity, string options) { IOpportunity opportunity = null; IContact contact = EntityFactory.Create<IContact>(); IAccount account = EntityFactory.Create<IAccount>(); string leadHistoryId = string.Empty; ILeadHistory leadHistory = null; EntityFactory.Create<ILeadHistory>(); leadHistoryId = lead.SaveLeadHistory(); lead.ConvertLeadToContact(contact, account, options); lead.ConvertLeadToAccount(account); lead.ConvertLeadAddressToAccountAddress(account); lead.ConvertLeadAddressToContactAddress(contact); account.Save(); //================================================== // CFX Code here //================================================== foreach (ILeadWebsite tmpWebsite in lead.LeadWebsites) { // Create Account Additional Website Record Sage.Entity.Interfaces.IAccountWebsite Acctwebsite = Sage.Platform.EntityFactory.Create<Sage.Entity.Interfaces.IAccountWebsite>(); Acctwebsite.Account = account; Acctwebsite.Notes = tmpWebsite.Notes; Acctwebsite.WebAddress = tmpWebsite.WebAddress; try { Acctwebsite.Save(); } catch (Exception) { //Exception But Continue } } // =========================================================== // End CFX Code //================================================================ contact.SaveContactAccount(account); if (createOpportunity) { opportunity = EntityFactory.Create<IOpportunity>(); opportunity.Account = contact.Account; opportunity.Description = string.Format(GetLocalResourceObject("Opportunity_Description").ToString(), lead.LeadNameLastFirst); opportunity.Owner = contact.Account.Owner; opportunity.AccountManager = contact.Account.AccountManager; opportunity.Save(); } AddAttachmentsToLead(lead, account, contact, opportunity); lead.AddHistoryAndQualificationRecords(contact, account, opportunity, false); lead.AddActivities(contact, account, opportunity); IList<ICampaignTarget> campaignTargets = EntityFactory.GetRepository<ICampaignTarget>().FindByProperty("EntityId", lead.Id.ToString()); foreach (ICampaignTarget campaignTarget in campaignTargets) lead.ChangeCampaignTargetEntityID(contact, campaignTarget); leadHistory = EntityFactory.GetById<ILeadHistory>(leadHistoryId); if (leadHistory != null) { leadHistory.ContactId = contact.Id.ToString(); leadHistory.AccountId = account.Id.ToString(); leadHistory.Save(); } lead.Delete(); EntityContext.RemoveEntityHistory(typeof(ILead), lead.Id); if (opportunity != null) { Response.Redirect(string.Format("Opportunity.aspx?entityid={0}", opportunity.Id),false); } else { Response.Redirect(string.Format("Contact.aspx?entityId={0}", contact.Id), false); } }
/// <summary> /// Gets the LeadQualification entity based on the parameters. /// </summary> /// <param name="lead">The Lead.</param> /// <param name="qualification">The Qualification.</param> /// <returns></returns> protected static ILeadQualification GetLeadQualification(ILead lead, IQualification qualification) { using (new SessionScopeWrapper()) { IRepository<ILeadQualification> rep = EntityFactory.GetRepository<ILeadQualification>(); IQueryable qry = (IQueryable)rep; IExpressionFactory ep = qry.GetExpressionFactory(); ICriteria crt = qry.CreateCriteria(); IJunction all = ep.Conjunction(); all.Add(ep.Eq("Lead", lead)); all.Add(ep.Eq("Qualification", qualification)); crt.Add(all); ILeadQualification result = crt.UniqueResult<ILeadQualification>(); return result; } }
private void ConvertLeadToNewAccountAndContact(ILead lead, bool createOpportunity, string options) { //====================================================================== // CFX ssommerfeldt Copied from LeadSearchAndConvert.ascx.cs //====================================================================== IOpportunity opportunity = null; IContact contact = EntityFactory.Create<IContact>(); IAccount account = EntityFactory.Create<IAccount>(); string leadHistoryId = string.Empty; ILeadHistory leadHistory = null; EntityFactory.Create<ILeadHistory>(); leadHistoryId = lead.SaveLeadHistory(); lead.ConvertLeadToContact(contact, account, options); lead.ConvertLeadToAccount(account); lead.ConvertLeadAddressToAccountAddress(account); lead.ConvertLeadAddressToContactAddress(contact); account.Save(); //============================================================== // CFX Customized Below this line ssommerfeldt July 28, 2011 //=============================================================== // CFX quite often has contacts with no Person Name if (contact.FirstName == null && contact.LastName == null) { contact.FirstName = "No"; contact.LastName = "Name"; } try { contact.SaveContactAccount(account); } catch (Exception) { // throw; } //============================================================== // CFX Customized Below this line ssommerfeldt July 28, 2011 //=============================================================== if (createOpportunity) { opportunity = EntityFactory.Create<IOpportunity>(); opportunity.Account = contact.Account; opportunity.Description = string.Format(GetLocalResourceObject("Opportunity_Description").ToString(), lead.LeadNameLastFirst); opportunity.Owner = contact.Account.Owner; opportunity.AccountManager = contact.Account.AccountManager; opportunity.Save(); } AddAttachmentsToLead(lead, account, contact, opportunity); lead.AddHistoryAndQualificationRecords(contact, account, opportunity, false); lead.AddActivities(contact, account, opportunity); IList<ICampaignTarget> campaignTargets = EntityFactory.GetRepository<ICampaignTarget>().FindByProperty("EntityId", lead.Id.ToString()); foreach (ICampaignTarget campaignTarget in campaignTargets) lead.ChangeCampaignTargetEntityID(contact, campaignTarget); leadHistory = EntityFactory.GetById<ILeadHistory>(leadHistoryId); if (leadHistory != null) { leadHistory.ContactId = contact.Id.ToString(); leadHistory.AccountId = account.Id.ToString(); leadHistory.Save(); } lead.Delete(); //EntityContext.RemoveEntityHistory(typeof(ILead), lead.Id); //if (opportunity != null) //{ // Response.Redirect(string.Format("Opportunity.aspx?entityid={0}", opportunity.Id), false); //} //else //{ // //Response.Redirect(string.Format("Contact.aspx?entityId={0}", contact.Id), false); //CFX // Response.Redirect(string.Format("Account.aspx?entityId={0}", account.Id), false); //} }
/// <summary> /// Gets a collection of LeadQualfication entities based on the parameters. /// </summary> /// <param name="qualificationCategory">The QualificationCategory.</param> /// <param name="qualifications">The Qualifications.</param> /// <param name="lead">The Lead.</param> /// <returns></returns> protected static IList<ILeadQualification> GetLeadQualifications(IQualificationCategory qualificationCategory, IList<IQualification> qualifications, ILead lead) { using (new SessionScopeWrapper()) { IRepository<ILeadQualification> rep = EntityFactory.GetRepository<ILeadQualification>(); IQueryable qry = (IQueryable)rep; IExpressionFactory ep = qry.GetExpressionFactory(); ICriteria crt = qry.CreateCriteria(); IJunction all = ep.Conjunction(); all.Add(ep.Eq("Lead", lead)); all.Add(ep.In("Qualification", (System.Collections.ICollection)qualifications)); crt.Add(all); IList<ILeadQualification> list = crt.List<ILeadQualification>(); return list; } }
/// <summary> /// Loads the source snapshot. /// </summary> /// <param name="lead">The lead.</param> private void LoadSourceSnapshot(ILead lead) { if (lead != null) { lblLead.Text = !String.IsNullOrEmpty(lead.LastName) ? String.Format("{0}, {1}", lead.LastName, lead.FirstName) : lead.FirstName; lblValueCompany.Text = lead.Company; if (lead.Address != null) lblAddress.Text = lead.Address.FormatFullLeadAddress(); lblValueEmail.Text = lead.Email; lblValueTitle.Text = lead.Title; phnWorkPhone.Text = lead.WorkPhone; lblValueWeb.Text = lead.WebAddress; } }
/// <summary> /// Converts the lead to new account and contact. /// </summary> /// <param name="lead">The lead.</param> /// <param name="createOpportunity">if set to <c>true</c> [create opportunity].</param> /// <param name="options">The options.</param> private void ConvertLeadToNewAccountAndContact(ILead lead, bool createOpportunity, string options) { var keyGen = new SalesLogixEntityKeyGenerator(); string key = keyGen.GenerateIds(typeof(IContact), 1).FirstOrDefault(); IContact contact = EntityFactory.Create<IContact>(); ((IAssignableId)contact).Id = key; IAccount account = EntityFactory.Create<IAccount>(); lead.ConvertLeadToContact(contact, account, options); lead.ConvertLeadToAccount(account); lead.ConvertLeadAddressToAccountAddress(account); lead.ConvertLeadAddressToContactAddress(contact); contact.SaveContactAccount(account); IOpportunity opportunity = CreateOpportunity(createOpportunity, contact, lead); AddAttachmentsToLead(lead, account, contact, opportunity); lead.AddHistoryAndQualificationRecords(contact, account, opportunity, false); lead.AddActivities(contact, account, opportunity); IList<ICampaignTarget> campaignTargets = EntityFactory.GetRepository<ICampaignTarget>().FindByProperty("EntityId", lead.Id.ToString()); foreach (ICampaignTarget campaignTarget in campaignTargets) lead.ChangeCampaignTargetEntityID(contact, campaignTarget); ILeadHistory leadHistory = EntityFactory.GetById<ILeadHistory>(lead.SaveLeadHistory()); if (leadHistory != null) { leadHistory.ContactId = contact.Id.ToString(); leadHistory.AccountId = account.Id.ToString(); leadHistory.Save(); } lead.Delete(); EntityContext.RemoveEntityHistory(typeof(ILead), lead.Id); Response.Redirect( opportunity != null ? string.Format("Opportunity.aspx?entityid={0}", opportunity.Id) : string.Format("Contact.aspx?entityId={0}", contact.Id), false); }
/// <summary> /// Converts the lead to contact. /// </summary> /// <param name="sourceLead">The source lead.</param> /// <param name="accountId">The account ID.</param> /// <param name="createOpportunity">if set to <c>true</c> [create opportunity].</param> /// <param name="mergeRule">The merge rule.</param> private void ConvertLeadToContact(ILead sourceLead, string accountId, bool createOpportunity, string mergeRule) { if (accountId != null) { IAccount account = EntityFactory.GetById<IAccount>(accountId); if (account != null) { var keyGen = new SalesLogixEntityKeyGenerator(); string key = keyGen.GenerateIds(typeof(IContact), 1).FirstOrDefault(); IContact contact = EntityFactory.Create<IContact>(); ((IAssignableId)contact).Id = key; string leadHistoryId = sourceLead.SaveLeadHistory(); sourceLead.ConvertLeadToContact(contact, account, "Add Contact to this Account"); if (mergeRule.ToUpper().Equals("LEADWINS")) { sourceLead.ConvertLeadAddressToContactAddress(contact); } else { contact.Address.Address1 = account.Address.Address1; contact.Address.Address2 = account.Address.Address2; contact.Address.Address3 = account.Address.Address3; contact.Address.Address4 = account.Address.Address4; contact.Address.City = account.Address.City; contact.Address.Country = account.Address.Country; contact.Address.County = account.Address.County; contact.Address.Description = account.Address.Description; contact.Address.PostalCode = account.Address.PostalCode; contact.Address.Salutation = account.Address.Salutation; contact.Address.State = account.Address.State; contact.Address.TimeZone = account.Address.TimeZone; contact.Address.Type = account.Address.Type; contact.Address.GlobalSyncId = account.Address.GlobalSyncId; contact.Address.AppId = account.Address.AppId; contact.Address.Tick = account.Address.Tick; } sourceLead.MergeLeadWithAccount(account, mergeRule, contact); CreateContactLeadSource(sourceLead, contact); account.Save(); contact.Save(); IOpportunity opportunity = CreateOpportunity(createOpportunity, contact, sourceLead); IList<IAttachment> attachment = EntityFactory.GetRepository<IAttachment>().FindByProperty("LeadId", sourceLead.Id. ToString()); foreach (IAttachment attach in attachment) sourceLead.AddAttachmentsContactID(contact, account, null, attach); sourceLead.AddHistoryAndQualificationRecords(contact, account, opportunity, false); sourceLead.AddActivities(contact, account, opportunity); IList<ICampaignTarget> campaignTarget = EntityFactory.GetRepository<ICampaignTarget>().FindByProperty("EntityId", sourceLead.Id.ToString()); foreach (ICampaignTarget ct in campaignTarget) sourceLead.ChangeCampaignTargetEntityID(contact, ct); ILeadHistory leadHistory = EntityFactory.GetById<ILeadHistory>(leadHistoryId); if (leadHistory != null) { leadHistory.ContactId = contact.Id.ToString(); leadHistory.AccountId = account.Id.ToString(); leadHistory.Save(); } sourceLead.Delete(); EntityContext.RemoveEntityHistory(typeof (ILead), sourceLead.Id); Response.Redirect( opportunity != null ? string.Format("Opportunity.aspx?entityid={0}", opportunity.Id) : string.Format("Contact.aspx?entityId={0}", contact.Id), false); } } }
private IOpportunity CreateOpportunity(bool createOpportunity, IContact contact, ILead lead) { IOpportunity opportunity = null; if (createOpportunity) { opportunity = EntityFactory.Create<IOpportunity>(); opportunity.Account = contact.Account; opportunity.Description = String.Format(GetLocalResourceObject("Opportunity_Description").ToString(), lead.LeadNameLastFirst); opportunity.Owner = contact.Account.Owner; opportunity.AccountManager = contact.Account.AccountManager; //assign opp contact based on opportunity default options string oppContactOption = BusinessRuleHelper.GetUserOption(BusinessRuleEnums.UserOptionType.String, "grpContact", "OpportunityDefaults").ToString(); if (oppContactOption == "0" || oppContactOption == "1") { IOpportunityContact opportunityContact = EntityFactory.Create<IOpportunityContact>(); opportunityContact.Contact = contact; opportunityContact.Opportunity = opportunity; opportunityContact.IsPrimary = contact.IsPrimary; opportunity.Contacts.Add(opportunityContact); } opportunity.Save(); } return opportunity; }
private IOpportunity CreateOpportunity(bool createOpportunity, IContact contact, ILead lead) { IOpportunity opportunity = null; if (createOpportunity) { opportunity = EntityFactory.Create<IOpportunity>(); opportunity.Account = contact.Account; opportunity.Description = String.Format(GetLocalResourceObject("Opportunity_Description").ToString(), lead.LeadNameLastFirst); opportunity.Owner = contact.Account.Owner; opportunity.AccountManager = contact.Account.AccountManager; /*string pluginID = ""; pluginID = ddLSalesProcess.SelectedValue.ToString();*/ //assign opp contact based on opportunity default options string oppContactOption = BusinessRuleHelper.GetUserOption(BusinessRuleEnums.UserOptionType.String, "grpContact", "OpportunityDefaults").ToString(); if (oppContactOption == "0" || oppContactOption == "1") { IOpportunityContact opportunityContact = EntityFactory.Create<IOpportunityContact>(); opportunityContact.Contact = contact; opportunityContact.Opportunity = opportunity; opportunityContact.IsPrimary = contact.IsPrimary; opportunity.Contacts.Add(opportunityContact); foreach (ILeadProduct prd in lead.Products) { IOpportunityProduct oppr = Sage.Platform.EntityFactory.Create<IOpportunityProduct>(); oppr.Product = prd.Product; oppr.Opportunity = opportunity; //oppr.Save(); opportunity.Products.Add(oppr); } foreach (ILeadCompetitor prd in lead.Competitors) { IOpportunityCompetitor oppr = Sage.Platform.EntityFactory.Create<IOpportunityCompetitor>(); oppr.Competitor = prd.Competitor; oppr.Opportunity = opportunity; //oppr.Save(); opportunity.Competitors.Add(oppr); } } opportunity.Save(); /*Sage.Entity.Interfaces.ISalesProcesses salesProcess = Sage.Platform.EntityFactory.Create<Sage.Entity.Interfaces.ISalesProcesses>(); salesProcess.InitSalesProcess(pluginID, opportunity.Id.ToString());*/ } return opportunity; }
public static void cfxSendLeadToBD(ILead lead) { //Get Current user Sage.SalesLogix.Security.SLXUserService usersvc = (Sage.SalesLogix.Security.SLXUserService)Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Security.IUserService>(); Sage.Entity.Interfaces.IUser currentuser = usersvc.GetUser(); String Distributionlist = "SendLeadToBD"; String Subject = "*** New Trader Lead*** " + lead.Company; string Body = "User: "******" " + currentuser.UserInfo.LastName + " is ready to send over this Lead to you. <br/>"; Body += "http://10.10.0.25:3333/slxclient/Lead.aspx?entityid=" + lead.Id.ToString() + "<br/>"; Body += @"<br /> <br /> Please process at your earliest convenience.<br /> <br /> Best Regards,<br /> <br /> -----------------------<br /> <span style=""font-weight: bold; color: rgb(255, 165, 0);"">Calforex Notifications</span><br /> <br />"; //Send Lead Emails to BD and DistributionList if (lead.BDAccountManager != null) { SendSimpleEmail(lead.BDAccountManager.UserInfo.Email, Body, Subject); } // Send an Email to All Recipients of the Dupe Check List. string Listid = GetField<string>("CFXDISTRIBUTIONLISTID", "CFXDISTRIBUTIONLIST", "DESCRIPTION = '" + Distributionlist + "'"); if (Listid != null || Listid != String.Empty) { ICFXDistributionList cfxList = Sage.Platform.EntityFactory.GetById<ICFXDistributionList>(Listid) as ICFXDistributionList; foreach (ICFXDistributionItems tmpRecpient in cfxList.CFXDistributionItems) { SendSimpleEmail(tmpRecpient.Email, Body, Subject); // Redirect to Ticket Page } } }
public Opportunity(ILead lead) : base((IContact)lead) { }
public static void cfxNeedDupeCheck(ILead lead) { //Get Current user Sage.SalesLogix.Security.SLXUserService usersvc = (Sage.SalesLogix.Security.SLXUserService)Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Security.IUserService>(); Sage.Entity.Interfaces.IUser currentuser = usersvc.GetUser(); // Create Audit Record Sage.Entity.Interfaces.ICFXDupeCheckAudit AuditRecord = Sage.Platform.EntityFactory.Create<Sage.Entity.Interfaces.ICFXDupeCheckAudit>(); AuditRecord.Status = "Dupe Check Needed"; AuditRecord.Lead = lead; try { AuditRecord.Save(); } catch (Exception) { //Exception But Continue } // Create History Record Sage.Entity.Interfaces.IHistory history = Sage.Platform.EntityFactory.Create<Sage.Entity.Interfaces.IHistory>(); history.AccountName = lead.Company; history.ContactName = lead.LastName + ", " + lead.FirstName; history.Type = HistoryType.atNote; history.Category = "DupeCheck"; history.UserId = currentuser.Id.ToString(); history.UserName = currentuser.UserName; history.Duration = 1; history.StartDate = DateTime.UtcNow; history.OriginalDate = DateTime.UtcNow; history.CompletedDate = DateTime.UtcNow; history.CompletedUser = currentuser.Id.ToString(); history.Timeless = false; history.Result = "Complete"; history.Description = "Dupe Check Needed"; history.LongNotes = "Dupe Check Needed"; history.Notes = "Dupe Check Needed"; history.LeadId = lead.Id.ToString(); history.LeadName = lead.LastName + ", " + lead.FirstName; try { history.Save(); } catch (Exception) { //Exception But Continue } //===================================== // Send The Email Notification //===================================== //===================================== // Send The Email Notification //===================================== string Subject = "Dupe Check Needed for " + lead.Company; string Body = "User: "******" Has Requested a Dupe check <br/>"; Body += "http://10.10.0.25:3333/slxclient/Lead.aspx?entityid=" + lead.Id.ToString() + "<br/>"; Body += @"<br /> <br /> Please process at your earliest convenience.<br /> <br /> Best Regards,<br /> <br /> -----------------------<br /> <span style=""font-weight: bold; color: rgb(255, 165, 0);"">Calforex Notifications</span><br /> <br />"; SendEmail("Dupe Check", Body, Subject); }
public static void cfxDupeCheckComplete(ILead lead) { //Get Current user Sage.SalesLogix.Security.SLXUserService usersvc = (Sage.SalesLogix.Security.SLXUserService)Sage.Platform.Application.ApplicationContext.Current.Services.Get<Sage.Platform.Security.IUserService>(); Sage.Entity.Interfaces.IUser currentuser = usersvc.GetUser(); // Create Audit Record Sage.Entity.Interfaces.ICFXDupeCheckAudit AuditRecord = Sage.Platform.EntityFactory.Create<Sage.Entity.Interfaces.ICFXDupeCheckAudit>(); AuditRecord.Status = "Dupe Check Completed"; AuditRecord.Lead = lead; try { AuditRecord.Save(); } catch (Exception) { //Exception But Continue } // Create History Record Sage.Entity.Interfaces.IHistory history = Sage.Platform.EntityFactory.Create<Sage.Entity.Interfaces.IHistory>(); history.AccountName = lead.Company; history.ContactName = lead.LastName + ", " + lead.FirstName; history.Type = HistoryType.atNote; history.Category = "DupeCheck"; history.UserId = currentuser.Id.ToString(); history.UserName = currentuser.UserName; history.Duration = 1; history.StartDate = DateTime.UtcNow; history.OriginalDate = DateTime.UtcNow; history.CompletedDate = DateTime.UtcNow; history.CompletedUser = currentuser.Id.ToString(); history.Timeless = false; history.Result = "Complete"; history.Description = "Dupe Check Completed"; history.LongNotes = "Dupe Check Completed"; history.Notes = "Dupe Check Completed"; history.LeadId = lead.Id.ToString(); history.LeadName = lead.LastName + ", " + lead.FirstName; try { history.Save(); } catch (Exception) { //Exception But Continue } string Subject = "**DUPE CHECK COMPLETED** for " + lead.Company; string Body = "User: "******" Has Completed the Dupe Check<br/>"; Body += "http://10.10.0.25:3333/slxclient/Lead.aspx?entityid=" + lead.Id.ToString() + "<br/>"; Body += @"<br /> <br /> <br /> Best Regards,<br /> <br /> -----------------------<br /> <span style=""font-weight: bold; color: rgb(255, 165, 0);"">Calforex Notifications</span><br /> <br />"; string userid = GetField<string>("CREATEUSER", "CFXDUPECHECKAUDIT", "status = 'Dupe Check Needed' and Leadid = '" + lead.Id.ToString() + "'"); SendUserEmail(userid, Body, Subject); }
/// <summary> /// Converts the lead to contact. /// </summary> /// <param name="sourceLead">The source lead.</param> /// <param name="accountID">The account ID.</param> private void ConvertLeadToContact(ILead sourceLead, string accountID, bool createOpportinity, string mergeRule) { if (accountID != null) { IAccount account = EntityFactory.GetById<IAccount>(accountID); if (account != null) { IContact contact = EntityFactory.Create<IContact>(); IOpportunity opportunity = null; ILeadHistory leadHistory = null; string leadHistoryId = string.Empty; leadHistoryId = sourceLead.SaveLeadHistory(); sourceLead.ConvertLeadToContact(contact, account, "Add Contact to this Account"); if (mergeRule.ToUpper().Equals("LEADWINS")) { sourceLead.ConvertLeadAddressToContactAddress(contact); //sourceLead.ConvertLeadAddressToAccountAddress(account); } else { contact.Address.Address1 = account.Address.Address1; contact.Address.Address2 = account.Address.Address2; contact.Address.Address3 = account.Address.Address3; contact.Address.Address4 = account.Address.Address4; contact.Address.City = account.Address.City; contact.Address.Country = account.Address.Country; contact.Address.County = account.Address.County; contact.Address.Description = account.Address.Description; contact.Address.PostalCode = account.Address.PostalCode; contact.Address.Salutation = account.Address.Salutation; contact.Address.State = account.Address.State; contact.Address.TimeZone = account.Address.TimeZone; contact.Address.Type = account.Address.Type; } sourceLead.MergeLeadWithAccount(account, mergeRule, contact); account.Save(); contact.Save(); if (createOpportinity) { opportunity = EntityFactory.Create<IOpportunity>(); opportunity.Account = contact.Account; opportunity.Description = string.Format("Opportunity for {0}", sourceLead.LeadNameLastFirst); opportunity.Owner = contact.Account.Owner; opportunity.AccountManager = contact.Account.AccountManager; opportunity.Save(); } IList<IAttachment> attachment = EntityFactory.GetRepository<IAttachment>().FindByProperty("LeadId", sourceLead.Id.ToString()); foreach (IAttachment attach in attachment) sourceLead.AddAttachmentsContactID(contact, account, null, attach); sourceLead.AddHistoryAndQualificationRecords(contact, account, opportunity, false); sourceLead.AddActivities(contact, account, opportunity); IList<ICampaignTarget> campaignTarget = EntityFactory.GetRepository<ICampaignTarget>().FindByProperty("EntityId", sourceLead.Id.ToString()); foreach (ICampaignTarget ct in campaignTarget) sourceLead.ChangeCampaignTargetEntityID(contact, ct); leadHistory = EntityFactory.GetById<ILeadHistory>(leadHistoryId); if (leadHistory != null) { leadHistory.ContactId = contact.Id.ToString(); leadHistory.AccountId = account.Id.ToString(); leadHistory.Save(); } sourceLead.Delete(); EntityContext.RemoveEntityHistory(typeof(ILead), sourceLead.Id); if (opportunity != null) { Response.Redirect(string.Format("Opportunity.aspx?entityid={0}", opportunity.Id), false); } else { Response.Redirect(string.Format("Contact.aspx?entityId={0}", contact.Id),false); } } } }
private void LoadAccountGrid() { bool conditionMet = false; string company = String.Empty; string cityStatePostal = String.Empty; string workPhone = String.Empty; string tollFree = String.Empty; string webAddress = String.Empty; string industry = String.Empty; ILead lead = BindingSource.Current as ILead; if (lead != null) { company = lead.Company; cityStatePostal = lead.Address.LeadCtyStZip; workPhone = lead.WorkPhone; tollFree = lead.TollFree; webAddress = lead.WebAddress; industry = lead.Industry; } IRepository <IAccount> accountList = EntityFactory.GetRepository <IAccount>(); IQueryable qryAccount = (IQueryable)accountList; IExpressionFactory exp = qryAccount.GetExpressionFactory(); ICriteria criteria = qryAccount.CreateCriteria(); criteria.CreateAlias("Address", "ad"); IList <IExpression> expression = new List <IExpression>(); if (chkCompany.Checked && company != null) { expression.Add(GetExpression(exp, "AccountName", company)); conditionMet = true; } if (chkIndustry.Checked && industry != null) { expression.Add(GetExpression(exp, "Industry", industry)); conditionMet = true; } if (chkWebAddress.Checked && webAddress != null) { expression.Add(GetExpression(exp, "WebAddress", webAddress)); conditionMet = true; } if (chkCityStatePostal.Checked && cityStatePostal != null) { expression.Add(GetExpression(exp, "ad.CityStateZip", cityStatePostal)); conditionMet = true; } if (chkWorkPhone.Checked && workPhone != null) { expression.Add(GetExpression(exp, "MainPhone", workPhone)); conditionMet = true; } if (chkTollFreePhone.Checked && tollFree != null) { expression.Add(GetExpression(exp, "TollFree", tollFree)); conditionMet = true; } IJunction junction = rdbMatchAll.Checked ? exp.Conjunction() : exp.Disjunction(); foreach (IExpression e in expression) { junction.Add(e); } criteria.Add(junction); if (conditionMet.Equals(true)) { IList list = criteria.List(); dtsAccounts.setCustomData(list); lblAccountMatches.Text = String.Format(GetLocalResourceObject("PotentialAccountMatches_rsc").ToString(), list.Count); } }
public void CreateContactLeadSource(ILead lead, IContact contact) { IContactLeadSource contactLeadSource = EntityFactory.GetRepository<IContactLeadSource>().Create(); contactLeadSource.Contact = contact; contactLeadSource.LeadSource = lead.LeadSource; contactLeadSource.LeadDate = DateTime.UtcNow; contact.LeadSources.Add(contactLeadSource); }
/// <summary> /// Loads the marketing. /// </summary> private void LoadMarketing() { try { ISession session = SessionFactoryHolder.HolderInstance.CreateSession(); try { if (EntityContext != null && EntityContext.EntityType == typeof(ILead)) { ILead lead = BindingSource.Current as ILead; StringBuilder qry = new StringBuilder(); qry.Append("Select campaign.CampaignName, campaign.CampaignCode, target.Status, target.Stage, "); qry.Append("campaign.StartDate, campaign.EndDate, response.ResponseDate, response.ResponseMethod, "); qry.Append("target.Id, response.Id "); qry.Append("From CampaignTarget as target "); qry.Append("Join target.Campaign as campaign "); qry.Append("Left Join target.TargetResponses as response "); qry.Append("Where target.EntityId = :leadId"); if (grdLeadMarketing.AllowSorting) { qry.Append(GetOrderByClause()); } IQuery q = session.CreateQuery(qry.ToString()); q.SetAnsiString("leadId", lead.Id.ToString()); IList result; using (new SparseQueryScope()) result = q.List(); System.Data.DataTable dt = new System.Data.DataTable(); dt.Columns.Add("CampaignName"); dt.Columns.Add("CampaignCode"); dt.Columns.Add("Status"); dt.Columns.Add("Stage"); System.Data.DataColumn col = new System.Data.DataColumn("StartDate", typeof(DateTime)); dt.Columns.Add(col); col = new System.Data.DataColumn("EndDate", typeof(DateTime)); dt.Columns.Add(col); col = new System.Data.DataColumn("ResponseDate", typeof(DateTime)); dt.Columns.Add(col); dt.Columns.Add("ResponseMethod"); dt.Columns.Add("TargetId"); dt.Columns.Add("ResponseId"); if (result != null) { foreach (object[] data in result) { dt.Rows.Add(data[0], data[1], data[2], data[3], ConvertData(data[4]), ConvertData(data[5]), ConvertData(data[6]), data[7], data[8], data[9]); } } grdLeadMarketing.DataSource = dt; grdLeadMarketing.DataBind(); } } finally { SessionFactoryHolder.HolderInstance.ReleaseSession(session); } } catch (Exception ex) { log.Error(ex.Message); throw; } }
/// <summary> /// Converts the lead to new account and contact. /// </summary> /// <param name="lead">The lead.</param> /// <param name="createOpportunity">if set to <c>true</c> [create opportunity].</param> /// <param name="options">The options.</param> private void ConvertLeadToNewAccountAndContact(ILead lead, bool createOpportunity, string options) { IOpportunity opportunity = null; IContact contact = EntityFactory.Create<IContact>(); IAccount account = EntityFactory.Create<IAccount>(); string leadHistoryId = string.Empty; ILeadHistory leadHistory = null; EntityFactory.Create<ILeadHistory>(); leadHistoryId = lead.SaveLeadHistory(); lead.ConvertLeadToContact(contact, account, options); lead.ConvertLeadToAccount(account); lead.ConvertLeadAddressToAccountAddress(account); lead.ConvertLeadAddressToContactAddress(contact); account.Save(); contact.SaveContactAccount(account); if (createOpportunity) { opportunity = EntityFactory.Create<IOpportunity>(); opportunity.Account = contact.Account; opportunity.Description = string.Format(GetLocalResourceObject("Opportunity_Description").ToString(), lead.LeadNameLastFirst); opportunity.Owner = contact.Account.Owner; opportunity.AccountManager = contact.Account.AccountManager; opportunity.Save(); } AddAttachmentsToLead(lead, account, contact, opportunity); lead.AddHistoryAndQualificationRecords(contact, account, opportunity, false); lead.AddActivities(contact, account, opportunity); IList<ICampaignTarget> campaignTargets = EntityFactory.GetRepository<ICampaignTarget>().FindByProperty("EntityId", lead.Id.ToString()); foreach (ICampaignTarget campaignTarget in campaignTargets) lead.ChangeCampaignTargetEntityID(contact, campaignTarget); leadHistory = EntityFactory.GetById<ILeadHistory>(leadHistoryId); if (leadHistory != null) { leadHistory.ContactId = contact.Id.ToString(); leadHistory.AccountId = account.Id.ToString(); leadHistory.Save(); } lead.Delete(); EntityContext.RemoveEntityHistory(typeof(ILead), lead.Id); if (opportunity != null) { Response.Redirect(string.Format("Opportunity.aspx?entityid={0}", opportunity.Id),false); } else { Response.Redirect(string.Format("Contact.aspx?entityId={0}", contact.Id), false); } }