Ejemplo n.º 1
0
        public override bool PerformAction(Assignment assignment, Person currentPerson)
        {
            try
            {
                assignment.WorkerPersonId = assignment.RequesterPersonId;
                assignment.Save("AssignRequesterAsWorker", null);

                AssignmentHistory history = new AssignmentHistory();
                history.AssignmentId = assignment.AssignmentId;
                history.Action       = "Assigned to " + assignment.Worker.FullName;
                history.Save("AssignRequesterAsWorker");

                if (assignment.WorkerPersonId != -1 && Boolean.Parse(NotifyWorkerSetting))
                {
                    AssignmentEntryWorkerEmail email = new AssignmentEntryWorkerEmail();
                    if (currentPerson != null && currentPerson.Emails.FirstActive != string.Empty)
                    {
                        email.Template.Sender      = currentPerson.FullName;
                        email.Template.SenderEmail = currentPerson.Emails.FirstActive;
                    }
                    email.Send(assignment);
                }

                return(true);
            }
            catch (System.Exception ex)
            {
                assignment.AddNote("Exception", ex.Message, false, null, "AssignRequesterAsWorker");
                return(false);
            }
        }
 private void NotifyNewWorker(Assignment assignment, Person currentPerson)
 {
     if (assignment.WorkerPersonId != -1 && bool.Parse(this.NotifyWorkerSetting))
     {
         AssignmentEntryWorkerEmail assignmentEntryWorkerEmail = new AssignmentEntryWorkerEmail();
         if (currentPerson != null && currentPerson.Emails.FirstActive != string.Empty)
         {
             assignmentEntryWorkerEmail.Template.Sender      = currentPerson.FullName;
             assignmentEntryWorkerEmail.Template.SenderEmail = currentPerson.Emails.FirstActive;
         }
         assignmentEntryWorkerEmail.Send(assignment);
     }
 }
Ejemplo n.º 3
0
        public override bool PerformAction(Assignment assignment, Person currentPerson)
        {
            try
            {
                CustomFieldValue customField = assignment.FieldValues.FindById(Convert.ToInt32(FieldSetting));
                if (customField != null)
                {
                    if (customField.SelectedValue.Trim() != string.Empty)
                    {
                        assignment.WorkerPersonId = Int32.Parse(customField.SelectedValue.Trim());
                        assignment.Save("AssignFieldAsWorker", null);

                        AssignmentHistory history = new AssignmentHistory();
                        history.AssignmentId = assignment.AssignmentId;
                        history.Action       = "Assigned to " + assignment.Worker.FullName;
                        history.Save("AssignFieldAsWorker");

                        if (assignment.RequesterPersonId != -1 && Boolean.Parse(NotifyRequesterSetting))
                        {
                            AssignmentEntryRequesterEmail email = new AssignmentEntryRequesterEmail();
                            if (currentPerson != null && currentPerson.Emails.FirstActive != string.Empty)
                            {
                                email.Template.Sender      = currentPerson.FullName;
                                email.Template.SenderEmail = currentPerson.Emails.FirstActive;
                            }
                            email.Send(assignment);
                        }

                        if (assignment.WorkerPersonId != -1 && Boolean.Parse(NotifyWorkerSetting))
                        {
                            AssignmentEntryWorkerEmail email = new AssignmentEntryWorkerEmail();
                            if (currentPerson != null && currentPerson.Emails.FirstActive != string.Empty)
                            {
                                email.Template.Sender      = currentPerson.FullName;
                                email.Template.SenderEmail = currentPerson.Emails.FirstActive;
                            }
                            email.Send(assignment);
                        }
                    }
                }
                return(true);
            }
            catch (System.Exception ex)
            {
                assignment.AddNote("Exception", ex.Message, false, null, "AssignFieldAsWorker");
                return(false);
            }
        }
Ejemplo n.º 4
0
        public override bool PerformAction(Assignment assignment, Person currentPerson)
        {
            try
            {
                if (assignment.WorkerPersonId == -1)
                {
                    AssignmentTypeField field = assignment.AssignmentType.Fields.FindByTitle("Requester's Area");
                    if (field != null)
                    {
                        AssignmentFieldValue fieldValue = assignment.FieldValues.FindByID(field.CustomFieldId);
                        if (fieldValue != null)
                        {
                            Area area = new Area(Convert.ToInt32(fieldValue.SelectedValue));
                            if (area != null)
                            {
                                foreach (AreaOutreachCoordinator leader in area.OutreachCoordinators)
                                {
                                    if (leader.AreaRole.LookupID == Convert.ToInt32(AreaRoleSetting))
                                    {
                                        assignment.WorkerPersonId = leader.PersonId;
                                        assignment.Save("AssignAreaLeader", null);
                                        break;
                                    }
                                }
                            }
                        }
                    }
                }

                if (assignment.WorkerPersonId != -1)
                {
                    if (assignment.RequesterPersonId != -1 && Boolean.Parse(NotifyRequesterSetting))
                    {
                        AssignmentEntryRequesterEmail email = new AssignmentEntryRequesterEmail();
                        if (currentPerson != null && currentPerson.Emails.FirstActive != string.Empty)
                        {
                            email.Template.Sender      = currentPerson.FullName;
                            email.Template.SenderEmail = currentPerson.Emails.FirstActive;
                        }
                        email.Send(assignment);
                    }

                    if (assignment.WorkerPersonId != -1 && Boolean.Parse(NotifyWorkerSetting))
                    {
                        AssignmentEntryWorkerEmail email = new AssignmentEntryWorkerEmail();
                        if (currentPerson != null && currentPerson.Emails.FirstActive != string.Empty)
                        {
                            email.Template.Sender      = currentPerson.FullName;
                            email.Template.SenderEmail = currentPerson.Emails.FirstActive;
                        }
                        email.Send(assignment);
                    }
                }

                return(true);
            }
            catch (System.Exception ex)
            {
                assignment.AddNote(ex.Message, false, currentPerson, "AssignAreaLeader");
                return(false);
            }
        }