// this makes is possible to sort per date.
        // flight date over sim date. and offblocktime within flight dates.
        private int CompareFLTDate(object x, object y)
        {
            Flight lhs = x as Flight;
            Flight rhs = y as Flight;
            // make nullable values comparable

            DateTime a = DateTime.MinValue;
            DateTime b = DateTime.MinValue;
            TimeSpan c = TimeSpan.Zero;
            TimeSpan d = TimeSpan.Zero;

            if (lhs.DateOfSim.HasValue)
            {
                if (lhs.DateOfSim.Value.Ticks > DateTime.MinValue.Ticks)
                {
                    a = lhs.DateOfSim.Value;
                }
            }
            if (lhs.FlightDate.HasValue)
            {
                if (lhs.FlightDate.Value.Ticks > DateTime.MinValue.Ticks)
                {
                    a = lhs.FlightDate.Value;
                }
            }
            if (rhs.DateOfSim.HasValue)
            {
                if (rhs.DateOfSim.Value.Ticks > DateTime.MinValue.Ticks)
                {
                    b = rhs.DateOfSim.Value;
                }
            }
            if (rhs.FlightDate.HasValue)
            {
                if (rhs.FlightDate.Value.Ticks > DateTime.MinValue.Ticks)
                {
                    b = rhs.FlightDate.Value;
                }
            }
            if (lhs.OffBlockTime.HasValue)
            {
                if (lhs.OffBlockTime.Value.Ticks > TimeSpan.Zero.Ticks)
                {
                    c = lhs.OffBlockTime.Value;
                }
            }
            if (rhs.OffBlockTime.HasValue)
            {
                if (rhs.OffBlockTime.Value.Ticks > TimeSpan.Zero.Ticks)
                {
                    d = rhs.OffBlockTime.Value;
                }
            }
            // compare values
            if (a.Ticks < b.Ticks)
            {
                return(-1);
            }
            if (a.Ticks > b.Ticks)
            {
                return(1);
            }
            if (a.Ticks == b.Ticks)
            {
                if (c.Ticks < d.Ticks)
                {
                    return(-1);
                }
                if (c.Ticks > d.Ticks)
                {
                    return(1);
                }
            }
            // The orders are equivalent.
            return(0);
        }
Beispiel #2
0
        public string EasaOutputLine(Flight flight)
        {
            string _stringbuilder = "";

            _stringbuilder += "<tr>\n<td height=\"19\" align=\"center\" valign=middle >";
            if (!flight.FlightDate.HasValue || flight.FlightDate.Equals(DateTime.MinValue))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.FlightDate.Value.ToString("dd.MM.yy") + "</td>\n";
            }

            _stringbuilder += "<td align=\"center\" valign=middle>";
            _stringbuilder += flight.DepartureAirport + "</td>\n";

            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.OffBlockTime.HasValue || flight.OffBlockTime.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.OffBlockTime.Value.ToString("%h\\:mm") + "</td>\n";
            }

            _stringbuilder += "<td align=\"center\" valign=middle>";
            _stringbuilder += flight.DestinationAirport + "</td>\n";

            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.OnBlockTime.HasValue || flight.OnBlockTime.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.OnBlockTime.Value.ToString("%h\\:mm") + "</td>\n";
            }

            _stringbuilder += "<td align=\"center\" valign=middle>";
            _stringbuilder += flight.TypeOfAircraft + "</td>\n";

            _stringbuilder += "<td align=\"center\" valign=middle>";
            _stringbuilder += flight.AircraftRegistration + "</td>\n";

            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.SEPTime)
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += "X" + "</td>\n";
            }

            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.MEPTime)
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += "X" + "</td>\n";
            }

            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.MultiPilotTime.HasValue || flight.MultiPilotTime.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.MultiPilotTime.Value.Hours.ToString() + "</td>\n";
            }
            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.MultiPilotTime.HasValue || flight.MultiPilotTime.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.MultiPilotTime.Value.Minutes.ToString("00") + "</td>\n";
            }

            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.TotalTimeOfFlight.HasValue || flight.TotalTimeOfFlight.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.TotalTimeOfFlight.Value.Hours.ToString() + "</td>\n";
            }
            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.TotalTimeOfFlight.HasValue || flight.TotalTimeOfFlight.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.TotalTimeOfFlight.Value.Minutes.ToString("00") + "</td>\n";
            }

            _stringbuilder += "<td align=\"center\" valign=middle>";
            _stringbuilder += flight.PilotInCommand + "</td>\n";

            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.DayLandings.HasValue || flight.DayLandings < 1)
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.DayLandings.Value + "</td>\n";
            }

            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.NightLandings.HasValue || flight.NightLandings < 1)
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.NightLandings.Value + "</td>\n";
            }

            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.NightTime.HasValue || flight.NightTime.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.NightTime.Value.Hours.ToString() + "</td>\n";
            }
            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.NightTime.HasValue || flight.NightTime.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.NightTime.Value.Minutes.ToString("00") + "</td>\n";
            }

            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.IFRTime.HasValue || flight.IFRTime.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.IFRTime.Value.Hours.ToString() + "</td>\n";
            }
            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.IFRTime.HasValue || flight.IFRTime.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.IFRTime.Value.Minutes.ToString("00") + "</td>\n";
            }

            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.PICTime.HasValue || flight.PICTime.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.PICTime.Value.Hours.ToString() + "</td>\n";
            }
            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.PICTime.HasValue || flight.PICTime.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.PICTime.Value.Minutes.ToString("00") + "</td>\n";
            }

            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.CopilotTime.HasValue || flight.CopilotTime.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.CopilotTime.Value.Hours.ToString() + "</td>\n";
            }
            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.CopilotTime.HasValue || flight.CopilotTime.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.CopilotTime.Value.Minutes.ToString("00") + "</td>\n";
            }

            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.DualTime.HasValue || flight.DualTime.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.DualTime.Value.Hours.ToString() + "</td>\n";
            }
            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.DualTime.HasValue || flight.DualTime.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.DualTime.Value.Minutes.ToString("00") + "</td>\n";
            }

            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.InstructorTime.HasValue || flight.InstructorTime.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.InstructorTime.Value.Hours.ToString() + "</td>\n";
            }
            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.InstructorTime.HasValue || flight.InstructorTime.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.InstructorTime.Value.Minutes.ToString("00") + "</td>\n";
            }

            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.DateOfSim.HasValue || flight.DateOfSim.Equals(DateTime.MinValue))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.DateOfSim.Value.ToString("dd.MM.yy") + "</td>\n";
            }
            _stringbuilder += "<td align=\"center\" valign=middle>";
            _stringbuilder += flight.TypeOfSim + "</td>\n";

            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.SimTime.HasValue || flight.SimTime.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.SimTime.Value.Hours.ToString() + "</td>\n";
            }
            _stringbuilder += "<td align=\"center\" valign=middle>";
            if (!flight.SimTime.HasValue || flight.SimTime.Equals(TimeSpan.Zero))
            {
                _stringbuilder += "</td>\n";
            }
            else
            {
                _stringbuilder += flight.SimTime.Value.Minutes.ToString("00") + "</td>\n";
            }

            _stringbuilder += "<td align=\"center\" valign=middle>";
            _stringbuilder += flight.Remarks + "</td>\n";
            return(_stringbuilder);
        }