Exemplo n.º 1
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);
        }
Exemplo n.º 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, 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);
        }