Ejemplo n.º 1
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                // Set the check-in state from values passed on query string
                CurrentKioskId = PageParameter("KioskId").AsIntegerOrNull();

                CurrentGroupTypeIds = (PageParameter("GroupTypeIds") ?? "")
                                      .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                                      .ToList()
                                      .Select(s => s.AsInteger())
                                      .ToList();

                if (CurrentKioskId.HasValue && CurrentGroupTypeIds != null && CurrentGroupTypeIds.Any() && !UserBackedUp)
                {
                    // Save the check-in state
                    SaveState();

                    // Navigate to the next page
                    NavigateToNextPage();
                }
                else
                {
                    RockPage.AddScriptLink("~/Blocks/CheckIn/Scripts/geo-min.js");

                    AttemptKioskMatchByIpOrName();

                    string script = string.Format(@"
                <script>
                    $(document).ready(function (e) {{
                        if (localStorage) {{
                            if (localStorage.checkInKiosk) {{
                                $('[id$=""hfKiosk""]').val(localStorage.checkInKiosk);
                                if (localStorage.checkInGroupTypes) {{
                                    $('[id$=""hfGroupTypes""]').val(localStorage.checkInGroupTypes);
                                }}
                            }}
                            {0};
                        }}
                    }});
                </script>
                ", this.Page.ClientScript.GetPostBackEventReference(lbRefresh, ""));
                    phScript.Controls.Add(new LiteralControl(script));

                    // Initiate the check-in variables
                    lbOk.Focus();
                    SaveState();
                }
            }
            else
            {
                phScript.Controls.Clear();
            }
        }
Ejemplo n.º 2
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                // Set the check-in state from values passed on query string
                var themeRedirect = PageParameter("ThemeRedirect").AsBoolean(false);

                var preferredKioskId = PageParameter("KioskId").AsIntegerOrNull();
                if (preferredKioskId != null)
                {
                    CurrentKioskId = preferredKioskId;
                }

                var checkinTypeId = PageParameter("CheckinTypeId").AsIntegerOrNull();
                if (checkinTypeId != null)
                {
                    CurrentCheckinTypeId = checkinTypeId;
                }

                var queryStringConfig = PageParameter("GroupTypeIds");
                if (!string.IsNullOrEmpty(queryStringConfig))
                {
                    CurrentGroupTypeIds = queryStringConfig.ToStringSafe()
                                          .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                                          .ToList()
                                          .Select(s => s.AsInteger())
                                          .ToList();
                }

                if (CurrentCheckInState != null && CurrentCheckInState.Kiosk != null && CurrentGroupTypeIds != null && CurrentGroupTypeIds.Any() && !UserBackedUp)
                {
                    // Set the local cache if a session is already active
                    CurrentKioskId      = CurrentCheckInState.DeviceId;
                    CurrentGroupTypeIds = CurrentCheckInState.ConfiguredGroupTypes;
                    CurrentCheckInState = null;
                    CurrentWorkflow     = null;

                    // If checkin type not set, try to calculate it from the group types.
                    if (!CurrentCheckinTypeId.HasValue)
                    {
                        foreach (int groupTypeId in CurrentGroupTypeIds)
                        {
                            var checkinType = GetCheckinType(groupTypeId);
                            if (checkinType != null)
                            {
                                CurrentCheckinTypeId = checkinType.Id;
                                break;
                            }
                        }
                    }

                    // Save the check-in state
                    SaveState();

                    // Navigate to the next page
                    NavigateToNextPage();
                }
                else
                {
                    if (GetAttributeValue("AllowManualSetup").AsBoolean())
                    {
                        ddlKiosk.Visible = true;
                    }
                    else if (!GetAttributeValue("EnableLocationSharing").AsBoolean())
                    {
                        lbOk.Visible = true;
                        AttemptKioskMatchByIpOrName();
                    }
                    else
                    {
                        // Inject script used for geo location determination
                        RockPage.AddScriptLink("~/Blocks/CheckIn/Scripts/geo-min.js");
                        lbRefresh.Visible = true;
                        AddGeoLocationScript();
                    }

                    AttemptKioskMatchByIpOrName();

                    var script = string.Format(@"<script>
                        $(document).ready(function (e) {{
                            if (localStorage) {{
                                if (localStorage.checkInKiosk) {{
                                    $('[id$=""hfKiosk""]').val(localStorage.checkInKiosk);
                                    if (localStorage.theme) {{
                                        $('[id$=""hfTheme""]').val(localStorage.theme);
                                    }}
                                    if (localStorage.checkInType) {{
                                        $('[id$=""hfCheckinType""]').val(localStorage.checkInType);
                                    }}
                                    if (localStorage.checkInGroupTypes) {{
                                        $('[id$=""hfGroupTypes""]').val(localStorage.checkInGroupTypes);
                                    }}
                                }}
                                window.location = ""javascript:{0}"";
                            }}
                        }});
                        </script>", this.Page.ClientScript.GetPostBackEventReference(lbRefresh, "")
                                               );
                    using (var literalControl = new LiteralControl(script))
                    {
                        phScript.Controls.Add(literalControl);
                    }

                    if (GetAttributeValue("AllowManualSetup").AsBoolean())
                    {
                        ddlTheme.Items.Clear();
                        var 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(CurrentTheme))
                        {
                            ddlTheme.SetValue(CurrentTheme);
                        }
                        else
                        {
                            ddlTheme.SetValue(RockPage.Site.Theme.ToLower());
                        }

                        ddlKiosk.Items.Clear();
                        var kioskDeviceType = Rock.SystemGuid.DefinedValue.DEVICE_TYPE_CHECKIN_KIOSK.AsGuid();
                        using (var rockContext = new RockContext())
                        {
                            ddlKiosk.DataSource = new DeviceService(rockContext)
                                                  .Queryable().AsNoTracking()
                                                  .Where(d => d.DeviceType.Guid.Equals(kioskDeviceType))
                                                  .OrderBy(d => d.Name)
                                                  .Select(d => new
                            {
                                d.Id,
                                d.Name
                            })
                                                  .ToList();
                        }
                        ddlKiosk.DataBind();
                        ddlKiosk.Items.Insert(0, new ListItem(None.Text, None.IdValue));

                        if (CurrentKioskId.HasValue)
                        {
                            ddlKiosk.SetValue(CurrentKioskId);
                        }
                    }

                    // Initiate the check-in variables
                    lbOk.Focus();
                    SaveState();
                }
            }
            else if (Request["__EVENTTARGET"] == lbTestPrint.ClientID)
            {
                SendTestPrint();
            }
            else
            {
                phScript.Controls.Clear();
            }
        }
Ejemplo n.º 3
0
        protected override void OnLoad(EventArgs e)
        {
            RockPage.AddScriptLink("~/Blocks/CheckIn/Scripts/geo-min.js");
            RockPage.AddScriptLink("~/Scripts/iscroll.js");
            RockPage.AddScriptLink("~/Scripts/CheckinClient/checkin-core.js");

            if (!Page.IsPostBack)
            {
                // Set the check-in state from values passed on query string
                CurrentKioskId = PageParameter("KioskId").AsIntegerOrNull();

                CurrentGroupTypeIds = (PageParameter("GroupTypeIds") ?? "")
                                      .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                                      .ToList()
                                      .Select(s => s.AsInteger())
                                      .ToList();

                // If valid parameters were used, set state and navigate to welcome page
                if (CurrentKioskId.HasValue && CurrentGroupTypeIds.Any())
                {
                    // Save the check-in state
                    SaveState();

                    // Navigate to the check-in home (welcome) page
                    NavigateToNextPage();
                }
                else
                {
                    bool enableLocationSharing = GetAttributeValue("EnableLocationSharing").AsBoolean();

                    // Inject script used for geo location determiniation
                    if (enableLocationSharing)
                    {
                        lbRetry.Visible = true;
                        AddGeoLocationScript();
                    }
                    else
                    {
                        pnlManualConfig.Visible = true;
                        lbOk.Visible            = true;
                        AttemptKioskMatchByIpOrName();
                    }

                    string script = string.Format(@"
                    <script>
                        $(document).ready(function (e) {{
                            if (localStorage) {{
                                if (localStorage.checkInKiosk) {{
                                    $('[id$=""hfKiosk""]').val(localStorage.checkInKiosk);
                                    if (localStorage.theme) {{
                                        $('[id$=""hfTheme""]').val(localStorage.theme);
                                    }}
                                    if (localStorage.checkInGroupTypes) {{
                                        $('[id$=""hfGroupTypes""]').val(localStorage.checkInGroupTypes);
                                    }}
                                    {0};
                                }}
                            }}
                        }});
                    </script>
                ", this.Page.ClientScript.GetPostBackEventReference(lbRefresh, ""));
                    phScript.Controls.Add(new LiteralControl(script));

                    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(CurrentTheme))
                    {
                        ddlTheme.SetValue(CurrentTheme);
                    }
                    else
                    {
                        ddlTheme.SetValue(RockPage.Site.Theme.ToLower());
                    }

                    Guid kioskDeviceType = 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.DeviceType.Guid.Equals(kioskDeviceType))
                                              .OrderBy(d => d.Name)
                                              .Select(d => new
                        {
                            d.Id,
                            d.Name
                        })
                                              .ToList();
                    }
                    ddlKiosk.DataBind();
                    ddlKiosk.Items.Insert(0, new ListItem(None.Text, None.IdValue));

                    if (CurrentKioskId.HasValue)
                    {
                        ListItem item = ddlKiosk.Items.FindByValue(CurrentKioskId.Value.ToString());
                        if (item != null)
                        {
                            item.Selected = true;
                            BindGroupTypes();
                        }
                    }
                }
            }
            else
            {
                phScript.Controls.Clear();
            }
        }
Ejemplo n.º 4
0
        /// <summary>
        /// Raises the <see cref="E:System.Web.UI.Control.Load" /> event.
        /// </summary>
        /// <param name="e">The <see cref="T:System.EventArgs" /> object that contains the event data.</param>
        protected override void OnLoad(EventArgs e)
        {
            if (!Page.IsPostBack)
            {
                // Set the check-in state from values passed on query string
                bool themeRedirect = PageParameter("ThemeRedirect").AsBoolean(false);

                var preferredKioskId = PageParameter("KioskId").AsIntegerOrNull();
                if (preferredKioskId != null)
                {
                    CurrentKioskId = preferredKioskId;
                }

                var checkinTypeId = PageParameter("CheckinTypeId").AsIntegerOrNull();
                if (checkinTypeId != null)
                {
                    CurrentCheckinTypeId = checkinTypeId;
                }

                var queryStringConfig = PageParameter("GroupTypeIds");
                if (!string.IsNullOrEmpty(queryStringConfig))
                {
                    CurrentGroupTypeIds = queryStringConfig.ToStringSafe()
                                          .Split(new char[] { ',' }, StringSplitOptions.RemoveEmptyEntries)
                                          .ToList()
                                          .Select(s => s.AsInteger())
                                          .ToList();
                }

                if (CurrentCheckInState != null && CurrentCheckInState.Kiosk != null && CurrentGroupTypeIds != null && CurrentGroupTypeIds.Any() && !UserBackedUp)
                {
                    // Set the local cache if a session is already active
                    CurrentKioskId      = CurrentCheckInState.DeviceId;
                    CurrentGroupTypeIds = CurrentCheckInState.ConfiguredGroupTypes;
                    CurrentCheckInState = null;
                    CurrentWorkflow     = null;

                    if (!CurrentCheckinTypeId.HasValue)
                    {
                        foreach (int groupTypeId in CurrentGroupTypeIds)
                        {
                            var checkinType = GetCheckinType(groupTypeId);
                            if (checkinType != null)
                            {
                                CurrentCheckinTypeId = checkinType.Id;
                                break;
                            }
                        }
                    }

                    // Save the check-in state
                    SaveState();

                    // Navigate to the next page
                    NavigateToNextPage();
                }
                else
                {
                    bool useGeoLocationService = GetAttributeValue("EnableLocationSharing").AsBoolean();

                    // Inject script used for geo location determiniation
                    if (!useGeoLocationService)
                    {
                        lbOk.Visible = true;
                        AttemptKioskMatchByIpOrName();
                    }
                    else
                    {
                        RockPage.AddScriptLink("~/Blocks/CheckIn/Scripts/geo-min.js");
                        lbRefresh.Visible = true;
                        AddGeoLocationScript();
                    }

                    AttemptKioskMatchByIpOrName();

                    string script = string.Format(@"<script>
                        $(document).ready(function (e) {{
                            if (localStorage) {{
                                if (localStorage.checkInKiosk) {{
                                    $('[id$=""hfKiosk""]').val(localStorage.checkInKiosk);
                                    if (localStorage.checkInType) {{
                                        $('[id$=""hfCheckinType""]').val(localStorage.checkInType);
                                    }}
                                    if (localStorage.checkInGroupTypes) {{
                                        $('[id$=""hfGroupTypes""]').val(localStorage.checkInGroupTypes);
                                    }}
                                }}
                                {0};
                            }}
                        }});
                        </script>", this.Page.ClientScript.GetPostBackEventReference(lbRefresh, "")
                                                  );
                    phScript.Controls.Add(new LiteralControl(script));

                    // Initiate the check-in variables
                    lbOk.Focus();
                    SaveState();
                }
            }
            else if (Request["__EVENTTARGET"] == lbTestPrint.ClientID)
            {
                SendTestPrint();
            }
            else
            {
                phScript.Controls.Clear();
            }
        }