Exemplo n.º 1
0
        public override void ExamineFlight(ExaminerFlightRow cfr)
        {
            if (cfr == null)
            {
                throw new ArgumentNullException(nameof(cfr));
            }

            // quick short circuit for anything more than 24 hours old, or not a real aircraft
            if (!cfr.fIsRealAircraft || cfr.dtFlight.CompareTo(dt24HoursAgo.Date) < 0)
            {
                return;
            }

            EffectiveDutyPeriod edp = new EffectiveDutyPeriod(cfr)
            {
                FlightDutyStart = DateTime.UtcNow.AddDays(-1), FlightDutyEnd = DateTime.UtcNow
            };

            TimeSpan ts = edp.TimeSince(dt24HoursAgo, (double)cfr.Total, cfr);

            if (ts.TotalHours > 0)
            {
                TotalFlying += Math.Min((double)cfr.Total, ts.TotalHours);
            }
        }
Exemplo n.º 2
0
        protected void btnViewDutyPeriods_Click(object sender, EventArgs e)
        {
            pnlResults.Visible = true;

            DutyPeriodExaminer dpe = new DutyPeriodExaminer(Profile.GetUser(Page.User.Identity.Name).UsesFAR117DutyTimeAllFlights);
            DBHelper           dbh = new DBHelper(FlightCurrency.CurrencyQuery(FlightCurrency.CurrencyQueryDirection.Descending));

            dbh.ReadRows(
                (comm) =>
            {
                comm.Parameters.AddWithValue("UserName", Page.User.Identity.Name);
                comm.Parameters.AddWithValue("langID", Thread.CurrentThread.CurrentUICulture.TwoLetterISOLanguageName);
            },
                (dr) => { dpe.ExamineFlight(new ExaminerFlightRow(dr)); });

            dpe.Finalize(0, 0);

            TimeSpan ts = new TimeSpan(decDayTimeSpan.IntValue, 0, 0, 0);

            lblCutoffDate.Text = DateTime.UtcNow.Subtract(ts).UTCDateFormatString(false);

            IEnumerable <EffectiveDutyPeriod> effectiveDutyPeriods = dpe.EffectiveDutyPeriods;

            decimal dutyTime       = EffectiveDutyPeriod.DutyTimeSince(ts, effectiveDutyPeriods);
            decimal flightdutyTime = EffectiveDutyPeriod.FlightDutyTimeSince(ts, effectiveDutyPeriods);
            decimal rest           = (decimal)((decimal)ts.TotalHours - dutyTime);

            lblTotalFlightDuty.Text = String.Format(CultureInfo.CurrentCulture, "{0:#,##0.0}hrs ({1})", flightdutyTime, flightdutyTime.ToHHMM());
            lblTotalDuty.Text       = String.Format(CultureInfo.CurrentCulture, "{0:#,##0.0}hrs ({1})", dutyTime, dutyTime.ToHHMM());
            lblTotalRest.Text       = String.Format(CultureInfo.CurrentCulture, "{0:#,##0.0}hrs ({1})", rest, rest.ToHHMM());

            gvDutyPeriods.DataSource = dpe.EffectiveDutyPeriods;
            gvDutyPeriods.DataBind();
        }