Esempio n. 1
0
        /// <summary>
        /// Gets the device from the GeoLocation callback result;
        /// </summary>
        /// <param name="callbackResult">The callback result.</param>
        private void ProcessGeolocationCallback(string callbackResult)
        {
            hfGetGeoLocation.Value = false.ToJavaScriptValue();

            var    latitude  = hfLatitude.Value.AsDoubleOrNull();
            var    longitude = hfLongitude.Value.AsDoubleOrNull();
            Device device;

            if (callbackResult == "Success" && latitude.HasValue && longitude.HasValue)
            {
                bbtnGetGeoLocation.Visible = false;
                HttpCookie rockHasLocationApprovalCookie = new HttpCookie(CheckInCookieKey.RockHasLocationApproval, "true");
                rockHasLocationApprovalCookie.Expires = RockDateTime.Now.AddYears(1);
                Response.Cookies.Set(rockHasLocationApprovalCookie);

                device = GetFirstMatchingKioskByGeoFencing(latitude.Value, longitude.Value);
            }
            else
            {
                lMessage.Text = GetMessageText(AttributeKey.UnableToDetermineMobileLocationTemplate);
                return;
            }

            if (device == null)
            {
                lMessage.Text = GetMessageText(AttributeKey.NoDevicesFoundTemplate);
                return;
            }

            // device found for mobile person's location
            LocalDeviceConfig.CurrentKioskId = device.Id;
            LocalDeviceConfig.AllowCheckout  = false;

            LocalDeviceConfig.SaveToCookie(this.Page);

            // create new checkin state since we are starting a new checkin sessions
            this.CurrentCheckInState = new CheckInState(this.LocalDeviceConfig);

            SaveState();

            CheckinConfigurationHelper.CheckinStatus checkinStatus = CheckinConfigurationHelper.CheckinStatus.Closed;
            if (CurrentCheckInState.Kiosk != null)
            {
                checkinStatus = CheckinConfigurationHelper.GetCheckinStatus(CurrentCheckInState);
            }

            RefreshCheckinStatusInformation(checkinStatus);
        }
Esempio n. 2
0
        /// <summary>
        /// Handles the Click event of the bbtnCheckin 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 bbtnCheckin_Click(object sender, EventArgs e)
        {
            UpdateConfigurationFromBlockSettings();

            // checkin status might have changed after the Checkin Button was displayed, so make sure the kiosk is still active
            var checkinStatus = CheckinConfigurationHelper.GetCheckinStatus(CurrentCheckInState);

            if (checkinStatus != CheckinConfigurationHelper.CheckinStatus.Active)
            {
                RefreshCheckinStatusInformation(checkinStatus);
                return;
            }

            var latitude  = hfLatitude.Value.AsDoubleOrNull();
            var longitude = hfLongitude.Value.AsDoubleOrNull();

            if (latitude == null || longitude == null)
            {
                // shouldn't happen
                return;
            }

            var device = GetFirstMatchingKioskByGeoFencing(latitude.Value, longitude.Value);

            if (device == null)
            {
                // shouldn't happen
                return;
            }

            LocalDeviceConfig.CurrentKioskId = device.Id;
            SaveState();

            var checkInState = CurrentCheckInState;

            checkInState.CheckIn            = new CheckInStatus();
            checkInState.CheckIn.SearchType = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.CHECKIN_SEARCH_TYPE_FAMILY_ID);

            var mobilePerson = this.GetMobilePerson();

            if (mobilePerson == null)
            {
                // shouldn't happen
                return;
            }

            var family = mobilePerson.GetFamily();

            var familyMembers = mobilePerson.GetFamilyMembers(true);

            var firstNames = familyMembers
                             .OrderBy(m => m.GroupRole.Order)
                             .ThenBy(m => m.Person.BirthYear)
                             .ThenBy(m => m.Person.BirthMonth)
                             .ThenBy(m => m.Person.BirthDay)
                             .ThenBy(m => m.Person.Gender)
                             .Select(m => m.Person.NickName)
                             .ToList();

            var checkInFamily = new CheckInFamily();

            checkInFamily.Group           = family.Clone(false);
            checkInFamily.Caption         = family.ToString();
            checkInFamily.FirstNames      = firstNames;
            checkInFamily.SubCaption      = firstNames.AsDelimited(", ");
            checkInFamily.Selected        = true;
            checkInState.CheckIn.Families = new List <CheckInFamily>();
            checkInState.CheckIn.Families.Add(checkInFamily);

            var rockContext = new RockContext();

            SaveState();

            var noMatchingPeopleMessage = this.GetAttributeValue(AttributeKey.NoPeopleMessage);

            Func <bool> doNotProceedCondition = () =>
            {
                var noMatchingFamilies =
                    (
                        CurrentCheckInState.CheckIn.Families.All(f => f.People.Count == 0) &&
                        CurrentCheckInState.CheckIn.Families.All(f => f.Action == CheckinAction.CheckIn)   // not sure this is needed
                    )
                    &&
                    (
                        !CurrentCheckInState.AllowCheckout ||
                        (
                            CurrentCheckInState.AllowCheckout &&
                            CurrentCheckInState.CheckIn.Families.All(f => f.CheckOutPeople.Count == 0)
                        )
                    );

                if (noMatchingFamilies)
                {
                    maWarning.Show(noMatchingPeopleMessage, Rock.Web.UI.Controls.ModalAlertType.None);
                    return(true);
                }
                else
                {
                    return(false);
                }
            };

            ProcessSelection(maWarning, doNotProceedCondition, noMatchingPeopleMessage);
        }
Esempio n. 3
0
        /// <summary>
        /// Refreshes the view.
        /// </summary>
        private void RefreshView()
        {
            bool isActive = false;

            hfRefreshTimerSeconds.Value = CurrentCheckInType != null?CurrentCheckInType.RefreshInterval.ToString() : "10";

            pnlNotActive.Visible    = false;
            pnlNotActiveYet.Visible = false;
            pnlClosed.Visible       = false;
            pnlActive.Visible       = false;
            ManagerLoggedIn         = false;
            pnlManagerLogin.Visible = false;
            pnlManager.Visible      = false;
            HideReprintPanels();

            btnManager.Visible  = CurrentCheckInType != null ? CurrentCheckInType.EnableManagerOption : true;
            btnOverride.Visible = CurrentCheckInType != null ? CurrentCheckInType.EnableOverride : true;

            hfCountdownSecondsUntil.Value = string.Empty;

            if (CurrentCheckInState == null || CheckinConfigurationHelper.IsMobileAndExpiredDevice(this.Request))
            {
                NavigateToPreviousPage();
                return;
            }

            // Set to null so that object will be recreated with a potentially updated group type cache.
            CurrentCheckInState.CheckInType = null;

            var checkinStatus = CheckinConfigurationHelper.GetCheckinStatus(CurrentCheckInState);

            switch (checkinStatus)
            {
            case CheckinConfigurationHelper.CheckinStatus.Inactive:
            {
                pnlNotActive.Visible = true;
                break;
            }

            case CheckinConfigurationHelper.CheckinStatus.TemporarilyClosed:
            {
                DateTime activeAt = CurrentCheckInState.Kiosk.FilteredGroupTypes(CurrentCheckInState.ConfiguredGroupTypes).Select(g => g.NextActiveTime).Min();
                if (activeAt == DateTime.MaxValue)
                {
                    pnlClosed.Visible = true;
                }
                else
                {
                    hfCountdownSecondsUntil.Value = (( int )(activeAt - RockDateTime.Now).TotalSeconds).ToString();
                    pnlNotActiveYet.Visible       = true;
                }

                break;
            }

            case CheckinConfigurationHelper.CheckinStatus.Closed:
            {
                pnlClosed.Visible = true;
                break;
            }

            case CheckinConfigurationHelper.CheckinStatus.Active:
            default:
            {
                isActive          = true;
                pnlActive.Visible = true;
                break;
            }
            }

            bool?wasActive = PageParameter(PageParameterKey.IsActive).AsBooleanOrNull();

            if (!wasActive.HasValue || wasActive.Value != isActive)
            {
                // redirect to current page with correct IsActive query string value
                var qryParams = Request.QueryString.AllKeys.ToDictionary(k => k, k => this.Request.QueryString[k]);
                qryParams.AddOrReplace(PageParameterKey.IsActive, isActive.ToString());
                NavigateToCurrentPage(qryParams);
            }
        }