예제 #1
0
        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);
        }
예제 #2
0
파일: Printer.cs 프로젝트: dstewartewu/ERK
        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;
        }
예제 #3
0
        // 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;
        }
예제 #4
0
파일: Printer.cs 프로젝트: dstewartewu/ERK
 // 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;
 }
예제 #5
0
파일: WebAPI.cs 프로젝트: dstewartewu/ERK
        // 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;
            }
        }
예제 #6
0
        // 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);
            }
        }
예제 #7
0
        // 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);
        }
예제 #8
0
 public async Task GetRegistrantByEmailNullTest()
 {
     Registrant testRegistrant = new Registrant();
     testRegistrant = await webAPI.GetRegistrantByEmail("NotAnEmail");
     Assert.IsNull(testRegistrant);
 }
예제 #9
0
 public async Task GetRegistrantByCodeNullTest()
 {
     Registrant testRegistrant = new Registrant();
     testRegistrant = await webAPI.GetRegistrantByCode("000000");
     Assert.IsNull(testRegistrant);
 }
예제 #10
0
 public async Task GetRegistrantByEmailTest()
 {
     Registrant testRegistrant = new Registrant();
     testRegistrant = await webAPI.GetRegistrantByEmail(TEST_EMAIL);
     Assert.IsNotNull(testRegistrant);
 }
예제 #11
0
 public async Task GetRegistrantByCodeTest()
 {
     Registrant testRegistrant = new Registrant();
     testRegistrant = await webAPI.GetRegistrantByCode(TEST_CODE);
     Assert.IsNotNull(testRegistrant);
 }
예제 #12
0
 public void ClearRegistrant()
 {
     if (activeRegistrant != null)
         activeRegistrant = null;
 }