private void buttonStart_Click(object sender, RoutedEventArgs e) { if (_scenarioList.Count == 0) { return; } if (STFDispatcherManager.Dispatcher == null) { ConnectToDispatcher(); if (STFDispatcherManager.Dispatcher == null) { return; } } if (_isScenarioExecuting) { UpdateStatus("Stopping"); SessionClient.Instance.Shutdown(_ticket.SessionId, _shutdownOptions); } else { _isAborted = false; buttonStart.IsEnabled = false; _sessionRetention = EnumUtil.GetByDescription <SessionLogRetention>(comboBoxRetention.Text); ExecuteScenario(_scenarioList.ElementAt(_currentScenarioIndex)); _isScenarioExecuting = true; buttonStart.Content = "Stop"; buttonStart.IsEnabled = true; buttonAbort.IsEnabled = true; } }
/// <summary> /// Gets the expiration date. /// </summary> /// <param name="retention">The retention.</param> /// <param name="start">The start.</param> /// <returns></returns> public static DateTime GetExpirationDate(this SessionLogRetention retention, DateTime start) { switch (retention) { case SessionLogRetention.None: return(FormatExpirationDate(start)); case SessionLogRetention.Day: return(FormatExpirationDate(start.AddDays(1))); case SessionLogRetention.Week: return(FormatExpirationDate(start.AddDays(7))); case SessionLogRetention.Month: return(FormatExpirationDate(start.AddDays(30))); case SessionLogRetention.ThreeMonths: return(FormatExpirationDate(start.AddDays(90))); case SessionLogRetention.SixMonths: return(FormatExpirationDate(start.AddDays(120))); case SessionLogRetention.NineMonths: return(FormatExpirationDate(start.AddDays(270))); case SessionLogRetention.OneYear: return(FormatExpirationDate(start.AddDays(365))); default: throw new ArgumentException("Unknown retention period " + retention.ToString()); } }
/// <summary> /// Performs final validation before allowing the user to navigate away from the page. /// </summary> /// <returns> /// True if this page was successfully validated. /// </returns> public virtual bool Complete() { Guid scenarioId = Ticket.ScenarioIds.FirstOrDefault(); if (!ValidateInput(scenarioId)) { return(false); } // STE-only if (GlobalSettings.IsDistributedSystem) { PopulateSelectedVMs(); } using (EnterpriseTestContext context = new EnterpriseTestContext()) { // Perform a data integrity check on the scenario if (PerformDataIntegrityCheck(context, scenarioId) == false) { Cancel?.Invoke(this, EventArgs.Empty); return(false); } PopulateNotificationSettings(); SetAssociatedProducts(); // Populate ticket data from the UI Ticket.CollectEventLogs = eventLog_CheckBox.Checked; Ticket.SessionName = string.IsNullOrEmpty(sessionName_ComboBox.Text) ? selectedScenario_TextBox.Text : sessionName_ComboBox.Text; Ticket.SessionType = sessionType_ComboBox.Text; Ticket.SessionCycle = sessionCycle_ComboBox.Text; Ticket.Reference = WizardPageManager.GetReferenceData(reference_TextBox); Ticket.SessionNotes = notes_TextBox.Text; Ticket.DurationHours = (int)runtime_NumericUpDown.Value; SessionLogRetention selected = EnumUtil.GetByDescription <SessionLogRetention>((string)retention_ComboBox.SelectedItem); Ticket.ExpirationDate = selected.GetExpirationDate(DateTime.Now); Ticket.LogLocation = logLocation_TextBox.Text; Ticket.RemoveUnresponsiveDevices = deviceOffline_CheckBox.Checked; // Save session name and selected VMs SaveSessionName(context, scenarioId); context.SaveChanges(); } // Save selected scenario to settings so it can be selected next time Properties.Settings.Default.LastExecutedScenario = scenarioId; Properties.Settings.Default.Save(); // Initiate the session with the dispatcher TraceFactory.Logger.Debug("Calling Initiate() on {0}".FormatWith(Ticket.SessionId)); SessionClient.Instance.InitiateSession(Ticket); return(true); }
/// <summary> /// Performs final validation before allowing the user to navigate away from the page. /// </summary> /// <returns> /// True if this page was successfully validated. /// </returns> public bool Complete() { if (!ValidateInput()) { return(false); } // We're gonna need a data context several times in the following lines using (EnterpriseTestContext context = new EnterpriseTestContext()) { List <EnterpriseScenario> scenarios = EnterpriseScenario.Select(context, Ticket.ScenarioIds).ToList(); // Perform a data integrity check on the scenarios if (PerformDataIntegrityCheck(scenarios) == false) { return(false); } //PopulateNotificationSettings() TODO: What about the email list? The ticket has an email list. Can we repurpose it for batch operations? // Populate ticket data from the UI Ticket.ScenarioIds = GetSelectedScenarioIds(); Ticket.CollectEventLogs = false; Ticket.SessionName = sessionName_ComboBox.Text; Ticket.SessionType = sessionType_ComboBox.Text; Ticket.SessionCycle = sessionCycle_ComboBox.Text; Ticket.Reference = WizardPageManager.GetReferenceData(reference_TextBox); Ticket.SessionNotes = notes_TextBox.Text; Ticket.DurationHours = (int)runtime_NumericUpDown.Value; SessionLogRetention logRetention = EnumUtil.GetByDescription <SessionLogRetention>((string)retention_ComboBox.SelectedItem); Ticket.ExpirationDate = logRetention.GetExpirationDate(DateTime.Now); Ticket.LogLocation = GlobalSettings.WcfHosts[WcfService.DataLog]; SetAssociatedProducts(context, scenarios); // Doesn't make sense to save session name for batch operation. context.SaveChanges(); } // Initiate the session with the dispatcher TraceFactory.Logger.Debug($"Calling Initiate() on {Ticket.SessionId}"); SessionClient.Instance.InitiateSession(Ticket); return(true); }
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(); } }