private async Task LoadExtDroneFlight()
        {
            using (FlightProcessorConnection Info = new FlightProcessorConnection()) {
                var Query = from d in Info.MSTR_Drone
                            where d.DroneId == _DroneID
                            select new {
                    AccountID = d.AccountID,
                    DroneName = d.DroneName
                };
                if (await Query.AnyAsync())
                {
                    var Data = await Query.FirstAsync();

                    _ExtDroneFlight.DroneName   = Data.DroneName;
                    _ExtDroneFlight.AccountID   = Data.AccountID == null ? 0 : (int)Data.AccountID;
                    _ExtDroneFlight.AccountName = await Info.MSTR_Account
                                                  .Where(e => e.AccountId == _ExtDroneFlight.AccountID)
                                                  .Select(e => e.Name)
                                                  .FirstOrDefaultAsync();
                }
                int PilotID = (int)_ExtDroneFlight.GetBase().PilotID;
                var Query2  = from d in Info.MSTR_User
                              where d.UserId == PilotID
                              select d.FirstName + " " + d.LastName;
                if (await Query2.AnyAsync())
                {
                    _ExtDroneFlight.PilotName = await Query2.FirstOrDefaultAsync();
                }
            }
        }//LoadExtDroneFlight
Example #2
0
        public bool Generate(String AlertCategory, String AlertType = "High", Proximity ProximityFlight = null)
        {
            bool   IsMessageGenerated = false;
            String sAltitude          = ((Decimal)(_Flight.Altitude)).ToString("0.00");
            String sFlightTime        = ((DateTime)_Flight.GetBase().FlightDate).ToString("dd-MMM-yyyy HH:mm:ss");

            _AlertCategory = AlertCategory;
            _AlertType     = AlertType;
            switch (AlertCategory.ToLower())
            {
            case "boundary":
            case "altitude":
                _AlertMessage =
                    AlertCategory + "\n" +
                    _AccountName + "\n" +
                    _Flight.PilotName + "\n" +
                    GetLocation() + "\n" +
                    "Altitude: " + sAltitude + " Meter\n" +
                    "UTC " + sFlightTime + "\n" +
                    "Ref: " + _Flight.GetBase().ID;
                IsMessageGenerated = true;
                break;

            case "proximity":
                _AlertMessage =
                    AlertCategory + Environment.NewLine +
                    _AccountName + Environment.NewLine +
                    _Flight.PilotName + Environment.NewLine +
                    _DroneName + Environment.NewLine +
                    GetLocation() + Environment.NewLine +
                    "Altitude: " + sAltitude + " Meter" + Environment.NewLine +
                    "Ref: " + _Flight.GetBase().ID.ToString() + Environment.NewLine +
                    Environment.NewLine +

                    ProximityFlight.AccountName + Environment.NewLine +
                    ProximityFlight.PilotName + Environment.NewLine +
                    ProximityFlight.DroneName + Environment.NewLine +
                    ProximityFlight.Location + Environment.NewLine +
                    "Altitude: " + sAltitude + " Meter" + Environment.NewLine +
                    "Ref: " + ProximityFlight.FlightID.ToString() + Environment.NewLine +
                    Environment.NewLine +

                    "Distance: " + ProximityFlight.Distance.ToString("0.00") + Environment.NewLine +
                    "UTC " + sFlightTime;


                IsMessageGenerated = true;
                break;
            }
            return(IsMessageGenerated);
        }//public String GetAlert