public IActionResult DeleteHolyDay(Guid holidaysId) { Weekend weekend = Weekendrepository.FindById(holidaysId); Weekendrepository.Remove(weekend); return(Redirect("/Holidays/HolydaysView")); }
protected void StartBtn_Click(object sender, EventArgs e) { using (WebhostEntities db = new WebhostEntities()) { if (!LoadWeekendFromDate()) { // Initialize a new weekend! int id = db.Weekends.Count() > 0 ? db.Weekends.OrderBy(w => w.id).ToList().Last().id + 1 : 0; Weekend weekend = new Weekend() { id = id, DutyTeamIndex = DutyTeamID, StartDate = WeekendRange.Start, EndDate = WeekendRange.End, Notes = "" }; db.Weekends.Add(weekend); db.SaveChanges(); WeekendID = id; } LogInformation("Created a new Weekend from scratch."); LoadWeekend(); } }
private static void ReEvaluate(WeekendInfo previous, WeekendInfo current, AbstractScoring scoring) { if (current == null) { throw new ArgumentNullException(); } if (scoring == null) { throw new ArgumentNullException(); } if (current.Weekend.Race.IsEmpty()) { throw new ArgumentException(); } Weekend weekend = current.Weekend; RaceSession race = weekend.Race; var poss = race.Positions.GetLastLap(); weekend.Points.Clear(); PrepareNewStandings(previous, current); Dictionary <Driver, TempData> tmp = CalculateTempData(poss); foreach (var item in poss) { UpdateNewDriverStandingsByNewRace(previous, current, scoring, weekend, race, tmp, item); } OrderDriverStandingsByPointsAndAssignPosition(current); }
protected void Page_Load(object sender, EventArgs e) { using (WebhostEntities db = new WebhostEntities()) { if (WeekendId == -1) { WeekendLabel.Text = "No information Yet!"; return; } Weekend weekend = db.Weekends.Where(w => w.id == WeekendId).Single(); WeekendLabel.Text = weekend.DutyTeam.Name + " Weekend!"; ActivitiesTable.Rows.Clear(); ActivitiesTable.Rows.Add(DutyScheduleRow.HeaderRow); List <DutyScheduleRow> rows = new List <DutyScheduleRow>(); foreach (WeekendActivity activity in weekend.WeekendActivities.Where(act => !act.IsDeleted).ToList()) { rows.Add(new DutyScheduleRow(activity.id, false, IsMobile, ((BasePage)Page).user.IsTeacher)); } if (((BasePage)Page).user.IsTeacher) { foreach (WeekendDuty duty in weekend.WeekendDuties.Where(dut => !dut.IsDeleted).ToList()) { rows.Add(new DutyScheduleRow(duty.id, true, IsMobile, true)); } } rows.Sort(); ActivitiesTable.Rows.AddRange(rows.ToArray()); } }
protected void SaveBtn_Click(object sender, EventArgs e) { using (WebhostEntities db = new WebhostEntities()) { Weekend weekend = db.Weekends.Where(w => w.id == WeekendId).Single(); //weekend.DetentionList.Clear(); foreach (int id in DetentionListSelector.GroupIds) { Student student = db.Students.Where(s => s.ID == id).Single(); //weekend.DetentionList.Add(student); } //weekend.CampusedStudents.Clear(); foreach (int id in CampusedListSelector.GroupIds) { Student student = db.Students.Where(s => s.ID == id).Single(); //weekend.CampusedStudents.Add(student); } db.SaveChanges(); } }
protected void LoadBtn_Click(object sender, EventArgs e) { using (WebhostEntities db = new WebhostEntities()) { if (db.Weekends.Where(w => w.id == WeekendId).Count() > 0) { IDField.Value = Convert.ToString(WeekendId); Weekend weekend = db.Weekends.Where(w => w.id == WeekendId).Single(); DetentionListSelector.AddStudent(AttendanceControl.GetOneHourDetention(weekend.id)); DetentionListSelector.AddStudent(AttendanceControl.GetTwoHourDetention(weekend.id)); CampusedListSelector.AddStudent(AttendanceControl.GetCampusedList(weekend.id)); LoadBtn.Visible = false; SaveBtn.Visible = true; DetentionListSelector.Visible = true; CampusedListSelector.Visible = true; return; } } DetentionListSelector.Visible = false; CampusedListSelector.Visible = false; LoadBtn.Visible = true; SaveBtn.Visible = false; LoadBtn.Text = "That Weekend Schedule hasn't been started yet."; }
public override Task <DeploymentDaysReply> GetDeploymentDays(DeploymentDaysRequest request, ServerCallContext context) { Weekend deploymentDays = Weekend.Friday | Weekend.Saturday | Weekend.Sunday; return(Task.FromResult(new DeploymentDaysReply { DeploymentDays = (int)deploymentDays })); }
public static void SaveWeekend(string fileName, Weekend weekend) { BinaryFormatter bf = new BinaryFormatter(); using (System.IO.Stream str = new System.IO.FileStream(fileName, System.IO.FileMode.OpenOrCreate)) { bf.Serialize(str, weekend); str.Close(); } }
/* [Route("/CreateNewHolydays")]*/ public IActionResult CreateNewHolydays(Holydays newweekend) { Weekend weekend = new Weekend(); weekend.Id = Guid.NewGuid(); weekend.startDate = DateTime.ParseExact(newweekend.startDay, "M/d/yyyy", CultureInfo.InvariantCulture); weekend.EndDate = DateTime.ParseExact(newweekend.EndDay, "M/d/yyyy", CultureInfo.InvariantCulture); Weekendrepository.Create(weekend); return(Redirect("/HolydaysView")); }
public FrmRace(Weekend weekend) : this() { if (weekend == null) { throw new ArgumentNullException("Argument \"weekend\" is null."); } this.weekend = weekend; }
protected void SaveNotes_Click(object sender, EventArgs e) { using (WebhostEntities db = new WebhostEntities()) { Weekend weekend = db.Weekends.Find(WeekendID); weekend.Notes = NotesInput.Text; db.SaveChanges(); LogInformation("Updated Weekend Notes: {0}", weekend.Notes); } LoadWeekend(); }
public FrmRace(WeekendInfo weekendData) : this() { if (weekendData == null) { throw new ArgumentNullException("Argument \"weekendData\" is null."); } this.weekendData = weekendData; this.weekend = weekendData.Weekend; }
public static RaceStatistics Create(Weekend w) { RaceStatistics ret = new RaceStatistics(w); ret.CalculateBasicRaceStats(); ret.CalculateCautions(); ret.CalculateDriverStats(); ret.CalculateOtherRaceStats(); return(ret); }
public IActionResult ChnageHolydays(Guid holidaysId, Holydays Updateholydays) { Weekend weekend = Weekendrepository.FindById(holidaysId); weekend.startDate = DateTime.ParseExact(Updateholydays.startDay, "M/d/yyyy", CultureInfo.InvariantCulture); weekend.EndDate = weekend.startDate.AddDays(Updateholydays.AddDays - 1); weekend.Name = Updateholydays.Name; Weekendrepository.Update(weekend); return(Redirect("/Holidays/HolydaysView")); }
protected void Page_Load(object sender, EventArgs e) { if (!Page.IsPostBack && WeekendID != -1) { using (WebhostEntities db = new WebhostEntities()) { Weekend weekend = db.Weekends.Where(w => w.id == WeekendID).Single(); StartDate.Text = weekend.StartDate.ToShortDateString(); StartDate_CalendarExtender.SelectedDate = weekend.StartDate; } } }
public IActionResult ChangeWeekend(Guid holidaysId) { Weekend weekend = Weekendrepository.FindById(holidaysId); ViewBag.holidaysId = holidaysId; Holydays holydays = new Holydays(); holydays.Name = weekend.Name; ViewBag.holidaysId = holidaysId; holydays.startDay = weekend.startDate.ToString("MM/dd/yyyy", CultureInfo.InvariantCulture); holydays.AddDays = (weekend.EndDate - weekend.startDate).Days + 1; return(View(holydays)); }
/// <summary> /// Use as Disposable for memory conservation! File is writtin to the disk on Dispose. /// /// i.e. form of: /// /// <code> /// string filename; /// using (WeekendDutySchedule ds = new WeekendDutySchedule(weekendId)) /// { /// filename = ds.Publish(); /// } /// /// Response.Redirect(filename); /// </code> /// </summary> /// <param name="weekendId"></param> public WeekendDutySchedule(int weekendId) : base("~/Temp/WeekendSchedule.pdf", "Weekend Duty Schedule") { using (WebhostEntities db = new WebhostEntities()) { if (db.Weekends.Where(w => w.id == weekendId).Count() <= 0) { throw new WebhostException(String.Format("No weekend with id={0}", weekendId)); } WeekendId = weekendId; Weekend weekend = db.Weekends.Where(w => w.id == weekendId).Single(); DutyTeam = weekend.DutyTeam.Name; WeekendDates = new DateRange(weekend.StartDate, weekend.EndDate); } }
public override string[] Evaluate(Weekend weekend) { List <string> ret = new List <string>(); if (weekend.Race.IsEmpty()) { ret.Add("This hint is evaluated only for if race has been taken."); } else { Driver user = AbstractHint.TryGetUserDriver(weekend); if (user == null) { ret.Add("Cannot recognize user driver."); } else { Meaner mD = new Meaner(); Meaner mA = new Meaner(); foreach (Driver d in weekend.Drivers.Values) { foreach (RacePit rp in weekend.Race.PitLaps.Get(d)) { if (weekend.Race.Yellows.IsInYellow(rp.Time)) { continue; } if (d == user) { mD.Add(rp.Time.TotalMiliseconds); } else { mA.Add(rp.Time.TotalMiliseconds); } } } ret.Add("Your medium pit time is : " + new Time((int)mD.Mean)); ret.Add("AI medium pit time is : " + new Time((int)mA.Mean)); ret.Add("\t* pit times are taken without yellow laps"); } } return(ret.ToArray());; }
protected void Page_Load(object sender, EventArgs e) { /*if(Request.Browser.IsMobileDevice) * { * Response.Redirect("~/Mobile/Weekend.aspx"); * }*/ int id = DateRange.GetCurrentWeekendId(); if (!Page.IsPostBack) { LogInformation("Loading Weekend Signpus Page."); if (!DateRange.WeekendDays.Contains(DateTime.Today.DayOfWeek) || (DateTime.Today.DayOfWeek == DayOfWeek.Friday && (DateTime.Now.Hour < 11 || (DateTime.Now.Hour == 11 && DateTime.Now.Minute < 30)))) { LogInformation("Signup's are not open yet!"); StudentSignupSelector1.Visible = false; NotAvailablePanel.Visible = true; } else if (id != -1) { LogInformation("Loading Weekend!"); StudentSignupSelector1.WeekendId = id; if (Request.QueryString.AllKeys.Contains("act_id")) { int actid = Convert.ToInt32(Request.QueryString["act_id"]); LogInformation("Activity id {0} is selected.", actid); StudentSignupSelector1.SetActiity(actid); } else { LogInformation("No activity is selected."); } } } if (id != -1 && NotAvailablePanel.Visible) { using (WebhostEntities db = new WebhostEntities()) { Weekend weekend = db.Weekends.Where(w => w.id == id).Single(); foreach (WeekendActivity activity in weekend.WeekendActivities.Where(act => act.showStudents && !act.IsDeleted).OrderBy(act => act.DateAndTime)) { ViewTable.Rows.Add(new StudentWeekendSignupViewRow(activity.id)); } } } }
protected void AllTeamCB_CheckedChanged(object sender, EventArgs e) { DutyAssignmentSelector.Visible = !AllTeamCB.Checked; if (AllTeamCB.Checked) { using (WebhostEntities db = new WebhostEntities()) { Weekend weekend = db.Weekends.Where(w => w.id == WeekendId).Single(); DutyAssignmentSelector.Clear(); DutyAssignmentSelector.AddFaculty(weekend.DutyTeam.Members.Select(f => f.ID).ToList()); } } else { DutyAssignmentSelector.Clear(); } }
internal static void FillWeekendFromTelemetry(Weekend w, out bool changed) { changed = false; FrmImportLog f = new FrmImportLog(); f.Init(w); f.ShowDialog(); var res = f.Result; if (res == null) { return; } changed = true; FillWeekend(w, res); }
protected void LoadWeekend() { NewWeekendPnl.Visible = false; BuilderPanel.Visible = true; using (WebhostEntities db = new WebhostEntities()) { Weekend weekend = db.Weekends.Find(WeekendID); //StartDate.Text = weekend.StartDate.ToShortDateString(); DutyTeamID = weekend.DutyTeamIndex; // Load Details! WeekendLabel.Text = weekend.DutyTeam.Name + " Weekend!"; ActivitiesTable.Rows.Clear(); ActivitiesTable.Rows.Add(DutyScheduleRow.HeaderRow); List <DutyScheduleRow> rows = new List <DutyScheduleRow>(); foreach (WeekendActivity activity in weekend.WeekendActivities.Where(act => !act.IsDeleted).ToList()) { rows.Add(new DutyScheduleRow(activity.id)); } foreach (WeekendDuty duty in weekend.WeekendDuties.Where(dut => !dut.IsDeleted).ToList()) { rows.Add(new DutyScheduleRow(duty.id, true)); } rows.Sort(); ActivitiesTable.Rows.AddRange(rows.ToArray()); if (!Page.IsPostBack) { DeleteActivityDDL.DataSource = DutyListItem.GetDataSource(weekend.WeekendActivities.Where(act => !act.IsDeleted).Select(act => act.id).ToList(), weekend.WeekendDuties.Where(dut => !dut.IsDeleted).Select(dut => dut.id).ToList()); DeleteActivityDDL.DataTextField = "Text"; DeleteActivityDDL.DataValueField = "Value"; DeleteActivityDDL.DataBind(); } NotesInput.Text = weekend.Notes; LogInformation("Loaded {0}", WeekendLabel.Text); } }
private void addRaceToolStripMenuItem_Click(object sender, EventArgs e) { Weekend w = WeekendWizard.RunNewWeekendProvider(this.Season); if (w != null) { WeekendInfo wd = new WeekendInfo(w); this.Season.RaceWeekends.Add(wd); //bool changed = false; //WeekendWizard.FillWeekendFromTelemetry(w, out changed); //SeasonEvaluator.ReEvaluate(this.season, this.season.RaceWeekends.Count - 1); RefreshData(); FrmRace f = new FrmRace(wd); f.Show(); } }
public override string[] Evaluate(Weekend weekend) { List <string> ret = new List <string>(); if (weekend.Qualify.IsEmpty()) { ret.Add("This hint can be calculated only for qualify is taken."); } else { Driver user = TryGetUserDriver(weekend); if (user == null) { ret.Add("User driver not found."); } else { Meaner dm = new Meaner(); Meaner am = new Meaner(); foreach (var item in weekend.Qualify.Laps.GetAll()) { if (item.Driver == user) { dm.Add(item.Time.TotalMiliseconds); } else { am.Add(item.Time.TotalMiliseconds); } } ret.Add("Your mean qualify time is: " + new Time((int)dm.Mean)); ret.Add("AI mean qualify time is: " + new Time((int)am.Mean)); ret.Add(""); ret.Add("Your best time is: " + weekend.Qualify.Positions[user].Time); ret.Add("AI best time is: " + weekend.Qualify.Positions[0].Time); } } return(ret.ToArray()); }
public static void ReEvaluate(Season season, Weekend weekend) { int ci = -1; for (int i = 0; i < season.RaceWeekends.Count; i++) { if (season.RaceWeekends[i].Weekend == weekend) { ci = i; break; } } if (ci < 0) { throw new ApplicationException("Cannot find weekend to update in season."); } ReEvaluate(season, ci); }
private void FillByCurrentWeekend(Weekend weekend, CurrentWeekend te) { weekend.Settings = new WeekendSettings(); weekend.Settings.PracticeLength = new Time(te.Sessions.PracticeLength); weekend.Settings.QualifyLapCount = te.Sessions.QualifyLapCount; weekend.Settings.PreRaceLength = new Time(te.Sessions.HappyHourLength); weekend.Settings.RaceLapCount = te.Sessions.RaceLapCount; weekend.Realism = new WeekendRealism(); switch (te.Options.DamageLevel) { case CurrentWeekend.cwOptions.eDamageLevel.Full: weekend.Realism.DamageLevel = WeekendRealism.eDamageLevel.Full; break; case CurrentWeekend.cwOptions.eDamageLevel.Moderate: weekend.Realism.DamageLevel = WeekendRealism.eDamageLevel.Moderate; break; case CurrentWeekend.cwOptions.eDamageLevel.None: weekend.Realism.DamageLevel = WeekendRealism.eDamageLevel.None; break; } weekend.Realism.IsAdaptiveSpeedControlEnabled = te.Options.IsAdaptiveSpeedControlEnabled; weekend.Realism.IsDoubleFileRestartEnabled = te.Options.IsDoubleFileRestartEnabled; weekend.Realism.IsFullPaceLapEnabled = te.Options.IsFullPaceLapEnabled; weekend.Realism.IsRealWeatherEnabled = te.Options.IsRealWeatherEnabled; weekend.Realism.IsYellowFlagEnabled = te.Options.IsYellowFlagEnabled; weekend.Realism.PitFuelMultiplier = te.Options.PitFuelMultiplier; switch (te.Options.GameType) { case CurrentWeekend.cwOptions.eGameType.Arcade: weekend.Realism.Mode = WeekendRealism.eMode.Arcade; break; case CurrentWeekend.cwOptions.eGameType.Simulation: weekend.Realism.Mode = WeekendRealism.eMode.Simulation; break; } }
private static void FillWeekend(Weekend w, FrmImportLog.ResultData res) { if (res.Practice != null) { FillSession(w.Practice, res.Practice); } if (res.Qualify != null) { FillSession(w.Qualify, res.Qualify); } if (res.PreRace != null) { FillSession(w.HappyHour, res.PreRace); } if (res.Race != null) { FillSession(w.Race, res.Race); } }
public IHttpActionResult GetWeekendActivities([FromUri] bool listStudents = true) { DateTime friday = DateRange.ThisFriday; using (WebhostEntities db = new WebhostAPI.WebhostEntities()) { if (db.Weekends.Where(w => w.StartDate.Equals(friday)).Count() <= 0) { return(ResponseMessage(Request.CreateErrorResponse(HttpStatusCode.BadRequest, new InvalidOperationException("No Weekend Information for this week.")))); } List <WeekendActivityInfo> info = new List <WeekendActivityInfo>(); Weekend thisWeekend = db.Weekends.Where(w => w.StartDate.Equals(friday)).Single(); foreach (WeekendActivity activity in thisWeekend.WeekendActivities.Where(act => !act.IsDeleted).OrderBy(act => act.DateAndTime).ToList()) { info.Add(new RequestHandlers.WeekendActivityInfo(activity.id, listStudents)); } return(ResponseMessage(Request.CreateResponse(HttpStatusCode.OK, info, "text/json"))); } }
private string CreateFillState(Weekend weekend) { StringBuilder sb = new StringBuilder(); if (weekend.Practice.IsEmpty() == false) { sb.Append("P"); } if (weekend.Qualify.IsEmpty() == false) { sb.Append("Q"); } if (weekend.HappyHour.IsEmpty() == false) { sb.Append("H"); } if (weekend.Race.IsEmpty() == false) { sb.Append("R"); } return(sb.ToString()); }
public IActionResult NextYear() { List <Person> people = PersonRepository.IncludeGet(p => p.Team).ToList(); HistoryAddingDays historyAddingDays = new HistoryAddingDays(); if (people[0] == null) { return(Redirect("/Home/Workers/Home/Workers")); } historyAddingDays.Year = people[0].Year; historyAddingDays.NumberAddDays = 17; historyAddingDays.Id = Guid.NewGuid(); historyAddingDays.CheckAddDays = true; HistoryAddingDaysRepository.Create(historyAddingDays); foreach (Person person in people) { Person newperson = person; person.Year++; newperson.Days += 18; PersonRepository.Update(newperson); } IEnumerable <Weekend> weekends = WeekendRepository.Get(p => p.startDate.Year == DateTime.Now.Year); List <Weekend> NewWeekends = new List <Weekend>(); Weekend Updateweekend = new Weekend(); foreach (Weekend weekend in weekends) { Updateweekend.Id = Guid.NewGuid(); Updateweekend.Name = weekend.Name; Updateweekend.startDate = weekend.startDate.AddYears(1); Updateweekend.EndDate = weekend.EndDate.AddYears(1); WeekendRepository.Create(Updateweekend); NewWeekends.Add(weekend); } return(View(NewWeekends)); }