private void attach_T_Activities1(T_Activity entity)
		{
			this.SendPropertyChanging();
			entity.T_UserInformation1 = this;
		}
		private void detach_T_Activities2(T_Activity entity)
		{
			this.SendPropertyChanging();
			entity.T_UserInformation2 = null;
		}
		private void attach_T_Activities(T_Activity entity)
		{
			this.SendPropertyChanging();
			entity.T_Lead = this;
		}
		private void detach_T_Activities(T_Activity entity)
		{
			this.SendPropertyChanging();
			entity.T_Priority = null;
		}
 partial void UpdateT_Activity(T_Activity instance);
 partial void DeleteT_Activity(T_Activity instance);
 partial void InsertT_Activity(T_Activity instance);
Пример #8
0
		public string GetActivityType(int id)
		{
			var activity = new T_Activity();
			var actType = new T_ActivityType();
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				activity = dc.T_Activities.Where(a => a.ActivityID == id).FirstOrDefault();
				try
				{
					actType = dc.T_ActivityTypes.Where(a => a.TypeID == activity.TypeID).FirstOrDefault();
				}
				catch (NullReferenceException e)
				{
					var exc = new Exception("No such activity in DB", e);
					throw exc;
				}
			}
			if (actType == null)
			{
				var exc = new Exception("No such activity type in DB");
				throw exc;
			}
			return actType.atType;
		}
Пример #9
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;
			}
		}
Пример #10
0
		private static Activity GetActivityEntity(T_Activity tActivity)
		{
			using (var dc = new EngageCCTDataClassesDataContext())
			{
				UserInformation createdBy = new UserInformation { FirstName = tActivity.T_UserInformation.usrFirstName, LastName = tActivity.T_UserInformation.usrLastName, Login = tActivity.T_UserInformation.Login };
				UserInformation owner = new UserInformation { FirstName = tActivity.T_UserInformation1.usrFirstName, LastName = tActivity.T_UserInformation1.usrLastName, Login = tActivity.T_UserInformation1.Login };
				UserInformation sender = new UserInformation { FirstName = tActivity.T_UserInformation2.usrFirstName, LastName = tActivity.T_UserInformation2.usrLastName, Login = tActivity.T_UserInformation2.Login };

				var tActivityLeads = dc.T_ActivityLeads.Where(al => al.ActivityID == tActivity.ActivityID);
				var tLeads = dc.T_Leads.Where(l => tActivityLeads.Any(ac => ac.LeadID == l.LeadID));
				CCTLeadProvider leadProvider = new CCTLeadProvider();
				List<Lead> recipients = new List<Lead>();
				foreach (var lead in tLeads)
				{
					var recipient = leadProvider.GetLeadEntity(lead);
					recipients.Add(recipient);
				}

				Priority priority = new Priority { PriorityID = tActivity.T_Priority.PriorityID, Type = tActivity.T_Priority.prType };
				ActivityType activityType = new ActivityType { Type = tActivity.T_ActivityType.atType, TypeID = tActivity.T_ActivityType.TypeID };

				DateTime createdDate = tActivity.actCreationDate;
				DateTime? dueDate = tActivity.actDue;

				List<Note> notes = new List<Note>();
				var tActivityNotes = dc.T_ActivityNotes.Where(e => e.ActivityID == tActivity.ActivityID);
				foreach (var tActivityNote in tActivityNotes)
				{
					notes.Add(leadProvider.GetNoteEntity(tActivityNote.T_Note));
				}


				//Activity activity = new Activity()
				//{
				//  ActivityID = tActivity.ActivityID,
				//  CreatedBy = createdBy,
				//  ActivityType = activityType,
				//  CreatedOn = createdDate,
				//  Due = dueDate,
				//  Notes = notes,
				//  Owner = owner,
				//  Post = tActivity.actPost,
				//  Priority = priority,
				//  Recipient = recipient,
				//  Sender = sender,
				//  Subject = tActivity.actSubject
				//};

				ActivityStatus status = new ActivityStatus();
				status.StatusID = tActivity.StatusID;
				var stat = dc.T_ActivityStatus.Where(st => st.StatusID == status.StatusID).Select(s => s.asStatus).First();
				status.Status = stat;
				Activity activity = new Activity();
				activity.ActivityID = tActivity.ActivityID;
				activity.CreatedBy = createdBy;
				activity.ActivityType = activityType;
				activity.CreatedOn = createdDate;
				activity.Due = dueDate;
				activity.Notes = notes;
				activity.Owner = owner;
				activity.Post = tActivity.actPost;
				activity.Priority = priority;
				activity.Recipient = recipients;
				activity.Sender = sender;
				activity.Subject = tActivity.actSubject;
				activity.Status = status;

				if (tActivity.actPhone != null)
				{
					activity.Phone = tActivity.actPhone;
				}
				if (tActivity.actAddress != null)
				{
					activity.Address = tActivity.actAddress;
				}

				return activity;
			}
		}
Пример #11
0
		private static string GetDateFormat(T_Activity activity)
		{
			StringBuilder date = new StringBuilder();

			if (activity.actCreationDate.Month < 10)
				date.AppendFormat("0{0}/", activity.actCreationDate.Month);
			else date.AppendFormat("{0}/", activity.actCreationDate.Month);

			if (activity.actCreationDate.Day < 10)
				date.AppendFormat("0{0}/", activity.actCreationDate.Day);
			else date.AppendFormat("{0}/", activity.actCreationDate.Day);

			date.AppendFormat("{0}", activity.actCreationDate.Year);

			return date.ToString();
		}