Пример #1
0
 [Ignore]    // Ignored due to hardware usage. Comment out in order to run test.
 public async Task NetPrintTest()
 {
     WebAPI API = new WebAPI("http://www.timjunger.com/", "");
     Registrant testRegistrant = await API.GetRegistrantByCode("123456");
     string testString = Printer.FormatRegistrant(testRegistrant);
     Printer.Print(testRegistrant, null);
 }
Пример #2
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);
        }
Пример #3
0
        public async void Connect(String kioskRegistration)
        {
            registerKiosk.SetMessage("Attempting to register kiosk...");

            try
            {
                webAPI = await WebAPI.CreateWebAPI(api_url, kioskRegistration);

                if(webAPI == null)
                {
                    registerKiosk.SetMessage(String.Format("{1}{0}{2}{0}{3}",
                        Environment.NewLine,
                        "Kiosk registration not found.",
                        "Please check your registration code and try again."));
                }
                else
                {
                    registerKiosk.SetMessage(String.Format("{1}{0}{2}",
                        Environment.NewLine,
                        "Kiosk registration successful!",
                        "Event \"" + EventName + "\" loaded."));

                    startMenu.Connect();
                    kiosk.Connect();
                    registerKiosk.Connect();
                    noCode.Connect();

                    SetView(WindowView.START_MENU);
                }
            }
            catch(System.Net.Http.HttpRequestException http_ex)
            {
                registerKiosk.SetMessage(String.Format("{1}{0}{2}",
                    Environment.NewLine,
                    "Online connection failed.",
                    "Please check your internet connection and try again."));

                LogError("Online connection failed.", http_ex.Message);
            }
            catch(Exception e)
            {
                registerKiosk.SetMessage(String.Format("{1}{0}{2}{0}{3}{0}{4}",
                    Environment.NewLine, 
                    "An error has occurred.",
                    "Please check your registration code and try again.",
                    "If errors continue, contact the system administrator",
                    "and check ERROR_LOG.txt in the kiosk program folder."));

                LogError(e.Message);
            }
        }
Пример #4
0
        public void Disconnect()
        {
            webAPI = null;
            ClearRegistrant();

            startMenu.Disconnect();
            kiosk.Disconnect();
            registerKiosk.Disconnect();
            noCode.Disconnect();
        }
Пример #5
0
        // Asynchronously create a WebAPI instance.
        public static async Task <WebAPI> CreateWebAPI(string target, string kioskRegistration)
        {
            WebAPI NewAPI = await Task <WebAPI> .Run(() => { return(new WebAPI(target, kioskRegistration)); });

            return(NewAPI);
        }