예제 #1
0
        public CloudAhoyFlight()
        {
            aircraft  = new CloudAhoyAircraftDescriptor();
            airports  = new CloudAhoyAirportDescriptor[0];
            crew      = new CloudAhoyCrewDescriptor[0];
            maneuvers = new CloudAhoyManeuverDescriptor[0];
            cfiaScore = flightId = remarks = url = userRole = string.Empty;

            DictProps = new Dictionary <CustomPropertyType.KnownProperties, CustomFlightProperty>();

            UserName = null;
        }
예제 #2
0
        public override LogbookEntry ToLogbookEntry()
        {
            StringBuilder sb = new StringBuilder();

            if (airports != null)
            {
                foreach (CloudAhoyAirportDescriptor ap in airports)
                {
                    sb.AppendFormat(CultureInfo.CurrentCulture, "{0} ", ap.icao);
                }
            }
            if (aircraft == null)
            {
                aircraft = new CloudAhoyAircraftDescriptor();
            }

            DateTime dtStart = DateTimeOffset.FromUnixTimeSeconds(time).DateTime;

            DictProps.Clear();

            List <string> lstText = new List <string>()
            {
                MarkdownLink(remarks, url)
            };

            PendingFlight le = new PendingFlight()
            {
                FlightID        = LogbookEntry.idFlightNew,
                TailNumDisplay  = aircraft.registration,
                ModelDisplay    = aircraft.model,
                Route           = sb.ToString().Trim(),
                TotalFlightTime = duration / 3600.0M,
                EngineStart     = dtStart,
                EngineEnd       = dtStart.AddSeconds(duration),
                Date            = dtStart.Date
            };

            PopulateCrewInfo(le);
            PopulateManeuvers(le, lstText);

            le.Comment = String.Join(" ", lstText);

            le.CustomProperties = PropertiesWithoutNullOrDefault(DictProps.Values).ToArray();

            if (!string.IsNullOrEmpty(flightId))
            {
                le.PendingID = flightId;
            }

            if (!String.IsNullOrEmpty(UserName))
            {
                le.User = UserName;
                UserAircraft ua = new UserAircraft(UserName);
                Aircraft     ac = ua.GetUserAircraftByTail(le.TailNumDisplay);
                if (ac != null)
                {
                    le.AircraftID = ac.AircraftID;
                }
            }

            return(le);
        }
예제 #3
0
        public override LogbookEntry ToLogbookEntry()
        {
            StringBuilder sb = new StringBuilder();

            if (airports != null)
            {
                foreach (CloudAhoyAirportDescriptor ap in airports)
                {
                    sb.AppendFormat(CultureInfo.CurrentCulture, "{0} ", ap.icao);
                }
            }
            if (aircraft == null)
            {
                aircraft = new CloudAhoyAircraftDescriptor();
            }

            DateTime dtStart = DateTimeOffset.FromUnixTimeSeconds(time).DateTime;

            DictProps.Clear();

            List <string> lstText = new List <string>()
            {
                MarkdownLink(remarks, link)
            };

            PendingFlight le = new PendingFlight()
            {
                FlightID        = LogbookEntry.idFlightNew,
                TailNumDisplay  = aircraft.registration,
                ModelDisplay    = aircraft.model,
                Route           = sb.ToString().Trim(),
                TotalFlightTime = duration / 3600.0M,
                EngineStart     = dtStart,
                EngineEnd       = dtStart.AddSeconds(duration),
                Date            = dtStart.Date
            };

            PopulateCrewInfo(le);
            PopulateManeuvers(le, lstText);

            le.Comment = String.Join(" ", lstText);

            if (!string.IsNullOrEmpty(flightId))
            {
                le.PendingID = flightId;
            }

            if (!String.IsNullOrEmpty(UserName))
            {
                le.User = UserName;
                Aircraft ac = BestGuessAircraftID(UserName, le.TailNumDisplay);
                if (ac != null)
                {
                    le.AircraftID = ac.AircraftID;
                    if (ac.IsAnonymous)
                    {
                        DictProps[CustomPropertyType.KnownProperties.IDPropAircraftRegistration] = CustomFlightProperty.PropertyWithValue(CustomPropertyType.KnownProperties.IDPropAircraftRegistration, le.TailNumDisplay);
                    }
                }
            }

            le.CustomProperties.SetItems(DictProps.Values);

            return(le);
        }