Beispiel #1
0
    public ActionResult Index()
    {
        if (Session["SessionSummary"] == null)
          Session["SessionSummary"] = new SessionSummary();

        return View(Session["SessionSummary"]);
    }
Beispiel #2
0
        private void ComputeRatingAsLast(SessionSummary sessionSummary)
        {
            Driver player = sessionSummary.Drivers.FirstOrDefault(x => x.IsPlayer);

            if (player == null)
            {
                return;
            }
            var newRatings = _ratingUpdater.UpdateRatingsAsLoss(SharedContext.RaceContext.FieldRating, SharedContext.DifficultyRating, SharedContext.SimulatorRating, SharedContext.RaceContext.UsedDifficulty, player, sessionSummary.TrackInfo.TrackFullName);
        }
        private string GetReportName(SessionSummary sessionSummary)
        {
            StringBuilder reportName = new StringBuilder(ReportNamePrefix);

            reportName.Append(DateTime.Now.ToString("s") + "_").Replace(":", "-");
            reportName.Append(sessionSummary.TrackInfo.TrackName + "_");
            reportName.Append(sessionSummary.SessionType);
            reportName.Append(".xlsx");
            return(reportName.ToString());
        }
        private List <Driver> FilterNotEligibleDriversAndOrder(SessionSummary sessionSummary)
        {
            if (!sessionSummary.IsMultiClass)
            {
                return(sessionSummary.Drivers.OrderBy(x => x.FinishingPosition).ToList());
            }

            Driver player = sessionSummary.Drivers.FirstOrDefault(x => x.IsPlayer);

            return(player == null ? null : sessionSummary.Drivers.Where(x => x.ClassId == player.ClassId).OrderBy(x => x.FinishingPosition).ToList());
        }
 private static void FillSessionInfo(SessionSummary summary, SessionTiming timing)
 {
     summary.SessionType        = timing.SessionType;
     summary.TrackInfo          = timing.LastSet.SessionInfo.TrackInfo;
     summary.Simulator          = timing.LastSet.Source;
     summary.SessionLength      = TimeSpan.FromSeconds(timing.TotalSessionLength);
     summary.SessionLengthType  = timing.LastSet.SessionInfo.SessionLengthType;
     summary.TotalNumberOfLaps  = timing.LastSet.SessionInfo.TotalNumberOfLaps;
     summary.SessionRunDuration = timing.SessionTime;
     summary.WasGreen           = timing.WasGreen;
     summary.IsMultiClass       = timing.IsMultiClass;
 }
 private string GetSessionLength(SessionSummary sessionSummary)
 {
     if (sessionSummary.SessionLengthType == SessionLengthType.Laps)
     {
         return(sessionSummary.TotalNumberOfLaps + " Laps");
     }
     if (sessionSummary.SessionLength.Hours > 0)
     {
         return(sessionSummary.SessionLength.Hours + "h " + (sessionSummary.SessionLength.Minutes + 1) + "min");
     }
     return(Math.Ceiling((decimal)sessionSummary.SessionLength.Minutes) + "mins");
 }
Beispiel #7
0
        private bool OnPackagerNamedMethodPredicate(SessionSummary session)
        {
            Assert.IsNotNull(session);

            var match = (session.Application == Log.SessionSummary.Application) && (session.Product == Log.SessionSummary.Product);

            if (match)
            {
                m_PredicateMatches++;
            }

            return(match);
        }
        private void AddLapsInfoHeader(ExcelWorksheet sheet, SessionSummary sessionSummary)
        {
            int maxLaps = sessionSummary.Drivers.Select(d => d.TotalLaps).Max();

            sheet.SelectedRange["A1"].Value = "Lap/Driver";
            for (int i = 1; i <= maxLaps; i++)
            {
                sheet.SelectedRange["A" + (i + 2)].Value = i;
            }
            ExcelRange range = sheet.SelectedRange["A1:A" + 2 + maxLaps];

            range.Style.Font.Bold = true;
            sheet.Column(1).AutoFit();
            sheet.View.FreezePanes(1, 2);
        }
Beispiel #9
0
        /// <summary>
        ///     appends the current session data in the previous ServerDataToSave object
        /// </summary>
        /// <params name="totalUsers"> Total number of users in the current session </params>
        /// <params name="totalChats"> Total chats in the current session </params>
        public void UpdateServerData(int totalUsers, int totalChats)
        {
            // retrieve the previous server data till previous session
            ServerDataToSave serverData = retrieveAllServerData();

            serverData.sessionCount++;
            // current session data
            SessionSummary currSessionSummary = new SessionSummary();

            currSessionSummary.userCount = totalUsers;
            currSessionSummary.chatCount = totalChats;
            currSessionSummary.score     = totalChats * totalUsers;
            serverData.allSessionsSummary.Add(currSessionSummary);
            saveServerData(serverData);
        }
Beispiel #10
0
 private void AddDrivers(int driverCount, SessionSummary sessionSummary)
 {
     for (int i = 0; i < driverCount; i++)
     {
         sessionSummary.Drivers.Add(new Driver()
         {
             CarName           = "A caaaar",
             DriverName        = "Driver " + i,
             TotalLaps         = 20,
             TopSpeed          = Velocity.FromKph(_random.Next(150, 250)),
             FinishingPosition = i + 1,
             Finished          = _random.Next(0, 10) > 0 ? true : false,
             IsPlayer          = i == 0
         });
     }
 }
        private void AddLapsInfo(ExcelWorksheet sheet, SessionSummary sessionSummary)
        {
            AddLapsInfoHeader(sheet, sessionSummary);
            int currentColumn = 2;

            foreach (Driver driver in sessionSummary.Drivers.Where(d => d.Finished).OrderBy(o => o.FinishingPosition))
            {
                AddDriverLaps(sheet, currentColumn, driver, sessionSummary);
                currentColumn = currentColumn + 4;
            }

            foreach (Driver driver in sessionSummary.Drivers.Where(d => !d.Finished).OrderBy(d => d.TotalLaps).Reverse())
            {
                AddDriverLaps(sheet, currentColumn, driver, sessionSummary);
                currentColumn = currentColumn + 4;
            }
        }
 public async Task NotifySessionCompletion(SessionSummary sessionSummary)
 {
     if (_inMp || !_displaySettingsViewModel.RatingSettingsViewModel.IsEnabled || !RatingApplicationViewModel.IsRateRaceCheckboxChecked)
     {
         Logger.Info("Session Completed Notified - but is either MP or rating is disabled");
         return;
     }
     try
     {
         Logger.Info("Session Completed Notified");
         await _raceObserverController.NotifySessionCompletion(sessionSummary);
     }
     catch (Exception ex)
     {
         Logger.Error(ex);
     }
 }
Beispiel #13
0
    public bool Equals(SessionSummary other)
    {
        if (ReferenceEquals(null, other)) return false;
        if (ReferenceEquals(this, other)) return true;

        //This Equals makes sure what's in the lists is
        // compared, not the reference
        if (other.AddedTodos.Count != other.AddedTodos.Count)
          return false;

        for (int i = 0; i < other.AddedTodos.Count; i++)
        {
          if (!other.AddedTodos[i].Equals(AddedTodos[i]))
        return false;
        }
          return true;
    }
Beispiel #14
0
        public SessionSummary SaveSession(SessionSummary session)
        {
            using (var cxt = DataStore.GetDataStore())
            {
                var data = cxt.GetOrCreateSession(session.SessionID);
                if (data.IsNew)
                {
                    // TODO If there is no active term, throw error...
                }
                data.Date   = session.AttendanceDate;
                data.TermID = session.TermID;
                cxt.SubmitChanges();
                //this.SavePlayerAttendances(data.SessionID, session.PlayerAttendances);

                return(this.GetSession(data.SessionID));
            }
        }
        private void AddRaceProgress(ExcelWorksheet sheet, SessionSummary sessionSummary)
        {
            int           maxLaps        = sessionSummary.Drivers.Select(x => x.Laps.Count).Max();
            List <Driver> orderedDrivers = sessionSummary.Drivers.OrderBy(x => x.Laps.LastOrDefault()?.LapEndSnapshot.PlayerData.Position).ToList();
            int           startRow       = 100;
            int           startColumn    = 1;

            sheet.Cells[startRow + 1, startColumn].Value = "Start";
            GenerateNumberColumn(sheet, new ExcelCellAddress(startRow + 2, startColumn), maxLaps);
            GenerateDriversRow(sheet, new ExcelCellAddress(startRow, startColumn + 1), orderedDrivers.Select(x => x.DriverName));

            ExcelCellAddress startAddress = new ExcelCellAddress(startRow + 1, startColumn + 1);

            orderedDrivers.ForEach(
                x =>
            {
                GenerateLapsPositionColumn(sheet, startAddress, x.Laps, maxLaps);
                startAddress = new ExcelCellAddress(startAddress.Row, startAddress.Column + 1);
            });
            ExcelLineChart chart = (ExcelLineChart)sheet.Drawings.AddChart("Race Progress", eChartType.LineMarkers);

            chart.SetPosition(0, 0, 0, 0);
            int currentColumn = 2;

            orderedDrivers.ForEach(
                x =>
            {
                ExcelLineChartSerie series = (ExcelLineChartSerie)chart.Series.Add(ExcelCellBase.GetAddress(startRow + 1, currentColumn, startRow + 1 + maxLaps, currentColumn), ExcelCellBase.GetAddress(startRow + 1, 1, startRow + 1 + maxLaps, 1));
                series.Header = x.DriverName;
                currentColumn++;
            });
            chart.ShowDataLabelsOverMaximum = false;
            chart.DataLabel.ShowValue       = true;
            chart.ShowHiddenData            = true;

            chart.Axis[1].MinValue          = 0;
            chart.Axis[1].TickLabelPosition = eTickLabelPosition.NextTo;
            chart.Axis[1].MajorUnit         = 1;
            chart.Axis[1].MinorUnit         = 1;
            chart.Axis[1].Orientation       = eAxisOrientation.MaxMin;
            chart.Axis[1].MaxValue          = orderedDrivers.Count;
            chart.SetSize(70 * maxLaps, 30 * orderedDrivers.Count);
            chart.Axis[0].MajorUnit = 1;
            chart.Axis[0].MinorUnit = 1;
            chart.Title.Text        = "Race Progress";
        }
Beispiel #16
0
        /// <summary>
        /// Create a new publisher
        /// </summary>
        /// <remarks>The publisher is a very central class; generally there should be only one per process.
        /// More specifically, there should be a one to one relationship between publisher, packet cache, and
        /// messengers to ensure integrity of the message output.</remarks>
        internal Publisher(string sessionName, AgentConfiguration configuration, SessionSummary sessionSummary, IPrincipalResolver principalResolver, IApplicationUserProvider userProvider)
        {
            if (string.IsNullOrEmpty(sessionName))
            {
                throw new ArgumentNullException(nameof(sessionName));
            }

            if (configuration == null)
            {
                throw new ArgumentNullException(nameof(configuration));
            }

            if (sessionSummary == null)
            {
                throw new ArgumentNullException(nameof(sessionSummary));
            }

            //store off all our input
            m_SessionName    = sessionName;
            m_SessionSummary = sessionSummary;
            m_Configuration  = configuration;

            var serverConfig = Log.Configuration.Server;

            if (serverConfig.AutoSendOnError && serverConfig.AutoSendSessions && serverConfig.Enabled)
            {
                m_AutoSendOnError = true;
            }

            //create our queue, cache, and messenger objects
            m_MessageQueue         = new Queue <PacketEnvelope>(50); //a more or less arbitrary initial queue size.
            m_MessageOverflowQueue = new Queue <PacketEnvelope>(50); //a more or less arbitrary initial queue size.
            m_CachedTypes          = new PacketDefinitionList();
            m_PacketCache          = new PacketCache();
            m_Messengers           = new List <IMessenger>();
            m_Filters = new List <ILoupeFilter>();

            m_MessageQueueMaxLength = Math.Max(configuration.Publisher.MaxQueueLength, 1); //make sure there's no way to get it below 1.

            m_PrincipalResolver       = principalResolver;
            m_ApplicationUserProvider = userProvider;

            //create the thread we use for dispatching messages
            CreateMessageDispatchThread();
        }
        /// <summary>
        /// Inserts a ActivityExecution record in the STF Data Log database.
        /// Records the username and domain, host machine, Date/Time the reset occurred for the session.
        /// </summary>
        /// <param name="sessionId">The session Id</param>
        public void LogSessionReset(string sessionId)
        {
            if (string.IsNullOrEmpty(UserName))
            {
                TraceFactory.Logger.Debug("UserName not set.");
            }

            using (var context = DbConnect.DataLogContext())
            {
                SessionSummary session = context.DbSessions.FirstOrDefault(s => s.SessionId == sessionId);
                if (session != null)
                {
                    session.ShutdownUser     = UserName;
                    session.ShutdownDateTime = DateTime.UtcNow;
                    context.SaveChanges();
                }
            }
        }
Beispiel #18
0
        /// <summary>
        /// Gets a <see cref="DataLog.SessionData" /> object for the specified session.
        /// </summary>
        /// <param name="sessionId">The session ID.</param>
        /// <returns>
        /// <see cref="DataLog.SessionData" /> for the specified session.
        /// (If session is not found, returns an empty <see cref="DataLog.SessionData" /> instance.
        /// </returns>
        public SessionData SessionData(string sessionId)
        {
            SessionSummary sessionSummary = DbSessions.SingleOrDefault(n => n.SessionId == sessionId);

            if (sessionSummary != null)
            {
                IQueryable <ActivityExecution> sessionActivities = Set <ActivityExecution>().Where(n => n.SessionId == sessionId);
                return(new SessionData(sessionSummary, sessionActivities));
            }
            else
            {
                // Return an empty SessionData object
                SessionSummary summary = new SessionSummary {
                    SessionId = sessionId
                };
                return(new SessionData(summary, Enumerable.Empty <ActivityExecution>().AsQueryable()));
            }
        }
        public SessionSummary ToSessionSummary(SmtpSession core)
        {
            if (core == null)
            {
                return(null);
            }

            var result = new SessionSummary
            {
                Id               = core.SessionId,
                RemoteIp         = core.RemoteIp,
                SessionEndTime   = core.SessionEndTime,
                SessionId        = this._dataEncryptor.EncryptSessionId(core.SessionId),
                SessionStartTime = core.SessionStartTime,
                Username         = core.Username
            };

            return(result);
        }
        private void AddSessionBestInfo(SessionSummary sessionSummary, ExcelWorksheet sheet)
        {
            ExcelRange range = sheet.Cells["K5:L9"];

            range.Style.Border.BorderAround(ExcelBorderStyle.Medium, SessionBestColor.ToDrawingColor());
            sheet.Cells["K5"].Value = "Session Best:";
            sheet.Cells["K6"].Value = "Sector 1:";
            sheet.Cells["K7"].Value = "Sector 2:";
            sheet.Cells["K8"].Value = "Sector 3:";
            sheet.Cells["K9"].Value = "Lap:";

            if (sessionSummary.SessionBestSector1 != null)
            {
                sheet.Cells["L6"].Value = FormatSessionBest(
                    sessionSummary.SessionBestSector1,
                    sessionSummary.SessionBestSector1.Sector1);
            }

            if (sessionSummary.SessionBestSector2 != null)
            {
                sheet.Cells["L7"].Value = FormatSessionBest(
                    sessionSummary.SessionBestSector2,
                    sessionSummary.SessionBestSector2.Sector2);
            }

            if (sessionSummary.SessionBestSector3 != null)
            {
                sheet.Cells["L8"].Value = FormatSessionBest(
                    sessionSummary.SessionBestSector3,
                    sessionSummary.SessionBestSector3.Sector3);
            }

            if (sessionSummary.SessionBestLap != null)
            {
                sheet.Cells["L9"].Value = FormatSessionBest(
                    sessionSummary.SessionBestLap,
                    sessionSummary.SessionBestLap.LapTime);
            }
            sheet.Cells["K5:K9"].Style.Font.Bold           = true;
            sheet.Cells["L5:L9"].Style.HorizontalAlignment = ExcelHorizontalAlignment.Right;
            range.AutoFitColumns();
        }
Beispiel #21
0
        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();
            }
        }
Beispiel #22
0
        public void Should_Convert_A_thought_In_A_Todo()
        {
            var            title       = "Title test";
            var            outcome     = "Outcome teste";
            SessionSummary value       = new SessionSummary();
            var            sessionMock = new Mock <ISession>();

            sessionMock.Setup(_ => _.Set <SessionSummary>("SessionSummary", It.IsAny <SessionSummary>()))
            .Callback <string, SessionSummary>((k, v) => value = v);

            sessionMock.Setup(_ => _.Get <SessionSummary>("SessionSummary")).Returns(value);

            var rmContext = new Mock <HttpContext>();

            rmContext.Setup(x => x.Session).Returns(sessionMock.Object);

            var expectedTodo = new Todo()
            {
                Title = title, Completed = false, Topic = Topic.topics.First(), Outcome = outcome
            };
            var thought = new Thought()
            {
                Id = 1, Name = title, Topic = Topic.topics.First()
            };
            var sessionSummary = new SessionSummary();

            sessionSummary.todos.Add(expectedTodo);

            var controller        = new TodoController(null);
            var controllerContext = new ControllerContext();

            controllerContext.HttpContext = rmContext.Object;
            controller.ControllerContext  = controllerContext;
            var result = (RedirectToActionResult)controller.Convert(thought, outcome);

            Assert.Contains(expectedTodo, Todo.ThingsToBoDone);
            Assert.DoesNotContain(thought, Thought.Thoughts);
            Assert.Equal("Process", result.ActionName);
            Assert.Equal("Thought", result.ControllerName);
            Assert.Equal(sessionSummary, controller.HttpContext.Session.Get <SessionSummary>("SessionSymmary"));
        }
        public override bool DoSessionCompletion(SessionSummary sessionSummary)
        {
            if (ElapsedStateTime.TotalSeconds < 20)
            {
                Logger.Info("Session time too short.");
                return(false);
            }

            if (sessionSummary.SessionType != SessionType.Qualification)
            {
                Logger.Info("Session is not qualification");
                return(false);
            }


            if (!IsSessionResultAcceptable(sessionSummary))
            {
                Logger.Info("Seesion is not acceptable to be used by rating calculations. Not enough drivers with laps times. Session Summary type was:" + sessionSummary.SessionType);
                return(false);
            }

            List <Driver> eligibleDrivers = FilterNotEligibleDriversAndOrder(sessionSummary);

            if (eligibleDrivers == null)
            {
                Logger.Info("Seesion is not acceptable to be used by rating calculations - no drivers");
                return(false);
            }

            Logger.Info("Seesion is acceptable to be used by rating calculations.");
            if (SharedContext.QualificationContext == null)
            {
                SharedContext.QualificationContext = new QualificationContext()
                {
                    QualificationDifficulty = SharedContext.UserSelectedDifficulty
                };
            }
            SharedContext.QualificationContext.LastQualificationResult = eligibleDrivers;
            _sessionCompleted = true;
            return(false);
        }
        private void AddPlayersLaps(ExcelWorksheet sheet, SessionSummary sessionSummary)
        {
            AddPlayerLapsHeader(sheet);
            Driver player = sessionSummary.Drivers.FirstOrDefault(x => x.IsPlayer);

            if (player == null)
            {
                return;
            }

            Lap lastLap    = null;
            int currentRow = 6;

            player.Laps.Where(l => l.LapEndSnapshot != null).ToList().ForEach(
                x =>
            {
                currentRow = AddPlayerLapInfo(sheet, sessionSummary, x, lastLap, currentRow);
                lastLap    = x;
            });
            sheet.Cells["A1:M5"].AutoFitColumns();
        }
Beispiel #25
0
        public void TestExportSummaryTime()
        {
            // Arrange
            string         fileName       = @"time.xlsx";
            SessionSummary sessionSummary = GetBlankSessionSummary();

            sessionSummary.SessionLength     = TimeSpan.FromMinutes(90);
            sessionSummary.SessionLengthType = SessionLengthType.Time;
            AddDrivers(20, sessionSummary);
            sessionSummary.Drivers.ForEach((s) => FillLaps(s, 140, 20));
            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            // Act
            _testee.ExportSessionSummary(sessionSummary, fileName);

            // Assert
            Assert.That(File.Exists(fileName), Is.True);
            System.Diagnostics.Process.Start(fileName);
        }
 private void UpdateSessionShutdownState(MachineShutdownState state, string sessionId, bool ignoreMissing = false)
 {
     SetTraceSessionContext(sessionId);
     using (var context = DbConnect.DataLogContext())
     {
         SessionSummary session = context.DbSessions.FirstOrDefault(s => s.SessionId == sessionId);
         if (session != null)
         {
             session.ShutdownState = state.ToString();
             context.SaveChanges();
         }
         else
         {
             // If we could not find the requested session, check to see if this method has been called with
             // the parameters to ignore missing sessions.  If not, throw an exception.
             if (!ignoreMissing)
             {
                 throw new ArgumentException($"Session ID {sessionId} not found.");
             }
         }
     }
 }
 public void CreateReport(SessionSummary sessionSummary)
 {
     if (!ShouldBeExported(sessionSummary))
     {
         return;
     }
     try
     {
         string reportName = GetReportName(sessionSummary);
         SessionSummaryExporter sessionSummaryExporter = CreateSessionSummaryExporter();
         string fullReportPath = Path.Combine(
             GetReportDirectory(),
             reportName);
         sessionSummaryExporter.ExportSessionSummary(sessionSummary, fullReportPath);
         OpenReportIfEnabled(sessionSummary, fullReportPath);
         CheckAndDeleteIfMaximumReportsExceeded();
     }
     catch (Exception ex)
     {
         Logger.Error(ex, "Unable to export session info");
     }
 }
        private void AddDriversInfo(ExcelWorksheet sheet, SessionSummary sessionSummary)
        {
            int rowNum = 5;

            foreach (Driver driver in sessionSummary.Drivers.Where(d => d.Finished).OrderBy(driver => driver.FinishingPosition))
            {
                ExcelRow row = sheet.Row(rowNum);
                AddDriverInfo(sheet, row, driver, sessionSummary);
                rowNum++;
            }

            foreach (Driver driver in sessionSummary.Drivers.Where(d => !d.Finished).OrderBy(d => d.TotalLaps).Reverse())
            {
                ExcelRow row = sheet.Row(rowNum);
                AddDriverInfo(sheet, row, driver, sessionSummary);
                rowNum++;
            }

            for (int i = 1; i <= 9; i++)
            {
                sheet.Column(i).AutoFit();
            }
        }
Beispiel #29
0
        public void ExportSessionSummary(SessionSummary sessionSummary, string filePath)
        {
            try
            {
                if (File.Exists(filePath))
                {
                    File.Delete(filePath);
                }
                FileInfo     newFile = new FileInfo(filePath);
                ExcelPackage package = new ExcelPackage(newFile);

                CreateWorkBook(package);
                ExcelWorkbook workbook = package.Workbook;
                AddSummary(workbook.Worksheets[SummarySheet], sessionSummary);
                AddLapsInfo(workbook.Worksheets[LapsAndSectorsSheet], sessionSummary);
                AddPlayersLaps(workbook.Worksheets[PlayerLapsSheet], sessionSummary);
                package.Save();
            }
            catch (Exception ex)
            {
                Logger.Error(ex, "Unable to export session info");
            }
        }
Beispiel #30
0
        public void TestExportSummaryLaps()
        {
            // Arrange
            string         fileName       = @"Laps.xlsx";
            SessionSummary sessionSummary = GetBlankSessionSummary();

            sessionSummary.TotalNumberOfLaps = 20;
            sessionSummary.SessionLengthType = SessionLengthType.Laps;
            AddDrivers(20, sessionSummary);
            sessionSummary.Drivers.ForEach((s) => FillLaps(s, 140, 20));

            if (File.Exists(fileName))
            {
                File.Delete(fileName);
            }

            // Act
            _testee.ExportSessionSummary(sessionSummary, fileName);

            // Assert
            Assert.That(File.Exists(fileName), Is.True);
            System.Diagnostics.Process.Start(fileName);
        }
Beispiel #31
0
        private void SessionNotesForm_Load(object sender, EventArgs e)
        {
            _sessionSummary = _dataLogContext.DbSessions.FirstOrDefault(x => x.SessionId == SessionId);

            // Populate the form
            sessionId_Label.Text = _sessionSummary.SessionId;
            notes_TextBox.Text   = _sessionSummary.Notes;

            sessionName_ComboBox.Text  = _sessionSummary.SessionName;
            sessionType_ComboBox.Text  = _sessionSummary.Type;
            sessionCycle_ComboBox.Text = _sessionSummary.Cycle;
            reference_TextBox.Text     = _sessionSummary.Reference;
            LoadTags();

            try
            {
                RefreshDataGrid();
            }
            catch
            {
                product_GridView.DataSource = null;
            }
        }
Beispiel #32
0
        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();
            }
        }