Пример #1
0
        public void Pull()
        {
            foreach (Airport apAp in Airport.listSorted)
            {
                apAp.Reset();
            }

            Client.Reset();
            Pilot.Reset();
            FPlan.ResetPrefiles();
            ATC.Reset();
            ATC.ResetOBS();
            Server.Reset();

            int intCurrent = 0;

            Random rndTemp  = new Random();
            int    intIndex = rndTemp.Next(0, listFull.Count - 1);

            WebClient wcTemp = new WebClient();
            string    strRaw = wcTemp.DownloadString(listFull[intIndex]);

            foreach (string strStr in strRaw.Split(new string[] { "\n" }, StringSplitOptions.None))
            {
                if (strStr.Length != 0 && strStr[0] != ';')
                {
                    if (strStr[0] == '!')
                    {
                        switch (strStr.Substring(1, 7))
                        {
                        case "GENERAL":
                            intCurrent = 1;
                            break;

                        case "CLIENTS":
                            intCurrent = 2;
                            break;

                        case "SERVERS":
                            intCurrent = 3;
                            break;

                        case "PREFILE":
                            intCurrent = 4;
                            break;
                        }
                    }
                    else
                    {
                        string[] strarrTemp;
                        switch (intCurrent)
                        {
                        case 1:
                            strarrTemp = Regex.Replace(strStr, @"\s+", "").Split('=');
                            switch (strarrTemp[0])
                            {
                            case "VERSION":
                                intVersion = int.Parse(strarrTemp[1], DataCulture);

                                //if (intVersion != Properties.Settings.Default.DataVersion)
                                //{
                                //MessageBox.Show("This version of VATGlasses was designed for an old version of the VATSIM.net Status API. Please update to the latest version. If this is currently the latest version, please submit a bug report at our website.", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
                                //Environment.Exit(0);
                                //}

                                break;

                            case "RELOAD":
                                decReload = decimal.Parse(strarrTemp[1], DataCulture);
                                break;

                            case "UPDATE":
                                dtUpdate = new DateTime(int.Parse(strarrTemp[1].Substring(0, 4), DataCulture), int.Parse(strarrTemp[1].Substring(4, 2), DataCulture), int.Parse(strarrTemp[1].Substring(6, 2), DataCulture), int.Parse(strarrTemp[1].Substring(8, 2), DataCulture), int.Parse(strarrTemp[1].Substring(10, 2), DataCulture), int.Parse(strarrTemp[1].Substring(12, 2), DataCulture));
                                break;

                            case "CONNECTEDCLIENTS":
                                intConnected = int.Parse(strarrTemp[1], DataCulture);
                                break;

                            default:
                                break;
                            }
                            break;

                        case 2:
                            strarrTemp = strStr.Split(':');
                            Client cltTemp = null;

                            if (strarrTemp[3] == "PILOT")
                            {
                                cltTemp = new Pilot(strarrTemp);
                                Pilot.Add((Pilot)cltTemp);
                            }
                            else if (strarrTemp[3] == "ATC")
                            {
                                if (isATC(strarrTemp[0], strarrTemp[18]))
                                {
                                    cltTemp = ATC.Add(strarrTemp, false);
                                }
                                else
                                {
                                    cltTemp = ATC.Add(strarrTemp, true);
                                }
                            }

                            int intCID = -1;
                            int.TryParse(strarrTemp[1], NumberStyles.None, DataCulture, out intCID);

                            //if (Client.listFavCSs.Contains(strarrTemp[0]) && Client.listFavCIDs.Contains(intCID))
                            //{
                            //    Client.listFavs.Add(new FavClient(cltTemp, cltTemp.strCallsign, intCID));
                            //}
                            //else if (Client.listFavCSs.Contains(strarrTemp[0]))
                            //{
                            //    Client.listFavs.Add(new FavClient(cltTemp, cltTemp.strCallsign, null));
                            //}
                            //else if (Client.listFavCIDs.Contains(intCID))
                            //{
                            //    Client.listFavs.Add(new FavClient(cltTemp, null, intCID));
                            //}
                            break;

                        case 3:
                            Server.Add(new Server(strStr.Split(':')));
                            break;

                        case 4:
                            FPlan.AddPrefile(new FPlan(strStr.Split(':')));
                            break;

                        default:
                            break;
                        }
                    }
                }
            }

            Pilot.SortList();
            ATC.SortList();
            Controller.AssignAll();
            Airport.AssignTopDown();
            Client.UpdateFavs();
        }
Пример #2
0
 public static void AddPrefile(FPlan _prefile)
 {
     prefiles.Add(_prefile);
 }