Example #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);
            }
        }
        public override bool PerformAction(Assignment assignment, Person currentPerson)
        {
            try
            {
                if (assignment.Requester != null && assignment.Requester.Area != null)
                {
                    AssignmentTypeField field = assignment.AssignmentType.Fields.FindByTitle("Requester's Area");
                    if (field != null)
                    {
                        AssignmentFieldValue fieldValue = assignment.FieldValues.FindByID(field.CustomFieldId);
                        if (fieldValue == null)
                        {
                            fieldValue = new AssignmentFieldValue();
                            fieldValue.AssignmentId  = assignment.AssignmentId;
                            fieldValue.CustomFieldId = field.CustomFieldId;
                            assignment.FieldValues.Add(fieldValue);
                        }
                        fieldValue.SelectedValue = assignment.Requester.Area.AreaID.ToString();
                        assignment.Save("SetAreaFromRequester", null);
                    }
                }

                return(true);
            }
            catch (System.Exception ex)
            {
                assignment.AddNote(ex.Message, false, currentPerson, "SetAreaFromRequester");
                return(false);
            }
        }
        public override bool PerformAction(Assignment assignment, Person currentPerson)
        {
            bool result;

            try
            {
                CustomFieldValue customFieldValue = assignment.FieldValues.FindById(Convert.ToInt32(this.FieldSetting));
                if (customFieldValue != null && customFieldValue.SelectedValue.Trim() == this.TestValueSetting.Trim())
                {
                    foreach (AssignmentTypeWorker worker in assignment.AssignmentType.Workers)
                    {
                        if (worker.PersonID.ToString() == this.WorkerPersonSetting)
                        {
                            assignment.WorkerPersonId = worker.PersonID;
                            assignment.Save("SetWorkerAfterTestField", null);
                            NotifyNewWorker(assignment, currentPerson);
                            NotifyRequesterOfNewWorker(assignment, currentPerson);
                            break;
                        }
                    }
                }
                result = true;
            }
            catch (Exception ex)
            {
                assignment.AddNote("Exception", ex.Message, false, null, "SetWorkerAfterTestField");
                result = false;
            }
            return(result);
        }
Example #4
0
        public override bool PerformAction(Assignment assignment, Person currentPerson)
        {
            bool result;

            try
            {
                List <string> list = new List <string>();
                CommunicationType.ParseMergeFieldNames(list, this.SubjectSetting);
                CommunicationType.ParseMergeFieldNames(list, this.BodySetting);
                string text  = this.BodySetting;
                string text2 = this.SubjectSetting;
                string text3 = this.RecipientSetting;
                foreach (KeyValuePair <string, string> current in assignment.GetMergedValues(list, true))
                {
                    text  = text.Replace(current.Key, current.Value);
                    text2 = text2.Replace(current.Key, current.Value);
                    text3 = text3.Replace(current.Key, current.Value);
                }

                if (this.RecipientFieldSetting != string.Empty)
                {
                    CustomFieldValue customFieldValue = assignment.FieldValues.FindById(Convert.ToInt32(this.RecipientFieldSetting));
                    if (customFieldValue != null)
                    {
                        string text4 = customFieldValue.SelectedValue;
                        if (customFieldValue.FieldTypeAssemblyName.ToLower().Contains("personfield"))
                        {
                            try
                            {
                                Person person = new Person(Convert.ToInt32(customFieldValue.SelectedValue));
                                text4 = person.Emails.FirstActive;
                            }
                            catch
                            {
                            }
                        }
                        if (text4.Trim() != string.Empty)
                        {
                            text3 = ((text3 == string.Empty) ? text4 : (text3 + ";" + text4));
                        }
                    }
                }
                result = ArenaSendMail.SendMail(this.FromAddressSetting, this.FromNameSetting, text3, this.FromAddressSetting, this.CCSetting, this.BCCSetting, text2, text, string.Empty);
            }
            catch (Exception ex)
            {
                assignment.AddNote("Exception", ex.Message, false, null, "SendAssignmentEmail");
                result = false;
            }
            return(result);
        }
Example #5
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);
            }
        }
        public override bool PerformAction(Assignment assignment, Person currentPerson)
        {
            try
            {
                ArrayList lst = new ArrayList();
                lst.Add(new SqlParameter("@AssignmentId", assignment != null ? assignment.AssignmentId : -1));
                lst.Add(new SqlParameter("@PersonId", currentPerson != null ? currentPerson.PersonID : -1));

                bool          result = true;
                SqlDataReader rdr    = new Arena.DataLayer.Organization.OrganizationData().ExecuteReader(StoredProcSetting, lst);
                if (rdr.Read())
                {
                    try { result = (bool)rdr["result"]; }
                    catch { }
                }
                rdr.Close();

                if (result)
                {
                    // Because the Assignment Object's ProcessState method saves the assignment object before reading any
                    // changes that this action may have made, every property on the passed in object should be updated
                    // prior to returning (since we don't really know what properties the SQL Proc may have updated)
                    Assignment newAssignment = new Assignment(assignment.AssignmentId);
                    assignment.Description       = newAssignment.Description;
                    assignment.DueDate           = newAssignment.DueDate;
                    assignment.FieldValues       = newAssignment.FieldValues;
                    assignment.PriorityId        = newAssignment.PriorityId;
                    assignment.RequesterPersonId = newAssignment.RequesterPersonId;
                    assignment.ResolutionText    = newAssignment.ResolutionText;
                    assignment.ResolvedDate      = newAssignment.ResolvedDate;
                    assignment.StateId           = newAssignment.StateId;
                    assignment.Title             = newAssignment.Title;
                    assignment.WorkerPersonId    = newAssignment.WorkerPersonId;
                }

                return(result);
            }
            catch (System.Exception ex)
            {
                assignment.AddNote("Exception", ex.Message, false, null, "ExecuteSQLProc");
                return(false);
            }
        }
        public override bool PerformAction(Assignment assignment, Person currentPerson)
        {
            try
            {
                // Find the custom field, then load the person.
                CustomFieldValue customField = assignment.FieldValues.FindById(int.Parse(FieldSetting));
                if (customField != null && customField.SelectedValue.Trim() != string.Empty)
                {
                    int personID = int.Parse(customField.SelectedValue.Trim());

                    PersonHistory history = new PersonHistory();
                    history.PersonID      = personID;
                    history.HistoryType   = new Lookup(SystemLookup.PersonHistoryType_User);
                    history.Text          = assignment.ResolutionText;
                    history.SystemHistory = false;
                    history.Save(int.Parse(OrganizationIDSetting), assignment.Worker.FullName);

                    Person            person            = new Person(personID);
                    AssignmentHistory assignmentHistory = new AssignmentHistory();
                    assignmentHistory.AssignmentId = assignment.AssignmentId;
                    assignmentHistory.Action       = "Resolution copied to " + person.FullName + " as a note";
                    assignmentHistory.Save("AddResolutionToPersonNote");

                    // This will let the worker view the person note:
                    history.ApplyPersonSecurity(assignment.WorkerPersonId, assignment.Worker.FullName);

                    // Now, we'll apply the security template if one was selected.
                    if (SecurityTemplateSetting != string.Empty)
                    {
                        history.ApplyTemplateSecurity(int.Parse(SecurityTemplateSetting));
                    }
                }

                return(true);
            }
            catch (System.Exception ex)
            {
                assignment.AddNote("Exception", ex.Message, false, null, "AssignRequesterAsWorker");
                return(false);
            }
        }
        public override bool PerformAction(Assignment assignment, Person currentPerson)
        {
            try
            {
                if (StoredProcedureNameSetting != null && !string.IsNullOrEmpty(StoredProcedureNameSetting.Trim()))
                {
                    // someday, maybe we'll want to pass some parameters/values via two "Settings"...
                    // but doing it that way would require some assumptions about the values.
                    ArrayList arrayList = new ArrayList();

                    new OrganizationData().ExecuteNonQuery(StoredProcedureNameSetting.Trim(), arrayList);
                }

                return(true);
            }
            catch (System.Exception ex)
            {
                assignment.AddNote("Exception", ex.Message, false, null, "ExecuteStoredProcedure");
                return(false);
            }
        }
Example #9
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);
            }
        }