/// <summary> /// Generates labels and attaches appropriate scripts to print labels client side /// </summary> private void ProcessLabels() { LabelPrinter labelPrinter = new LabelPrinter(CurrentCheckInState, Request); labelPrinter.PrintNetworkLabels(); var script = labelPrinter.GetClientScript(); script += "setTimeout( function(){ __doPostBack( '" + btnDone.UniqueID + "', 'OnClick' ); },6000)"; ScriptManager.RegisterStartupScript(upContent, upContent.GetType(), "addLabelScript", script, true); }
private void MobileCheckin(string accessKey) { var mobileDidAttendId = DefinedValueCache.Get(Constants.DEFINED_VALUE_MOBILE_DID_ATTEND).Id; var mobileNotAttendId = DefinedValueCache.Get(Constants.DEFINED_VALUE_MOBILE_NOT_ATTEND).Id; RockContext rockContext = new RockContext(); MobileCheckinRecordService mobileCheckinRecordService = new MobileCheckinRecordService(rockContext); var mobileCheckinRecord = mobileCheckinRecordService.Queryable().Where(r => r.AccessKey == accessKey).FirstOrDefault(); if (mobileCheckinRecord == null) { mdAlert.Show("Mobile check-in record not found", ModalAlertType.Alert); BindRepeater(); return; } else if (mobileCheckinRecord.Status == MobileCheckinStatus.Canceled) { mdAlert.Show("Mobile check-in record is expired.", ModalAlertType.Alert); BindRepeater(); return; } else if (mobileCheckinRecord.Status == MobileCheckinStatus.Complete) { mdAlert.Show("Mobile check-in record has already been completed.", ModalAlertType.Alert); BindRepeater(); return; } try { if (mobileCheckinRecord == null) { return; } List <CheckInLabel> labels = null; if (mobileCheckinRecord.Attendances.Any(a => a.EndDateTime != null)) { var people = mobileCheckinRecord.Attendances.Select(a => a.PersonAlias.Person).DistinctBy(p => p.Id).ToList(); labels = CheckinLabelGen.GenerateLabels(people, CurrentCheckInState.Kiosk.Device, GetAttributeValue("AggregatedLabel").AsGuidOrNull()); } else { labels = JsonConvert.DeserializeObject <List <CheckInLabel> >(mobileCheckinRecord.SerializedCheckInState); } LabelPrinter labelPrinter = new LabelPrinter() { Request = Request, Labels = labels }; labelPrinter.PrintNetworkLabels(); var script = labelPrinter.GetClientScript(); ScriptManager.RegisterStartupScript(upContent, upContent.GetType(), "addLabelScript", script, true); foreach (var attendance in mobileCheckinRecord.Attendances) { if (attendance.QualifierValueId == mobileDidAttendId) { attendance.DidAttend = true; attendance.QualifierValueId = null; attendance.StartDateTime = Rock.RockDateTime.Now; } else if (attendance.QualifierValueId == mobileNotAttendId) { attendance.DidAttend = false; attendance.QualifierValueId = null; } attendance.Note = "Completed mobile check-in at: " + CurrentCheckInState.Kiosk.Device.Name; } mobileCheckinRecord.Status = MobileCheckinStatus.Complete; rockContext.SaveChanges(); //wait until we successfully save to update cache foreach (var attendance in mobileCheckinRecord.Attendances) { AttendanceCache.AddOrUpdate(attendance); } MobileCheckinRecordCache.Update(mobileCheckinRecord.Id); BindRepeater(); } catch (Exception e) { LogException(e); mdAlert.Show("An unexpected issue occurred.", ModalAlertType.Alert); BindRepeater(); } }
private void MobileCheckin(string accessKey) { var mobileDidAttendId = DefinedValueCache.Get(Constants.DEFINED_VALUE_MOBILE_DID_ATTEND).Id; var mobileNotAttendId = DefinedValueCache.Get(Constants.DEFINED_VALUE_MOBILE_NOT_ATTEND).Id; RockContext rockContext = new RockContext(); MobileCheckinRecordService mobileCheckinRecordService = new MobileCheckinRecordService(rockContext); var mobileCheckinRecord = mobileCheckinRecordService.Queryable().Where(r => r.AccessKey == accessKey).FirstOrDefault(); if (mobileCheckinRecord == null) { MobileCheckinMessage(GetAttributeValue(AttributeKeys.NoMobileCheckinRecord)); return; } else if (mobileCheckinRecord.Status == MobileCheckinStatus.Canceled) { MobileCheckinMessage(GetAttributeValue(AttributeKeys.ExpiredMobileCheckinRecord)); return; } else if (mobileCheckinRecord.Status == MobileCheckinStatus.Complete) { MobileCheckinMessage(GetAttributeValue(AttributeKeys.AlreadyCompleteCheckinRecord)); return; } try { if (mobileCheckinRecord == null) { return; } if (KioskType.CampusId.HasValue && KioskType.CampusId != 0 && KioskType.CampusId != mobileCheckinRecord.CampusId) { ShowWrongCampusSign(mobileCheckinRecord.Campus.Name, KioskType.Campus.Name); return; } List <CheckInLabel> labels = JsonConvert.DeserializeObject <List <CheckInLabel> >(mobileCheckinRecord.SerializedCheckInState); LabelPrinter labelPrinter = new LabelPrinter() { Request = Request, Labels = labels }; labelPrinter.PrintNetworkLabels(); var script = labelPrinter.GetClientScript(); ScriptManager.RegisterStartupScript(upContent, upContent.GetType(), "addLabelScript", script, true); foreach (var attendance in mobileCheckinRecord.Attendances) { if (attendance.QualifierValueId == mobileDidAttendId) { attendance.DidAttend = true; attendance.QualifierValueId = null; attendance.StartDateTime = Rock.RockDateTime.Now; } else if (attendance.QualifierValueId == mobileNotAttendId) { attendance.DidAttend = false; attendance.QualifierValueId = null; } attendance.Note = "Completed mobile check-in at: " + CurrentCheckInState.Kiosk.Device.Name; } mobileCheckinRecord.Status = MobileCheckinStatus.Complete; rockContext.SaveChanges(); //wait until we successfully save to update cache foreach (var attendance in mobileCheckinRecord.Attendances) { AttendanceCache.AddOrUpdate(attendance); } MobileCheckinRecordCache.Update(mobileCheckinRecord.Id); MobileCheckinMessage(GetAttributeValue(AttributeKeys.CompletingMobileCheckin), 5); } catch (Exception e) { } }
private void FastPassCheckin(string accessKey) { try { CurrentCheckInState.CheckIn.SearchType = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.CHECKIN_SEARCH_TYPE_SCANNED_ID); CurrentCheckInState.CheckIn.SearchValue = accessKey; CurrentCheckInState.CheckIn.ConfirmSingleFamily = false; CurrentCheckInState.CheckIn.UserEnteredSearch = false; string workflowActivity = GetAttributeValue("WorkflowActivity"); List <string> errors = new List <string>(); bool test = ProcessActivity(workflowActivity, out errors); if (!CurrentCheckInState.CheckIn.Families.Any() || !CurrentCheckInState.CheckIn.CheckedInByPersonAliasId.HasValue) { MobileCheckinMessage(GetAttributeValue(AttributeKeys.FastPassNotFound)); return; } CurrentCheckInState.CheckIn.Families.FirstOrDefault().Selected = true; test = ProcessActivity(GetAttributeValue(AttributeKeys.PersonSearchActivityName), out errors); RockContext rockContext = new RockContext(); PersonAliasService personAliasService = new PersonAliasService(rockContext); var personId = personAliasService.Queryable().AsNoTracking() .Where(pa => pa.Id == CurrentCheckInState.CheckIn.CheckedInByPersonAliasId.Value) .Select(pa => pa.PersonId) .FirstOrDefault(); var person = CurrentCheckInState.CheckIn.CurrentFamily.People.Where(p => p.Person.Id == personId).FirstOrDefault(); var selected = false; if (person == null) { MobileCheckinMessage(GetAttributeValue(AttributeKeys.NoCheckinAvailable), 4); return; } foreach (var gt in person.GroupTypes.OrderByDescending(gt => gt.PreSelected)) { foreach (var g in gt.Groups.OrderByDescending(g => g.PreSelected)) { foreach (var l in g.Locations.OrderByDescending(l => l.PreSelected)) { foreach (var s in l.Schedules) { s.Selected = true; l.Selected = true; g.Selected = true; gt.Selected = true; selected = true; } if (selected) { break; } } if (selected) { break; } } if (selected) { break; } } if (!selected) { if (person.GroupTypes.SelectMany(gt => gt.Groups).Any()) { MobileCheckinMessage(GetAttributeValue(AttributeKeys.AlreadyCheckedIn), 4); } else { MobileCheckinMessage(GetAttributeValue(AttributeKeys.NoCheckinAvailable), 4); } return; } test = ProcessActivity(GetAttributeValue(AttributeKeys.SaveAttendanceActivtyName), out errors); LabelPrinter labelPrinter = new LabelPrinter() { Request = Request, Labels = person.GroupTypes.Where(gt => gt.Labels != null).SelectMany(gt => gt.Labels).ToList() }; labelPrinter.PrintNetworkLabels(); var script = labelPrinter.GetClientScript(); ScriptManager.RegisterStartupScript(upContent, upContent.GetType(), "addLabelScript", script, true); MobileCheckinMessage(GetAttributeValue(AttributeKeys.FastPassComplete), 2); } catch (Exception e) { LogException(e); } }