Beispiel #1
0
        public async Task WriteFileAsync(string jsonString)
        {
            StorageFile copyTemp = await folder.CreateFileAsync("temp.json", CreationCollisionOption.ReplaceExisting);

            try
            {
                try
                {
                    try
                    {
                        //MessageDialogHelper.Show(jsonString, "");
                        using (StreamWriter sWriter = new StreamWriter(await copyTemp.OpenStreamForWriteAsync()))
                        {
                            await sWriter.WriteAsync(jsonString);
                        }
                    }
                    catch (System.Exception e)
                    {
                        MessageDialogHelper.Show(e.Message, e.Source);
                    }
                }
                catch (System.IO.FileNotFoundException e)
                {
                    MessageDialogHelper.Show(e.Message, e.Source);
                }
            }
            catch (System.UnauthorizedAccessException e)
            {
                MessageDialogHelper.Show(e.Message, e.Source);
            }
            await copyTemp.CopyAndReplaceAsync(file);

            IInputStream inputStream = await file.OpenAsync(FileAccessMode.Read);

            HttpMultipartFormDataContent multipartContent = new HttpMultipartFormDataContent();

            multipartContent.Add(new HttpStreamContent(inputStream), "myFile", file.Name);

            HttpClient          client   = new HttpClient();
            HttpResponseMessage response = await client.PostAsync(new Uri("http://mypoi.ugu.pl/main.php"), multipartContent);
        }
Beispiel #2
0
 public async Task <String> ReadFileAsync()
 {
     try
     {
         try
         {
             using (StreamReader sRead = new StreamReader(await file.OpenStreamForReadAsync()))
             {
                 jsonText = await sRead.ReadToEndAsync();
             }
         }
         catch (System.Exception e)
         {
             MessageDialogHelper.Show(e.Message, e.Source);
         }
     }
     catch (System.UnauthorizedAccessException e)
     {
         MessageDialogHelper.Show(e.Message, e.Source);
     }
     return(jsonText);
 }
Beispiel #3
0
        public async Task <LocalizationHelper> SetMyGeopositionAsync()
        {
            if (myGeolocator == null)
            {
                myGeolocator = new Geolocator();
                myGeolocator.DesiredAccuracyInMeters = 50;
                try
                {
                    myGeoposition = await myGeolocator.GetGeopositionAsync(maximumAge : TimeSpan.FromMinutes(5), timeout : TimeSpan.FromSeconds(10));
                }
                catch (Exception ex)
                {
                    MessageDialogHelper.Show(ex.Message, ex.GetType().ToString());
                }
            }

            if (myGeolocator != null)
            {
                myGeolocator.MovementThreshold = 3.0;
                myGeolocator.PositionChanged  += new TypedEventHandler <Geolocator, PositionChangedEventArgs>(myGeolocator_PositionChanged);
            }
            return(this);
        }