示例#1
0
		public void UpdateValidationResource(ValidationResource update)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				T_ValidationResource tvr = dc.T_ValidationResources.SingleOrDefault(vr => vr.vrName == update.Name);
				if (tvr == null)
				{
					throw new ApplicationException("Invalid validation resource name");
				}
				tvr.vrDownloadDate = update.DownloadDate;
				tvr.vrContent = update.Content;
				dc.SubmitChanges();
			}
		}
示例#2
0
		public void SaveTask(ScheduledTaskInfo taskInfo)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				T_ScheduledTask tTask;
				tTask = dc.T_ScheduledTasks.SingleOrDefault(t => t.SheduledTaskID == taskInfo.ID);
				if (tTask == null)
				{
					throw new ApplicationException("Invalid sheduled task ID");
				}
				tTask.stTitle = taskInfo.Title;
				tTask.stInterval = taskInfo.Interval;
				tTask.stLastRan = taskInfo.LastRan;
				dc.SubmitChanges();
			}
		}
示例#3
0
		private void IncrementLastNumber()
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				var config = dc.T_Configurations.First();
				config.cfgLastNumber++;
				dc.SubmitChanges();
			}
		}
示例#4
0
		public int SaveValidationAddress(ValidationAddress address)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				T_ValidationAddressError tError = new T_ValidationAddressError();
				if (address.Error != null)
				{
					tError.erDesc = address.Error.Description;
					tError.erLocation = address.Error.Location;
					tError.erNumber = address.Error.Number;
					dc.T_ValidationAddressErrors.InsertOnSubmit(tError);
					dc.SubmitChanges();
				}
				T_ValidationAddress tAddress = new T_ValidationAddress();
				if (!string.IsNullOrEmpty(address.Address))
				{
					tAddress.vadAddress = address.Address;
				}
				if (!string.IsNullOrEmpty(address.City))
				{
					tAddress.vadCity = address.City;
				}
				if (!string.IsNullOrEmpty(address.Country))
				{
					tAddress.vadCountry = address.Country;
				}
				if (!string.IsNullOrEmpty(address.State))
				{
					tAddress.vadState = address.State;
				}
				if (!string.IsNullOrEmpty(address.ZipCode))
				{
					tAddress.vadZipCode = address.ZipCode;
				}
				if (address.Error != null)
				{
					tAddress.ErrorID = tError.ErrorID;
				}
				dc.T_ValidationAddresses.InsertOnSubmit(tAddress);
				dc.SubmitChanges();
				return tAddress.AddressID;
			}
		}
示例#5
0
		public void SaveExcludedCompanies(IEnumerable<Company> companies)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				foreach (var company in companies)
				{
					T_ExcListCompany tCompany = new T_ExcListCompany();
					tCompany.elcAddressLine1 = company.AddressLine1;
					tCompany.elcAddressLine2 = company.AddressLine2;
					tCompany.elcAddressLine3 = company.AddressLine3;
					tCompany.elcAkaDba = company.Aka;
					tCompany.elcCity = company.City;
					tCompany.elcComments = company.Comments;
					tCompany.elcCompanyName = company.CompanyName;
					tCompany.elcIssuingState = company.IssuingState;
					tCompany.elcLicenseNumber = company.LicenseNumber;
					tCompany.elcState = company.State;
					tCompany.elcZip = company.Zip;
					dc.T_ExcListCompanies.InsertOnSubmit(tCompany);
				}
				dc.SubmitChanges();
			}
		}
示例#6
0
		public int SaveExcList(int validationID, Lead lead, string status)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				//int statusPassed = dc.T_ValidationStatus
				//  .Where(s => s.vsDescription == ValidationConstants.StatusPassed)
				//  .Select(st => st.StatusID)
				//  .First();
				//int statusFailed = dc.T_ValidationStatus
				//  .Where(s => s.vsDescription == ValidationConstants.StatusFailed)
				//  .Select(st => st.StatusID)
				//  .First();
				//int statusNoInfo = dc.T_ValidationStatus
				//  .Where(s => s.vsDescription == ValidationConstants.StatusNoInformation)
				//  .Select(st => st.StatusID)
				//  .First();

				int exRes = 0;
				T_ValidationResult tResult = new T_ValidationResult();
				T_ValidationFail tExcListValidation = new T_ValidationFail();
				LeadValidationManager tLeadVM = new LeadValidationManager();



				tResult.ValidationID = validationID;
				tResult.TypeID = dc.T_ValidationTypes
					.Where(t => t.vtDescription == ValidationConstants.FreddieList)
					.Select(tp => tp.TypeID)
					.First();

				if (status != ValidationConstants.StatusNoInformation)
				{
					var validResult = LeadValidationManager.SearchInExclusionaryList(lead);
					if (validResult != null)
					{
						exRes = (int)StatusValidation.Failed;
						tExcListValidation.vfExcList = tLeadVM.GetXmlExcListEntry(validResult);

						dc.T_ValidationFails.InsertOnSubmit(tExcListValidation);
						dc.SubmitChanges();
						tResult.StatusID = (int)StatusValidation.Failed;
						tResult.FailID = tExcListValidation.FailID;
						//---------------
					}
					else
					{
						exRes = (int)StatusValidation.Passed;
						tResult.StatusID = (int)StatusValidation.Passed;
						tResult.FailID = null;
					}
				}
				else
				{
					exRes = (int)StatusValidation.NoInformation;
					tResult.StatusID = (int)StatusValidation.NoInformation;
					tResult.FailID = null;
				}

				dc.T_ValidationResults.InsertOnSubmit(tResult);
				dc.SubmitChanges();
				return exRes;
			}
		}
示例#7
0
		public int SaveValidationLead(ValidationLead validation)
		{

			using (var dc = new EngageCCTDataClassesDataContext())
			{
				T_Validation tValidation = new T_Validation();

				tValidation.LeadID = (int)validation.Lead.LeadID;
				tValidation.Login = validation.User.Login;
				tValidation.vldDate = DateTime.Now;
				dc.T_Validations.InsertOnSubmit(tValidation);


				dc.SubmitChanges();

				List<ValidationResult> results = validation.Results;
				int ofac = 0;
				int exList = 0;
				int addVal = 0;

				int noInfoStatus = dc.T_ValidationStatus
					.Where(s => s.vsDescription == ValidationConstants.StatusNoInformation)
					.Select(f => f.StatusID).First();


				foreach (var result in results)
				{
					switch (result.Type.Type)
					{
						case ValidationConstants.OFAC:
							ofac = SaveOFAC(tValidation.ValidationID, validation.Lead, result.Status.Status);
							break;
						case ValidationConstants.FreddieList:
							exList = SaveExcList(tValidation.ValidationID, validation.Lead, result.Status.Status);
							break;
						case ValidationConstants.Address:
							addVal = SaveAddrValidation(tValidation.ValidationID, validation.Lead, result.Status.Status);
							break;
						default: break;
					}
				}

				var tLead = dc.T_Leads.Where(l => l.LeadID == (int)validation.Lead.LeadID).First();
				tLead.ldOFAC = ofac;
				tLead.ldAddrVal = addVal;
				tLead.ldExlList = exList;
				dc.SubmitChanges();
				return tValidation.ValidationID;
			}
		}
示例#8
0
		public void DeleteActivityNote(int noteID)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				var tNote = dc.T_Notes.AsQueryable().SingleOrDefault(n => n.NoteID == noteID);
				var tNoteActivity = dc.T_ActivityNotes.AsQueryable().SingleOrDefault(n => n.NoteID == noteID);
				if (tNote == null || tNoteActivity == null)
				{
					throw new ApplicationException("Invalid note ID");
				}
				dc.T_Notes.DeleteOnSubmit(tNote);
				dc.T_ActivityNotes.DeleteOnSubmit(tNoteActivity);
				dc.SubmitChanges();
			}
		}
示例#9
0
		private T_AllowedContact SaveContactPreferences(ContactPreferences contact, int id)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				T_AllowedContact tContact = dc.T_AllowedContacts.SingleOrDefault(c => c.LeadID == id);
				if (tContact == null)
				{
					tContact = new T_AllowedContact();
					tContact.LeadID = id;
					dc.T_AllowedContacts.InsertOnSubmit(tContact);
				}
				tContact.acBusinessPhone = contact.IsAllowBusinessPhone;
				tContact.acCellPhone = contact.IsAllowMobilePhone;
				tContact.acEmail = contact.IsAllowEmail;
				tContact.acFax = contact.IsAllowFax;
				tContact.acHomePhone = contact.IsAllowHomePhone;
				tContact.acSkypeName = contact.IsAllowSkype;
				tContact.acPreferredContact = contact.PreferredContact;
				dc.SubmitChanges();
				return tContact;
			}
		}
示例#10
0
 public void LeadModified(int leadId)
 {
     using (var dc = new EngageCCTDataClassesDataContext())
     {
         var lead = dc.T_Leads.Where(l => l.LeadID == leadId).FirstOrDefault();
         if (lead == null)
         {
             throw new Exception("Lead Not Found");
         }
         else
         {
             lead.ldCreatedOn = DateTime.Now;
             dc.SubmitChanges();
         }
     }
 }
示例#11
0
		public void DeleteImportantDate(int id)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				var tLeadDate = dc.T_LeadImportantDates.Where(d => d.DateID == id).FirstOrDefault();
				var tDate = dc.T_ImportantDates.Where(d => d.DateID == id).FirstOrDefault();

				if (tLeadDate == null || tDate == null)
				{
					throw new ApplicationException("Important Date not found");
				}
				dc.T_LeadImportantDates.DeleteOnSubmit(tLeadDate);
				dc.T_ImportantDates.DeleteOnSubmit(tDate);
				dc.SubmitChanges();
			}

		}
示例#12
0
		public int SaveLead(Lead entity)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				T_Lead tLead;
				if (!entity.LeadID.HasValue)
				{
					tLead = new T_Lead();
					dc.T_Leads.InsertOnSubmit(tLead);
				}
				else
				{
					tLead = dc.T_Leads.SingleOrDefault(l => l.LeadID == entity.LeadID);
					if (tLead == null)
					{
						throw new ApplicationException("Lead not found");
					}
				}
				tLead.ldBusinessPhone = entity.BusinessPhone;
				tLead.ldCompanyName = entity.CompanyName;
				tLead.ldEmail = entity.Email;
				tLead.ldFirstName = entity.FirstName;
				tLead.ldHomePhone = entity.HomePhone;
				tLead.ldJobTitle = entity.JobTitle;
				tLead.ldLastName = entity.LastName;
				tLead.ldMobilePhone = entity.MobilePhone;
				tLead.ldSkype = entity.Skype;
				//if (entity.OFAC > 0 && entity.OFAC < 5)
				//{
				tLead.ldOFAC = entity.OFAC;
				//}
				//if (tLead.ldExlList > 0 && tLead.ldExlList < 5)
				//{
				tLead.ldExlList = entity.ExlList;
				//}
				//if (entity.AddrVal > 0 && entity.AddrVal < 5)
				//{
				tLead.ldAddrVal = entity.AddrVal;
				//}


				tLead.ldSSN = entity.SSN;
				tLead.ldFax = entity.Fax;

				//SaveContactPreferences(entity.Contact, tLead.LeadID);

				if (!entity.LeadID.HasValue)
				{
					var lastNumber = GetLastNumber();
					tLead.ldNumber = (lastNumber + 1).ToString();
					entity.Number = lastNumber + 1;
					IncrementLastNumber();
				}

				if (entity.Honorific != null)
				{
					tLead.SalutationID = GetSalutationIdByName(entity.Honorific);
				}
				else
				{
					tLead.SalutationID = null;
				}
				tLead.OwnerID = entity.Owner;
				tLead.ldTopic = entity.Topic;
				tLead.ldCreatedOn = entity.CreatedOn;
				tLead.LeadStatusID = (int)entity.LeadStatus.LeadStatusID;
				if (entity.LeadSource != null)
				{
					tLead.LeadSourceID = entity.LeadSource.LeadSourceID;
				}
				if (entity.CompanyAddress != null)
				{
					tLead.CompanyAddressID = SaveAddress(entity.CompanyAddress);
				}
				if (entity.HomeAddress != null)
				{
					tLead.HomeAddressID = SaveAddress(entity.HomeAddress);
				}
				if (entity.WorkAddress != null)
				{
					tLead.WorkAddressID = SaveAddress(entity.WorkAddress);
				}
				if (entity.SubjectPropertyAddress != null)
				{
					tLead.SubjectPropertyAddressID = SaveAddress(entity.SubjectPropertyAddress);
				}
				dc.SubmitChanges();
				//remove this code from line 58
				SaveContactPreferences(entity.Contact, tLead.LeadID);
				if (entity.Notes != null)
				{
					foreach (Note item in entity.Notes)
					{
						if (!item.NoteID.HasValue)
						{
							item.NoteID = SaveNote(item, tLead.LeadID);
						}
						else
						{
							T_Note tNote = dc.T_Notes.Single(n => n.NoteID == item.NoteID);
							if (tNote.ntEdited < item.Edited)
							{
								SaveNote(item, tLead.LeadID);
							}
						}
					}
				}
				//add logic to save important dates
				if (entity.Dates != null)
				{
					foreach (ImportantDate date in entity.Dates)
					{
						if (!date.DateID.HasValue)
							date.DateID = SaveImportantDate(date, tLead.LeadID);
						else
						{
							//T_ImportantDate tDate = dc.T_ImportantDates.SingleOrDefault(d => d.DateID == date.DateID);
						}

					}
				}

				return tLead.LeadID;
			}
		}
示例#13
0
		public void UpdateImportantDates(int id, string date, string reason, string note)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				Thread.CurrentThread.CurrentCulture = CultureInfo.CreateSpecificCulture("en-US");
				//CultureInfo provider = CultureInfo.InvariantCulture;
				DateTime dt = DateTime.Parse(date);

				var tDate = dc.T_ImportantDates.Where(d => d.DateID == id).First();
				tDate.idtNote = note;
				tDate.idtReason = reason;
				tDate.idtDate = dt;
				dc.SubmitChanges();

			}
		}
示例#14
0
		public int SaveImportantDate(ImportantDate entity, int leadID)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				T_ImportantDate tDate;
				T_LeadImportantDate tLeadDate;
				if (!entity.DateID.HasValue)
				{
					tDate = new T_ImportantDate();
					tLeadDate = new T_LeadImportantDate();
				}
				else
				{
					tDate = dc.T_ImportantDates.SingleOrDefault(d => d.DateID == entity.DateID);
					tLeadDate = dc.T_LeadImportantDates.SingleOrDefault(d => d.DateID == entity.DateID);
					if (tDate == null || tLeadDate == null)
					{
						throw new ApplicationException("Date not found");
					}
				}
				tDate.idtNote = entity.Note;
				tDate.idtReason = entity.Reason;
				tDate.idtDate = entity.Date;
				dc.T_ImportantDates.InsertOnSubmit(tDate);
				if (!entity.DateID.HasValue)
					dc.SubmitChanges();
				tLeadDate.LeadID = leadID;
				tLeadDate.DateID = tDate.DateID;
				dc.T_LeadImportantDates.InsertOnSubmit(tLeadDate);
				dc.SubmitChanges();
				return tDate.DateID;
			}
		}
示例#15
0
		private int SaveNote(Note entity, int activityID)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				T_Note tNote;
				T_ActivityNote tActivityNote;
				if (!entity.NoteID.HasValue)
				{
					tNote = new T_Note();
					tActivityNote = new T_ActivityNote();
				}
				else
				{
					tNote = dc.T_Notes.SingleOrDefault(n => n.NoteID == entity.NoteID);
					tActivityNote = dc.T_ActivityNotes.SingleOrDefault(n => n.NoteID == entity.NoteID);
					if (tNote == null || tActivityNote == null)
					{
						throw new ApplicationException("Note not found");
					}
				}
				tNote.ntCreated = entity.Created;
				tNote.ntEdited = entity.Edited;
				tNote.ntText = entity.Text;
				tNote.ntTitle = entity.Title;
				dc.T_Notes.InsertOnSubmit(tNote);
				if (!entity.NoteID.HasValue)
				{
					dc.SubmitChanges();
				}
				tActivityNote.NoteID = tNote.NoteID;
				tActivityNote.ActivityID = activityID;
				dc.T_ActivityNotes.InsertOnSubmit(tActivityNote);
				dc.SubmitChanges();
				return tNote.NoteID;
			}
		}
示例#16
0
		public void SaveRecipients(List<Recipient> usersRecipients, List<Recipient> leadsRecipients, int activityID)
		{
			_dataLeadProvider = new CCTLeadProvider();
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				//T_ActivityUserInformation tActivityUserInformation;
				//T_ActivityLead tActivityLead;
				//tActivityUserInformation = dc.T_ActivityUserInformations.SingleOrDefault(a => a.ActivityID == activityID);
				//tActivityLead = dc.T_ActivityLeads.SingleOrDefault(l => l.ActivityID == activityID);

				//if (tActivityUserInformation == null)
				//{
				//  tActivityUserInformation = new T_ActivityUserInformation();
				//}
				//if (tActivityLead == null)
				//{
				//  tActivityLead = new T_ActivityLead();
				//}

				if (usersRecipients.Count > 0)
				{

					foreach (var user in usersRecipients)
					{
						string login = GetUserLoginByFullName(user);
						T_ActivityUserInformation tActivityUserInformation = new T_ActivityUserInformation();
						tActivityUserInformation.ActivityID = activityID;
						tActivityUserInformation.Login = login;
						tActivityUserInformation.IsBcc = user.IsBcc;
						dc.T_ActivityUserInformations.InsertOnSubmit(tActivityUserInformation);
						dc.SubmitChanges();
					}
				}

				if (leadsRecipients.Count > 0)
				{
					foreach (var lead in leadsRecipients)
					{
						int id = _dataLeadProvider.GetLeadIDByFullName(lead);
						T_ActivityLead tActivityLead = new T_ActivityLead();
						tActivityLead.ActivityID = activityID;
						tActivityLead.LeadID = id;
						tActivityLead.IsBcc = lead.IsBcc;
						dc.T_ActivityLeads.InsertOnSubmit(tActivityLead);
						dc.SubmitChanges();
					}
				}

			}
		}
示例#17
0
		public int SaveAddress(Address entity)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				T_Address tAddress;
				if (!entity.AddressID.HasValue)
				{
					tAddress = new T_Address();
					dc.T_Addresses.InsertOnSubmit(tAddress);
				}
				else
				{
					tAddress = dc.T_Addresses.SingleOrDefault(a => a.AddressID == entity.AddressID);
					if (tAddress == null)
					{
						throw new ApplicationException("Address not found");
					}
				}
				tAddress.addrCity = entity.City;
				tAddress.addrCoords = entity.Coords;
				if (entity.Country != null)
				{
					tAddress.CountryID = dc.T_Countries.First(el => el.cntName == entity.Country.Name).CountryID;
				}
				tAddress.addrState = entity.State;
				tAddress.addrStreet = entity.Street;
				tAddress.addrZipCode = entity.ZipCode;
				tAddress.addrCounty = entity.County;
				dc.SubmitChanges();
				return tAddress.AddressID;
			}
		}
示例#18
0
		public bool ChangeStatus(int validationID, int typeID, int status)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				T_ValidationResult tResult = new T_ValidationResult();
				tResult = dc.T_ValidationResults.Where(r => r.ValidationID == validationID && r.TypeID == typeID).SingleOrDefault();
				if (tResult != null)
				{
					var tLead = dc.T_Validations.Where(w => w.ValidationID == validationID).Select(s => s.T_Lead).FirstOrDefault();
					if (tLead != null)
					{
						tLead.ldAddrVal = status;
					}
					tResult.StatusID = status;
					dc.SubmitChanges();
					return true;
				}
				return false;

			}
		}
示例#19
0
		public void SaveError(Error error)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				T_Error tError = new T_Error();
				tError.ErrorID = (Guid)error.ErrorID;
				tError.errDateTime = error.DateTime;
				tError.errMessage = error.Message;
				tError.errSource = error.Source;
				tError.errStackTrace = error.StackTrace;
				dc.T_Errors.InsertOnSubmit(tError);
				dc.SubmitChanges();
			}
		}
示例#20
0
		public int SaveOFAC(int validationID, Lead lead, string status)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				//int statusPassed = dc.T_ValidationStatus
				//  .Where(s => s.vsDescription == ValidationConstants.StatusPassed)
				//  .Select(st => st.StatusID)
				//  .First();
				//int statusFailed = dc.T_ValidationStatus
				//  .Where(s => s.vsDescription == ValidationConstants.StatusFailed)
				//  .Select(st => st.StatusID)
				//  .First();
				//int statusNoInfo = dc.T_ValidationStatus
				//  .Where(s => s.vsDescription == ValidationConstants.StatusNoInformation)
				//  .Select(st => st.StatusID)
				//  .First();

				T_ValidationResult tResult = new T_ValidationResult();
				LeadValidationManager tLeadVM = new LeadValidationManager();
				T_ValidationFail tFail = new T_ValidationFail();
				//T_Lead tLead = new T_Lead();

				tResult.ValidationID = validationID;
				tResult.TypeID = dc.T_ValidationTypes
					.Where(t => t.vtDescription == ValidationConstants.OFAC).Select(tp => tp.TypeID).First();

				int validStat = 0;
				if (status != ValidationConstants.StatusNoInformation)
				{
					var resultSearchInPLC = LeadValidationManager.SearchInPLC(lead);
					var resultSearchInSDN = LeadValidationManager.SearchInSDN(lead);

					if (resultSearchInPLC == null && resultSearchInSDN == null)
					{
						validStat = (int)StatusValidation.Passed;
						tResult.FailID = null;
					}
					else
					{
						if (resultSearchInPLC != null)
						{
							tFail.vfPLC = tLeadVM.GetXmlPLC(resultSearchInPLC);
						}
						if (resultSearchInSDN != null)
						{
							tFail.vfSDN = tLeadVM.GetXmlSDN(resultSearchInSDN);
						}
						dc.T_ValidationFails.InsertOnSubmit(tFail);
						dc.SubmitChanges();
						tResult.FailID = tFail.FailID;
						validStat = (int)StatusValidation.Failed;
					}
				}
				else
				{
					validStat = (int)StatusValidation.NoInformation;
					tResult.FailID = null;
				}



				//  if (resultSearchInPLC != null || resultSearchInSDN != null)
				//  {
				//    if (resultSearchInPLC != null)
				//    {
				//      tFail.vfPLC = tLeadVM.GetXmlPLC(resultSearchInPLC);
				//    }
				//    if (resultSearchInSDN != null)
				//    {
				//      tFail.vfSDN = tLeadVM.GetXmlSDN(resultSearchInSDN);

				//    }
				//    dc.T_ValidationFails.InsertOnSubmit(tFail);
				//    dc.SubmitChanges();
				//    tResult.FailID = tFail.FailID;
				//  }

				//  if (resultSearchInPLC == null && resultSearchInSDN == null)
				//  {
				//    validStat = (int)StatusValidation.Passed;
				//    tResult.FailID = null;
				//    //
				//  }
				//  else
				//  {
				//    validStat = (int)StatusValidation.Failed;
				//  }

				//}
				//else
				//{
				//  validStat = (int)StatusValidation.NoInformation;
				//  tResult.FailID = null;
				//}

				tResult.StatusID = validStat;
				dc.T_ValidationResults.InsertOnSubmit(tResult);
				dc.SubmitChanges();

				return validStat;
			}
		}
示例#21
0
		public void AddUserInformation(UserInformation entity)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				var userInfo = new T_UserInformation();
				userInfo.Login = entity.Login;
				userInfo.usrFirstName = entity.FirstName;
				userInfo.usrLastName = entity.LastName;
				dc.T_UserInformations.InsertOnSubmit(userInfo);
				dc.SubmitChanges();
			}
		}
示例#22
0
		public int SaveAddrValidation(int validationID, Lead lead, string status)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{

				int addrValStatus = 0;
				int addressID;
				T_ValidationResult tResult = new T_ValidationResult();
				T_ValidationAddress tAddress = new T_ValidationAddress();
				T_ValidationAddressError tError = new T_ValidationAddressError();

				tResult.ValidationID = validationID;
				tResult.TypeID = (int)TypeValidation.AddressValidation;
				if (status != ValidationConstants.StatusNoInformation)
				{
					var validAddress = LeadValidationManager.GetValidAddress(lead.SubjectPropertyAddress);
					if (validAddress.Error != null)
					{
						int errorID;
						ValidationAddressError error = new ValidationAddressError();
						error.Description = validAddress.Error.Description;
						error.Location = validAddress.Error.Location;
						error.Number = validAddress.Error.Number;
						errorID = SaveValidationAddressError(error);
						addrValStatus = (int)StatusValidation.Failed;
						tAddress.ErrorID = errorID;
					}
					else
					{
						//			SaveValidationAddress(validAddress);
						bool isCorrect = LeadValidationManager.CompareAddresses(lead.SubjectPropertyAddress, validAddress);
						if (isCorrect)
						{
							addrValStatus = (int)StatusValidation.Passed;
						}
						else
						{
							addrValStatus = (int)StatusValidation.Error;
						}
					}
					addressID = SaveValidationAddress(validAddress);
					tResult.AddressID = addressID;
					tResult.StatusID = addrValStatus;
				}
				else
				{
					addrValStatus = (int)StatusValidation.NoInformation;
					tResult.StatusID = addrValStatus;
				}
				dc.T_ValidationResults.InsertOnSubmit(tResult);
				dc.SubmitChanges();
				return addrValStatus;
			}
		}
示例#23
0
		//public void CancelOrRestoreLead(int leadId, int newstatusId)
		//{
		//  using (EngageCCTDataClassesDataContext dc = new EngageCCTDataClassesDataContext())
		//  {
		//    var leads = dc.T_Leads;
		//    var lead = leads.FirstOrDefault(l => l.LeadID == leadId);
		//    if (lead == null)
		//      throw new ApplicationException("There are no this lead!");
		//    else
		//    {
		//      if (lead.ldIsCancelled == true)
		//      {
		//        lead.ldIsCancelled = false;
		//      }
		//      else
		//      {
		//        lead.ldIsCancelled = true;
		//      }
		//      dc.SubmitChanges();
		//    }
		//  }
		//}

		public void UpdateUserInformation(UserInformation entity)
		{
			using (EngageCCTDataClassesDataContext dc = new EngageCCTDataClassesDataContext())
			{
				var user = dc.T_UserInformations.FirstOrDefault(u => u.Login == entity.Login);
				if (user != null)
				{
					user.usrFirstName = entity.FirstName;
					user.usrLastName = entity.LastName;
					dc.SubmitChanges();
				}
				else
					throw new ApplicationException("User is not found!");
			}
		}
示例#24
0
		public void SaveExcludedIndividuals(IEnumerable<Individual> individuals)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				foreach (var individual in individuals)
				{
					T_ExcListIndividual tIndividual = new T_ExcListIndividual();
					tIndividual.eliAddressLine1 = individual.AddressLine1;
					tIndividual.eliAddressLine2 = individual.AddressLine2;
					tIndividual.eliAddressLine3 = individual.AddressLine3;
					tIndividual.eliAkaDba = individual.Aka;
					tIndividual.eliCity = individual.City;
					tIndividual.eliComments = individual.Comments;
					tIndividual.eliFirstName = individual.FirstName;
					tIndividual.eliIssuingState = individual.IssuingState;
					tIndividual.eliLastName = individual.LastName;
					tIndividual.eliLicenseNumber = individual.LicenseNumber;
					tIndividual.eliLicenseType = individual.LicenseType;
					tIndividual.eliState = individual.State;
					tIndividual.eliZip = individual.Zip;
					dc.T_ExcListIndividuals.InsertOnSubmit(tIndividual);
				}
				dc.SubmitChanges();
			}
		}
示例#25
0
		public void SaveActivityLead(int activityID, List<Lead> leads)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				var activityLeads = new List<T_ActivityLead>();
				foreach (var lead in leads)
				{
					if (!dc.T_ActivityLeads.Any(al => (al.LeadID == lead.LeadID) && (al.ActivityID == activityID)))
					{
						if (lead.LeadID.HasValue)
						{
							activityLeads.Add(new T_ActivityLead { ActivityID = activityID, LeadID = lead.LeadID.Value });
						}
					}
				}
				dc.T_ActivityLeads.InsertAllOnSubmit(activityLeads);
				dc.SubmitChanges();
			}
		}
示例#26
0
		public int SaveValidationAddressError(ValidationAddressError error)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				T_ValidationAddressError tError = new T_ValidationAddressError();
				tError.erDesc = error.Description;
				tError.erLocation = error.Location;
				tError.erNumber = error.Number;
				dc.T_ValidationAddressErrors.InsertOnSubmit(tError);
				dc.SubmitChanges();
				return tError.ErrorID;
			}
		}
示例#27
0
		public int SaveEmailActivity(Activity entity, int Bcc)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				T_Activity tActivity;
				if (!entity.ActivityID.HasValue)
				{
					tActivity = new T_Activity();
					dc.T_Activities.InsertOnSubmit(tActivity);
				}
				else
				{
					tActivity = dc.T_Activities.SingleOrDefault(a => a.ActivityID == entity.ActivityID);
					if (tActivity == null)
					{
						throw new ApplicationException("Activity not found");
					}
				}
				tActivity.actCreationDate = entity.CreatedOn;
				tActivity.actPost = entity.Post;
				tActivity.actSubject = entity.Subject;
				tActivity.Author = entity.CreatedBy.Login;
				tActivity.Owner = entity.Owner.Login;
				tActivity.PriorityID = entity.Priority.PriorityID;
				tActivity.RecipientID = (int)entity.Recipient.First().LeadID;
				tActivity.Sender = entity.Sender.Login;
				tActivity.TypeID = entity.ActivityType.TypeID;
				tActivity.StatusID = entity.Status.StatusID;

				if (entity.Due != null)
				{
					tActivity.actDue = entity.Due;
				}
				if (entity.Phone != null)
				{
					tActivity.actPhone = entity.Phone;
				}
				if (entity.Address != null)
				{
					tActivity.actAddress = entity.Address;
				}
				if (entity.Notes != null)
				{
					foreach (Note item in entity.Notes)
					{
						if (!item.NoteID.HasValue)
						{
							item.NoteID = SaveNote(item, tActivity.ActivityID);
						}
						else
						{
							T_Note tNote = dc.T_Notes.Single(n => n.NoteID == item.NoteID);
							if (tNote.ntEdited < item.Edited)
							{
								SaveNote(item, tActivity.ActivityID);
							}
						}
					}
				}

				dc.SubmitChanges();
				this.SaveEmailActivityLead(tActivity.ActivityID, entity.Recipient, Bcc);
				return tActivity.ActivityID;
			}
		}
示例#28
0
		public void SaveEmailActivityLead(int activityID, List<Lead> leads, int Bcc)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				var activityLeads = new List<T_ActivityLead>();
				foreach (var lead in leads)
				{
					if (!dc.T_ActivityLeads.Any(al => (al.LeadID == lead.LeadID) && (al.ActivityID == activityID)))
					{
						if (lead.LeadID.HasValue)
						{
							bool isBcc = false;
							if (leads.IndexOf(lead) >= Bcc)
							{
								isBcc = true;
							}
							activityLeads.Add(new T_ActivityLead { ActivityID = activityID, LeadID = lead.LeadID.Value, IsBcc = isBcc });
						}
					}
					else
					{
						bool isBcc = false;
						if (leads.IndexOf(lead) >= Bcc)
						{
							isBcc = true;
						}
						var activityLead = dc.T_ActivityLeads.First(al => (al.LeadID == lead.LeadID) && (al.ActivityID == activityID));
						activityLead.IsBcc = isBcc;
					}
				}
				dc.T_ActivityLeads.InsertAllOnSubmit(activityLeads);
				dc.SubmitChanges();
			}
		}
示例#29
0
		public void AddDeleteNotificationToUser(Guid userID, int notificationID, bool flagAdd)
		{
			using (EngageCCTDataClassesDataContext dc = new EngageCCTDataClassesDataContext())
			{
				aspnet_User asp_User = dc.aspnet_Users.SingleOrDefault(a => a.UserId == userID);
				if (asp_User == null)
				{
					throw new ApplicationException("There are no this User");
				}
				T_NotificationType t_Ntype = dc.T_NotificationTypes.SingleOrDefault(n => n.TypeID == notificationID);
				if (t_Ntype == null)
				{
					throw new ApplicationException("There are no this notification");
				}
				T_NotificationUser t_userN = dc.T_NotificationUsers.SingleOrDefault(un => un.UserID == userID && un.TypeID == notificationID);
				if (t_userN == null && flagAdd == true)
				{
					t_userN = new T_NotificationUser() { UserID = userID, TypeID = notificationID };
					dc.T_NotificationUsers.InsertOnSubmit(t_userN);
					dc.SubmitChanges();
				}
				if (t_userN != null && flagAdd == false)
				{
					dc.T_NotificationUsers.DeleteOnSubmit(t_userN);
					dc.SubmitChanges();
				}

			}
		}