private void ok_Button_Click(object sender, EventArgs e) { if (_sessionSummary != null) { // Build string of selected tags. string tagList = BuildTagList(); // Update DataLog.SessionSummary. _sessionSummary.SessionName = sessionName_ComboBox.Text; _sessionSummary.Type = sessionType_ComboBox.Text; _sessionSummary.Cycle = sessionCycle_ComboBox.Text; _sessionSummary.Reference = reference_TextBox.Text; _sessionSummary.Tags = tagList; _sessionSummary.SessionName = sessionName_ComboBox.Text; _sessionSummary.Notes = notes_TextBox.Text; _sessionSummary.Tags = tagList; //Commit changes to the databases _dataLogContext.SaveChanges(); _enterpriseTestContext.SaveChanges(); this.DialogResult = DialogResult.OK; } else { this.DialogResult = DialogResult.Cancel; } }
private void deleteSessionInfoToolStripButton_Click(object sender, EventArgs e) { if (MessageBox.Show("Delete saved information for the selected session?", "Delete Session Info", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) { Cursor.Current = Cursors.WaitCursor; // Mark the selected session for deletion by the cleanup process. using (DataLogContext context = DbConnect.DataLogContext()) { SessionSummary session = context.DbSessions.FirstOrDefault(s => s.SessionId == SelectedSessionId); if (session != null) { session.ExpirationDateTime = DateTime.UtcNow; } context.SaveChanges(); } Cursor.Current = Cursors.Default; RefreshGrid(); } }
private void extendToolStripButton_Click(object sender, EventArgs e) { string result = InputDialog.Show("Select expiration extension for this Session.", "Extend Expiration", EnumUtil.GetDescription(GetDefaultLogRetention()), SessionLogRetentionHelper.ExpirationList); if (!string.IsNullOrEmpty(result)) { SessionLogRetention extension = EnumUtil.GetByDescription <SessionLogRetention>(result); using (DataLogContext context = DbConnect.DataLogContext()) { SessionSummary session = context.DbSessions.FirstOrDefault(s => s.SessionId == SelectedSessionId); if (session != null) { session.ExpirationDateTime = extension.GetExpirationDate(session.ExpirationDateTime.Value); } context.SaveChanges(); } RefreshGrid(); } }
private void CloseSessionHandler(string sessionId, ShutdownOptions options) { SetTraceSessionContext(sessionId); SessionProxyController controller = null; if (_proxyControllers.TryGetValue(sessionId, out controller)) //If a session exists, proceed with normal shutdown. Otherwise reset manually. { _proxyControllers.Remove(controller); TraceFactory.Logger.Debug("Found & removed controller: Count: {0} : {1}".FormatWith(_proxyControllers.Count, controller.Endpoint.AbsoluteUri)); if (!controller.SessionClosing) //Make sure the session isn't already closing { lock (controller) { controller.SessionClosing = true; try { ThreadPool.QueueUserWorkItem(t => ShutdownScenario(controller, sessionId, options)); } catch (Exception ex) { TraceFactory.Logger.Error(ex); } } } } else { TraceFactory.Logger.Debug(string.Format("Closing session {0}", sessionId)); // Manually reset DomainAccountReservation for all inactive SessionIds using (AssetInventoryContext context = DbConnect.AssetInventoryContext()) { List <string> activeSessionIds = context.FrameworkClients.Select(n => n.SessionId).Distinct().Where(n => n != null).ToList(); foreach (var reservation in context.DomainAccountReservations) { if (!activeSessionIds.Contains(reservation.SessionId)) { context.DomainAccountReservations.Remove(reservation); } } context.SaveChanges(); } try { // Parallel process the two actions required to clean up this session, first define // the collection of actions, then spawn them each off in the background and then // wait for them to return. var actions = new Collection <Action>() { () => CleanupAssetHosts(sessionId), () => CleanupResourceHosts(sessionId) }; Parallel.ForEach <Action>(actions, a => a()); using (DataLogContext context = DbConnect.DataLogContext()) { SessionSummary summary = context.DbSessions.First(n => n.SessionId == sessionId); summary.Status = SessionStatus.Aborted.ToString(); summary.EndDateTime = DateTime.UtcNow; context.SaveChanges(); } UpdateSessionShutdownState(MachineShutdownState.ManualReset, sessionId, ignoreMissing: true); TraceFactory.Logger.Info("Done closing {0}".FormatWith(sessionId)); } catch (Exception ex) { TraceFactory.Logger.Error(ex); } // Tell all clients to clean up any session info EventPublisher.ReleaseSession(sessionId); //Checks for any Virtual worker process which may have not been terminated correctly from the previous runs if (GlobalSettings.IsDistributedSystem == false) { using (DataLogContext context = DbConnect.DataLogContext()) { SessionSummary summary = context.DbSessions.First(n => n.SessionId == sessionId); if (summary.Dispatcher == Environment.MachineName) { KillOrphanedWorkerProcesses(sessionId); } } } } }