public static Lead GetLeadById(int id) { LeadFilter filter = new LeadFilter(); filter[LeadConstants.LeadID] = id.ToString(); List<Lead> leads = DataManager.SearchByFilter(filter); if (leads.Count == 0) { throw new ApplicationException("Invalid Lead ID"); } return leads[0]; }
protected void Page_Load(object sender, EventArgs e) { filter = CreateFilterFromQuery(); queryString = Request.QueryString; state = Status; ucSearch.Status = Status; if (state == "Active") { hHeader.InnerHtml = "ACTIVE LEADS VIEW"; lnkClearFilter.HRef = "../LeadPipeline.aspx"; } if (state == "Closed") { hHeader.InnerHtml = "CLOSED LEADS VIEW"; lnkClearFilter.HRef = "../ClosedLeadsPipeline.aspx"; } }
protected void BtnApply_Click(object sender, EventArgs e) { LeadFilter filter = new LeadFilter(); if (!String.IsNullOrEmpty(txtLeadNumber.Text)) { filter[LeadConstants.Number] = txtLeadNumber.Text; } if (!String.IsNullOrEmpty(txtFirstName.Text)) { filter[LeadConstants.FirstName] = txtFirstName.Text; } if (!String.IsNullOrEmpty(txtLastName.Text)) { filter[LeadConstants.LastName] = txtLastName.Text; } if (!String.IsNullOrEmpty(txtTopic.Text)) { filter[LeadConstants.Title] = txtTopic.Text; } string statuses = String.Empty; foreach (var item in cblStatus.Items) { var check = item as ListItem; if (check != null) { if (check.Selected) { statuses += check.Text + ","; } } } if (!String.IsNullOrEmpty(statuses)) { filter[LeadConstants.State] = statuses; } var leads = DataManager.SearchByFilter(filter); leads.RemoveAll(l => l.LeadStatus.Status.Equals("Completed") || l.LeadStatus.Status.Equals("Canceled")); var toAddedLeads = new List<Lead>(); var strAddedLeads = txtAddedLeads.Text.Split(';'); Recipients = strAddedLeads[0]; strAddedLeads[0] = String.Empty; Session["recipient"] = Recipients; foreach (var lead in strAddedLeads) { if (!String.IsNullOrEmpty(lead)) { var id = lead.Split(' ').Last(); int index = lead.IndexOf('('); var number = lead.Remove(0, index + 1); index = number.IndexOf(')'); number = number.Remove(index, number.Count() - index); int leadID; if (int.TryParse(id, out leadID)) { toAddedLeads.Add(DataManager.GetLeadById(leadID)); } } } var addedLeads = Session[Recipients] as List<Lead>; if (addedLeads != null) { leads.RemoveAll(l => addedLeads.Any(al => al.LeadID == l.LeadID)); } leads.RemoveAll(l => toAddedLeads.Any(al => al.LeadID == l.LeadID)); lstLeads.DataSource = leads; lstLeads.DataBind(); lstAddedLeads.DataSource = toAddedLeads; lstAddedLeads.DataBind(); }
public static List<Lead> SearchByFilterToPage(LeadFilter filter, int pageNumber, out int countOfPages) { return _dataProvider.SearchByFilter(filter, pageNumber, out countOfPages); }
public static List<Lead> SearchByFilter(LeadFilter filter) { int temp; return _dataProvider.SearchByFilter(filter, null, out temp); }
public static Lead GetLeadByNumber(int number) { LeadFilter filter = new LeadFilter(); filter[LeadConstants.Number] = number.ToString(); var leads = DataManager.SearchByFilter(filter); return leads.First(); }
public static List<Lead> GetLeadsPage(LeadFilter filter, int pageSize, int rowIndex, string sortExpression, out int leadsFilterCount) { return _dataProvider.GetLeadsPage(filter, pageSize, rowIndex, sortExpression, out leadsFilterCount); }
protected LeadFilter CreateFilterFromQuery() { LeadFilter filter = new LeadFilter(); foreach (var key in Request.QueryString.AllKeys) { filter[key] = Request.QueryString[key]; } return filter; }
public List<Lead> SearchByFilter(LeadFilter filter, int? pageNumber, out int countOfPages) { using (var dc = new EngageCCTDataClassesDataContext()) { IEnumerable<T_Lead> leads = dc.T_Leads; if (!String.IsNullOrEmpty(filter[LeadConstants.LeadID])) { int leadID; if (int.TryParse(filter[LeadConstants.LeadID], out leadID)) leads = leads.Where(l => l.LeadID == leadID); } if (!String.IsNullOrEmpty(filter[LeadConstants.Number])) { leads = leads.Where(l => l.ldNumber.ToLower().Contains(filter[LeadConstants.Number].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.LastName])) { leads = leads.Where(l => l.ldLastName.ToLower().Contains(filter[LeadConstants.LastName].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.FirstName])) { leads = leads.Where(l => l.ldFirstName.ToLower().Contains(filter[LeadConstants.FirstName].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.Title])) { leads = leads.Where(l => l.ldTopic.ToLower().Contains(filter[LeadConstants.Title].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.JobTitle])) { leads = leads.Where(l => l.ldJobTitle.ToLower().Contains(filter[LeadConstants.JobTitle].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.CompanyName])) { leads = leads.Where(l => l.ldCompanyName.ToLower().Contains(filter[LeadConstants.CompanyName].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.OwnerID])) { Guid ownerID; if (Guid.TryParse(filter[LeadConstants.OwnerID], out ownerID)) leads = leads.Where(l => l.OwnerID.Equals(ownerID)); } if (!String.IsNullOrEmpty(filter[LeadConstants.State])) { var states = filter[LeadConstants.State].Split(','); leads = leads.Where(l => states.Contains(l.T_LeadStatus.lstsStatus)); } if (!String.IsNullOrEmpty(filter[LeadConstants.Sort])) { var pair = filter[LeadConstants.Sort].Split(','); if (pair.Length == 2) { var sortBy = pair[0]; var sortDirection = pair[1]; switch (sortBy) { case SortConstants.Created: if (sortDirection.Equals(SortConstants.Ascending)) { leads = leads.OrderBy(l => l.ldCreatedOn); } if (sortDirection.Equals(SortConstants.Descending)) { leads = leads.OrderByDescending(l => l.ldCreatedOn); } break; case SortConstants.Lead: if (sortDirection.Equals(SortConstants.Ascending)) { leads = leads.OrderBy(l => l.ldLastName); leads = leads.OrderBy(l => l.ldFirstName); } if (sortDirection.Equals(SortConstants.Descending)) { leads = leads.OrderByDescending(l => l.ldLastName); leads = leads.OrderByDescending(l => l.ldFirstName); } break; case SortConstants.Status: if (sortDirection.Equals(SortConstants.Ascending)) { leads = leads.OrderBy(l => l.T_LeadStatus.lstsStatus); } if (sortDirection.Equals(SortConstants.Descending)) { leads = leads.OrderByDescending(l => l.T_LeadStatus.lstsStatus); } break; case SortConstants.Topic: if (sortDirection.Equals(SortConstants.Ascending)) { leads = leads.OrderBy(l => l.ldTopic); } if (sortDirection.Equals(SortConstants.Descending)) { leads = leads.OrderByDescending(l => l.ldTopic); } break; case SortConstants.Number: if (sortDirection.Equals(SortConstants.Ascending)) { leads = leads.OrderBy(l => l.ldNumber); } if (sortDirection.Equals(SortConstants.Descending)) { leads = leads.OrderByDescending(l => l.ldNumber); } break; } } } int countLeadsOnPage; if (int.TryParse(ConfigurationManager.AppSettings["countOfLeadsOnPage"], out countLeadsOnPage)) { countOfPages = (leads.Count() - 1) / countLeadsOnPage + 1; } else { countLeadsOnPage = 10; countOfPages = (leads.Count() - 1) / countLeadsOnPage + 1; } if (pageNumber != null) { if (pageNumber.Value > countOfPages || pageNumber.Value < 0) { pageNumber = 1; } int temp = leads.Count(); List<Lead> leadList = new List<Lead>(); for (int i = (pageNumber.Value - 1) * countLeadsOnPage; i < pageNumber.Value * countLeadsOnPage && i < leads.Count(); i++) { Lead lead = GetLeadEntity(leads.ElementAt(i)); leadList.Add(lead); } return leadList; } else { return leads.Select(l => this.GetLeadEntity(l)).ToList(); } } }
public List<Lead> GetLeadsPage(LeadFilter filter, int pageSize, int rowIndex, string sortExpression, out int leadFilterCount) { int totalRows; int pageIndex = rowIndex / pageSize; bool asc = !sortExpression.Contains("DESC"); using (var dc = new EngageCCTDataClassesDataContext()) { IQueryable<T_Lead> leads = dc.T_Leads; if (!String.IsNullOrEmpty(filter[LeadConstants.LeadID])) { int leadId; if (int.TryParse(filter[LeadConstants.LeadID], out leadId)) leads = leads.Where(l => l.LeadID == leadId); } if (!String.IsNullOrEmpty(filter[LeadConstants.Number])) { leads = leads.Where(l => l.ldNumber.ToLower().Contains(filter[LeadConstants.Number].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.LastName])) { leads = leads.Where(l => l.ldLastName.ToLower().Contains(filter[LeadConstants.LastName].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.FirstName])) { leads = leads.Where(l => l.ldFirstName.ToLower().Contains(filter[LeadConstants.FirstName].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.Title])) { leads = leads.Where(l => l.ldTopic.ToLower().Contains(filter[LeadConstants.Title].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.JobTitle])) { leads = leads.Where(l => l.ldJobTitle.ToLower().Contains(filter[LeadConstants.JobTitle].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.CompanyName])) { leads = leads.Where(l => l.ldCompanyName.ToLower().Contains(filter[LeadConstants.CompanyName].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.Topic])) { leads = leads.Where(l => l.ldTopic.ToLower().Contains(filter[LeadConstants.Topic].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.BusinessPhone])) { leads = leads.Where(l => l.ldBusinessPhone.ToLower().Contains(filter[LeadConstants.BusinessPhone].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.HomePhone])) { leads = leads.Where(l => l.ldHomePhone.ToLower().Contains(filter[LeadConstants.HomePhone].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.CellPhone])) { leads = leads.Where(l => l.ldMobilePhone.ToLower().Contains(filter[LeadConstants.CellPhone].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.Fax])) { leads = leads.Where(l => l.ldFax.ToLower().Contains(filter[LeadConstants.Fax].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.Email])) { leads = leads.Where(l => l.ldEmail.ToLower().Contains(filter[LeadConstants.Email].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.Skype])) { leads = leads.Where(l => l.ldSkype.ToLower().Contains(filter[LeadConstants.Skype].ToLower())); } if (!String.IsNullOrEmpty(filter[LeadConstants.Phone])) { leads = leads.Where(l=> l.ldBusinessPhone.ToLower().Contains(filter[LeadConstants.Phone].ToLower()) || l.ldHomePhone.ToLower().Contains(filter[LeadConstants.Phone].ToLower()) || l.ldMobilePhone.ToLower().Contains(filter[LeadConstants.Phone].ToLower()) || l.ldFax.ToLower().Contains(filter[LeadConstants.Phone].ToLower()) ); } if (!String.IsNullOrEmpty(filter[LeadConstants.OwnerID])) { Guid ownerID; if (Guid.TryParse(filter[LeadConstants.OwnerID], out ownerID)) leads = leads.Where(l => l.OwnerID.Equals(ownerID)); } if (!String.IsNullOrEmpty(filter[LeadConstants.State])) { var states = filter[LeadConstants.State].Split(','); leads = leads.Where(l => states.Contains(l.T_LeadStatus.lstsStatus)); } leadFilterCount=leads.Count(); switch (sortExpression.Split(' ')[0]) { case "LeadNumber": leads = leads.Page(pageIndex, pageSize, u => u.ldNumber, asc, out totalRows); break; case "Name": leads = leads.Page(pageIndex, pageSize, u => u.ldLastName, asc, out totalRows); break; case "Topic": leads = leads.Page(pageIndex, pageSize, u => u.ldTopic, asc, out totalRows); break; case "Status": leads = leads.Page(pageIndex, pageSize, u => u.LeadStatusID, asc, out totalRows); break; case "Created": leads = leads.Page(pageIndex, pageSize, u => u.ldCreatedOn, asc, out totalRows); break; case "OFAC": leads = leads.Page(pageIndex, pageSize, u => u.ldOFAC, asc, out totalRows); break; case "Exl": leads = leads.Page(pageIndex, pageSize, u => u.ldExlList, asc, out totalRows); break; case "Addr": leads = leads.Page(pageIndex, pageSize, u => u.ldAddrVal, asc, out totalRows); break; default: leads = leads.Page(pageIndex, pageSize, u => u.ldCreatedOn, !asc, out totalRows); break; } return leads.Select(l => this.GetLeadEntity(l)).ToList(); } }
public List<PipelineAction> GetAvailableLeadActions(int id) { var actions = new List<PipelineAction>(); var filter = new LeadFilter(); filter[LeadConstants.LeadID] = id.ToString(); int i; var lead = SearchByFilter(filter, null, out i).FirstOrDefault(); if (lead == null) { throw new Exception("Lead not found."); } using (var dc = new EngageCCTDataClassesDataContext()) { var tActionsStatus = dc.T_ActionsStatus.Where(sa => sa.LeadStatusID == lead.LeadStatus.LeadStatusID); foreach (var tActionStatus in tActionsStatus) { var tA = tActionStatus.T_Action; var newAction = GetActionEntity(tA); switch (newAction.Name) { case PipelineActionConstants.AddActivity: case PipelineActionConstants.Edit: case PipelineActionConstants.CancelLead: case PipelineActionConstants.RestoreLead: case PipelineActionConstants.Validation: case PipelineActionConstants.ViewLead: case PipelineActionConstants.PushToEngage: newAction.Link += id; break; case PipelineActionConstants.ViewActivities: newAction.Link += lead.Number; break; } actions.Add(newAction); } return actions; } }