Inheritance: Lava.ILiquidizable
Exemplo n.º 1
0
 /// <summary>
 /// Initializes a new instance of the <see cref="CheckInPersonSummary"/> class.
 /// </summary>
 /// <param name="schedule">The schedule.</param>
 /// <param name="groupType">Type of the group.</param>
 /// <param name="group">The group.</param>
 /// <param name="location">The location.</param>
 public CheckInPersonSummary(CheckInSchedule schedule, CheckInGroupType groupType, CheckInGroup group, CheckInLocation location)
 {
     Schedule  = schedule;
     GroupType = groupType;
     Group     = group;
     Location  = location;
 }
Exemplo n.º 2
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="rockContext">The rock context.</param>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute( RockContext rockContext, Model.WorkflowAction action, Object entity, out List<string> errorMessages )
        {
            var checkInState = GetCheckInState( entity, out errorMessages );
            if ( checkInState != null )
            {
                bool loadAll = GetAttributeValue( action, "LoadAll" ).AsBoolean();

                foreach ( var family in checkInState.CheckIn.Families.Where( f => f.Selected ).ToList() )
                {
                    foreach ( var person in family.People.Where( p => p.Selected || loadAll ).ToList() )
                    {
                        foreach ( var groupType in person.GroupTypes.Where( g => g.Selected || loadAll ).ToList() )
                        {
                            var kioskGroupType = checkInState.Kiosk.FilteredGroupTypes( checkInState.ConfiguredGroupTypes ).Where( g => g.GroupType.Id == groupType.GroupType.Id ).FirstOrDefault();
                            if ( kioskGroupType != null )
                            {
                                foreach ( var kioskGroup in kioskGroupType.KioskGroups )
                                {
                                    bool validGroup = true;
                                    if ( groupType.GroupType.AttendanceRule == AttendanceRule.AlreadyBelongs )
                                    {
                                        validGroup = new GroupMemberService( rockContext ).Queryable()
                                            .Any( m =>
                                                m.GroupId == kioskGroup.Group.Id &&
                                                m.PersonId == person.Person.Id );
                                    }

                                    if ( validGroup && !groupType.Groups.Any( g => g.Group.Id == kioskGroup.Group.Id ) )
                                    {
                                        var checkInGroup = new CheckInGroup();
                                        checkInGroup.Group = kioskGroup.Group.Clone( false );
                                        checkInGroup.Group.CopyAttributesFrom( kioskGroup.Group );
                                        groupType.Groups.Add( checkInGroup );
                                    }
                                }
                            }
                        }
                    }
                }

                return true;
            }

            return false;
        }
Exemplo n.º 3
0
        /// <summary>
        /// Executes the specified workflow.
        /// </summary>
        /// <param name="action">The workflow action.</param>
        /// <param name="entity">The entity.</param>
        /// <param name="errorMessages">The error messages.</param>
        /// <returns></returns>
        /// <exception cref="System.NotImplementedException"></exception>
        public override bool Execute( Model.WorkflowAction action, Object entity, out List<string> errorMessages )
        {
            var checkInState = GetCheckInState( entity, out errorMessages );
            if ( checkInState != null )
            {

                bool loadAll = false;
                if ( bool.TryParse( GetAttributeValue( action, "LoadAll" ), out loadAll ) && loadAll )
                {
                    loadAll = true;
                }

                foreach ( var family in checkInState.CheckIn.Families.Where( f => f.Selected ).ToList() )
                {
                    foreach ( var person in family.People.Where( p => p.Selected || loadAll ).ToList() )
                    {
                        foreach ( var groupType in person.GroupTypes.Where( g => g.Selected || loadAll ).ToList() )
                        {
                            var kioskGroupType = checkInState.Kiosk.FilteredGroupTypes(checkInState.ConfiguredGroupTypes).Where( g => g.GroupType.Id == groupType.GroupType.Id ).FirstOrDefault();
                            if ( kioskGroupType != null )
                            {
                                foreach ( var kioskGroup in kioskGroupType.KioskGroups )
                                {
                                    if ( !groupType.Groups.Any( g => g.Group.Id == kioskGroup.Group.Id ) )
                                    {
                                        var checkInGroup = new CheckInGroup();
                                        checkInGroup.Group = kioskGroup.Group.Clone( false );
                                        checkInGroup.Group.CopyAttributesFrom( kioskGroup.Group );
                                        groupType.Groups.Add( checkInGroup );
                                    }
                                }
                            }
                        }
                    }
                }

                return true;
            }

            return false;
        }
Exemplo n.º 4
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CheckInPersonSummary" /> class.
        /// </summary>
        /// <param name="label">The label.</param>
        /// <param name="schedule">The schedule.</param>
        /// <param name="groupType">Type of the group.</param>
        /// <param name="group">The group.</param>
        /// <param name="location">The location.</param>
        public CheckInPersonSummary(KioskLabel label, CheckInSchedule schedule, CheckInGroupType groupType, CheckInGroup group, CheckInLocation location)
            : this(schedule, groupType, group, location)
        {
            if (groupType != null && groupType.GroupType != null && label != null)
            {
                if (groupType.GroupType.Attributes == null)
                {
                    // shouldn't happen since GroupType is a ModelCache<,> type
                    return;
                }

                foreach (var attribute in groupType.GroupType.Attributes.OrderBy(a => a.Value.Order))
                {
                    if (attribute.Value.FieldType.Guid == SystemGuid.FieldType.LABEL.AsGuid())
                    {
                        Guid?binaryFileGuid = groupType.GroupType.GetAttributeValue(attribute.Key).AsGuidOrNull();
                        if (binaryFileGuid.HasValue && binaryFileGuid.Value == label.Guid)
                        {
                            GroupTypeConfiguredForLabel = true;
                            break;
                        }
                    }
                }
            }
        }
Exemplo n.º 5
0
        /// <summary>
        /// Initializes a new instance of the <see cref="CheckInPersonSummary" /> class.
        /// </summary>
        /// <param name="label">The label.</param>
        /// <param name="schedule">The schedule.</param>
        /// <param name="groupType">Type of the group.</param>
        /// <param name="group">The group.</param>
        /// <param name="location">The location.</param>
        public CheckInPersonSummary(KioskLabel label, CheckInSchedule schedule, CheckInGroupType groupType, CheckInGroup group, CheckInLocation location)
            : this(schedule, groupType, group, location)
        {
            if (groupType != null && groupType.GroupType != null && label != null)
            {
                if (groupType.GroupType.Attributes == null)
                {
                    groupType.GroupType.LoadAttributes();
                }

                foreach (var attribute in groupType.GroupType.Attributes.OrderBy(a => a.Value.Order))
                {
                    if (attribute.Value.FieldType.Guid == SystemGuid.FieldType.BINARY_FILE.AsGuid() &&
                        attribute.Value.QualifierValues.ContainsKey("binaryFileType") &&
                        attribute.Value.QualifierValues["binaryFileType"].Value.Equals(SystemGuid.BinaryFiletype.CHECKIN_LABEL, StringComparison.OrdinalIgnoreCase))
                    {
                        Guid?binaryFileGuid = groupType.GroupType.GetAttributeValue(attribute.Key).AsGuidOrNull();
                        if (binaryFileGuid.HasValue && binaryFileGuid.Value == label.Guid)
                        {
                            GroupTypeConfiguredForLabel = true;
                            break;
                        }
                    }
                }
            }
        }