コード例 #1
0
ファイル: MobileLauncher.ascx.cs プロジェクト: waldo2590/Rock
        /// <summary>
        /// Sets the configured theme and updates the theme cookie if needed
        /// </summary>
        /// <param name="theme">The theme.</param>
        private void SetSelectedTheme(string theme)
        {
            if (theme.IsNullOrWhiteSpace())
            {
                return;
            }

            if (LocalDeviceConfig.CurrentTheme != theme)
            {
                LocalDeviceConfig.CurrentTheme = theme;
                LocalDeviceConfig.SaveToCookie(this.Page);
            }

            if (!RockPage.Site.Theme.Equals(LocalDeviceConfig.CurrentTheme, StringComparison.OrdinalIgnoreCase))
            {
                // if the site's theme doesn't match the configured theme, reload the page with the theme parameter so that the correct theme gets loaded and the theme cookie gets set
                Dictionary <string, string> themeParameters = new Dictionary <string, string>();
                themeParameters.Add("theme", LocalDeviceConfig.CurrentTheme);

                var urlTheme = this.PageParameter("theme");

                // Check if theme specified in the url is different than the one we want to set.
                // This will help prevent infinite redirects which could happen if an invalid theme was specified
                if (!urlTheme.Equals(theme, StringComparison.OrdinalIgnoreCase))
                {
                    NavigateToCurrentPageReference(themeParameters);
                }
            }
        }
コード例 #2
0
ファイル: MobileLauncher.ascx.cs プロジェクト: waldo2590/Rock
        /// <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);
        }
コード例 #3
0
ファイル: Admin.ascx.cs プロジェクト: marcoramzy/Rock
        /// <summary>
        /// Sets the configured theme and updates the theme cookie if needed
        /// </summary>
        /// <param name="theme">The theme.</param>
        private void SetSelectedTheme(string theme)
        {
            if (LocalDeviceConfig.CurrentTheme != theme)
            {
                LocalDeviceConfig.CurrentTheme = ddlTheme.SelectedValue;
                LocalDeviceConfig.SaveToCookie(this.Page);
            }

            if (!RockPage.Site.Theme.Equals(LocalDeviceConfig.CurrentTheme, StringComparison.OrdinalIgnoreCase))
            {
                // if the site's theme doesn't match the configured theme, reload the page with the theme parameter so that the correct theme gets loaded and the theme cookie gets set
                Dictionary <string, string> themeParameters = new Dictionary <string, string>();
                themeParameters.Add("theme", LocalDeviceConfig.CurrentTheme);

                NavigateToCurrentPageReference(themeParameters);
            }
        }
コード例 #4
0
ファイル: Admin.ascx.cs プロジェクト: marcoramzy/Rock
        /// <summary>
        /// Handles the Click event of the lbOk 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 lbOk_Click(object sender, EventArgs e)
        {
            if (ddlKiosk.SelectedValue == None.IdValue)
            {
                maWarning.Show("A Kiosk Device needs to be selected", ModalAlertType.Warning);
                return;
            }

            var groupTypeIds = new List <int>();

            foreach (ListItem item in cblPrimaryGroupTypes.Items)
            {
                if (item.Selected)
                {
                    groupTypeIds.Add(item.Value.AsInteger());
                }
            }

            foreach (ListItem item in cblAlternateGroupTypes.Items)
            {
                if (item.Selected)
                {
                    groupTypeIds.Add(item.Value.AsInteger());
                }
            }

            ClearMobileCookie();
            LocalDeviceConfig.CurrentTheme         = ddlTheme.SelectedValue;
            LocalDeviceConfig.CurrentKioskId       = ddlKiosk.SelectedValueAsInt();
            LocalDeviceConfig.CurrentCheckinTypeId = ddlCheckinType.SelectedValueAsInt();
            LocalDeviceConfig.CurrentGroupTypeIds  = groupTypeIds;

            LocalDeviceConfig.SaveToCookie(this.Page);

            CurrentCheckInState = null;
            CurrentWorkflow     = null;
            SaveState();

            NavigateToNextPage();
        }
コード例 #5
0
ファイル: MobileLauncher.ascx.cs プロジェクト: waldo2590/Rock
        /// <summary>
        /// Updates the configuration from block settings.
        /// </summary>
        private void UpdateConfigurationFromBlockSettings()
        {
            var configuredCheckinTypeGuid = this.GetAttributeValue(AttributeKey.CheckinConfiguration_GroupTypeGuid).AsGuid();

            var configuredCheckinTypeId = GroupTypeCache.GetId(configuredCheckinTypeGuid);

            LocalDeviceConfig.CurrentCheckinTypeId = configuredCheckinTypeId;
            LocalDeviceConfig.CurrentGroupTypeIds  = this.GetAttributeValue(AttributeKey.ConfiguredAreas_GroupTypeIds).SplitDelimitedValues().AsIntegerList();

            LocalDeviceConfig.CurrentTheme = this.GetAttributeValue(AttributeKey.CheckinTheme);

            // override the HomePage block setting to the mobile home page
            LocalDeviceConfig.HomePageOverride = this.PageCache.Guid;
            LocalDeviceConfig.BlockedPageIds   = null;

            LocalDeviceConfig.AllowCheckout = false;

            var blockedPageIds = new List <int?>();

            blockedPageIds.Add(PageCache.GetId(Rock.SystemGuid.Page.CHECKIN_ADMIN.AsGuid()));
            blockedPageIds.Add(PageCache.GetId(Rock.SystemGuid.Page.CHECKIN_WELCOME.AsGuid()));
            blockedPageIds.Add(PageCache.GetId(Rock.SystemGuid.Page.CHECKIN_SEARCH.AsGuid()));
            blockedPageIds.Add(PageCache.GetId(Rock.SystemGuid.Page.CHECKIN_FAMILY_SELECT.AsGuid()));

            LocalDeviceConfig.BlockedPageIds = blockedPageIds.Where(a => a.HasValue).Select(a => a.Value).ToArray();

            // turn off the idle redirect blocks since we don't a person's mobile device to do that
            LocalDeviceConfig.DisableIdleRedirect = true;

            // we want the SuccessBlock to generate a QR Code that contains the AttendanceSession(s)
            LocalDeviceConfig.GenerateQRCodeForAttendanceSessions = true;

            LocalDeviceConfig.SaveToCookie(this.Page);

            // create new checkin state since we are starting a new checkin sessions
            this.CurrentCheckInState = new CheckInState(this.LocalDeviceConfig);
            SaveState();
        }
コード例 #6
0
ファイル: Admin.ascx.cs プロジェクト: marcoramzy/Rock
        /// <summary>
        /// Shows the detail.
        /// </summary>
        private void ShowDetail()
        {
            // just in case the local device config had some overrides (from the MobileLauncher Block)
            LocalDeviceConfig.ClearOverrides();

            SaveState();

            bool enableLocationSharing = GetAttributeValue(AttributeKey.EnableLocationSharing).AsBoolean();
            bool allowManualSetup      = GetAttributeValue(AttributeKey.AllowManualSetup).AsBoolean(true);

            // 1. Match by IP/DNS first.
            AttemptKioskMatchByIpOrName();

            // 2. Then attempt to match by Geo location if enabled.
            if (enableLocationSharing)
            {
                lbRetry.Visible = true;

                // We'll re-enable things if the geo lookup fails.
                pnlManualConfig.AddCssClass("hidden");
                lbOk.AddCssClass("hidden");

                // Inject script used for geo location determination
                AddGeoLocationScript();
            }

            // 3. Allow manual setup if enabled.
            if (allowManualSetup)
            {
                pnlManualConfig.Visible = true;
                lbOk.Visible            = true;
            }

            //
            // If neither location sharing nor manual setup are enabled
            // then display a friendly message.
            //
            if (!enableLocationSharing && !allowManualSetup)
            {
                lbRetry.Visible = true;
                nbGeoMessage.NotificationBoxType = NotificationBoxType.Danger;
                nbGeoMessage.Text = "Manual configuration is not currently enabled.";
            }

            ddlTheme.Items.Clear();
            DirectoryInfo di = new DirectoryInfo(this.Page.Request.MapPath(ResolveRockUrl("~~")));

            foreach (var themeDir in di.Parent.EnumerateDirectories().OrderBy(a => a.Name))
            {
                ddlTheme.Items.Add(new ListItem(themeDir.Name, themeDir.Name.ToLower()));
            }

            if (!string.IsNullOrWhiteSpace(LocalDeviceConfig.CurrentTheme))
            {
                ddlTheme.SetValue(LocalDeviceConfig.CurrentTheme);
                SetSelectedTheme(LocalDeviceConfig.CurrentTheme);
            }
            else
            {
                ddlTheme.SetValue(RockPage.Site.Theme.ToLower());
            }

            int?kioskDeviceTypeValueId = DefinedValueCache.GetId(Rock.SystemGuid.DefinedValue.DEVICE_TYPE_CHECKIN_KIOSK.AsGuid());

            ddlKiosk.Items.Clear();
            using (var rockContext = new RockContext())
            {
                ddlKiosk.DataSource = new DeviceService(rockContext)
                                      .Queryable().AsNoTracking()
                                      .Where(d => d.DeviceTypeValueId == kioskDeviceTypeValueId &&
                                             d.IsActive)
                                      .OrderBy(d => d.Name)
                                      .Select(d => new
                {
                    d.Id,
                    d.Name
                })
                                      .ToList();
            }

            ddlKiosk.DataBind();
            ddlKiosk.Items.Insert(0, new ListItem(None.Text, None.IdValue));

            ddlKiosk.SetValue(this.LocalDeviceConfig.CurrentKioskId);
            BindCheckinTypes(this.LocalDeviceConfig.CurrentCheckinTypeId);
            BindGroupTypes(this.LocalDeviceConfig.CurrentGroupTypeIds);
        }