示例#1
0
        /// <summary>
        /// Show the details for the given person.
        /// </summary>
        /// <param name="personGuid"></param>
        private void ShowDetail(Guid personGuid)
        {
            btnReprintLabels.Visible = GetAttributeValue(AttributeKey.AllowLabelReprinting).AsBoolean();

            using (var rockContext = new RockContext())
            {
                var personService = new PersonService(rockContext);

                var person = personService.Queryable(true, true).Include(a => a.PhoneNumbers).Include(a => a.RecordStatusValue)
                             .FirstOrDefault(a => a.Guid == personGuid);

                if (person == null)
                {
                    return;
                }

                lName.Text = person.FullName;

                string photoTag = Rock.Model.Person.GetPersonPhotoImageTag(person, 200, 200);
                if (person.PhotoId.HasValue)
                {
                    lPhoto.Text = string.Format("<div class='photo'><a href='{0}'>{1}</a></div>", person.PhotoUrl, photoTag);
                }
                else
                {
                    lPhoto.Text = photoTag;
                }

                var campus = person.GetCampus();
                if (campus != null)
                {
                    hlCampus.Visible = true;
                    hlCampus.Text    = campus.Name;
                }
                else
                {
                    hlCampus.Visible = false;
                }

                lGender.Text = person.Gender != Gender.Unknown ? person.Gender.ConvertToString() : "";

                if (person.BirthDate.HasValue)
                {
                    string ageText = (person.BirthYear.HasValue && person.BirthYear != DateTime.MinValue.Year) ?
                                     string.Format("{0} yrs old ", person.BirthDate.Value.Age()) : string.Empty;
                    lAge.Text = string.Format("{0} <small>({1})</small><br/>", ageText, person.BirthDate.Value.ToShortDateString());
                }
                else
                {
                    lAge.Text = string.Empty;
                }

                lGrade.Text = person.GradeFormatted;

                lEmail.Visible = !string.IsNullOrWhiteSpace(person.Email);
                lEmail.Text    = person.GetEmailTag(ResolveRockUrl("/"), "btn btn-default", "<i class='fa fa-envelope'></i>");

                BindAttribute(person);
                // Text Message
                var phoneNumber = person.PhoneNumbers.FirstOrDefault(n => n.IsMessagingEnabled && n.Number.IsNotNullOrWhiteSpace());
                if (GetAttributeValue(AttributeKey.SMSFrom).IsNotNullOrWhiteSpace() && phoneNumber != null)
                {
                    btnSms.Text          = string.Format("<i class='fa fa-mobile'></i> {0} <small>({1})</small>", phoneNumber.NumberFormatted, phoneNumber.NumberTypeValue);
                    btnSms.Visible       = true;
                    rcwTextMessage.Label = "Text Message";
                }
                else
                {
                    btnSms.Visible       = false;
                    rcwTextMessage.Label = string.Empty;
                }

                // Get all family member from all families ( including self )
                var allFamilyMembers = personService.GetFamilyMembers(person.Id, true).ToList();

                // Add flag for this person in each family indicating if they are a child in family.
                var childGuid     = Rock.SystemGuid.GroupRole.GROUPROLE_FAMILY_MEMBER_CHILD.AsGuid();
                var isFamilyChild = new Dictionary <int, bool>();
                foreach (var thisPerson in allFamilyMembers.Where(m => m.PersonId == person.Id))
                {
                    isFamilyChild.Add(thisPerson.GroupId, thisPerson.GroupRole.Guid.Equals(childGuid));
                }

                // Get the current url's root (without the person's guid)
                string urlRoot = Request.Url.ToString().ReplaceCaseInsensitive(personGuid.ToString(), "");

                // Get the other family members and the info needed for rendering
                var familyMembers = allFamilyMembers.Where(m => m.PersonId != person.Id)
                                    .OrderBy(m => m.GroupId)
                                    .ThenBy(m => m.Person.BirthDate)
                                    .Select(m => new
                {
                    Url        = urlRoot + m.Person.Guid.ToString(),
                    FullName   = m.Person.FullName,
                    Gender     = m.Person.Gender,
                    FamilyRole = m.GroupRole,
                    Note       = isFamilyChild[m.GroupId] ?
                                 (m.GroupRole.Guid.Equals(childGuid) ? " (Sibling)" : "(Parent)") :
                                 (m.GroupRole.Guid.Equals(childGuid) ? " (Child)" : "")
                })
                                    .ToList();

                rcwFamily.Visible     = familyMembers.Any();
                rptrFamily.DataSource = familyMembers;
                rptrFamily.DataBind();

                rcwRelationships.Visible = false;
                if (GetAttributeValue(AttributeKey.ShowRelatedPeople).AsBoolean())
                {
                    var roles   = new List <int>();
                    var krRoles = new GroupTypeRoleService(rockContext)
                                  .Queryable().AsNoTracking()
                                  .Where(r => r.GroupType.Guid.Equals(new Guid(Rock.SystemGuid.GroupType.GROUPTYPE_KNOWN_RELATIONSHIPS)))
                                  .ToList();

                    foreach (var role in krRoles)
                    {
                        role.LoadAttributes(rockContext);
                        if (role.GetAttributeValue("CanCheckin").AsBoolean() &&
                            role.Attributes.ContainsKey("InverseRelationship"))
                        {
                            var inverseRoleGuid = role.GetAttributeValue("InverseRelationship").AsGuidOrNull();
                            if (inverseRoleGuid.HasValue)
                            {
                                var inverseRole = krRoles.FirstOrDefault(r => r.Guid == inverseRoleGuid.Value);
                                if (inverseRole != null)
                                {
                                    roles.Add(inverseRole.Id);
                                }
                            }
                        }
                    }

                    if (roles.Any())
                    {
                        var relatedMembers = personService.GetRelatedPeople(new List <int> {
                            person.Id
                        }, roles)
                                             .OrderBy(m => m.Person.LastName)
                                             .ThenBy(m => m.Person.NickName)
                                             .Select(m => new
                        {
                            Url      = urlRoot + m.Person.Guid.ToString(),
                            FullName = m.Person.FullName,
                            Gender   = m.Person.Gender,
                            Note     = " (" + m.GroupRole.Name + ")"
                        })
                                             .ToList();

                        rcwRelationships.Visible     = relatedMembers.Any();
                        rptrRelationships.DataSource = relatedMembers;
                        rptrRelationships.DataBind();
                    }
                }

                var phoneNumbers = person.PhoneNumbers.Where(p => !p.IsUnlisted).ToList();
                rptrPhones.DataSource = phoneNumbers;
                rptrPhones.DataBind();
                rcwPhone.Visible = phoneNumbers.Any();

                var schedules = new ScheduleService(rockContext)
                                .Queryable().AsNoTracking()
                                .Where(s => s.CheckInStartOffsetMinutes.HasValue)
                                .ToList();

                var scheduleIds = schedules.Select(s => s.Id).ToList();

                int?personAliasId = person.PrimaryAliasId;

                PersonAliasService personAliasService = new PersonAliasService(rockContext);
                if (!personAliasId.HasValue)
                {
                    personAliasId = personAliasService.GetPrimaryAliasId(person.Id);
                }

                var attendances = new AttendanceService(rockContext)
                                  .Queryable("Occurrence.Schedule,Occurrence.Group,Occurrence.Location,AttendanceCode")
                                  .Where(a =>
                                         a.PersonAliasId.HasValue &&
                                         a.PersonAliasId == personAliasId &&
                                         a.Occurrence.ScheduleId.HasValue &&
                                         a.Occurrence.GroupId.HasValue &&
                                         a.Occurrence.LocationId.HasValue &&
                                         a.DidAttend.HasValue &&
                                         a.DidAttend.Value &&
                                         scheduleIds.Contains(a.Occurrence.ScheduleId.Value))
                                  .OrderByDescending(a => a.StartDateTime)
                                  .Take(20)
                                  .ToList()                                               // Run query to get recent most 20 checkins
                                  .OrderByDescending(a => a.Occurrence.OccurrenceDate)    // Then sort again by start datetime and schedule start (which is not avail to sql query )
                                  .ThenByDescending(a => a.Occurrence.Schedule.StartTimeOfDay)
                                  .ToList()
                                  .Select(a =>
                {
                    var checkedInByPerson = a.CheckedInByPersonAliasId.HasValue ? personAliasService.GetPerson(a.CheckedInByPersonAliasId.Value) : null;

                    return(new AttendanceInfo
                    {
                        Id = a.Id,
                        Date = a.StartDateTime,
                        GroupId = a.Occurrence.Group.Id,
                        Group = a.Occurrence.Group.Name,
                        LocationId = a.Occurrence.LocationId.Value,
                        Location = a.Occurrence.Location.Name,
                        Schedule = a.Occurrence.Schedule.Name,
                        IsActive = a.IsCurrentlyCheckedIn,
                        Code = a.AttendanceCode != null ? a.AttendanceCode.Code : "",
                        CheckInByPersonName = checkedInByPerson != null ? checkedInByPerson.FullName : string.Empty,
                        CheckInByPersonGuid = checkedInByPerson != null ? checkedInByPerson.Guid : ( Guid? )null
                    });
                }
                                          ).ToList();

                // Set active locations to be a link to the room in manager page
                var qryParam = new Dictionary <string, string>();
                qryParam.Add("Group", "");
                qryParam.Add("Location", "");
                foreach (var attendance in attendances.Where(a => a.IsActive))
                {
                    qryParam["Group"]    = attendance.GroupId.ToString();
                    qryParam["Location"] = attendance.LocationId.ToString();
                    attendance.Location  = string.Format("<a href='{0}'>{1}</a>",
                                                         LinkedPageUrl(AttributeKey.ManagerPage, qryParam), attendance.Location);
                }

                rcwCheckinHistory.Visible = attendances.Any();

                // Get the index of the delete column
                var deleteField = gHistory.Columns.OfType <Rock.Web.UI.Controls.DeleteField>().First();
                _deleteFieldIndex = gHistory.Columns.IndexOf(deleteField);

                gHistory.DataSource = attendances;
                gHistory.DataBind();
            }
        }
        /// <summary>
        /// Handles the Click event of the lbSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void lbSave_Click(object sender, EventArgs e)
        {
            if (_group != null && _occurrence != null)
            {
                var rockContext        = new RockContext();
                var attendanceService  = new AttendanceService(rockContext);
                var personAliasService = new PersonAliasService(rockContext);

                var existingAttendees = attendanceService.Queryable()
                                        .Where(a =>
                                               a.GroupId == _group.Id &&
                                               a.ScheduleId == _group.ScheduleId &&
                                               a.StartDateTime >= _occurrence.StartDateTime &&
                                               a.StartDateTime < _occurrence.EndDateTime)
                                        .ToList();

                // If did not meet was selected and this was a manually entered occurrence (not based on a schedule)
                // then just delete all the attendance records instead of tracking a 'did not meet' value
                if (cbDidNotMeet.Checked && !_occurrence.ScheduleId.HasValue)
                {
                    foreach (var attendance in existingAttendees)
                    {
                        attendanceService.Delete(attendance);
                    }
                }
                else
                {
                    if (cbDidNotMeet.Checked)
                    {
                        // If the occurrence is based on a schedule, set the did not meet flags
                        foreach (var attendance in existingAttendees)
                        {
                            attendance.DidAttend   = null;
                            attendance.DidNotOccur = true;
                        }
                    }

                    foreach (var item in lvMembers.Items)
                    {
                        var hfMember = item.FindControl("hfMember") as HiddenField;
                        var cbMember = item.FindControl("cbMember") as CheckBox;

                        if (hfMember != null && cbMember != null)
                        {
                            int personId = hfMember.ValueAsInt();

                            var attendance = existingAttendees
                                             .Where(a => a.PersonAlias.PersonId == personId)
                                             .FirstOrDefault();

                            if (attendance == null)
                            {
                                int?personAliasId = personAliasService.GetPrimaryAliasId(personId);
                                if (personAliasId.HasValue)
                                {
                                    attendance               = new Attendance();
                                    attendance.GroupId       = _group.Id;
                                    attendance.ScheduleId    = _group.ScheduleId;
                                    attendance.PersonAliasId = personAliasId;
                                    attendance.StartDateTime = _occurrence.StartDateTime;
                                    attendanceService.Add(attendance);
                                }
                            }

                            if (attendance != null)
                            {
                                if (cbDidNotMeet.Checked)
                                {
                                    attendance.DidAttend   = null;
                                    attendance.DidNotOccur = true;
                                }
                                else
                                {
                                    attendance.DidAttend   = cbMember.Checked;
                                    attendance.DidNotOccur = null;
                                }
                            }
                        }
                    }
                }

                rockContext.SaveChanges();

                WorkflowType workflowType     = null;
                Guid?        workflowTypeGuid = GetAttributeValue("Workflow").AsGuidOrNull();
                if (workflowTypeGuid.HasValue)
                {
                    var workflowTypeService = new WorkflowTypeService(rockContext);
                    workflowType = workflowTypeService.Get(workflowTypeGuid.Value);
                    if (workflowType != null)
                    {
                        try
                        {
                            var workflowService = new WorkflowService(rockContext);
                            var workflow        = Workflow.Activate(workflowType, _group.Name);

                            workflow.SetAttributeValue("StartDateTime", _occurrence.StartDateTime.ToString("o"));
                            workflow.SetAttributeValue("Schedule", _group.Schedule.Guid.ToString());

                            List <string> workflowErrors;
                            if (workflow.Process(rockContext, _group, out workflowErrors))
                            {
                                if (workflow.IsPersisted || workflow.IsPersisted)
                                {
                                    if (workflow.Id == 0)
                                    {
                                        workflowService.Add(workflow);
                                    }

                                    rockContext.WrapTransaction(() =>
                                    {
                                        rockContext.SaveChanges();
                                        workflow.SaveAttributeValues(_rockContext);
                                        foreach (var activity in workflow.Activities)
                                        {
                                            activity.SaveAttributeValues(rockContext);
                                        }
                                    });
                                }
                            }
                        }
                        catch (Exception ex)
                        {
                            ExceptionLogService.LogException(ex, this.Context);
                        }
                    }
                }

                NavigateToParentPage(new Dictionary <string, string> {
                    { "GroupId", _group.Id.ToString() }
                });
            }
        }
示例#3
0
        /// <summary>
        /// Handles the Click event of the lbSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void lbSave_Click(object sender, EventArgs e)
        {
            if (_group != null && _occurrence != null)
            {
                var rockContext        = new RockContext();
                var attendanceService  = new AttendanceService(rockContext);
                var personAliasService = new PersonAliasService(rockContext);
                var locationService    = new LocationService(rockContext);

                bool dateAdjusted = false;

                DateTime startDate = _occurrence.Date;

                // If this is a manuall entered occurrence, check to see if date was changed
                if (!_occurrence.ScheduleId.HasValue)
                {
                    DateTime?originalDate = PageParameter("Date").AsDateTime();
                    if (originalDate.HasValue && originalDate.Value.Date != startDate.Date)
                    {
                        startDate    = originalDate.Value.Date;
                        dateAdjusted = true;
                    }
                }
                DateTime endDate = startDate.AddDays(1);

                var existingAttendees = attendanceService
                                        .Queryable("PersonAlias")
                                        .Where(a =>
                                               a.GroupId == _group.Id &&
                                               a.LocationId == _occurrence.LocationId &&
                                               a.ScheduleId == _occurrence.ScheduleId &&
                                               a.StartDateTime >= startDate &&
                                               a.StartDateTime < endDate);

                if (dateAdjusted)
                {
                    foreach (var attendee in existingAttendees)
                    {
                        attendee.StartDateTime = _occurrence.Date;
                    }
                }

                // If did not meet was selected and this was a manually entered occurrence (not based on a schedule/location)
                // then just delete all the attendance records instead of tracking a 'did not meet' value
                if (cbDidNotMeet.Checked && !_occurrence.ScheduleId.HasValue)
                {
                    foreach (var attendance in existingAttendees)
                    {
                        attendanceService.Delete(attendance);
                    }
                }
                else
                {
                    int?campusId = locationService.GetCampusIdForLocation(_occurrence.LocationId);
                    if (!campusId.HasValue)
                    {
                        campusId = _group.CampusId;
                    }
                    if (!campusId.HasValue && _allowCampusFilter)
                    {
                        var campus = CampusCache.Read(ExtensionMethods.SelectedValueAsInt(bddlCampus) ?? 0);
                        if (campus != null)
                        {
                            campusId = campus.Id;
                        }
                    }

                    if (cbDidNotMeet.Checked)
                    {
                        // If the occurrence is based on a schedule, set the did not meet flags
                        foreach (var attendance in existingAttendees)
                        {
                            attendance.DidAttend   = null;
                            attendance.DidNotOccur = true;
                        }
                    }

                    foreach (var attendee in _attendees)
                    {
                        var attendance = existingAttendees
                                         .Where(a => a.PersonAlias.PersonId == attendee.PersonId)
                                         .FirstOrDefault();

                        if (attendance == null)
                        {
                            int?personAliasId = personAliasService.GetPrimaryAliasId(attendee.PersonId);
                            if (personAliasId.HasValue)
                            {
                                attendance               = new Attendance();
                                attendance.GroupId       = _group.Id;
                                attendance.ScheduleId    = _group.ScheduleId;
                                attendance.PersonAliasId = personAliasId;
                                attendance.StartDateTime = _occurrence.Date.Date.Add(_occurrence.StartTime);
                                attendance.LocationId    = _occurrence.LocationId;
                                attendance.CampusId      = campusId;
                                attendance.ScheduleId    = _occurrence.ScheduleId;

                                // check that the attendance record is valid
                                cvAttendance.IsValid = attendance.IsValid;
                                if (!cvAttendance.IsValid)
                                {
                                    cvAttendance.ErrorMessage = attendance.ValidationResults.Select(a => a.ErrorMessage).ToList().AsDelimited("<br />");
                                    return;
                                }

                                attendanceService.Add(attendance);
                            }
                        }

                        if (attendance != null)
                        {
                            if (cbDidNotMeet.Checked)
                            {
                                attendance.DidAttend   = null;
                                attendance.DidNotOccur = true;
                            }
                            else
                            {
                                attendance.DidAttend   = attendee.Attended;
                                attendance.DidNotOccur = null;
                            }
                        }
                    }
                }

                if (_occurrence.LocationId.HasValue)
                {
                    Rock.CheckIn.KioskLocationAttendance.Flush(_occurrence.LocationId.Value);
                }

                rockContext.SaveChanges();

                WorkflowType workflowType     = null;
                Guid?        workflowTypeGuid = GetAttributeValue("Workflow").AsGuidOrNull();
                if (workflowTypeGuid.HasValue)
                {
                    var workflowTypeService = new WorkflowTypeService(rockContext);
                    workflowType = workflowTypeService.Get(workflowTypeGuid.Value);
                    if (workflowType != null)
                    {
                        try
                        {
                            var workflow = Workflow.Activate(workflowType, _group.Name);

                            workflow.SetAttributeValue("StartDateTime", _occurrence.Date.ToString("o"));
                            workflow.SetAttributeValue("Schedule", _group.Schedule.Guid.ToString());

                            List <string> workflowErrors;
                            new WorkflowService(rockContext).Process(workflow, _group, out workflowErrors);
                        }
                        catch (Exception ex)
                        {
                            ExceptionLogService.LogException(ex, this.Context);
                        }
                    }
                }

                var qryParams = new Dictionary <string, string> {
                    { "GroupId", _group.Id.ToString() }
                };

                var groupTypeIds = PageParameter("GroupTypeIds");
                if (!string.IsNullOrWhiteSpace(groupTypeIds))
                {
                    qryParams.Add("GroupTypeIds", groupTypeIds);
                }

                NavigateToParentPage(qryParams);
            }
        }
示例#4
0
        /// <summary>
        /// Save RSVP response data from grid (to Attendance records).
        /// </summary>
        protected bool SaveRSVPData()
        {
            var attendees = new List <RSVPAttendee>();

            foreach (GridViewRow row in gAttendees.Rows)
            {
                if (row.RowType == DataControlRowType.DataRow)
                {
                    RockCheckBox     rcbAccept         = row.FindControl("rcbAccept") as RockCheckBox;
                    RockCheckBox     rcbDecline        = row.FindControl("rcbDecline") as RockCheckBox;
                    DataDropDownList rddlDeclineReason = row.FindControl("rddlDeclineReason") as DataDropDownList;
                    RockTextBox      tbDeclineNote     = row.FindControl("tbDeclineNote") as RockTextBox;
                    int    declineReason = int.Parse(rddlDeclineReason.SelectedValue);
                    string declineNote   = tbDeclineNote.Text;

                    attendees.Add(
                        new RSVPAttendee()
                    {
                        Accept        = rcbAccept.Checked,
                        Decline       = rcbDecline.Checked,
                        DeclineNote   = declineNote,
                        DeclineReason = declineReason,
                        PersonId      = ( int )gAttendees.DataKeys[row.RowIndex].Value
                    }
                        );
                }
            }
            using (var rockContext = new RockContext())
            {
                var occurrenceService  = new AttendanceOccurrenceService(rockContext);
                var attendanceService  = new AttendanceService(rockContext);
                var personAliasService = new PersonAliasService(rockContext);

                AttendanceOccurrence occurrence = null;

                int?groupId      = PageParameter(PageParameterKey.GroupId).AsIntegerOrNull();
                int?occurrenceId = PageParameter(PageParameterKey.OccurrenceId).AsIntegerOrNull();

                if ((occurrenceId == null) || (occurrenceId == 0))
                {
                    occurrenceId = hfNewOccurrenceId.Value.AsIntegerOrNull();
                    if ((occurrenceId == null) || (occurrenceId == 0))
                    {
                        throw new Exception("The AttendanceOccurrence does not exist.");
                    }
                }

                occurrence = occurrenceService.Get(occurrenceId.Value);

                var existingAttendees = occurrence.Attendees.ToList();

                foreach (var attendee in attendees)
                {
                    var attendance = existingAttendees
                                     .Where(a => a.PersonAlias.PersonId == attendee.PersonId)
                                     .FirstOrDefault();

                    if (attendance == null)
                    {
                        int?personAliasId = personAliasService.GetPrimaryAliasId(attendee.PersonId);
                        if (personAliasId.HasValue)
                        {
                            attendance = new Attendance();
                            attendance.PersonAliasId = personAliasId;
                            attendance.StartDateTime = occurrence.Schedule != null && occurrence.Schedule.HasSchedule() ? occurrence.OccurrenceDate.Date.Add(occurrence.Schedule.StartTimeOfDay) : occurrence.OccurrenceDate;
                            occurrence.Attendees.Add(attendance);
                        }
                    }

                    if (attendance != null)
                    {
                        if (attendee.Accept)
                        {
                            var groupMember = occurrence.Group.Members.Where(gm => gm.PersonId == attendee.PersonId).FirstOrDefault();
                            if (groupMember == null)
                            {
                                groupMember             = new GroupMember();
                                groupMember.PersonId    = attendee.PersonId;
                                groupMember.GroupId     = occurrence.Group.Id;
                                groupMember.GroupRoleId = occurrence.Group.GroupType.DefaultGroupRoleId ?? 0;

                                new GroupMemberService(rockContext).Add(groupMember);
                                rockContext.SaveChanges();
                            }

                            // only set the RSVP and Date if the value is changing
                            if (attendance.RSVP != Rock.Model.RSVP.Yes)
                            {
                                attendance.RSVPDateTime = DateTime.Now;
                                attendance.RSVP         = Rock.Model.RSVP.Yes;
                            }
                            attendance.Note = string.Empty;
                            attendance.DeclineReasonValueId = null;
                        }
                        else if (attendee.Decline)
                        {
                            // only set the RSVP and Date if the value is changing
                            if (attendance.RSVP != Rock.Model.RSVP.No)
                            {
                                attendance.RSVPDateTime = DateTime.Now;
                                attendance.RSVP         = Rock.Model.RSVP.No;
                            }

                            attendance.Note = attendee.DeclineNote;
                            if (attendee.DeclineReason != 0)
                            {
                                attendance.DeclineReasonValueId = attendee.DeclineReason;
                            }
                        }
                        else
                        {
                            attendance.RSVPDateTime         = null;
                            attendance.RSVP                 = Rock.Model.RSVP.Unknown;
                            attendance.Note                 = string.Empty;
                            attendance.DeclineReasonValueId = null;
                        }
                    }
                }

                rockContext.SaveChanges();

                if (occurrence.LocationId.HasValue)
                {
                    Rock.CheckIn.KioskLocationAttendance.Remove(occurrence.LocationId.Value);
                }
            }

            return(true);
        }
        /// <summary>
        /// Saves the attendance data.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="group">The group.</param>
        /// <param name="date">The date.</param>
        /// <param name="attendees">The attendees.</param>
        /// <param name="didNotMeet">if set to <c>true</c> then the group is marked as having not met.</param>
        /// <param name="notes">Contains the note text to save with the occurrence.</param>
        private void SaveAttendanceData(RockContext rockContext, Group group, DateTime date, List <Attendee> attendees, bool didNotMeet, string notes)
        {
            var attendanceService  = new AttendanceService(rockContext);
            var personAliasService = new PersonAliasService(rockContext);

            var occurrence        = GetOccurrence(rockContext, group, date, true);
            var existingAttendees = occurrence.Attendees.ToList();

            if (didNotMeet)
            {
                if (!occurrence.ScheduleId.HasValue)
                {
                    //
                    // If the attendance is not part of a schedule, just delete all the records.
                    //
                    foreach (var attendance in existingAttendees)
                    {
                        attendanceService.Delete(attendance);
                    }
                }
                else
                {
                    //
                    // If the occurrence is based on a schedule, clear the DidAttend property.
                    //
                    foreach (var attendance in existingAttendees)
                    {
                        attendance.DidAttend = null;
                    }
                }
            }
            else
            {
                foreach (var attendee in attendees)
                {
                    var attendance = existingAttendees
                                     .Where(a => a.PersonAlias.Person.Guid == attendee.PersonGuid)
                                     .FirstOrDefault();

                    if (attendance == null)
                    {
                        int?personAliasId = personAliasService.GetPrimaryAliasId(attendee.PersonGuid);
                        if (personAliasId.HasValue)
                        {
                            attendance = new Attendance
                            {
                                PersonAliasId = personAliasId,
                                CampusId      = null,
                                StartDateTime = occurrence.Schedule != null && occurrence.Schedule.HasSchedule() ? occurrence.OccurrenceDate.Date.Add(occurrence.Schedule.StartTimeOfDay) : occurrence.OccurrenceDate,
                                DidAttend     = attendee.Attended
                            };

                            occurrence.Attendees.Add(attendance);
                        }
                    }
                    else
                    {
                        // Otherwise, only record that they attended -- don't change their attendance startDateTime
                        attendance.DidAttend = attendee.Attended;
                    }
                }
            }

            occurrence.DidNotOccur = didNotMeet;

            // Only update the occurrence Notes if 'notes' is not null.
            occurrence.Notes = notes ?? occurrence.Notes;

            rockContext.SaveChanges();
        }
        /// <summary>
        /// Method to save attendance for use in two separate areas.
        /// </summary>
        protected bool SaveAttendance()
        {
            using (var rockContext = new RockContext())
            {
                var occurrenceService  = new AttendanceOccurrenceService(rockContext);
                var attendanceService  = new AttendanceService(rockContext);
                var personAliasService = new PersonAliasService(rockContext);
                var locationService    = new LocationService(rockContext);

                AttendanceOccurrence occurrence = null;

                if (_occurrence.Id != 0)
                {
                    occurrence = occurrenceService.Get(_occurrence.Id);
                }

                if (occurrence == null)
                {
                    var existingOccurrence = occurrenceService.Get(_occurrence.OccurrenceDate, _group.Id, _occurrence.LocationId, _occurrence.ScheduleId);
                    if (existingOccurrence != null)
                    {
                        nbNotice.Heading             = "Occurrence Already Exists";
                        nbNotice.Text                = "<p>An occurrence already exists for this group for the selected date, location, and schedule that you've selected. Please return to the list and select that occurrence to update it's attendance.</p>";
                        nbNotice.NotificationBoxType = NotificationBoxType.Danger;
                        nbNotice.Visible             = true;

                        return(false);
                    }
                    else
                    {
                        occurrence                = new AttendanceOccurrence();
                        occurrence.GroupId        = _occurrence.GroupId;
                        occurrence.LocationId     = _occurrence.LocationId;
                        occurrence.ScheduleId     = _occurrence.ScheduleId;
                        occurrence.OccurrenceDate = _occurrence.OccurrenceDate;
                        occurrenceService.Add(occurrence);
                    }
                }

                occurrence.Notes       = GetAttributeValue("ShowNotes").AsBoolean() ? dtNotes.Text : string.Empty;
                occurrence.DidNotOccur = cbDidNotMeet.Checked;

                var existingAttendees = occurrence.Attendees.ToList();

                // If did not meet was selected and this was a manually entered occurrence (not based on a schedule/location)
                // then just delete all the attendance records instead of tracking a 'did not meet' value
                if (cbDidNotMeet.Checked && !_occurrence.ScheduleId.HasValue)
                {
                    foreach (var attendance in existingAttendees)
                    {
                        attendanceService.Delete(attendance);
                    }
                }
                else
                {
                    int?campusId = locationService.GetCampusIdForLocation(_occurrence.LocationId) ?? _group.CampusId;
                    if (!campusId.HasValue && _allowCampusFilter)
                    {
                        var campus = CampusCache.Get(bddlCampus.SelectedValueAsInt() ?? 0);
                        if (campus != null)
                        {
                            campusId = campus.Id;
                        }
                    }

                    if (cbDidNotMeet.Checked)
                    {
                        // If the occurrence is based on a schedule, set the did not meet flags
                        foreach (var attendance in existingAttendees)
                        {
                            attendance.DidAttend = null;
                        }
                    }
                    else
                    {
                        foreach (var attendee in _attendees)
                        {
                            var attendance = existingAttendees
                                             .Where(a => a.PersonAlias.PersonId == attendee.PersonId)
                                             .FirstOrDefault();

                            if (attendance == null)
                            {
                                int?personAliasId = personAliasService.GetPrimaryAliasId(attendee.PersonId);
                                if (personAliasId.HasValue)
                                {
                                    attendance = new Attendance();
                                    attendance.PersonAliasId = personAliasId;
                                    attendance.CampusId      = campusId;
                                    attendance.StartDateTime = _occurrence.OccurrenceDate;

                                    // check that the attendance record is valid
                                    cvAttendance.IsValid = attendance.IsValid;
                                    if (!cvAttendance.IsValid)
                                    {
                                        cvAttendance.ErrorMessage = attendance.ValidationResults.Select(a => a.ErrorMessage).ToList().AsDelimited("<br />");
                                        return(false);
                                    }

                                    occurrence.Attendees.Add(attendance);
                                }
                            }

                            if (attendance != null)
                            {
                                attendance.DidAttend = attendee.Attended;
                            }
                        }
                    }
                }

                rockContext.SaveChanges();

                if (occurrence.LocationId.HasValue)
                {
                    Rock.CheckIn.KioskLocationAttendance.Remove(occurrence.LocationId.Value);
                }


                Guid?workflowTypeGuid = GetAttributeValue("Workflow").AsGuidOrNull();
                if (workflowTypeGuid.HasValue)
                {
                    var workflowType = WorkflowTypeCache.Get(workflowTypeGuid.Value);
                    if (workflowType != null && (workflowType.IsActive ?? true))
                    {
                        try
                        {
                            var workflow = Workflow.Activate(workflowType, _group.Name);

                            workflow.SetAttributeValue("StartDateTime", _occurrence.OccurrenceDate.ToString("o"));
                            workflow.SetAttributeValue("Schedule", _group.Schedule.Guid.ToString());

                            List <string> workflowErrors;
                            new WorkflowService(rockContext).Process(workflow, _group, out workflowErrors);
                        }
                        catch (Exception ex)
                        {
                            ExceptionLogService.LogException(ex, this.Context);
                        }
                    }
                }
            }

            return(true);
        }
示例#7
0
        public MediaElementInteraction GetWatchInteraction([FromUri] Guid?mediaElementGuid = null, [FromUri] Guid?personGuid = null, Guid?personAliasGuid = null)
        {
            var rockContext        = Service.Context as RockContext;
            var personService      = new PersonService(rockContext);
            var personAliasService = new PersonAliasService(rockContext);
            var interactionService = new InteractionService(rockContext);
            int?personAliasId;

            // Get the person alias to associate with the interaction in
            // order of provided Person.Guid, then PersonAlias.Guid, then
            // the logged in Person.
            if (personGuid.HasValue)
            {
                personAliasId = personAliasService.GetPrimaryAliasId(personGuid.Value);
            }
            else if (personAliasGuid.HasValue)
            {
                personAliasId = personAliasService.GetId(personAliasGuid.Value);
            }
            else
            {
                personAliasId = GetPersonAliasId(rockContext);
            }

            // Verify we have a person alias, otherwise bail out.
            if (!personAliasId.HasValue)
            {
                var errorResponse = Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"The personAliasId could not be determined.");
                throw new HttpResponseException(errorResponse);
            }

            MediaElement mediaElement = null;

            // In the future we might make MediaElementGuid optional so
            // perform the check this way rather than making it required
            // in the parameter list.
            if (mediaElementGuid.HasValue)
            {
                mediaElement = new MediaElementService(rockContext).GetNoTracking(mediaElementGuid.Value);
            }

            // Ensure we have our required MediaElement.
            if (mediaElement == null)
            {
                var errorResponse = Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"The MediaElement could not be found.");
                throw new HttpResponseException(errorResponse);
            }

            // Get (or create) the component.
            var interactionChannelId   = InteractionChannelCache.Get(SystemGuid.InteractionChannel.MEDIA_EVENTS).Id;
            var interactionComponentId = InteractionComponentCache.GetComponentIdByChannelIdAndEntityId(interactionChannelId, mediaElement.Id, mediaElement.Name);

            Interaction interaction = interactionService.Queryable()
                                      .AsNoTracking()
                                      .Include(a => a.PersonAlias)
                                      .Where(a => a.InteractionComponentId == interactionComponentId)
                                      .Where(a => a.PersonAliasId == personAliasId || a.PersonAlias.Person.Aliases.Any(b => b.Id == personAliasId))
                                      .OrderByDescending(a => a.InteractionEndDateTime)
                                      .ThenByDescending(a => a.InteractionDateTime)
                                      .FirstOrDefault();

            if (interaction == null)
            {
                var errorResponse = Request.CreateErrorResponse(HttpStatusCode.NotFound, $"The Interaction could not be found.");
                throw new HttpResponseException(errorResponse);
            }

            var data = interaction.InteractionData.FromJsonOrNull <MediaWatchedInteractionData>();

            return(new MediaElementInteraction
            {
                InteractionGuid = interaction.Guid,
                MediaElementGuid = mediaElement.Guid,
                PersonGuid = interaction.PersonAlias.Person?.Guid,
                PersonAliasGuid = interaction.PersonAlias.Guid,
                RelatedEntityTypeId = interaction.RelatedEntityTypeId,
                RelatedEntityId = interaction.RelatedEntityId,
                WatchMap = data?.WatchMap ?? string.Empty
            });
        }
示例#8
0
        public MediaElementInteraction PostWatchInteraction(MediaElementInteraction mediaInteraction)
        {
            var rockContext        = Service.Context as RockContext;
            var personService      = new PersonService(rockContext);
            var personAliasService = new PersonAliasService(rockContext);
            var interactionService = new InteractionService(rockContext);
            int?personAliasId;

            if (!IsWatchMapValid(mediaInteraction.WatchMap))
            {
                var errorResponse = Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"The WatchMap contains invalid characters.");
                throw new HttpResponseException(errorResponse);
            }

            // Get the person alias to associate with the interaction in
            // order of provided Person.Guid, then PersonAlias.Guid, then
            // the logged in Person.
            if (mediaInteraction.PersonGuid.HasValue)
            {
                personAliasId = personAliasService.GetPrimaryAliasId(mediaInteraction.PersonGuid.Value);
            }
            else if (mediaInteraction.PersonAliasGuid.HasValue)
            {
                personAliasId = personAliasService.GetId(mediaInteraction.PersonAliasGuid.Value);
            }
            else
            {
                personAliasId = GetPersonAliasId(rockContext);
            }

            var mediaElement = new MediaElementService(rockContext).GetNoTracking(mediaInteraction.MediaElementGuid);

            // Ensure we have our required MediaElement.
            if (mediaElement == null)
            {
                var errorResponse = Request.CreateErrorResponse(HttpStatusCode.BadRequest, $"The MediaElement could not be found.");
                throw new HttpResponseException(errorResponse);
            }

            // Get (or create) the component.
            var         interactionChannelId   = InteractionChannelCache.Get(SystemGuid.InteractionChannel.MEDIA_EVENTS).Id;
            var         interactionComponentId = InteractionComponentCache.GetComponentIdByChannelIdAndEntityId(interactionChannelId, mediaElement.Id, mediaElement.Name);
            Interaction interaction            = null;

            if (mediaInteraction.InteractionGuid.HasValue)
            {
                // Look for an existing Interaction by it's Guid and the
                // component it is supposed to show up under. But also
                // check that the RelatedEntityTypeId/RelatedEntityId values
                // are either null or match what was passed by the user.
                // Finally also make sure the Interaction Person Alias is
                // either the one for this user OR if there is a Person
                // record attached to that alias that the alias Id we have is
                // also attached to that Person record OR the interaction is
                // not tied to a person.
                interaction = interactionService.Queryable()
                              .Where(a => a.Guid == mediaInteraction.InteractionGuid.Value && a.InteractionComponentId == interactionComponentId)
                              .Where(a => !a.RelatedEntityTypeId.HasValue || !mediaInteraction.RelatedEntityTypeId.HasValue || a.RelatedEntityTypeId == mediaInteraction.RelatedEntityTypeId)
                              .Where(a => !a.RelatedEntityId.HasValue || !mediaInteraction.RelatedEntityId.HasValue || a.RelatedEntityId == mediaInteraction.RelatedEntityId)
                              .Where(a => !a.PersonAliasId.HasValue || a.PersonAliasId == personAliasId || a.PersonAlias.Person.Aliases.Any(b => b.Id == personAliasId))
                              .SingleOrDefault();
            }

            var watchedPercentage = CalculateWatchedPercentage(mediaInteraction.WatchMap);

            if (interaction != null)
            {
                // Update the interaction data with the new watch map.
                var data = interaction.InteractionData.FromJsonOrNull <MediaWatchedInteractionData>() ?? new MediaWatchedInteractionData();
                data.WatchMap          = mediaInteraction.WatchMap;
                data.WatchedPercentage = watchedPercentage;

                interaction.InteractionData        = data.ToJson();
                interaction.InteractionLength      = watchedPercentage;
                interaction.InteractionEndDateTime = RockDateTime.Now;
                interaction.PersonAliasId          = interaction.PersonAliasId ?? personAliasId;

                if (mediaInteraction.RelatedEntityTypeId.HasValue)
                {
                    interaction.RelatedEntityTypeId = mediaInteraction.RelatedEntityTypeId;
                }

                if (mediaInteraction.RelatedEntityId.HasValue)
                {
                    interaction.RelatedEntityId = mediaInteraction.RelatedEntityId;
                }
            }
            else
            {
                // Generate the interaction data from the watch map.
                var data = new MediaWatchedInteractionData
                {
                    WatchMap          = mediaInteraction.WatchMap,
                    WatchedPercentage = watchedPercentage
                };

                interaction = interactionService.CreateInteraction(interactionComponentId,
                                                                   null, "Watch", string.Empty, data.ToJson(), personAliasId, RockDateTime.Now,
                                                                   null, null, null, null, null, null);

                interaction.InteractionLength      = watchedPercentage;
                interaction.InteractionEndDateTime = RockDateTime.Now;
                interaction.RelatedEntityTypeId    = mediaInteraction.RelatedEntityTypeId;
                interaction.RelatedEntityId        = mediaInteraction.RelatedEntityId;

                interactionService.Add(interaction);
            }

            rockContext.SaveChanges();

            mediaInteraction.InteractionGuid = interaction.Guid;

            return(mediaInteraction);
        }
示例#9
0
        private static void SyncAttendee(RockContext rockContext, Attendee attendee, Order order, Group group, GroupMemberService groupMemberService, PersonAliasService personAliasService, AttendanceOccurrence occ, long evntid, bool IsRSVPEvent, string gmPersonAttributeKey, bool updatePrimaryEmail, int recordStatusId = 5, int connectionStatusId = 66, bool EnableLogging = false)
        {
            if (string.IsNullOrWhiteSpace(attendee.Profile.Email))
            {
                attendee.Profile.Email = order.Email;
            }

            if (!string.IsNullOrWhiteSpace(attendee.Profile.First_Name) && !string.IsNullOrWhiteSpace(attendee.Profile.Last_Name) && !string.IsNullOrWhiteSpace(attendee.Profile.Email))
            {
                var person             = MatchOrAddPerson(rockContext, attendee.Profile, connectionStatusId, updatePrimaryEmail, EnableLogging);
                var matchedGroupMember = MatchGroupMember(group.Members, order, person.Id, gmPersonAttributeKey, rockContext, EnableLogging);
                if (matchedGroupMember == null && (order.Status != "deleted" || order.Status != "abandoned"))
                {
                    var member = new GroupMember
                    {
                        GroupId           = group.Id,
                        Person            = person,
                        GuestCount        = (order.Attendees != null) ? order.Attendees.Count : 1,
                        GroupRoleId       = group.GroupType.DefaultGroupRoleId.Value,
                        GroupMemberStatus = GroupMemberStatus.Active
                    };

                    groupMemberService.Add(member);

                    SetPersonData(rockContext, person, attendee, group, IsRSVPEvent && order.Attendees != null ? order.Attendees.Count : attendee.Quantity, EnableLogging);
                }
                else if (matchedGroupMember != null && order.Status == "deleted")
                {
                    matchedGroupMember.GroupMemberStatus = GroupMemberStatus.Inactive;
                    matchedGroupMember.Note = "Eventbrite order deleted!";

                    groupMemberService.Delete(matchedGroupMember);
                }
                else if (matchedGroupMember != null && order.Status == "refunded")
                {
                    matchedGroupMember.GroupMemberStatus = GroupMemberStatus.Inactive;
                    matchedGroupMember.Note = "Eventbrite order canceled/refunded!";
                }
                else if (matchedGroupMember != null)
                {
                    if (matchedGroupMember.Attributes == null)
                    {
                        matchedGroupMember.LoadAttributes(rockContext);
                    }
                    var attributeVal = matchedGroupMember.GetAttributeValue(gmPersonAttributeKey);
                    if (attributeVal.IsNotNullOrWhiteSpace())
                    {
                        // Attribute Values in our special eventBritePerson field type are stored as a delimited string Eventbrite Id^Ticket Class(es)^Eventbrite Order Id^RSVP/Ticket Count(s)
                        var splitVal      = attributeVal.SplitDelimitedValues("^");
                        var ticketClasses = splitVal[1].SplitDelimitedValues("||");
                        var ticketQtys    = splitVal[3].SplitDelimitedValues("||");
                        if (!ticketClasses.Contains(attendee.Ticket_Class_Name))
                        {
                            splitVal[1] += "||" + attendee.Ticket_Class_Name;
                            splitVal[3] += "||" + order.Attendees?.Count(a => a.Profile.First_Name == attendee.Profile.First_Name && a.Profile.Last_Name == attendee.Profile.Last_Name && a.Profile.Email == attendee.Profile.Email && a.Ticket_Class_Id == attendee.Ticket_Class_Id).ToString();
                        }
                        else
                        {
                            ticketQtys[Array.IndexOf(ticketClasses, attendee.Ticket_Class_Name)] = order.Attendees?.Count(a => a.Profile.First_Name == attendee.Profile.First_Name && a.Profile.Last_Name == attendee.Profile.Last_Name && a.Profile.Email == attendee.Profile.Email && a.Ticket_Class_Id == attendee.Ticket_Class_Id).ToString();
                            splitVal[3] = ticketQtys.JoinStrings("||");
                        }
                        matchedGroupMember.SetAttributeValue(gmPersonAttributeKey, splitVal.JoinStrings("^"));
                        matchedGroupMember.SaveAttributeValue(gmPersonAttributeKey);
                    }
                }

                //Record Attendance
                if (attendee.Checked_In)
                {
                    if (EnableLogging)
                    {
                        LogEvent(rockContext, "SyncAttendee", string.Format("Attendee.Checked_in", evntid), "True");
                    }

                    var attendance = occ.Attendees
                                     .Where(a => a.PersonAlias != null && a.PersonAlias.PersonId == person.Id)
                                     .FirstOrDefault();

                    if (attendance == null)
                    {
                        int?personAliasId = personAliasService.GetPrimaryAliasId(person.Id);
                        if (personAliasId.HasValue)
                        {
                            attendance = new Attendance
                            {
                                PersonAliasId = personAliasId,
                                StartDateTime = occ.Schedule != null && occ.Schedule.HasSchedule() ? occ.OccurrenceDate.Date.Add(occ.Schedule.StartTimeOfDay) : occ.OccurrenceDate,
                                DidAttend     = true
                            };

                            occ.Attendees.Add(attendance);
                        }
                    }
                    else
                    {
                        // Otherwise, only record that they attended -- don't change their attendance startDateTime
                        attendance.DidAttend = true;
                    }
                    rockContext.SaveChanges();
                }
            }
        }
示例#10
0
        /// <summary>
        /// Handles the Click event of the lbSave control.
        /// </summary>
        /// <param name="sender">The source of the event.</param>
        /// <param name="e">The <see cref="EventArgs"/> instance containing the event data.</param>
        protected void lbSave_Click(object sender, EventArgs e)
        {
            if (_group != null && _occurrence != null)
            {
                var rockContext        = new RockContext();
                var attendanceService  = new AttendanceService(rockContext);
                var personAliasService = new PersonAliasService(rockContext);
                var locationService    = new LocationService(rockContext);

                DateTime startDate = _occurrence.Date;
                DateTime endDate   = _occurrence.Date.AddDays(1);

                var existingAttendees = attendanceService
                                        .Queryable("PersonAlias")
                                        .Where(a =>
                                               a.GroupId == _group.Id &&
                                               a.LocationId == _occurrence.LocationId &&
                                               a.ScheduleId == _occurrence.ScheduleId &&
                                               a.StartDateTime >= startDate &&
                                               a.StartDateTime < endDate);

                // If did not meet was selected and this was a manually entered occurrence (not based on a schedule/location)
                // then just delete all the attendance records instead of tracking a 'did not meet' value
                if (cbDidNotMeet.Checked && !_occurrence.ScheduleId.HasValue)
                {
                    foreach (var attendance in existingAttendees)
                    {
                        attendanceService.Delete(attendance);
                    }
                }
                else
                {
                    if (cbDidNotMeet.Checked)
                    {
                        // If the occurrence is based on a schedule, set the did not meet flags
                        foreach (var attendance in existingAttendees)
                        {
                            attendance.DidAttend   = null;
                            attendance.DidNotOccur = true;
                        }
                    }

                    foreach (var attendee in _attendees)
                    {
                        var attendance = existingAttendees
                                         .Where(a => a.PersonAlias.PersonId == attendee.PersonId)
                                         .FirstOrDefault();

                        if (attendance == null)
                        {
                            int?personAliasId = personAliasService.GetPrimaryAliasId(attendee.PersonId);
                            if (personAliasId.HasValue)
                            {
                                attendance               = new Attendance();
                                attendance.GroupId       = _group.Id;
                                attendance.ScheduleId    = _group.ScheduleId;
                                attendance.PersonAliasId = personAliasId;
                                attendance.StartDateTime = _occurrence.Date;
                                attendance.LocationId    = _occurrence.LocationId;
                                attendance.CampusId      = locationService.GetCampusIdForLocation(_occurrence.LocationId);
                                attendance.ScheduleId    = _occurrence.ScheduleId;
                                attendanceService.Add(attendance);
                            }
                        }

                        if (attendance != null)
                        {
                            if (cbDidNotMeet.Checked)
                            {
                                attendance.DidAttend   = null;
                                attendance.DidNotOccur = true;
                            }
                            else
                            {
                                attendance.DidAttend   = attendee.Attended;
                                attendance.DidNotOccur = null;
                            }
                        }
                    }
                }

                rockContext.SaveChanges();

                WorkflowType workflowType     = null;
                Guid?        workflowTypeGuid = GetAttributeValue("Workflow").AsGuidOrNull();
                if (workflowTypeGuid.HasValue)
                {
                    var workflowTypeService = new WorkflowTypeService(rockContext);
                    workflowType = workflowTypeService.Get(workflowTypeGuid.Value);
                    if (workflowType != null)
                    {
                        try
                        {
                            var workflow = Workflow.Activate(workflowType, _group.Name);

                            workflow.SetAttributeValue("StartDateTime", _occurrence.Date.ToString("o"));
                            workflow.SetAttributeValue("Schedule", _group.Schedule.Guid.ToString());

                            List <string> workflowErrors;
                            new WorkflowService(rockContext).Process(workflow, _group, out workflowErrors);
                        }
                        catch (Exception ex)
                        {
                            ExceptionLogService.LogException(ex, this.Context);
                        }
                    }
                }

                NavigateToParentPage(new Dictionary <string, string> {
                    { "GroupId", _group.Id.ToString() }
                });
            }
        }