Example #1
0
        private static SimpleGeoData CreateSimpleGeo(ISQLiteStatement stmt)
        {
            var basicGeo = new BasicGeoposition();

            basicGeo.Latitude  = (double)stmt[2];
            basicGeo.Longitude = (double)stmt[3];
            basicGeo.Altitude  = (double)stmt[4];

            var ret = new SimpleGeoData();

            ret.Position    = basicGeo;
            ret.DateCreated = DateTimeOffset.Parse((string)stmt[1]);
            return(ret);
        }
Example #2
0
        /// <summary>
        /// Save the BasicGeoposition list to roaming storage.
        /// </summary>
        /// <param name="locations">The BasicGeoposition list  to save.</param>
        public static async Task InsertLocationDataAsync(SimpleGeoData location)
        {
            StorageFile sampleFile = await ApplicationData.Current.RoamingFolder.CreateFileAsync(
                basicGeoLocationFileName, CreationCollisionOption.OpenIfExists);

            using (MemoryStream stream = new MemoryStream())
            {
                var serializer = new DataContractJsonSerializer(typeof(SimpleGeoData));
                serializer.WriteObject(stream, location);
                stream.Position = 0;
                using (StreamReader reader = new StreamReader(stream))
                {
                    string locationString = reader.ReadToEnd();
                    locationString = locationString + ",";
                    await FileIO.AppendTextAsync(sampleFile, locationString);
                }
            }
        }
Example #3
0
 /// <summary>
 /// Return true if statement successfuls
 /// </summary>
 /// <param name="simpleGeo"></param>
 /// <param name="db"></param>
 /// <returns></returns>
 public static bool InsertLocation(SimpleGeoData simpleGeo, SQLiteConnection db)
 {
     bool ret = false;
     try
     {
         using (var stmt = db.Prepare("INSERT INTO UserLocation (DateCreated, Lat, Long, Att) VALUES (?, ?, ?)"))
         {
             stmt.Bind(1, simpleGeo.DateCreated.ToString());
             stmt.Bind(2, simpleGeo.Position.Latitude.ToString());
             stmt.Bind(3, simpleGeo.Position.Longitude.ToString());
             stmt.Bind(4, simpleGeo.Position.Altitude.ToString());
             stmt.Step();
         }
         ret = true;
     }
     catch (Exception ex)
     {
         //TODO
     }
     return ret;
 }
Example #4
0
        /// <summary>
        /// Return true if statement successfuls
        /// </summary>
        /// <param name="simpleGeo"></param>
        /// <param name="db"></param>
        /// <returns></returns>
        public static bool InsertLocation(SimpleGeoData simpleGeo, SQLiteConnection db)
        {
            bool ret = false;

            try
            {
                using (var stmt = db.Prepare("INSERT INTO UserLocation (DateCreated, Lat, Long, Att) VALUES (?, ?, ?)"))
                {
                    stmt.Bind(1, simpleGeo.DateCreated.ToString());
                    stmt.Bind(2, simpleGeo.Position.Latitude.ToString());
                    stmt.Bind(3, simpleGeo.Position.Longitude.ToString());
                    stmt.Bind(4, simpleGeo.Position.Altitude.ToString());
                    stmt.Step();
                }
                ret = true;
            }
            catch (Exception ex)
            {
                //TODO
            }
            return(ret);
        }
Example #5
0
 /// <summary>
 /// Save the BasicGeoposition list to roaming storage. 
 /// </summary>
 /// <param name="locations">The BasicGeoposition list  to save.</param>
 public static async Task InsertLocationDataAsync(SimpleGeoData location)
 {
     StorageFile sampleFile = await ApplicationData.Current.RoamingFolder.CreateFileAsync(
         basicGeoLocationFileName, CreationCollisionOption.OpenIfExists);
     using (MemoryStream stream = new MemoryStream())
     {
         var serializer = new DataContractJsonSerializer(typeof(SimpleGeoData));
         serializer.WriteObject(stream, location);
         stream.Position = 0;
         using (StreamReader reader = new StreamReader(stream))
         {
             string locationString = reader.ReadToEnd();
             locationString = locationString + ",";
             await FileIO.AppendTextAsync(sampleFile, locationString);
         }
     }
 }
Example #6
0
        private void Geolocator_PositionChanged(Geolocator sender, PositionChangedEventArgs args)
        {
            var _ = Dispatcher.RunAsync(CoreDispatcherPriority.Normal, async () =>
            {
                if (args.Position.Coordinate.Accuracy < 55)
                {
                    var item = new SimpleGeoData
                    {
                        Position = args.Position.Coordinate.Point.Position
                    };
                    App.userLocData.Add(item);
                    await LocationDataStore.InsertLocationDataAsync(item);
                }

            });
        }
Example #7
0
        private static SimpleGeoData CreateSimpleGeo(ISQLiteStatement stmt)
        {
            var basicGeo = new BasicGeoposition();
            basicGeo.Latitude = (double)stmt[2];
            basicGeo.Longitude = (double)stmt[3];
            basicGeo.Altitude = (double)stmt[4];

            var ret = new SimpleGeoData();
            ret.Position = basicGeo;
            ret.DateCreated = DateTimeOffset.Parse((string)stmt[1]);
            return ret;
        }