private void butAuthGoogle_Click(object sender, EventArgs e)
 {
     try {
         string url = Google.GetGoogleAuthorizationUrl(textUsername.Text);
         Process.Start(url);
         InputBox inputbox = new InputBox("Please enter the authorization code from your browser");
         inputbox.setTitle("Google Account Authorization");
         inputbox.ShowDialog();
         if (inputbox.DialogResult != DialogResult.OK)
         {
             return;
         }
         if (string.IsNullOrWhiteSpace(inputbox.textResult.Text))
         {
             throw new ODException(Lan.g(this, "There was no authorization code entered."));
         }
         string      authCode = inputbox.textResult.Text;
         GoogleToken tokens   = Google.MakeAccessTokenRequest(authCode);
         if (tokens.ErrorMessage != "")
         {
             throw new Exception(tokens.ErrorMessage);
         }
         textAccessToken.Text         = tokens.AccessToken;
         textRefreshToken.Text        = tokens.RefreshToken;
         groupAuthentication.Location = new Point(_groupAuthLocationXAuthorized, groupAuthentication.Location.Y);
         groupGoogleAuth.Visible      = true;
     }
     catch (ODException ae) {
         MsgBox.Show(ae.Message);
     }
     catch (Exception ex) {
         MsgBox.Show("Error: " + ex.Message);
     }
 }
Esempio n. 2
0
        private void checkDisableBackupReminder_Click(object sender, EventArgs e)
        {
            InputBox inputbox = new InputBox("Please enter password");

            inputbox.setTitle("Change Backup Reminder Settings");
            inputbox.ShowDialog();
            if (inputbox.DialogResult != DialogResult.OK)
            {
                checkDisableBackupReminder.Checked = !checkDisableBackupReminder.Checked;
                return;
            }
            if (inputbox.textResult.Text != "abracadabra")
            {
                checkDisableBackupReminder.Checked = !checkDisableBackupReminder.Checked;
                MsgBox.Show(this, "Wrong password");
                return;
            }
        }
Esempio n. 3
0
 private void panelClose_Click(object sender, EventArgs e)
 {
     //It's fairly safe to not have a password, because the program will exit in remote mode, and in simple mode, the patient is usually supervised.
     if (PrefC.GetString(PrefName.TerminalClosePassword) != "")
     {
         InputBox iBox = new InputBox("Enter password to exit kiosk.");
         iBox.textResult.PasswordChar = '*';
         iBox.setTitle(Lan.g(this, "Kiosk Password"));
         iBox.ShowDialog();
         while (iBox.DialogResult == DialogResult.OK && iBox.textResult.Text != PrefC.GetString(PrefName.TerminalClosePassword))
         {
             MsgBox.Show(this, "Invalid Password");
             iBox.textResult.Text = "";
             iBox.ShowDialog();
         }
         if (iBox.DialogResult != DialogResult.OK)
         {
             return;
         }
     }
     //if we get here, either no password required or they entered the correct one
     Close();            //signal sent in form closing
 }
Esempio n. 4
0
        private void FormTerminal_Load(object sender, EventArgs e)
        {
            Size     = System.Windows.Forms.Screen.PrimaryScreen.Bounds.Size;
            Location = new Point(0, 0);
            labelConnection.Visible = false;
            _listSheets             = new List <Sheet>();
            if (IsSimpleMode)
            {
                //PatNum set externally (in FormPatientForms)
                return;
            }
            //NOT SimpleMode from here down
            Process processCur = Process.GetCurrentProcess();

            //Delete all terminalactives for this computer, except new one, based on CompName and SessionID
            TerminalActives.DeleteForCmptrSessionAndId(Environment.MachineName, processCur.SessionId, excludeId: processCur.Id);
            string clientName = null;
            string userName   = null;

            try {
                clientName = Environment.GetEnvironmentVariable("ClientName");
                userName   = Environment.GetEnvironmentVariable("UserName");
            }
            catch (Exception) {
                //user may not have permission to access environment variables or another error could happen
            }
            if (string.IsNullOrWhiteSpace(clientName))
            {
                //ClientName only set for remote sessions, try to find suitable replacement.
                clientName = userName;
                if (processCur.SessionId < 2 || string.IsNullOrWhiteSpace(userName))
                {
                    //if sessionId is 0 or 1, this is not a remote session, use MachineName
                    clientName = Environment.MachineName;
                }
            }
            if (string.IsNullOrWhiteSpace(clientName) || TerminalActives.IsCompClientNameInUse(Environment.MachineName, clientName))
            {
                InputBox iBox = new InputBox("Please enter a unique name to identify this kiosk.");
                iBox.setTitle(Lan.g(this, "Kiosk Session Name"));
                iBox.ShowDialog();
                while (iBox.DialogResult == DialogResult.OK && TerminalActives.IsCompClientNameInUse(Environment.MachineName, iBox.textResult.Text))
                {
                    MsgBox.Show(this, "The name entered is invalid or already in use.");
                    iBox.ShowDialog();
                }
                if (iBox.DialogResult != DialogResult.OK)
                {
                    DialogResult = DialogResult.Cancel;
                    return;                    //not allowed to enter kiosk mode unless a unique human-readable name is entered for this computer session
                }
                clientName = iBox.textResult.Text;
            }
            //if we get here, we have a SessionId (which could be 0 if not in a remote session) and a unique client name for this kiosk
            TerminalActive terminal = new TerminalActive();

            terminal.ComputerName = Environment.MachineName;
            terminal.SessionId    = processCur.SessionId;
            terminal.SessionName  = clientName;
            terminal.ProcessId    = processCur.Id;
            TerminalActives.Insert(terminal);                                          //tell the database that a terminal is newly active on this computer
            Signalods.SetInvalid(InvalidType.Kiosk, KeyType.ProcessId, processCur.Id); //signal FormTerminalManager to re-fill grids
            timer1.Enabled = true;
        }