コード例 #1
0
        public static ListSet GetAirfields(String text)
        {
            ListSet aset = new ListSet();

            if (text.Contains("(") && text.Contains(")"))
            {
                String id = text.Substring(text.LastIndexOf("(") + 1, text.LastIndexOf(")") - text.LastIndexOf("(") - 1);
                if (id.Contains("Lat:") && id.Contains("Long:"))
                {
                    Airfield a = new Airfield();
                    a.ICAOCODE     = "T-T" + RandomPassword.Generate(5);
                    a.AirfieldName = text.Remove(text.IndexOf(",")).Trim();
                    a.Country      = text.Substring(text.IndexOf(",") + 1, text.IndexOf("(") - text.IndexOf(",") - 1).Trim();
                    foreach (String l in id.Split(",".ToCharArray()))
                    {
                        Double temp;
                        if (l.Contains("Lat:"))
                        {
                            temp = Double.Parse(l.Substring(l.LastIndexOf(":") + 1));
                            string[] parts = DDtoDMS(temp, CoordinateType.latitude).Split(".".ToCharArray());
                            a.LattitudeDegrees = Int32.Parse(parts[0]);
                            a.LattitudeMinutes = Int32.Parse(parts[1]);
                            a.NS = Char.Parse(parts[2]);
                        }
                        else if (l.Contains("Long:"))
                        {
                            temp = Double.Parse(l.Substring(l.LastIndexOf(":") + 1));
                            string[] parts = DDtoDMS(temp, CoordinateType.longitude).Split(".".ToCharArray());
                            a.LongitudeDegrees = Int32.Parse(parts[0]);
                            a.LongitudeMinutes = Int32.Parse(parts[1]);
                            a.EW = Char.Parse(parts[2]);
                        }
                    }
                    aset.Add(a);
                }
                else
                {
                    Airfield a = AirfieldDAO.FindAirfieldByID(id);
                    aset.Add(a);
                }
            }
            else
            {
                aset.AddAll(SearchAifields(text));
                if (aset.Count == 0)
                {
                    String[] keywords = text.Split(", ".ToCharArray());
                    foreach (String s in keywords)
                    {
                        if (s.Length >= 3)
                        {
                            aset.AddAll(SearchAifields(s));
                        }
                    }
                }
            }
            return(aset);
        }
コード例 #2
0
        public static Airfield SaveAirfield(Airfield a)
        {
            Airfield at = AirfieldDAO.FindExactAirfield(a);

            if (at != null)
            {
                return(at);
            }
            else
            {
                a.ICAOCODE = "T-T" + GetAutoassignedNumberForTemporary();
                at         = AirfieldDAO.AddAirfield(a);
                return(at);
            }
        }
コード例 #3
0
        public static ListSet SearchAifields(String text)
        {
            ListSet          aset        = new ListSet();
            IList <Airfield> alistbyname = AirfieldDAO.FindByAirfieldName(text, "Start");

            if (alistbyname.Count > 0)
            {
                foreach (Airfield a in alistbyname)
                {
                    aset.Add(a);
                }
            }
            Airfield abyicao = AirfieldDAO.FindAirfieldByICAO(text);

            if (abyicao != null)
            {
                aset.Add(abyicao);
            }
            Airfield abyiata = AirfieldDAO.FindAirfieldByIATA(text);

            if (abyiata != null)
            {
                aset.Add(abyiata);
            }

            IList <Airfield> alistbycity = AirfieldDAO.FindAirfieldByCity(text, "");

            if (alistbycity.Count > 0)
            {
                foreach (Airfield a in alistbycity)
                {
                    aset.Add(a);
                }
            }
            if (aset.Count == 0)
            {
                IList <Airfield> alistbystate = AirfieldDAO.FindAirfieldByState(text, "");
                if (alistbystate.Count > 0)
                {
                    foreach (Airfield a in alistbystate)
                    {
                        aset.Add(a);
                    }
                }
            }
            return(aset);
        }
コード例 #4
0
        public static Int32 GetAutoassignedNumberForTemporary()
        {
            IList <Airfield> alist = AirfieldDAO.GetAutoassignedTemporary();
            Airfield         temp  = null;

            foreach (Airfield a in alist)
            {
                temp = a;
                break;
            }
            if (temp == null)
            {
                return(1);
            }
            else
            {
                String no = temp.ICAOCODE.Replace("T-T", "");
                return(Int32.Parse(no) + 1);
            }
        }
コード例 #5
0
 public static Airfield AirfieldFromAutoComplete(String text)
 {
     if (text.Contains("(") && text.Contains(")"))
     {
         String   id = text.Substring(text.LastIndexOf("(") + 1, text.LastIndexOf(")") - text.LastIndexOf("(") - 1);
         Airfield a  = AirfieldDAO.FindAirfieldByICAO(id);
         if (a != null)
         {
             return(a);
         }
         else
         {
             return(null);
         }
     }
     else
     {
         return(null);
     }
 }