public Control New() { return(Wrap(new TerminalDto { Name = SessionDao.NewName() })); }
public int GetAvailableTerms(Session openedSession, DateTime date, RemainingSession remainingSession) { var day = date.DayOfWeek; var startTime = date.TimeOfDay; Session nextSession = null; var sessions = SessionDao.FindByScheduleId(LastOpenedSchedule.Id); foreach (var session in sessions) { // sesion is on the same day or in same classroom if (session.Day == day && session.Classroom.Id == Classroom.Id) { var sessionStart = session.Time.TimeOfDay; var sessionEnd = sessionStart.Add(new TimeSpan(0, Subject.TermLenght * session.Terms, 0)); if (openedSession != null && openedSession.Time.TimeOfDay.CompareTo(sessionStart) == 0) { continue; } if (startTime.CompareTo(sessionStart) >= 0 && startTime.CompareTo(sessionEnd) < 0) { return(-1); } if (startTime.CompareTo(sessionStart) < 0) { if (nextSession == null || sessionStart.CompareTo(nextSession.Time.TimeOfDay) < 0) { nextSession = session; } } } } TimeSpan diff; if (nextSession != null) { var nextSessionStart = nextSession.Time.TimeOfDay; diff = nextSessionStart - startTime; } else { var maxTimeSpan = new TimeSpan(22, 0, 0); diff = maxTimeSpan - startTime; } var diffMinutes = diff.TotalMinutes; var maxTerms = (int)(diffMinutes / Subject.TermLenght); if (openedSession != null) { return(maxTerms > remainingSession.RemainingTerms + openedSession.Terms ? remainingSession.RemainingTerms + +openedSession.Terms : maxTerms); } return(maxTerms > remainingSession.RemainingTerms ? remainingSession.RemainingTerms : maxTerms); }
public Subject SaveSubject() { Subject.RequiredSoftware = new List <Software>(); foreach (var softwareViewModel in SoftwareList) { if (softwareViewModel.IsChecked) { Subject.RequiredSoftware.Add(softwareViewModel.Software); } } if (_adding) { SubjectDao.Add(Subject); } else { var subject = SubjectDao.FindById(Subject.Id); subject.Update(Subject); var sessions = SessionDao.GetIncompatibleSessions(subject); if (sessions.Count > 0) { var dialog = new ConfirmDelete(sessions, "Are you sure you want to update this subject? Some of the sessions have already been placed in the schedule. Following is the list of all sessions that will be deleted if you proceed with this update.") { HelpState = Constants.ApplicationState.SubjectsAdd }; dialog.ShowDialog(); if (dialog.Confirm) { SubjectDao.Update(subject); foreach (var session in sessions) { SessionDao.Remove(session.Id); } _mainWindowViewModel.InitRemainigSessions(); _mainWindowViewModel.InitSessions(); } else { return(null); } } else { SubjectDao.Update(subject); _mainWindowViewModel.InitRemainigSessions(); _mainWindowViewModel.InitSessions(); } } return(Subject); }
public void OutputTest() { var report = new Report(); var ses = new SessionDao(); var s1 = ses.Read(1); var ex = new ExcelIO(); ex.Output(report.GetAvgGradeBySpecialities(s1), @"C:\Users\lenni\source\repos\ZimnitskiYury\epam_gstu\task7\output5.xlsx"); Assert.Fail(); }
public void OutputTest() { var student = new StudentDao(); var session = new SessionDao(); var group = new GroupDao(); var report = new Report(); var ex = new ExcelIO(); ex.Output(report.GetResultsByStudent(session.Read(1), group.Read(2)), @"C:\Users\lenni\source\repos\ZimnitskiYury\epam_gstu\task6\output.xlsx"); ex.Output(report.GetGrades(session.Read(1)), @"C:\Users\lenni\source\repos\ZimnitskiYury\epam_gstu\task6\output2.xlsx"); ex.Output(report.GetSessionExpelledByStudent(session.Read(1), 50), @"C:\Users\lenni\source\repos\ZimnitskiYury\epam_gstu\task6\output3.xlsx"); Assert.Fail(); }
public Classroom SaveClassroom() { Classroom.InstalledSoftware = new List <Software>(); foreach (var softwareViewModel in SoftwareList) { if (softwareViewModel.IsChecked) { Classroom.InstalledSoftware.Add(softwareViewModel.Software); } } if (_adding) { ClassroomDao.Add(Classroom); } else { var sessions = SessionDao.GetIncompatibleSessions(Classroom); if (sessions.Count > 0) { var dialog = new ConfirmDelete(sessions, "Are you sure you want to update this classroom? Conflicting sessions have been found in the schedule. Following is the list of all sessions that will be deleted if you proceed with this update.") { HelpState = Constants.ApplicationState.ClassroomsAdd }; dialog.ShowDialog(); if (dialog.Confirm) { ClassroomDao.Update(Classroom); foreach (var session in sessions) { SessionDao.Remove(session.Id); } _mainWindowViewModel.InitRemainigSessions(); _mainWindowViewModel.InitSessions(); } } else { ClassroomDao.Update(Classroom); _mainWindowViewModel.InitRemainigSessions(); _mainWindowViewModel.InitSessions(); } } return(Classroom); }
public void InitSessions() { ScheduleAppointments.Clear(); var sessions = SessionDao.FindByScheduleId(Schedule.Id); foreach (var session in sessions) { var sessionAppoinment = new SessionAppointment() { Session = session, Subject = session.Subject.Name, StartTime = session.Time, EndTime = session.Time + TimeSpan.FromMinutes(session.Terms * Subject.TermLenght), RecurrenceRule = "week" }; ScheduleAppointments.Add(sessionAppoinment); } }
private void LoadData() { // TODO It's waste logic... var sessions = SessionDao.FindAll().Wait(); var titleResults = sessions.ToObservable() .Select(session => session.CreateTitleType()) .ToList().Wait(); var descriptionResults = sessions.ToObservable() .Select(session => session.CreateDescriptionType()) .ToList().Wait(); var speakerResults = sessions.ToObservable() .Select(session => session.CreateSpeakerType()) .ToList().Wait(); titleResults.AddAll(descriptionResults); titleResults.AddAll(speakerResults); adapter.SetAllList(titleResults); }
public Report() { StudentDao studentDao = new StudentDao(); students = studentDao.GetAll(); StudentGradeDao studentGradeDao = new StudentGradeDao(); grades = studentGradeDao.GetAll(); SubjectDao subjectDao = new SubjectDao(); subjects = subjectDao.GetAll(); ExaminationDao examinationDao = new ExaminationDao(); examinations = examinationDao.GetAll(); SessionDao sessionDao = new SessionDao(); sessions = sessionDao.GetAll(); GroupDao groupDao = new GroupDao(); groups = groupDao.GetAll(); }
private void SaveVisitorAsync(Session session, Visitor visitor) { var sessionDao = new SessionDao(); sessionDao.GetAndSave(session.Id, () => { //维护访问者数据 var visitorDao = new VisitorDao(); visitorDao.GetAndSave(visitor.Id, () => { //插入访问者 visitor.VisitCount = 1; visitorDao.MongoHelper.InsertOne(visitor); session.IsNewUser = true; //执行插入会话数据 sessionDao.MongoHelper.InsertOne(session); }, v => { //修改访问者数据 v.VisitPreviousTime = v.VisitLastTime; v.VisitLastTime = visitor.VisitLastTime; v.UpdateTime = DateTime.Now; v.VisitCount++; visitorDao.MongoHelper.ReplaceOne(v); session.IsNewUser = false; //执行插入会话数据 sessionDao.MongoHelper.InsertOne(session); }); }, s => { //执行修改,第一次登录状态时将本次会话修改为已登录 if (s.UserId == -1 && session.UserId != -1) { s.UserId = session.UserId; s.ClientInfo = session.ClientInfo; s.UpdateTime = session.UpdateTime; sessionDao.MongoHelper.ReplaceOne(session); } }); }
public void InitRemainigSessions() { RemainingSessions.Clear(); if (_classroom == null) { return; } var classroom = ClassroomDao.FindById(_classroom.Id); var schedule = LastOpenedSchedule; var subjects = SubjectDao.FindAll(); var sessionsDictionary = subjects.ToDictionary(subject => subject.Id, subject => new RemainingSession() { RemainingTerms = subject.RequiredTerms, Subject = subject }); var sessions = SessionDao.FindByScheduleId(schedule.Id); foreach (var session in sessions) { var currSession = sessionsDictionary[session.Subject.Id]; currSession.RemainingTerms -= session.Terms; } RemainingSessions.Clear(); var sessionList = sessionsDictionary.ToList(); sessionList.Sort( (pair1, pair2) => String.Compare(pair1.Value.Subject.Name, pair2.Value.Subject.Name, StringComparison.Ordinal)); foreach (var remainingSession in sessionList) { var session = remainingSession.Value; session.Compatible = classroom.CanHostSubject(session.Subject); RemainingSessions.Add(session); } }
public void InitSessions() { ScheduleAppointments.Clear(); if (_classroom == null) { return; } var sessions = SessionDao.FindByScheduleIdAndClassroomId(LastOpenedSchedule.Id, _classroom.Id); foreach (var session in sessions) { var sessionAppoinment = new SessionAppointment() { Session = session, Subject = session.Subject.Name, StartTime = session.Time, EndTime = session.Time + TimeSpan.FromMinutes(session.Terms * Subject.TermLenght), RecurrenceRule = "week" }; ScheduleAppointments.Add(sessionAppoinment); } }
public void DeleteSession() { SessionDao.Remove(Session.Id); }
public void UpdateSession() { SessionDao.Update(Session); }
public Session SaveSession() { return(SessionDao.Add(Session)); }
public TerminalFactory(string path) { this.path = path ?? SessionDao.DefaultPath(Name); }
public SessionsAdapter(ActivityNavigator activityNavigator, SessionDao dao, Activity activity) : base(activity) { this.activityNavigator = activityNavigator; this.dao = dao; }
public void UpdateSession(Session session) { SessionDao.Update(session); }
public void Save(string path, ISessionDto[] dtos) { SessionDao.Save(path, dtos); }
private async void buttonEmpezar_Click(object sender, EventArgs e) { string testName = textBoxName.Text; if (testName == "") { MessageBox.Show("Inserte un nombre antes de empezar la prueba"); } else { SessionDao sessionDao = new SessionDao(); currentSession = new Session(testName); try { sessionDao.SaveSession(currentSession); } catch (SqlException ex) { if (ex.ErrorCode == 2146232060 || ex.ErrorCode == -2146232060) { MessageBox.Show("Ya existe una prueba con ese nombre. Por favor elija otro"); return; } throw ex; } SessionEventDao sessionEventDao = new SessionEventDao(); SessionEvent sessionStart = new SessionEvent(currentSession.Id, currentSession.TestName, EventTypes.SESSION_START, DateTime.Now); sessionEventDao.SaveSessionEvent(sessionStart); requestSAM(); SessionEvent initialSAM = new SessionEvent(currentSession.Id, currentSession.TestName, EventTypes.INITIAL_SAM, DateTime.Now); sessionEventDao.SaveSessionEvent(initialSAM); timerLapso.Interval = 1000; buttonTerminar.Enabled = true; comboBoxPantallas.Enabled = false; comboBoxWebCam.Enabled = false; buttonEmpezar.Enabled = false; timerLapso.Start(); TestSet testSet = TestSetDao.GetTestSet(defaultTestSet); foreach (PhaseBase phase in testSet.Phases) { sessionEventDao.SaveSessionEvent(new SessionEvent(currentSession.Id, currentSession.TestName, string.Concat("INIT_", phase.ValenceArrousalQuadrant, "_", phase.Id.ToString()), DateTime.Now)); if (phase.StimuliType == ImagePhase.IAP_TYPE) { var imagePhase = (ImagePhase)phase; imagePlayer = new ImageDisplay(ConfigurationManager.AppSettings["iaps-path"]); imagePlayer.WindowState = FormWindowState.Maximized; imagePlayer.Show(); await Task.Run(async() => { foreach (IAP image in imagePhase.Iaps) { imagePlayer.ChangeImage(string.Concat(image.IdIaps, ".jpg")); await Task.Delay(2000); } }); imagePlayer.Close(); } if (phase.StimuliType == VideoPhase.DEVO_TYPE) { var videoPhase = (VideoPhase)phase; foreach (DEVO video in videoPhase.Videos) { videoPlayer = new VideoDisplay(ConfigurationManager.AppSettings["devo-path"]); videoPlayer.WindowState = FormWindowState.Maximized; videoPlayer.play(string.Concat(video.Id, ".mp4")); videoPlayer.ShowDialog(); } } sessionEventDao.SaveSessionEvent(new SessionEvent(currentSession.Id, currentSession.TestName, string.Concat("END_", phase.ValenceArrousalQuadrant, "_", phase.Id.ToString()), DateTime.Now)); requestSAM(); sessionEventDao.SaveSessionEvent(new SessionEvent(currentSession.Id, currentSession.TestName, string.Concat("SAM_", phase.ValenceArrousalQuadrant), DateTime.Now)); } } }
public void RemoveSession(Session session) { SessionDao.Remove(session.Id); }
public ISessionDto[] Load(string path) { SessionDao.Retype(path, 1, typeof(TerminalDto)); return(SessionDao.Load <TerminalDto>(path)); }