예제 #1
0
        public string LocationsToString(FlightSample flightSample)
        {
            string location = flightSample.location.longtitude.ToString() + "," +
                              flightSample.location.latitude.ToString() + "," +
                              flightSample.altitude.ToString() + "," +
                              flightSample.direction.ToString() + "," +
                              flightSample.velocity.ToString();

            return(location);
        }
예제 #2
0
        public FlightSample CreateFlightSample()
        {
            rnd = new Random();
            FlightSample flightSample = new FlightSample((double)rnd.Next(1, 50), (double)rnd.Next(1, 50));

            flightSample.altitude  = (float)rnd.Next(1, 50);
            flightSample.direction = (float)rnd.Next(1, 50);
            flightSample.velocity  = (float)rnd.Next(1, 50);
            return(flightSample);
        }
예제 #3
0
        //converting FlightSample to XML
        string ToXml(FlightSample sample)
        {
            //Initiate XML stuff
            StringBuilder     sb       = new StringBuilder();
            XmlWriterSettings settings = new XmlWriterSettings();
            XmlWriter         writer   = XmlWriter.Create(sb, settings);

            writer.WriteStartDocument();
            sample.ToXml(writer);
            writer.WriteEndDocument();
            writer.Flush();

            return(sb.ToString());
        }
예제 #4
0
        public void SaveLocations(FlightSample flightSample, string fileName, bool toCreateFile)
        {
            string location = LocationsToString(flightSample);
            string path     = HttpContext.Current.Server.MapPath(String.Format(SCENARIO_FILE, fileName));

            if (toCreateFile)
            {
                if (File.Exists(path))
                {
                    File.Delete(path);
                }
            }
            using (System.IO.StreamWriter file = new System.IO.StreamWriter(path, true))
            {
                file.WriteLine(location);
            }
        }
예제 #5
0
 public void SaveLocation(FlightSample flightSample, string fileName, bool toCreateFile)
 {
     infoModel = InfoModel.Instance;
     infoModel.SaveLocations(flightSample, fileName, toCreateFile);
 }
예제 #6
0
        public void GetLocation(string fileName, bool toCreateFile)
        {
            FlightSample flightSample = CreateFlightSample();

            SaveLocation(flightSample, fileName, toCreateFile);
        }