public Controller(Window_StartMenu admin_in) { startMenu = admin_in; kiosk = new Window_Kiosk(this); registerKiosk = new Window_RegisterKiosk(this); noCode = new Window_NoCode(this); api_url = "http://www.timjunger.com/"; webAPI = null; activeRegistrant = null; currentView = WindowView.START_MENU; //Hide and disable all windows at program start startMenu.Visibility = System.Windows.Visibility.Hidden; startMenu.IsEnabled = false; kiosk.Visibility = System.Windows.Visibility.Hidden; kiosk.IsEnabled = false; registerKiosk.Visibility = System.Windows.Visibility.Hidden; registerKiosk.IsEnabled = false; noCode.Visibility = System.Windows.Visibility.Hidden; noCode.IsEnabled = false; //Display initial window (admin) SetView(WindowView.START_MENU); }
public static Boolean Print(Registrant registrant, Controller controller) { // Format the two strings for the label var label = (DYMO.Label.Framework.ILabel)null; string labelName = registrant.FirstName + ((registrant.FirstName.Length + registrant.LastName.Length >= 16) ? "\n" : " ") + registrant.LastName; string labelDetails = FormatRegistrant(registrant); // Liable to throw System.IO.FileNotFoundException, and DYMO.DLS.Runtime.DlsRuntimeException label = DYMO.Label.Framework.Label.Open("ERK.label"); label.SetObjectText("Name", labelName); label.SetObjectText("Details", labelDetails); ManagementObjectSearcher searcher = new ManagementObjectSearcher("SELECT * FROM Win32_Printer"); string printerName = ""; foreach (ManagementObject printer in searcher.Get()) { printerName = printer["Name"].ToString(); if (printerName.Equals(@"DYMO LabelWriter 450 DUO Label")) { if (printer["WorkOffline"].ToString().ToLower().Equals("true")) { MessageBox.Show("'DYMO LabelWriter 450 DUO Label' - Printer not found."); if(controller != null) { controller.LogError("'DYMO LabelWriter 450 DUO Label' - Printer not found."); } return false; } else { try { label.Print("DYMO LabelWriter 450 DUO Label"); return true; } catch (DYMO.DLS.Runtime.DlsRuntimeException e) { MessageBox.Show("'DYMO LabelWriter 450 DUO Label' - Failed to print"); if(controller != null) { controller.LogError("'DYMO LabelWriter 450 DUO Label' - Failed to print", e.Message); } return false; } } } } return false; }
// Used as a shortcut to create Registrant objects. public static Registrant CreateRegistrant(string _FirstName, string _LastName, string _RegistrantType, string _College, string _Major, string _ClassStanding) { Registrant testRegistrant = new Registrant(); testRegistrant.FirstName = _FirstName; testRegistrant.LastName = _LastName; testRegistrant.RegistrantType = _RegistrantType; testRegistrant.Major = _Major; testRegistrant.College = _College; testRegistrant.ClassStanding = _ClassStanding; return testRegistrant; }
// Format the 'details' of the nametag, University/Major/Year public static string FormatRegistrant(Registrant registrant) { string regString = ""; if (registrant.RegistrantType.Equals("Student")) { if (!String.IsNullOrWhiteSpace(registrant.ClassStanding)) regString += registrant.ClassStanding.ToString(); if (!String.IsNullOrWhiteSpace(registrant.Major)) regString += (String.IsNullOrWhiteSpace(regString) ? "" : "\n") + registrant.Major; if (!String.IsNullOrWhiteSpace(registrant.College)) regString += (String.IsNullOrWhiteSpace(regString) ? "" : "\n") + registrant.College; } return regString; }
// Update existing student registrant entry public async Task<Boolean> UpdateRegistrant(Registrant registrant) { using (HttpClient client = new HttpClient()) { client.BaseAddress = TargetURI; client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // Add the kiosk registration and event number to JSON before POSTing. JObject RegJSON = JObject.FromObject(registrant); RegJSON.Add(new JProperty("kioskReg", KioskRegistration)); RegJSON["eventNum"] = Event.EventNumber; HttpResponseMessage response = await client.PostAsJsonAsync("api/register.php/updateRegistrant", RegJSON); return response.IsSuccessStatusCode; } }
// Update existing student registrant entry public async Task <Boolean> UpdateRegistrant(Registrant registrant) { using (HttpClient client = new HttpClient()) { client.BaseAddress = TargetURI; client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json")); // Add the kiosk registration and event number to JSON before POSTing. JObject RegJSON = JObject.FromObject(registrant); RegJSON.Add(new JProperty("kioskReg", KioskRegistration)); RegJSON["eventNum"] = Event.EventNumber; HttpResponseMessage response = await client.PostAsJsonAsync("api/register.php/updateRegistrant", RegJSON); return(response.IsSuccessStatusCode); } }
// Format the 'details' of the nametag, University/Major/Year public static string FormatRegistrant(Registrant registrant) { string regString = ""; if (registrant.RegistrantType.Equals("Student")) { if (!String.IsNullOrWhiteSpace(registrant.ClassStanding)) { regString += registrant.ClassStanding.ToString(); } if (!String.IsNullOrWhiteSpace(registrant.Major)) { regString += (String.IsNullOrWhiteSpace(regString) ? "" : "\n") + registrant.Major; } if (!String.IsNullOrWhiteSpace(registrant.College)) { regString += (String.IsNullOrWhiteSpace(regString) ? "" : "\n") + registrant.College; } } return(regString); }
public async Task GetRegistrantByEmailNullTest() { Registrant testRegistrant = new Registrant(); testRegistrant = await webAPI.GetRegistrantByEmail("NotAnEmail"); Assert.IsNull(testRegistrant); }
public async Task GetRegistrantByCodeNullTest() { Registrant testRegistrant = new Registrant(); testRegistrant = await webAPI.GetRegistrantByCode("000000"); Assert.IsNull(testRegistrant); }
public async Task GetRegistrantByEmailTest() { Registrant testRegistrant = new Registrant(); testRegistrant = await webAPI.GetRegistrantByEmail(TEST_EMAIL); Assert.IsNotNull(testRegistrant); }
public async Task GetRegistrantByCodeTest() { Registrant testRegistrant = new Registrant(); testRegistrant = await webAPI.GetRegistrantByCode(TEST_CODE); Assert.IsNotNull(testRegistrant); }
public void ClearRegistrant() { if (activeRegistrant != null) activeRegistrant = null; }