Exemplo n.º 1
0
        public IActionResult DeleteHolyDay(Guid holidaysId)
        {
            Weekend weekend = Weekendrepository.FindById(holidaysId);

            Weekendrepository.Remove(weekend);
            return(Redirect("/Holidays/HolydaysView"));
        }
Exemplo n.º 2
0
        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();
            }
        }
Exemplo n.º 3
0
        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);
        }
Exemplo n.º 4
0
        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.";
        }
Exemplo n.º 7
0
        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
            }));
        }
Exemplo n.º 8
0
        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();
            }
        }
Exemplo n.º 9
0
        /*     [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"));
        }
Exemplo n.º 10
0
        public FrmRace(Weekend weekend)
            : this()
        {
            if (weekend == null)
            {
                throw new ArgumentNullException("Argument \"weekend\" is null.");
            }

            this.weekend = weekend;
        }
Exemplo n.º 11
0
 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();
 }
Exemplo n.º 12
0
        public FrmRace(WeekendInfo weekendData)
            : this()
        {
            if (weekendData == null)
            {
                throw new ArgumentNullException("Argument \"weekendData\" is null.");
            }

            this.weekendData = weekendData;
            this.weekend     = weekendData.Weekend;
        }
Exemplo n.º 13
0
        public static RaceStatistics Create(Weekend w)
        {
            RaceStatistics ret = new RaceStatistics(w);

            ret.CalculateBasicRaceStats();
            ret.CalculateCautions();
            ret.CalculateDriverStats();
            ret.CalculateOtherRaceStats();

            return(ret);
        }
Exemplo n.º 14
0
        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"));
        }
Exemplo n.º 15
0
 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;
         }
     }
 }
Exemplo n.º 16
0
        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));
        }
Exemplo n.º 17
0
 /// <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);
     }
 }
Exemplo n.º 18
0
        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());;
        }
Exemplo n.º 19
0
        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));
                    }
                }
            }
        }
Exemplo n.º 20
0
 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();
     }
 }
Exemplo n.º 21
0
        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);
        }
Exemplo n.º 22
0
        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);
            }
        }
Exemplo n.º 23
0
        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();
            }
        }
Exemplo n.º 24
0
        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());
        }
Exemplo n.º 25
0
        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);
        }
Exemplo n.º 26
0
        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;
            }
        }
Exemplo n.º 27
0
        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);
            }
        }
Exemplo n.º 28
0
        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")));
            }
        }
Exemplo n.º 29
0
            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());
            }
Exemplo n.º 30
0
        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));
        }