Esempio n. 1
0
        private void BindDropDownLists(Kiosk kiosk = null)
        {
            RockContext      rockContext      = new RockContext();
            KioskTypeService kioskTypeService = new KioskTypeService(rockContext);

            var kioskTypes = kioskTypeService
                             .Queryable()
                             .OrderBy(t => t.Name)
                             .Select(t => new
            {
                t.Name,
                t.Id
            })
                             .ToList();

            ddlManualKioskType.DataSource = kioskTypes;
            ddlManualKioskType.DataBind();

            ddlKioskType.DataSource = kioskTypes;
            ddlKioskType.DataBind();

            var preSelectedKioskTypeId = GetBlockUserPreference("KioskTypeId").AsInteger();

            if (kioskTypes.Where(k => k.Id == preSelectedKioskTypeId).Any())
            {
                ddlManualKioskType.SelectedValue = preSelectedKioskTypeId.ToString();
            }
        }
Esempio n. 2
0
        protected void gKioskType_Delete(object sender, RowEventArgs e)
        {
            var checkinContext = new RockContext();
            KioskTypeService KioskTypeService = new KioskTypeService(checkinContext);
            KioskType        KioskType        = KioskTypeService.Get(e.RowKeyId);

            if (KioskType != null)
            {
                int kosktypeId = KioskType.Id;

                string errorMessage;
                if (!KioskTypeService.CanDelete(KioskType, out errorMessage))
                {
                    mdGridWarning.Show(errorMessage, ModalAlertType.Information);
                    return;
                }

                KioskTypeService.Delete(KioskType);
                checkinContext.SaveChanges();

                Rock.CheckIn.KioskDevice.FlushAll();
            }

            BindGrid();
        }
Esempio n. 3
0
        protected void btnSelectKiosk_Click(object sender, EventArgs e)
        {
            var rockContext = new RockContext();

            var kioskTypeService = new KioskTypeService(rockContext);
            var kioskType        = kioskTypeService.Get(ddlManualKioskType.SelectedValue.AsInteger());

            if (kioskType == null)
            {
                return;
            }


            var kioskService = new KioskService(rockContext);
            var kiosk        = kioskService.GetByClientName(CurrentUser.UserName);

            if (kiosk == null)
            {
                kiosk             = new Kiosk();
                kiosk.Name        = CurrentUser.UserName;
                kiosk.Description = "Automatically created personal Kiosk";
                kioskService.Add(kiosk);
            }
            kiosk.KioskTypeId = kioskType.Id;
            kiosk.CategoryId  = CategoryCache.GetId(Constants.KIOSK_CATEGORY_STAFFUSER.AsGuid());
            rockContext.SaveChanges();

            SetBlockUserPreference("KioskTypeId", kioskType.Id.ToString());

            ActivateKiosk(kiosk, false);
        }
Esempio n. 4
0
        protected void btnSelectKiosk_Click(object sender, EventArgs e)
        {
            var rockContext = new RockContext();

            var kioskTypeService = new KioskTypeService(rockContext);
            var kioskType        = kioskTypeService.Get(ddlKioskType.SelectedValue.AsInteger());

            if (kioskType == null)
            {
                return;
            }


            var kioskService = new KioskService(rockContext);
            var kiosk        = kioskService.GetByClientName(CurrentUser.UserName);

            if (kiosk == null)
            {
                kiosk             = new Kiosk();
                kiosk.Name        = CurrentUser.UserName;
                kiosk.Description = "Automatically created personal Kiosk";
                kioskService.Add(kiosk);
            }
            kiosk.KioskTypeId = kioskType.Id;
            rockContext.SaveChanges();
            GetKioskType(kiosk, rockContext);
        }
Esempio n. 5
0
        public static void Clear(List <int> groupTypeIds)
        {
            RockContext      rockContext      = new RockContext();
            KioskTypeService kioskTypeService = new KioskTypeService(rockContext);
            KioskService     kioskService     = new KioskService(rockContext);
            DeviceService    deviceService    = new DeviceService(rockContext);



            var kioskTypeIds = kioskTypeService.Queryable()
                               .Where(k => k.GroupTypes.Select(gt => gt.Id).Where(i => groupTypeIds.Contains(i)).Any())
                               .Select(kt => kt.Id)
                               .ToList();

            var deviceNames = kioskService.Queryable()
                              .Where(k => kioskTypeIds.Contains(k.KioskTypeId ?? 0)).Select(k => k.Name)
                              .ToList();

            var devices = deviceService.Queryable().Where(d => deviceNames.Contains(d.Name)).ToList();

            foreach (var device in devices)
            {
                FlushItem(device.Id);
            }
        }
Esempio n. 6
0
        public HttpResponseMessage KioskStatus(int param)
        {
            var kioskType = new KioskTypeService(new RockContext()).Get(param);
            var Session   = HttpContext.Current.Session;

            if (Session["CheckInState"] != null)
            {
                CurrentCheckInState = Session["CheckInState"] as CheckInState;
            }
            else
            {
                return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new Dictionary <string, bool> {
                    { "active", false }
                }));
            }

            if (kioskType == null ||
                CurrentCheckInState == null ||
                !kioskType.IsOpen() ||
                CurrentCheckInState.Kiosk.FilteredGroupTypes(CurrentCheckInState.ConfiguredGroupTypes).Count == 0 ||
                !CurrentCheckInState.Kiosk.HasLocations(CurrentCheckInState.ConfiguredGroupTypes))
            {
                return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new Dictionary <string, bool> {
                    { "active", false }
                }));
            }

            return(ControllerContext.Request.CreateResponse(HttpStatusCode.OK, new Dictionary <string, bool> {
                { "active", true }
            }));
        }
Esempio n. 7
0
        /// <summary>
        /// Binds the grid.
        /// </summary>
        private void BindGrid()
        {
            var kioskTypeService = new KioskTypeService(new RockContext());
            var kioskTypes       = kioskTypeService.Queryable()
                                   .Select(kt => kt)
                                   .OrderBy(k => k.Name)
                                   .ToList();

            gKioskTypes.DataSource = kioskTypes;
            gKioskTypes.DataBind();
        }
Esempio n. 8
0
        private void BindDropDownList(Kiosk kiosk = null)
        {
            RockContext      rockContext      = new RockContext();
            KioskTypeService kioskTypeService = new KioskTypeService(rockContext);


            ddlKioskType.DataSource = kioskTypeService
                                      .Queryable()
                                      .OrderBy(t => t.Name)
                                      .Select(t => new
            {
                t.Name,
                t.Id
            })
                                      .ToList();
            ddlKioskType.DataBind();
        }
Esempio n. 9
0
        private void BindDropDownList(Kiosk kiosk = null)
        {
            RockContext      rockContext      = new RockContext();
            KioskTypeService kioskTypeService = new KioskTypeService(rockContext);


            ddlKioskType.DataSource = kioskTypeService
                                      .Queryable()
                                      .OrderBy(t => t.Name)
                                      .Select(t => new
            {
                t.Name,
                t.Id
            })
                                      .ToList();
            ddlKioskType.DataBind();


            ddlPrintFrom.BindToEnum <PrintFrom>();

            ddlPrinter.Items.Clear();
            ddlPrinter.DataSource = new DeviceService(new RockContext())
                                    .GetByDeviceTypeGuid(new Guid(Rock.SystemGuid.DefinedValue.DEVICE_TYPE_PRINTER))
                                    .OrderBy(d => d.Name)
                                    .ToList();
            ddlPrinter.DataBind();
            ddlPrinter.Items.Insert(0, new ListItem(None.Text, None.IdValue));

            if (kiosk != null)
            {
                ddlKioskType.SetValue(kiosk.KioskTypeId);
                ddlPrintTo.SetValue(kiosk.PrintToOverride.ConvertToInt().ToString());
                ddlPrinter.SetValue(kiosk.PrinterDeviceId);
                ddlPrintFrom.SetValue(kiosk.PrintFrom.ConvertToInt().ToString());
            }
        }
Esempio n. 10
0
        /// <summary>
        /// Shows the edit.
        /// </summary>
        /// <param name="DeviceId">The device identifier.</param>
        public void ShowDetail(int KioskTypeId)
        {
            pnlDetails.Visible = true;
            KioskType KioskType = null;

            var checkinContext = new RockContext();

            if (!KioskTypeId.Equals(0))
            {
                KioskType         = new KioskTypeService(checkinContext).Get(KioskTypeId);
                lActionTitle.Text = ActionTitle.Edit(KioskType.FriendlyTypeName).FormatAsHtmlTitle();
            }

            if (KioskType == null)
            {
                KioskType = new KioskType {
                    Id = 0
                };
                lActionTitle.Text = ActionTitle.Add(KioskType.FriendlyTypeName).FormatAsHtmlTitle();
            }

            hfKioskTypeId.Value = KioskType.Id.ToString();

            tbName.Text        = KioskType.Name;
            tbDescription.Text = KioskType.Description;
            tbMessage.Text     = KioskType.Message;

            Locations = new Dictionary <int, string>();
            foreach (var location in KioskType.Locations)
            {
                string path           = location.Name;
                var    parentLocation = location.ParentLocation;
                while (parentLocation != null)
                {
                    path           = parentLocation.Name + " > " + path;
                    parentLocation = parentLocation.ParentLocation;
                }
                Locations.Add(location.Id, path);
            }

            Schedules = new Dictionary <int, string>();
            foreach (var schedule in KioskType.Schedules)
            {
                Schedules.Add(schedule.Id, schedule.Name);
            }

            BindDropDownList(KioskType);
            BindLocations();
            BindSchedules();

            // render UI based on Authorized and IsSystem
            bool readOnly = false;

            nbEditModeMessage.Text = string.Empty;
            if (!IsUserAuthorized(Authorization.EDIT))
            {
                readOnly = true;
                nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(KioskType.FriendlyTypeName);
            }

            if (readOnly)
            {
                lActionTitle.Text = ActionTitle.View(KioskType.FriendlyTypeName);
                btnCancel.Text    = "Close";
            }

            tbName.ReadOnly        = readOnly;
            tbDescription.ReadOnly = readOnly;

            btnSave.Visible = !readOnly;
        }
Esempio n. 11
0
        protected void btnSave_Click(object sender, EventArgs e)
        {
            KioskType KioskType = null;

            var rockContext      = new RockContext();
            var kioskTypeService = new KioskTypeService(rockContext);
            var attributeService = new AttributeService(rockContext);
            var locationService  = new LocationService(rockContext);
            var scheduleService  = new ScheduleService(rockContext);
            var groupTypeService = new GroupTypeService(rockContext);

            int KioskTypeId = int.Parse(hfKioskTypeId.Value);

            if (KioskTypeId != 0)
            {
                KioskType = kioskTypeService.Get(KioskTypeId);
            }

            if (KioskType == null)
            {
                KioskType = new KioskType();
                kioskTypeService.Add(KioskType);
            }

            if (KioskType != null)
            {
                KioskType.Name        = tbName.Text;
                KioskType.Description = tbDescription.Text;
                KioskType.Message     = tbMessage.Text;

                if (!KioskType.IsValid || !Page.IsValid)
                {
                    // Controls will render the error messages
                    return;
                }

                // Remove any deleted locations
                foreach (var location in KioskType.Locations
                         .Where(l =>
                                !Locations.Keys.Contains(l.Id))
                         .ToList())
                {
                    KioskType.Locations.Remove(location);
                }

                // Remove any deleted schedules
                foreach (var schedule in KioskType.Schedules
                         .Where(s =>
                                !Schedules.Keys.Contains(s.Id))
                         .ToList())
                {
                    KioskType.Schedules.Remove(schedule);
                }

                // Add any new locations
                var existingLocationIDs = KioskType.Locations.Select(l => l.Id).ToList();
                foreach (var location in locationService.Queryable()
                         .Where(l =>
                                Locations.Keys.Contains(l.Id) &&
                                !existingLocationIDs.Contains(l.Id)))
                {
                    KioskType.Locations.Add(location);
                }

                // Add any new schedules
                var existingScheduleIDs = KioskType.Schedules.Select(s => s.Id).ToList();
                foreach (var schedule in scheduleService.Queryable()
                         .Where(s =>
                                Schedules.Keys.Contains(s.Id) &&
                                !existingScheduleIDs.Contains(s.Id)))
                {
                    KioskType.Schedules.Add(schedule);
                }

                //Save checkin template
                KioskType.CheckinTemplateId = ddlTemplates.SelectedValue.AsInteger();


                var GroupTypes = KioskType.GroupTypes;
                GroupTypes.Clear();

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

                rockContext.SaveChanges();

                Rock.CheckIn.KioskDevice.FlushAll();

                NavigateToParentPage();
            }
        }