protected void gKiosk_Delete(object sender, RowEventArgs e) { var rockContext = new RockContext(); KioskService KioskService = new KioskService(rockContext); Kiosk Kiosk = KioskService.Get(e.RowKeyId); if (Kiosk != null) { int kioskId = Kiosk.Id; string errorMessage; if (!KioskService.CanDelete(Kiosk, out errorMessage)) { mdGridWarning.Show(errorMessage, ModalAlertType.Information); return; } KioskService.Delete(Kiosk); rockContext.SaveChanges(); Rock.CheckIn.KioskDevice.Clear(); } BindGrid(); }
public static void Main() { Console.Write("Enter number of registred student:\n"); Registration.registredStudents = Convert.ToInt32(Console.ReadLine()); Console.WriteLine("Main Started"); Kiosk kioskA = new Kiosk(101); Kiosk kioskB = new Kiosk(102); KioskManager KioskManagerA = new KioskManager(kioskA, kioskB); Thread T1 = new Thread(KioskManagerA.CancelRegistration); T1.Name = "T1"; KioskManager kioskManagerB = new KioskManager(kioskB, kioskA); Thread T2 = new Thread(kioskManagerB.CancelRegistration); T2.Name = "T2"; T1.Start(); T2.Start(); T1.Join(); T2.Join(); Console.WriteLine("Main Completed"); Console.ReadKey(); }
public void TestMultipleScannedItemOfDiffProduct() { var products = new List <Product>(); products.Add(ObjectCreator.CreateProduct(1, "Banana", 0.50, null)); products.Add(ObjectCreator.CreateProduct(2, "Apple", 0.65, null)); var items = new List <ScannedItem>(); items.Add(ObjectCreator.CreateScannedItem("Banana")); items.Add(ObjectCreator.CreateScannedItem("Apple")); items.Add(ObjectCreator.CreateScannedItem("Banana")); items.Add(ObjectCreator.CreateScannedItem("Apple")); Kiosk kiosk = new Kiosk(items, products, new List <Discount>()); kiosk.CheckOut(); Assert.AreEqual(1, items[0].ProductId); Assert.AreEqual(0.50, items[0].Price); Assert.AreEqual(null, items[0].DiscountedPrice); Assert.AreEqual(2, items[1].ProductId); Assert.AreEqual(0.65, items[1].Price); Assert.AreEqual(null, items[1].DiscountedPrice); Assert.AreEqual(1, items[0].ProductId); Assert.AreEqual(0.50, items[0].Price); Assert.AreEqual(null, items[0].DiscountedPrice); Assert.AreEqual(2, items[1].ProductId); Assert.AreEqual(0.65, items[1].Price); Assert.AreEqual(null, items[1].DiscountedPrice); Assert.AreEqual(2.30, kiosk.FinalBill); }
public void TestOneScannedItemWithRegularDiscount() { var products = new List <Product>(); products.Add(ObjectCreator.CreateProduct(1, "Banana", 0.65, Constants.REGULAR_SALE)); var discounts = new List <Discount>(); discounts.Add(ObjectCreator.CreateDiscount(1, 0.50, 0, Constants.REGULAR_SALE, 0)); var items = new List <ScannedItem>(); items.Add(ObjectCreator.CreateScannedItem("Banana")); items.Add(ObjectCreator.CreateScannedItem("Banana")); Kiosk kiosk = new Kiosk(items, products, discounts); kiosk.CheckOut(); Assert.AreEqual(1, items[0].ProductId); Assert.AreEqual(0.65, items[0].Price); Assert.AreEqual(0.50, items[0].DiscountedPrice); Assert.AreEqual(1, items[1].ProductId); Assert.AreEqual(0.65, items[1].Price); Assert.AreEqual(0.50, items[1].DiscountedPrice); Assert.AreEqual(1.00, kiosk.FinalBill); }
public void TestOneScannedItemWithBOGODiscount() { var products = new List <Product>(); products.Add(ObjectCreator.CreateProduct(1, "Banana", 0.65, Constants.DISCOUNT_BOGO)); var discounts = new List <Discount>(); discounts.Add(ObjectCreator.CreateDiscount(1, 0, 40, Constants.DISCOUNT_BOGO, 0)); var items = new List <ScannedItem>(); items.Add(ObjectCreator.CreateScannedItem("Banana")); items.Add(ObjectCreator.CreateScannedItem("Banana")); Kiosk kiosk = new Kiosk(items, products, discounts); kiosk.CheckOut(); Assert.AreEqual(1, items[0].ProductId); Assert.AreEqual(0.65, items[0].Price); Assert.AreEqual(null, items[0].DiscountedPrice); Assert.AreEqual(1, items[1].ProductId); Assert.AreEqual(0.65, items[1].Price); Assert.AreEqual(0.39, items[1].DiscountedPrice); Assert.AreEqual(1.04, kiosk.FinalBill); }
private static void DeviceHealthStatusInitialize(Kiosk dev) { using ( var ctx = ContextRegistry.NamedContextsFor(ContextRegistry.CreateNamed(ContextRegistry.Kind, UnikContextTypes. UnikWarehouseContextResourceKind))) { using (var dc = DocumentStoreLocator.ContextualResolve()) { var deviceHealthChangeEvt = new DeviceHealthStatusEvent { DeviceId = dev.Id, DeviceName = dev.Name, From = HealthStatus.Unknown, To = HealthStatus.Green, DeviceTags = dev.Tags, TimeChanged = DateTime.UtcNow }; dc.Store(deviceHealthChangeEvt); dc.SaveChanges(); } } }
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(); } }
protected void gKiosk_Delete(object sender, RowEventArgs e) { var rockContext = new RockContext(); KioskService kioskService = new KioskService(rockContext); Kiosk kiosk = kioskService.Get(e.RowKeyId); if (kiosk != null) { int kioskId = kiosk.Id; string errorMessage; if (!kioskService.CanDelete(kiosk, out errorMessage)) { mdGridWarning.Show(errorMessage, ModalAlertType.Information); return; } kioskService.Delete(kiosk); rockContext.SaveChanges(); DeviceService deviceService = new DeviceService(rockContext); var devices = deviceService.Queryable().Where(d => d.Name == kiosk.Name).ToList(); foreach (var device in devices) { KioskDeviceHelpers.FlushItem(device.Id); } } BindGrid(); }
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); }
private void LoadKioskList() { lbxKiosk.DataSource = Kiosk.GetAllKiosk(); lbxKiosk.DataTextField = "Name"; lbxKiosk.DataValueField = "KioskID"; lbxKiosk.DataBind(); }
private void SetCookie(Kiosk kiosk) { var kioskNameCookie = this.Page.Request.Cookies[Constants.COOKIE_KIOSK_NAME]; if (kioskNameCookie == null) { kioskNameCookie = new System.Web.HttpCookie(Constants.COOKIE_KIOSK_NAME); } if (kiosk.AccessKey.IsNullOrWhiteSpace()) { RockContext rockContext = new RockContext(); KioskService kioskService = new KioskService(rockContext); kiosk = kioskService.Get(kiosk.Id); kiosk.AccessKey = Guid.NewGuid().ToString(); rockContext.SaveChanges(); } kioskNameCookie.Expires = RockDateTime.Now.AddYears(1); string encryptedAccessKey; if (Encryption.TryEncryptString(kiosk.AccessKey, out encryptedAccessKey)) { kioskNameCookie.Value = encryptedAccessKey; Page.Response.Cookies.Set(kioskNameCookie); } }
protected void PrintTestButton(object sender, EventArgs e) { String printerName = null; try { if (rbSystemPrinters.Checked) { printerName = ddlSystemPrinters.SelectedItem.Text; } else if (rbArenaPrinters.Checked) { printerName = ddlArenaPrinters.SelectedValue; } else if (rbLocations.Checked) { printerName = new Location(Convert.ToInt32(ddlLocations.SelectedValue)).Printer.PrinterName; } else if (rbKiosks.Checked) { printerName = new Kiosk(Convert.ToInt32(ddlKiosks.SelectedValue)).System.Printer.PrinterName; } } catch (System.Exception ex) { lbResults.Text = "Invalid printer:<br />" + ex.Message + "<br />" + ex.StackTrace; return; } if (String.IsNullOrEmpty(printerName)) { lbResults.Text = "No valid printer has been selected."; return; } // // Do the print. // lbResults.Text = "No printing errors encountered."; try { if (rbPrintBasicText.Checked) { PrintStandardPage(printerName); } else if (rbPrintRSDirect.Checked) { PrintRSDirect(printerName, ddlRSDirectLabel.SelectedValue); } else if (rbPrintRSFramework.Checked) { PrintRSFramework(printerName, ddlRSFrameworkLabel.SelectedValue); } } catch (System.Exception ex) { lbResults.Text = "Exception while printing:<br />" + ex.Message + "<br />" + ex.StackTrace; } }
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); }
private Kiosk GetOrCreateKiosk(string kioskName, int kioskTypeId) { var rockContext = new RockContext(); var kioskService = new KioskService(rockContext); var kiosk = kioskService.GetByClientName(kioskName); if (kiosk == null) { kiosk = new Kiosk { Name = kioskName, Description = "Automatically created Kiosk" }; kioskService.Add(kiosk); } if (kioskTypeId != 0) { kiosk.KioskTypeId = kioskTypeId; } kiosk.CategoryId = CategoryCache.GetId(Constants.KIOSK_CATEGORY_STATION.AsGuid()); rockContext.SaveChanges(); //Fresh version with new context. kiosk = new KioskService(new RockContext()).Get(kiosk.Id); return(kiosk); }
static void Main(string[] args) { var screen = new ConsoleScreen(); var keypad = new ConsoleKeyPad(); Kiosk kiosk = new Kiosk(screen, keypad); kiosk.Run(); }
/// <summary> /// Attempts to match a known kiosk based on the IP address of the client. /// </summary> private void GetKioskType(Kiosk kiosk, RockContext rockContext) { if (kiosk.KioskType != null) { DeviceService deviceService = new DeviceService(rockContext); //Load matching device and update or create information var device = deviceService.Queryable().Where(d => d.Name == kiosk.Name).FirstOrDefault(); //create new device to match our kiosk if (device == null) { device = new Device(); device.DeviceTypeValueId = DefinedValueCache.Get(Rock.SystemGuid.DefinedValue.DEVICE_TYPE_CHECKIN_KIOSK).Id; device.Name = kiosk.Name; deviceService.Add(device); } device.LoadAttributes(); device.IPAddress = kiosk.IPAddress; device.Locations.Clear(); foreach (var loc in kiosk.KioskType.Locations.ToList()) { device.Locations.Add(loc); } device.PrintFrom = kiosk.PrintFrom; device.PrintToOverride = kiosk.PrintToOverride; device.PrinterDeviceId = kiosk.PrinterDeviceId; rockContext.SaveChanges(); if (PageParameter("DateTime").AsDateTime().HasValue) { device.SetAttributeValue("core_device_DebugDateTime", PageParameter("datetime")); } else { device.SetAttributeValue("core_device_DebugDateTime", ""); } device.SaveAttributeValues(rockContext); CurrentKioskId = device.Id; CurrentGroupTypeIds = kiosk.KioskType.GroupTypes.Select(gt => gt.Id).ToList(); CurrentCheckinTypeId = kiosk.KioskType.CheckinTemplateId; CurrentCheckInState = null; CurrentWorkflow = null; Session["KioskTypeId"] = kiosk.KioskType.Id; Session["KioskMessage"] = kiosk.KioskType.Message; KioskDevice.Remove(device.Id); SaveState(); NavigateToNextPage(); } else { ltDNS.Text = kiosk.Name; pnlMain.Visible = true; } }
public void WhenICallTheAddKioskPostApiEndpointToAddAKioskItChecksIfExistsPullsItemEditsItAndDeletesIt() { HttpResponseMessage response; _addItem = Add(_addItem, out response); Assert.IsNotNull(response); ScenarioContext.Current[AddItemKey] = response; }
/// <summary> /// Shows the edit. /// </summary> /// <param name="DeviceId">The device identifier.</param> public void ShowDetail(int kioskId) { pnlDetails.Visible = true; Kiosk kiosk = null; var rockContext = new RockContext(); if (!kioskId.Equals(0)) { kiosk = new KioskService(rockContext).Get(kioskId); lActionTitle.Text = ActionTitle.Edit(Kiosk.FriendlyTypeName).FormatAsHtmlTitle(); } if (kiosk == null) { kiosk = new Kiosk { Id = 0 }; lActionTitle.Text = ActionTitle.Add(Kiosk.FriendlyTypeName).FormatAsHtmlTitle(); } hfKioskId.Value = kiosk.Id.ToString(); tbName.Text = kiosk.Name; tbDescription.Text = kiosk.Description; tbIPAddress.Text = kiosk.IPAddress; // render UI based on Authorized and IsSystem bool readOnly = false; nbEditModeMessage.Text = string.Empty; if (!IsUserAuthorized(Authorization.EDIT)) { readOnly = true; nbEditModeMessage.Text = EditModeMessage.ReadOnlyEditActionNotAllowed(Kiosk.FriendlyTypeName); } pCategory.SetValue(kiosk.CategoryId); if (readOnly) { lActionTitle.Text = ActionTitle.View(Kiosk.FriendlyTypeName); btnCancel.Text = "Close"; } tbName.ReadOnly = readOnly; tbDescription.ReadOnly = readOnly; tbAccessKey.Text = kiosk.AccessKey; if (tbAccessKey.Text.IsNullOrWhiteSpace()) { tbAccessKey.Text = Guid.NewGuid().ToString(); } btnSave.Visible = !readOnly; BindDropDownList(kiosk); }
public static Kiosk ToEntity(this KioskBindingModel model, Kiosk original = null) { var isUpdate = original != null; var entity = isUpdate ? model.Map(original) // update : model.Map <KioskBindingModel, Kiosk>(); //insert return(entity); }
private void DoViewNewItems(int id) { //int id = Convert.ToInt32(hdnKioskID.Value); var instance = Kiosk.GetKioskByID(id); lblKioskNameList.Text = instance.Name; gvNewItems.DataSource = Inventory.GetAllByKiosk(id); gvNewItems.DataBind(); }
private void DoView(int id) { var ins = Kiosk.SelectKioskByID(id); hdnKioskID.Value = Convert.ToString(id); lblKioskLabel.Text = ins.Name; gvInventory.DataSource = Inventory.GetAllByKiosk(id); gvInventory.DataBind(); }
public static KioskViewModel ToViewModel(this Kiosk model) { var viewModel = model.Map <Kiosk, KioskViewModel>( cfg => { cfg.CreateMap <Kiosk, KioskViewModel>() .ForMember(x => x.LocationName, x => x.MapFrom(y => y.Location.LocationName)); } ); return(viewModel); }
private void loadKioskList() { ddlKiosk.DataSource = Kiosk.GetAllKiosk(); ddlKiosk.DataTextField = "Name"; ddlKiosk.DataValueField = "KioskID"; ddlKiosk.DataBind(); // ListItem item = new ListItem(); item.Text = " [<<<Select All>>>] "; item.Value = "0"; ddlKiosk.Items.Insert(0, item); }
public ActionResult Create(Kiosk kiosk) { if (ModelState.IsValid) { var user = db.Users .Include(us => us.Campus) .Include(us => us.Department) .Include(us => us.Cohort) .SingleOrDefault(us => us.Barcode == kiosk.Barcode); if (user == null) { ModelState.AddModelError("", "Invalid Barcode"); return(View("Kiosk", kiosk)); } var userId = user.Id; var openAttendance = db.Attendances .Where(att => att.ApplicationUserId == userId) .SingleOrDefault(att => att.TimeOut == null); if (openAttendance == null) { // We did not find an open attendance item for this user, create a new one. var newAttendance = new Attendance { ApplicationUserId = userId, TimeIn = DateTime.Now, CampusId = user.CampusId, DepartmentId = user.DepartmentId, CohortId = user.CohortId }; db.Attendances.Add(newAttendance); db.SaveChanges(); return(RedirectToAction("ViewKiosk")); } else { // We DID find an open attendance item for this user. Mark the current time as the timeout and calcuate the duration. openAttendance.TimeOut = DateTime.Now; openAttendance.Duration = openAttendance.TimeOut - openAttendance.TimeIn; db.SaveChanges(); return(RedirectToAction("ViewKiosk")); } } return(View("Kiosk", kiosk)); }
public async Task <IActionResult> OnGetAsync(int?id) { if (id == null) { return(NotFound()); } Kiosk = await _context.Kiosk.FirstOrDefaultAsync(m => m.KioskId == id); if (Kiosk == null) { return(NotFound()); } return(Page()); }
public void AddNewKiosk(Kiosk k) { bool exists = false; for (int i=0; i<kiosks.Count; i++) { if (kiosks[i].name == k.name) { exists = true; break; } } if (!exists) { Debug.Log("Added new Kiosk : "+k.name+"\n"); kiosks.Add(k); Send(k.ip, k.port, "REGISTER_OK"); } }
private void DoEdit(int id) { hdnKioskID.Value = id + ""; var ins = Kiosk.SelectKioskByID(id); tbKioskCode.Text = ins.KioskCode; tbKioskCode.Enabled = false; tbKioskName.Text = ins.Name; tbKioskLocation.Text = ins.Location; tbKioskRemarks.Text = ins.Remarks; // ddlClass.ClearSelection(); ddlClass.Items.FindByValue(ins.ClassID + "").Selected = true; }
public void Print(FamilyMember person, IEnumerable <Occurrence> occurrences, OccurrenceAttendance attendance, ComputerSystem system) { // Don't new up Kiosk w/o empty constructor, might be too costly Kiosk kiosk = new Kiosk() { System = system }; var jobs = kiosk.GetPrintJobs(attendance); ReportPrinter printer = new ReportPrinter(); foreach (ReportPrintJob job in jobs) { printer.PrintReport(job.PrinterName, job.ReportPath, job.Copies, job.Landscape, job.Parameters, job.PrinterName); } }
public SubmitItemEventInfo CreateSubmitItemEventInfo(Player submitterPlayer, Kiosk kiosk, Item item) { if (MyTarget.Definition != item.Definition) { return(null); } var amountNeeded = _progressCounter.MaxValue - _progressCounter.Current; var o = item.Unstack(amountNeeded); var missionEvent = new SubmitItemEventInfo(submitterPlayer, o, kiosk, kiosk.CurrentPosition); Entity.Repository.Delete(o); return(missionEvent); }
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(); }
public async Task <IActionResult> OnPostAsync(int?id) { if (id == null) { return(NotFound()); } Kiosk = await _context.Kiosk.FindAsync(id); if (Kiosk != null) { _context.Kiosk.Remove(Kiosk); await _context.SaveChangesAsync(); } return(RedirectToPage("./Index")); }
public void Print(FamilyMember person, IEnumerable <Occurrence> occurrences, OccurrenceAttendance attendance, ComputerSystem system) { // Don't new up Kiosk w/o empty constructor, might be too costly Kiosk kiosk = new Kiosk() { System = system }; var jobs = kiosk.GetPrintJobs(attendance); ReportPrinter printer = new ReportPrinter(); // Work around a bug in the way the ReportPrinter.PrintReports(jobs) method works... // ...it uses impersonation which seems to cause some problems with printing on Win 2008 R2 SP1. foreach (ReportPrintJob job in jobs) { printer.PrintReport(job.PrinterName, job.ReportPath, job.Copies, job.Landscape, job.Parameters, job.PrinterName); } }
void ListenThread() { listener = new UdpClient(listenPort); IPEndPoint groupEP = new IPEndPoint(IPAddress.Any, listenPort); string dat; byte[] receive_byte_array; Debug.Log("Listener: Waiting for broadcasts...\n"); while (true) { receive_byte_array = listener.Receive(ref groupEP); dat = Encoding.ASCII.GetString(receive_byte_array, 0, receive_byte_array.Length); // Debug.Log ("Listener: Received a broadcast from " + // groupEP.ToString() + "\nMessage: " + received_data); // route message if (dat.StartsWith("REGISTER")) { // register a kiosk string name = dat.Substring(9); Kiosk k = new Kiosk(name, groupEP.Address, groupEP.Port); msgName = "AddNewKiosk"; msgPayload = k; msgFromThread = true; } } }
public KioskRater(Kiosk kiosk) { this._kiosk = kiosk; }
public KioskManager(Kiosk _aKiosk, Kiosk _bKiosk) { this._aKiosk = _aKiosk; this._bKiosk = _bKiosk; //this._roomsToBook = roomsToBook; }