Пример #1
0
        /*
         * TAG FOUND EVENT:
         * This event occurs when the user passes a NFC card near the reader.
         * It checks if the UID is valid and unlock the door if so.
         */
        private void TagFound(string uid)
        {
            if (!scanWindow.IsShowing())
            {
                // Check authorization
                var authorized = DataHelper.CheckCardId(uid);

                // Show access window
                accessWindow.Show(authorized);

                // Log the event
                string logText;
                Log    log;

                if (authorized)
                {
                    // Access granted
                    UnlockDoor();
                    logText = "Card \"" + uid + "\" inserted. Authorized access.";
                    log     = new Log(Log.TypeAccess, null, uid, logText);
                }
                else
                {
                    // Access denied
                    logText = "Card \"" + uid + "\" inserted. Access denied!";
                    log     = new Log(Log.TypeInfo, logText);
                }

                DebugOnly.Print(logText);

                // Add log to loglist
                DataHelper.AddLog(log);
            }
            else
            {
                // Log new cardID
                var newCardIdLog = new Log(
                    Log.TypeAccess,
                    pendingPin,
                    uid,
                    "Card \"" + uid + "\" has been added for pin \"" + pendingPin + "\".");

                // Update CardID in userList
                DataHelper.AddCardId(pendingPin, uid);

                // Send urgent log
                DataHelper.AddLog(newCardIdLog, true);

                var cardAddedAlert = new AlertWindow(WindowAlertPeriod);
                cardAddedAlert.SetText("NFC card added!");
                cardAddedAlert.SetPositiveButton("Ok", delegate { cardAddedAlert.Dismiss(); });
                cardAddedAlert.Show();

                DebugOnly.Print("Card added to user with pin \"" + pendingPin + "\"");
            }
        }
        /// <summary>
        /// Uses the incoming alert details to dispaly message
        /// </summary>
        private void DisplayAlertMessage(AlertMessage alertMessage)
        {
            _currentDispatcher.Invoke(DispatcherPriority.Background, (Action)(() =>
            {
                AlertWindow notificationWindow = new AlertWindow();
                notificationWindow.DataContext = new AlertWindowViewModel(alertMessage);

                notificationWindow.Show();
            }));
        }
Пример #3
0
    public void ClickSignUp()
    {
        bool emailformat = validateEmail(dataManager.data.email);

        if (dataManager.data.userName == "" || dataManager.data.email == "" || emailformat == false || dataManager.data.realName == "" ||
            dataManager.data.password == "" || dataManager.data.password != reEnterPW.text)
        {
            alert.Show("Invalid input");
        }
        else
        {
            StartCoroutine(dataManager.signUp());
            userName.text  = "";
            email.text     = "";
            realName.text  = "";
            password.text  = "";
            reEnterPW.text = "";
        }
    }
Пример #4
0
        private void SendForgotPasswordCommand(string username)
        {
            ServerManager.Instance.Reset();
            ServerManager.Instance.SendUserCommand("FORGOTPASSWORD", username);

            var alert = new AlertWindow();

            alert.Closed += (o, e) =>
            {
                ScreenManager.SetScreen(new LoginScreen());
            };
            alert.Show("Password Sent", "Your password has been sent to the email address you used when the account was created.");
        }
Пример #5
0
        private void DoorOpen(Button sender, Button.ButtonState state)
        {
            doorOpen = true;

            pinWindow.SetText("Door open");
            DebugOnly.Print("Door open!");

            if (!authorizedAccess)
            {
                // Security breach
                DebugOnly.Print("Security breach! Unauthorized access!");
                DataHelper.AddLog(new Log(Log.TypeError, "Security breach! Unauthorized access!"));

                var breachWindow = new AlertWindow(20000);
                breachWindow.SetText("BREACH ALERT!!! \n UNAUTHORIZED ACCESS!!! \n\n\n\n Please contact the administrator immediately.");
                breachWindow.Show();
            }
        }
Пример #6
0
        protected override void OnStartup(StartupEventArgs e)
        {
            var systemVersion = Environment.OSVersion.Version;

            if (systemVersion.Major < 6)
            {
                MessageBox.Show("Incompatible system version, must be at least Windows Vista", "Warning", MessageBoxButton.OK, MessageBoxImage.Warning);
            }

            DirectoryGuard.DirectoriesSanityCheck();
            if (!HasWriteAccessToFolder(AppDomain.CurrentDomain.BaseDirectory))
            {
                AlertWindow.Show(LocaleSelector.GetLocaleString("AlertWindow_NoWriteAccess"));
                CanWriteToCurrentFolder = false;
            }
            else
            {
                CanWriteToCurrentFolder = true;
            }
            AppDomain.CurrentDomain.UnhandledException += CurrentDomain_UnhandledException;
            WindowFlashHelper = new WindowFlashHelper(this);

            Connection = new Connection
            {
                SendUserAgent = SettingsSelector.GetConfigurationValue <bool>("Behavior_SendUserAgent")
            };
            StatsManager   = new StatsManager(Connection);
            ArchiveManager = new ArchiveManager();

            LocaleSelector.SetLocaleIdentifier(
                SettingsSelector.GetConfigurationValue <string>("Language")
                );

            ColorSchemeLoader = new ColorSchemeLoader();

            ColorSchemeLoader.LoadColorSchemes();
            ColorSchemeLoader.ApplyColors();

            base.OnStartup(e);
        }
Пример #7
0
        void LoginScreen_Loaded(object sender, RoutedEventArgs e)
        {
            // Check socket port, if fails to open a connection then use the http handler.
            ServerManager.Connected += (o, args) =>
            {
                this.Dispatcher.BeginInvoke(() =>
                {
                    ServerManager.Instance.Reset();
                    ServerManager.Instance.Response += new ServerResponseEventHandler(_server_Response);

                    txtUsername.Focus();

                    // Check local storage for the remember me token.
                    var token = StorageManager.GetPersistLoginToken();
                    if (!String.IsNullOrEmpty(token))
                    {
                        _waitDialog.Show("Attempting login...");
                        ServerManager.Instance.SendUserCommand("LOGIN", token);
                    }

                    txtUsername.Text = _username;
                });
            };
            ServerManager.ConnectFailed += (o, args) =>
            {
                this.Dispatcher.BeginInvoke(() =>
                {
                    var alert     = new AlertWindow();
                    alert.Closed += (s, a) =>
                    {
                        System.Windows.Browser.HtmlPage.Window.Navigate(new Uri("http://www.perenthia.com"));
                    };
                    alert.Show("Connection to Server Failed", String.Format(SR.ConnectionFailed, Settings.GameServerPort));
                });
            };
            ServerManager.Configure();
        }
Пример #8
0
        /*
         * PIN FOUND EVENT:
         * This event occurs when the user inserts a pin code. It checks if the pin is valid and unlock the door if so.
         * If the pin has no related CardId it prompts the user to add it.
         */
        private void PinFound(string pin)
        {
            string masterPin = SettingsManager.Get(SettingsManager.MasterPin);

            // Check master pin
            if (String.Compare(masterPin, pin) == 0)
            {
                maintenanceWindow.Show();
                return;
            }

            // Check authorization
            var authorized = DataHelper.CheckPin(pin);
            var nullCardId = DataHelper.PinHasNullCardId(pin);

            // Log the event
            string logText;
            Log    log;

            if (authorized)
            {
                // Access granted
                UnlockDoor();
                logText = "Pin \"" + pin + "\" inserted. Authorized access.";
                log     = new Log(Log.TypeAccess, pin, logText);
            }
            else
            {
                // Access denied
                logText = "Pin \"" + pin + "\" inserted. Access denied!";
                log     = new Log(Log.TypeInfo, logText);
            }

            DebugOnly.Print(logText);

            // Add log to loglist
            DataHelper.AddLog(log);

            if (nullCardId && authorized)
            {
                // Null CardID detected, prompt the user to set one
                var nullCardIdAlert = new AlertWindow(WindowAlertPeriod);
                nullCardIdAlert.SetText(
                    "It happears that this user has no related NFC card.\nDo you want to scan it now?");
                nullCardIdAlert.SetPositiveButton("Yes", delegate
                {
                    // User wants to add a new NFC card
                    pendingPin = pin;
                    scanWindow.Show();
                });
                nullCardIdAlert.SetNegativeButton("No", delegate
                {
                    // User doesn't want to add a new NFC card
                    nullCardIdAlert.Dismiss();
                });
                nullCardIdAlert.Show();
            }
            else
            {
                // Everything is fine
                accessWindow.Show(authorized);
            }
        }
Пример #9
0
 public void Alert(object content)
 {
     AlertWindow.Show(content.ToString());
     //RadWindow.Alert(content);
 }