///<summary>Delete the Kiosk or MobileDevice.</summary> public void Delete() { if (IsKiosk) { TerminalActives.DeleteForCmptrSessionAndId(_computerKiosk.ComputerName, _computerKiosk.SessionId, processId: _computerKiosk.ProcessId); } else { MobileAppDevices.Delete(_mobileDevice.MobileAppDeviceNum); } }
private void butDelete_Click(object sender, EventArgs e) { if (gridMain.GetSelectedIndex() == -1 || gridMain.GetSelectedIndex() >= _terminalList.Count) { MsgBox.Show(this, "Please select a terminal first."); return; } if (!MsgBox.Show(this, MsgBoxButtons.OKCancel, "A terminal row should not be deleted unless it is showing erroneously and there really is no " + "terminal running on the computer shown. Continue anyway?")) { return; } TerminalActive selectedTerm = _terminalList[gridMain.GetSelectedIndex()]; TerminalActives.DeleteForCmptrSessionAndId(selectedTerm.ComputerName, selectedTerm.SessionId, processId: selectedTerm.ProcessId); Signalods.SetInvalid(InvalidType.Kiosk, KeyType.ProcessId, Process.GetCurrentProcess().Id); FillGrid(); FillPat(); }
private void FormTerminal_FormClosing(object sender, FormClosingEventArgs e) { if (IsSimpleMode) { return; } Process processCur = Process.GetCurrentProcess(); try { Sheets.ClearFromTerminal(PatNum); TerminalActives.DeleteForCmptrSessionAndId(Environment.MachineName, processCur.SessionId, processId: processCur.Id); //Just in case, close remaining forms that are open _formSheetFillEdit.ForceClose(); } catch (Exception) { //SocketException if db connection gets lost. //if either fail, do nothing, the terminalactives will be cleaned up the next time the kiosk mode is enabled for this computer } finally { Signalods.SetInvalid(InvalidType.Kiosk, KeyType.ProcessId, processCur.Id); } }
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; }