diff --git a/main/Libs/Hammock-Binaries/.NET 2.0/Hammock.dll b/main/Libs/Hammock-Binaries/.NET 2.0/Hammock.dll deleted file mode 100644 index 3665ed6..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 2.0/Hammock.dll and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 2.0/Hammock.pdb b/main/Libs/Hammock-Binaries/.NET 2.0/Hammock.pdb deleted file mode 100644 index 7580c6e..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 2.0/Hammock.pdb and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 2.0/LinqBridge.dll b/main/Libs/Hammock-Binaries/.NET 2.0/LinqBridge.dll deleted file mode 100644 index bf038c2..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 2.0/LinqBridge.dll and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 3.5 SP1/.NET Framework 3.5/Hammock.dll b/main/Libs/Hammock-Binaries/.NET 3.5 SP1/.NET Framework 3.5/Hammock.dll deleted file mode 100644 index 9f73af2..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 3.5 SP1/.NET Framework 3.5/Hammock.dll and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 3.5 SP1/.NET Framework 3.5/Hammock.pdb b/main/Libs/Hammock-Binaries/.NET 3.5 SP1/.NET Framework 3.5/Hammock.pdb deleted file mode 100644 index dca6b5d..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 3.5 SP1/.NET Framework 3.5/Hammock.pdb and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 3.5 SP1/Client Profile/Hammock.ClientProfile.dll b/main/Libs/Hammock-Binaries/.NET 3.5 SP1/Client Profile/Hammock.ClientProfile.dll deleted file mode 100644 index 45e3278..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 3.5 SP1/Client Profile/Hammock.ClientProfile.dll and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 3.5 SP1/Client Profile/Hammock.ClientProfile.pdb b/main/Libs/Hammock-Binaries/.NET 3.5 SP1/Client Profile/Hammock.ClientProfile.pdb deleted file mode 100644 index 3ebf241..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 3.5 SP1/Client Profile/Hammock.ClientProfile.pdb and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 3.5 SP1/Silverlight 3/Hammock.Silverlight.dll b/main/Libs/Hammock-Binaries/.NET 3.5 SP1/Silverlight 3/Hammock.Silverlight.dll deleted file mode 100644 index 8a424e2..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 3.5 SP1/Silverlight 3/Hammock.Silverlight.dll and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 3.5 SP1/Silverlight 3/Hammock.Silverlight.pdb b/main/Libs/Hammock-Binaries/.NET 3.5 SP1/Silverlight 3/Hammock.Silverlight.pdb deleted file mode 100644 index 85454d2..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 3.5 SP1/Silverlight 3/Hammock.Silverlight.pdb and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 3.5 SP1/Silverlight 3/ICSharpCode.SharpZipLib.Silverlight.dll b/main/Libs/Hammock-Binaries/.NET 3.5 SP1/Silverlight 3/ICSharpCode.SharpZipLib.Silverlight.dll deleted file mode 100644 index a76bb3a..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 3.5 SP1/Silverlight 3/ICSharpCode.SharpZipLib.Silverlight.dll and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 3.5 SP1/Silverlight 3/ICSharpCode.SharpZipLib.Silverlight.pdb b/main/Libs/Hammock-Binaries/.NET 3.5 SP1/Silverlight 3/ICSharpCode.SharpZipLib.Silverlight.pdb deleted file mode 100644 index 0a41296..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 3.5 SP1/Silverlight 3/ICSharpCode.SharpZipLib.Silverlight.pdb and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 4.0/.NET Framework 4.0/Hammock.dll b/main/Libs/Hammock-Binaries/.NET 4.0/.NET Framework 4.0/Hammock.dll deleted file mode 100644 index 55e87b4..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 4.0/.NET Framework 4.0/Hammock.dll and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 4.0/.NET Framework 4.0/Hammock.pdb b/main/Libs/Hammock-Binaries/.NET 4.0/.NET Framework 4.0/Hammock.pdb deleted file mode 100644 index 2e195ac..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 4.0/.NET Framework 4.0/Hammock.pdb and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 4.0/Client Profile/Hammock.ClientProfile.dll b/main/Libs/Hammock-Binaries/.NET 4.0/Client Profile/Hammock.ClientProfile.dll deleted file mode 100644 index 9c3ca8a..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 4.0/Client Profile/Hammock.ClientProfile.dll and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 4.0/Client Profile/Hammock.ClientProfile.pdb b/main/Libs/Hammock-Binaries/.NET 4.0/Client Profile/Hammock.ClientProfile.pdb deleted file mode 100644 index 2f08615..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 4.0/Client Profile/Hammock.ClientProfile.pdb and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 4.0/Silverlight 4/Hammock.Silverlight.dll b/main/Libs/Hammock-Binaries/.NET 4.0/Silverlight 4/Hammock.Silverlight.dll deleted file mode 100644 index 47a1374..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 4.0/Silverlight 4/Hammock.Silverlight.dll and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 4.0/Silverlight 4/Hammock.Silverlight.pdb b/main/Libs/Hammock-Binaries/.NET 4.0/Silverlight 4/Hammock.Silverlight.pdb deleted file mode 100644 index 9a7b810..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 4.0/Silverlight 4/Hammock.Silverlight.pdb and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 4.0/Silverlight 4/ICSharpCode.SharpZipLib.Silverlight.dll b/main/Libs/Hammock-Binaries/.NET 4.0/Silverlight 4/ICSharpCode.SharpZipLib.Silverlight.dll deleted file mode 100644 index f8a2806..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 4.0/Silverlight 4/ICSharpCode.SharpZipLib.Silverlight.dll and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 4.0/Silverlight 4/ICSharpCode.SharpZipLib.Silverlight.pdb b/main/Libs/Hammock-Binaries/.NET 4.0/Silverlight 4/ICSharpCode.SharpZipLib.Silverlight.pdb deleted file mode 100644 index 501b381..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 4.0/Silverlight 4/ICSharpCode.SharpZipLib.Silverlight.pdb and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 4.0/Windows Phone 7/Hammock.WindowsPhone.dll b/main/Libs/Hammock-Binaries/.NET 4.0/Windows Phone 7/Hammock.WindowsPhone.dll deleted file mode 100644 index eebed3b..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 4.0/Windows Phone 7/Hammock.WindowsPhone.dll and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 4.0/Windows Phone 7/Hammock.WindowsPhone.pdb b/main/Libs/Hammock-Binaries/.NET 4.0/Windows Phone 7/Hammock.WindowsPhone.pdb deleted file mode 100644 index 17d5ecd..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 4.0/Windows Phone 7/Hammock.WindowsPhone.pdb and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 4.0/Windows Phone 7/ICSharpCode.SharpZipLib.WindowsPhone.dll b/main/Libs/Hammock-Binaries/.NET 4.0/Windows Phone 7/ICSharpCode.SharpZipLib.WindowsPhone.dll deleted file mode 100644 index 11b3021..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 4.0/Windows Phone 7/ICSharpCode.SharpZipLib.WindowsPhone.dll and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/.NET 4.0/Windows Phone 7/ICSharpCode.SharpZipLib.WindowsPhone.pdb b/main/Libs/Hammock-Binaries/.NET 4.0/Windows Phone 7/ICSharpCode.SharpZipLib.WindowsPhone.pdb deleted file mode 100644 index 6d0fd48..0000000 Binary files a/main/Libs/Hammock-Binaries/.NET 4.0/Windows Phone 7/ICSharpCode.SharpZipLib.WindowsPhone.pdb and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/Mono 2.6/Hammock.Mono.dll b/main/Libs/Hammock-Binaries/Mono 2.6/Hammock.Mono.dll deleted file mode 100644 index 1e514a2..0000000 Binary files a/main/Libs/Hammock-Binaries/Mono 2.6/Hammock.Mono.dll and /dev/null differ diff --git a/main/Libs/Hammock-Binaries/Mono 2.6/Hammock.Mono.pdb b/main/Libs/Hammock-Binaries/Mono 2.6/Hammock.Mono.pdb deleted file mode 100644 index 1f5fad4..0000000 Binary files a/main/Libs/Hammock-Binaries/Mono 2.6/Hammock.Mono.pdb and /dev/null differ diff --git a/main/Libs/Hammock/wp7/Hammock.WindowsPhone.dll b/main/Libs/Hammock/wp7/Hammock.WindowsPhone.dll new file mode 100644 index 0000000..99ac7e8 Binary files /dev/null and b/main/Libs/Hammock/wp7/Hammock.WindowsPhone.dll differ diff --git a/main/Libs/Hammock/wp7/Hammock.WindowsPhone.pdb b/main/Libs/Hammock/wp7/Hammock.WindowsPhone.pdb new file mode 100644 index 0000000..ef687b9 Binary files /dev/null and b/main/Libs/Hammock/wp7/Hammock.WindowsPhone.pdb differ diff --git a/main/Libs/Hammock/wp7/ICSharpCode.SharpZipLib.WindowsPhone.dll b/main/Libs/Hammock/wp7/ICSharpCode.SharpZipLib.WindowsPhone.dll new file mode 100644 index 0000000..1d8c9f6 Binary files /dev/null and b/main/Libs/Hammock/wp7/ICSharpCode.SharpZipLib.WindowsPhone.dll differ diff --git a/main/Libs/Hammock/wp7/ICSharpCode.SharpZipLib.WindowsPhone.pdb b/main/Libs/Hammock/wp7/ICSharpCode.SharpZipLib.WindowsPhone.pdb new file mode 100644 index 0000000..db056c3 Binary files /dev/null and b/main/Libs/Hammock/wp7/ICSharpCode.SharpZipLib.WindowsPhone.pdb differ diff --git a/main/MyFriendsAround.WP7/App.xaml b/main/MyFriendsAround.WP7/App.xaml index 86e6d0e..96b5071 100644 --- a/main/MyFriendsAround.WP7/App.xaml +++ b/main/MyFriendsAround.WP7/App.xaml @@ -8,7 +8,9 @@ mc:Ignorable="d" xmlns:vm="clr-namespace:MyFriendsAround.WP7.ViewModel" xmlns:my="clr-namespace:Coding4Fun.Phone.Controls.Converters;assembly=Coding4Fun.Phone.Controls" - xmlns:my1="clr-namespace:Microsoft.Silverlight.Testing.Client;assembly=Microsoft.Silverlight.Testing"> + xmlns:my1="clr-namespace:Microsoft.Silverlight.Testing.Client;assembly=Microsoft.Silverlight.Testing" + xmlns:Controls="clr-namespace:Coding4Fun.Phone.Controls;assembly=Coding4Fun.Phone.Controls" + xmlns:Views="clr-namespace:MyFriendsAround.WP7.Views"> @@ -16,6 +18,8 @@ d:IsDataSource="True" /> + + diff --git a/main/MyFriendsAround.WP7/App.xaml.cs b/main/MyFriendsAround.WP7/App.xaml.cs index 13a2704..202d2aa 100644 --- a/main/MyFriendsAround.WP7/App.xaml.cs +++ b/main/MyFriendsAround.WP7/App.xaml.cs @@ -15,6 +15,7 @@ using Microsoft.Phone.Shell; using MyFriendsAround.WP7.ViewModel; using MyFriendsAround.WP7.Utils; using GalaSoft.MvvmLight.Threading; +using MyFriendsAround.WP7.Views; namespace MyFriendsAround.WP7 @@ -95,7 +96,7 @@ namespace MyFriendsAround.WP7 } else { - Container.Instance.RegisterInstance( new AboutViewModel(), "AboutViewModel"); + Container.Instance.RegisterInstance(new AboutViewModel(), "AboutViewModel"); } } @@ -109,6 +110,14 @@ namespace MyFriendsAround.WP7 // Code to execute if a navigation fails void RootFrame_NavigationFailed(object sender, NavigationFailedEventArgs e) { + //LittleWatson.ReportException(e.Exception, string.Empty); + DispatcherHelper.CheckBeginInvokeOnUI(() => + { + var exception = new ExceptionPrompt(); + exception.Show(e.Exception); + } + ); + if (System.Diagnostics.Debugger.IsAttached) { // A navigation has failed; break into the debugger @@ -119,11 +128,22 @@ namespace MyFriendsAround.WP7 // Code to execute on Unhandled Exceptions private void Application_UnhandledException(object sender, ApplicationUnhandledExceptionEventArgs e) { + //LittleWatson.ReportException(e.ExceptionObject, string.Empty); + + DispatcherHelper.CheckBeginInvokeOnUI(() => + { + var exception = new ExceptionPrompt(); + exception.Show(e.ExceptionObject); + } + ); + if (System.Diagnostics.Debugger.IsAttached) { // An unhandled exception has occurred; break into the debugger System.Diagnostics.Debugger.Break(); } + + e.Handled = true; } @@ -159,6 +179,8 @@ namespace MyFriendsAround.WP7 // Remove this handler since it is no longer needed RootFrame.Navigated -= CompleteInitializePhoneApplication; + // + //LittleWatson.CheckForPreviousException(); } #endregion diff --git a/main/MyFriendsAround.WP7/MyFriendsAround.WP7.csproj b/main/MyFriendsAround.WP7/MyFriendsAround.WP7.csproj index 89621a2..a622537 100644 --- a/main/MyFriendsAround.WP7/MyFriendsAround.WP7.csproj +++ b/main/MyFriendsAround.WP7/MyFriendsAround.WP7.csproj @@ -20,7 +20,7 @@ true true - MyFriendsAround.WP7.xap + MyFriendsAround.xap Properties\AppManifest.xml MyFriendsAround.WP7.App true @@ -77,12 +77,18 @@ False C:\Program Files\Laurent Bugnion (GalaSoft)\Mvvm Light Toolkit\Binaries\WP7\GalaSoft.MvvmLight.Extras.WP7.dll - - ..\Libs\Hammock-Binaries\.NET 4.0\Windows Phone 7\Hammock.WindowsPhone.dll + + ..\Libs\Hammock\wp7\Hammock.WindowsPhone.dll + + + ..\packages\Hammock.1.2.1\lib\sl4\ICSharpCode.SharpZipLib.Silverlight.dll ..\Libs\Hammock-Binaries\.NET 4.0\Windows Phone 7\ICSharpCode.SharpZipLib.WindowsPhone.dll + + ..\packages\Hammock.1.2.1\lib\sl4\Microsoft.CSharp.dll + ..\packages\Coding4Fun.Phone.Controls.Complete.1.2\lib\Microsoft.Phone.Controls.Toolkit.dll @@ -97,7 +103,13 @@ ..\Libs\Json40r1\WindowsPhone\Newtonsoft.Json.WindowsPhone.dll + + ..\packages\Hammock.1.2.1\lib\sl4\System.Json.dll + + + ..\packages\Hammock.1.2.1\lib\sl4\System.Runtime.Serialization.Json.dll + False @@ -111,6 +123,10 @@ + + True + ..\packages\Hammock.1.2.1\lib\sl4\System.Xml.Linq.dll + @@ -125,9 +141,15 @@ + + Code + AboutPage.xaml + + Code + MainPage.xaml @@ -150,6 +172,10 @@ MSBuild:Compile Designer + + MSBuild:Compile + Designer + Designer MSBuild:Compile diff --git a/main/MyFriendsAround.WP7/Properties/WMAppManifest.xml b/main/MyFriendsAround.WP7/Properties/WMAppManifest.xml index d6ddf84..9885f30 100644 --- a/main/MyFriendsAround.WP7/Properties/WMAppManifest.xml +++ b/main/MyFriendsAround.WP7/Properties/WMAppManifest.xml @@ -1,7 +1,6 @@  - - + ApplicationIcon.png @@ -13,11 +12,11 @@ - + - + diff --git a/main/MyFriendsAround.WP7/Service/FriendsListEventArgs.cs b/main/MyFriendsAround.WP7/Service/FriendsListEventArgs.cs index 4fd4612..2f39f13 100644 --- a/main/MyFriendsAround.WP7/Service/FriendsListEventArgs.cs +++ b/main/MyFriendsAround.WP7/Service/FriendsListEventArgs.cs @@ -16,5 +16,6 @@ namespace MyFriendsAround.WP7.Service public class FriendsListEventArgs: EventArgs { public List Friends { get; set; } + public Exception Error { get; set; } } } diff --git a/main/MyFriendsAround.WP7/Service/PublishLocationEventArgs.cs b/main/MyFriendsAround.WP7/Service/PublishLocationEventArgs.cs index 3c304a0..539c888 100644 --- a/main/MyFriendsAround.WP7/Service/PublishLocationEventArgs.cs +++ b/main/MyFriendsAround.WP7/Service/PublishLocationEventArgs.cs @@ -8,5 +8,6 @@ namespace MyFriendsAround.WP7.Service public class PublishLocationEventArgs: EventArgs { public bool IsSuccess { get; set; } + public Exception Error { get; set; } } } diff --git a/main/MyFriendsAround.WP7/Service/ServiceAgent.cs b/main/MyFriendsAround.WP7/Service/ServiceAgent.cs index 7e9a62b..eef9d78 100644 --- a/main/MyFriendsAround.WP7/Service/ServiceAgent.cs +++ b/main/MyFriendsAround.WP7/Service/ServiceAgent.cs @@ -1,27 +1,17 @@ using System; using System.Collections.Generic; using System.Net; -using System.Windows; -using System.Windows.Controls; -using System.Windows.Documents; -using System.Windows.Ink; -using System.Windows.Input; -using System.Windows.Media; -using System.Windows.Media.Animation; -using System.Windows.Shapes; using Hammock; -using Hammock.Streaming; -using Hammock.Tasks; using Hammock.Web; using MyFriendsAround.Common.Entities; -using Hammock.Caching; -using CacheMode = Hammock.Caching.CacheMode; namespace MyFriendsAround.WP7.Service { public static class ServiceAgent { + private static int _timeOut = 10; + #region GetFriends private static EventHandler friendscallback; @@ -32,15 +22,25 @@ namespace MyFriendsAround.WP7.Service RestClient client = new RestClient { Authority = "http://localhost.:55672/myfriends", + Timeout = new TimeSpan(0, 0, 0, _timeOut), Serializer = serializer, Deserializer = serializer }; RestRequest request = new RestRequest { - Path = "GetFriends" + "?timestamp=" + DateTime.Now.Ticks.ToString() + Path = "GetFriends" + "?timestamp=" + DateTime.Now.Ticks.ToString(), + Timeout = new TimeSpan(0, 0, 0, _timeOut) }; friendscallback = callback; - client.BeginRequest(request, new RestCallback>(GetFriendsCallback)); + try + { + client.BeginRequest(request, new RestCallback>(GetFriendsCallback)); + } + catch (Exception ex) + { + friendscallback.Invoke(null, new FriendsListEventArgs() { Friends = null, Error = ex }); + } + } public static void GetFriendsCallback(RestRequest request, RestResponse> response, object userState) @@ -50,6 +50,10 @@ namespace MyFriendsAround.WP7.Service List list = response.ContentEntity; friendscallback.Invoke(null, new FriendsListEventArgs() { Friends = list }); } + else + { + friendscallback.Invoke(null, new FriendsListEventArgs() { Friends = null, Error = new Exception("Communication Error!") }); + } } #endregion @@ -66,17 +70,27 @@ namespace MyFriendsAround.WP7.Service RestClient client = new RestClient { Authority = "http://localhost.:55672/myfriends", + Timeout = new TimeSpan(0, 0, 0, _timeOut), Serializer = serializer, Deserializer = serializer }; RestRequest request = new RestRequest { + Timeout = new TimeSpan(0, 0, 0, _timeOut), Method = WebMethod.Post, Path = "PublishLocation", Entity = friend }; publishlocationcallback = callback; - client.BeginRequest(request, new RestCallback(PublishLocationCallback)); + try + { + client.BeginRequest(request, new RestCallback(PublishLocationCallback)); + } + catch (Exception ex) + { + publishlocationcallback.Invoke(null, new PublishLocationEventArgs() { IsSuccess = false, Error = ex }); + } + } public static void PublishLocationCallback(RestRequest request, RestResponse response, object userState) @@ -86,6 +100,10 @@ namespace MyFriendsAround.WP7.Service bool success = response.ContentEntity; publishlocationcallback.Invoke(null, new PublishLocationEventArgs() { IsSuccess = success }); } + else + { + publishlocationcallback.Invoke(null, new PublishLocationEventArgs() { IsSuccess = false, Error = new Exception("Communication Error!")}); + } } #endregion diff --git a/main/MyFriendsAround.WP7/Themes/Generic.xaml b/main/MyFriendsAround.WP7/Themes/Generic.xaml new file mode 100644 index 0000000..863f508 --- /dev/null +++ b/main/MyFriendsAround.WP7/Themes/Generic.xaml @@ -0,0 +1,59 @@ + + + + + + + + \ No newline at end of file diff --git a/main/MyFriendsAround.WP7/Utils/LittleWatson.cs b/main/MyFriendsAround.WP7/Utils/LittleWatson.cs new file mode 100644 index 0000000..cfa1130 --- /dev/null +++ b/main/MyFriendsAround.WP7/Utils/LittleWatson.cs @@ -0,0 +1,82 @@ +using System; +using System.IO; +using System.IO.IsolatedStorage; +using System.Windows; +using Microsoft.Phone.Tasks; + +namespace MyFriendsAround.WP7.Utils +{ + public class LittleWatson + { + const string filename = "LittleWatson.txt"; + + internal static void ReportException(Exception ex, string extra) + { + try + { + using (var store = IsolatedStorageFile.GetUserStoreForApplication()) + { + SafeDeleteFile(store); + using (TextWriter output = new StreamWriter(store.CreateFile(filename))) + { + output.WriteLine(extra); + output.WriteLine(ex.Message); + output.WriteLine(ex.StackTrace); + } + } + } + catch (Exception) + { + } + } + + internal static void CheckForPreviousException() + { + try + { + string contents = null; + using (var store = IsolatedStorageFile.GetUserStoreForApplication()) + { + if (store.FileExists(filename)) + { + using (TextReader reader = new StreamReader(store.OpenFile(filename, FileMode.Open, FileAccess.Read, FileShare.None))) + { + contents = reader.ReadToEnd(); + } + SafeDeleteFile(store); + } + } + if (contents != null) + { + if (MessageBox.Show("A problem occurred the last time you ran this application. Would you like to send an email to report it?", "Problem Report", MessageBoxButton.OKCancel) == MessageBoxResult.OK) + { + EmailComposeTask email = new EmailComposeTask(); + email.To = "someone@example.com"; + email.Subject = "YourAppName auto-generated problem report"; + email.Body = contents; + SafeDeleteFile(IsolatedStorageFile.GetUserStoreForApplication()); // line added 1/15/2011 + email.Show(); + } + } + } + catch (Exception) + { + } + finally + { + SafeDeleteFile(IsolatedStorageFile.GetUserStoreForApplication()); + } + } + + private static void SafeDeleteFile(IsolatedStorageFile store) + { + try + { + store.DeleteFile(filename); + } + catch (Exception ex) + { + } + } + } +} diff --git a/main/MyFriendsAround.WP7/ViewModel/MainViewModel.cs b/main/MyFriendsAround.WP7/ViewModel/MainViewModel.cs index add22c6..386c31c 100644 --- a/main/MyFriendsAround.WP7/ViewModel/MainViewModel.cs +++ b/main/MyFriendsAround.WP7/ViewModel/MainViewModel.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Collections.ObjectModel; using System.Device.Location; using System.Net; +using System.Security; using System.ServiceModel.Channels; using System.Windows; using System.Windows.Input; @@ -17,6 +18,7 @@ using Microsoft.Silverlight.Testing; using MyFriendsAround.Common.Entities; using MyFriendsAround.WP7.Service; using MyFriendsAround.WP7.Utils; +using MyFriendsAround.WP7.Views; using Newtonsoft.Json; namespace MyFriendsAround.WP7.ViewModel @@ -59,7 +61,6 @@ namespace MyFriendsAround.WP7.ViewModel // PublishLocationCommand = new RelayCommand(() => PublishLocationAction()); DisplayAboutCommand = new RelayCommand(() => DisplayAbout()); - InputBoxCommand = new RelayCommand(() => InputBox()); NavigateToAboutCommand = new RelayCommand(() => NavigateToAbout()); RefreshFriendsCommand = new RelayCommand(() => RefreshFriends()); @@ -80,17 +81,12 @@ namespace MyFriendsAround.WP7.ViewModel ServiceAgent.GetFriends(this.GetFriendsResult); } - private void NavigateToAbout() + private void NavigateToAbout() { // this.PageNav.NavigateTo(new Uri("/Views/AboutPage.xaml", UriKind.Relative)); } - private void InputBox() - { - MessageBox.Show("Input box"); - } - private void DisplayAbout() { @@ -109,7 +105,7 @@ namespace MyFriendsAround.WP7.ViewModel PinSource = "/ApplicationIcon.png", Location = new GeoCoordinate(f.Latitude, f.Longitude) }); - }); + }); PushPins = result; } @@ -127,30 +123,60 @@ namespace MyFriendsAround.WP7.ViewModel public void GetFriendsResult(object sender, FriendsListEventArgs args) { - List list = args.Friends; - DispatcherHelper.CheckBeginInvokeOnUI(() => - { - PopulatePushPins(list); - IsBusy = false; - } - ); + if (args.Error == null) + { + List list = args.Friends; + DispatcherHelper.CheckBeginInvokeOnUI(() => + { + PopulatePushPins(list); + IsBusy = false; + } + ); + } + else + { + DispatcherHelper.CheckBeginInvokeOnUI(() => + { + IsBusy = false; + var exception = new ExceptionPrompt(); + exception.Show(args.Error); + } + ); + } } public void PublishLocationResult(object sender, PublishLocationEventArgs args) { - if (!args.IsSuccess) + if (args.Error != null) { - var message = new DialogMessage("Communication error!", DialogMessageCallback) - { - Button = MessageBoxButton.OK, - Caption = "Error!" - }; - - Messenger.Default.Send(message); + DispatcherHelper.CheckBeginInvokeOnUI(() => + { + IsBusy = false; + var exception = new ExceptionPrompt(); + exception.Show(args.Error); + }); } - // - //update - ServiceAgent.GetFriends(this.GetFriendsResult); + else + { + if (!args.IsSuccess) + { + DispatcherHelper.CheckBeginInvokeOnUI(() => + { + var message = new DialogMessage( + "Communication error!", DialogMessageCallback) + { + Button = MessageBoxButton.OK, + Caption = "Error!" + }; + + Messenger.Default.Send(message); + }); + } + // + //update + ServiceAgent.GetFriends(this.GetFriendsResult); + } + } private void DialogMessageCallback(MessageBoxResult result) @@ -167,7 +193,6 @@ namespace MyFriendsAround.WP7.ViewModel public ICommand PublishLocationCommand { get; set; } public ICommand DisplayAboutCommand { get; set; } - public ICommand InputBoxCommand { get; set; } public ICommand NavigateToAboutCommand { get; set; } public ICommand RefreshFriendsCommand { get; set; } @@ -198,7 +223,8 @@ namespace MyFriendsAround.WP7.ViewModel } - public string AppBarTextAbout { + public string AppBarTextAbout + { get { return "About"; } } @@ -260,7 +286,7 @@ namespace MyFriendsAround.WP7.ViewModel /// The property's name. /// public const string MapCenterPropertyName = "MapCenter"; - private GeoCoordinate _mapCenter = new GeoCoordinate(0,0); + private GeoCoordinate _mapCenter = new GeoCoordinate(0, 0); /// /// Gets the MapCenter property. diff --git a/main/MyFriendsAround.WP7/Views/ExceptionPrompt.cs b/main/MyFriendsAround.WP7/Views/ExceptionPrompt.cs new file mode 100644 index 0000000..62eccc9 --- /dev/null +++ b/main/MyFriendsAround.WP7/Views/ExceptionPrompt.cs @@ -0,0 +1,68 @@ +using System; +using System.Text; +using System.Windows; +using System.Windows.Controls; +using Coding4Fun.Phone.Controls; + +namespace MyFriendsAround.WP7.Views +{ + public class ExceptionPrompt: PopUp + { + + private Button okButton; + private CheckBox submitCheckBox; + private Exception exception; + + public ExceptionPrompt() + { + DefaultStyleKey = typeof(ExceptionPrompt); + DataContext = this; + } + + public override void OnApplyTemplate() + { + base.OnApplyTemplate(); + + if (okButton != null) + okButton.Click -= okButton_Click; + + okButton = GetTemplateChild("okButton") as Button; + submitCheckBox = GetTemplateChild("canSubmitCheckBox") as CheckBox; + + if (okButton != null) + okButton.Click += okButton_Click; + } + + public string To { get; set; } + + void okButton_Click(object sender, RoutedEventArgs e) + { + var message = new StringBuilder(); + message.Append("Exception type: "); + message.Append(exception.GetType()); + message.Append(Environment.NewLine); + message.Append("Message: "); + message.Append(exception.Message); + message.Append(Environment.NewLine); + message.Append("Stack trace: "); + message.Append(exception.StackTrace); + message.ToString(); + + var task = new Microsoft.Phone.Tasks.EmailComposeTask { Body = message.ToString(), Subject = "Error Report", To = To }; + + if (submitCheckBox.IsChecked == true) + { + task.Show(); + } + + OnCompleted(new PopUpEventArgs { PopUpResult = PopUpResult.Ok }); + } + + public void Show(Exception exception) + { + this.exception = exception; + base.Show(); + } + + } +} diff --git a/main/MyFriendsAround.WP7/Views/MainPage.xaml b/main/MyFriendsAround.WP7/Views/MainPage.xaml index ce18653..9bde0da 100644 --- a/main/MyFriendsAround.WP7/Views/MainPage.xaml +++ b/main/MyFriendsAround.WP7/Views/MainPage.xaml @@ -38,11 +38,11 @@ - + diff --git a/main/MyFriendsAround.WP7/Views/MainPage.xaml.cs b/main/MyFriendsAround.WP7/Views/MainPage.xaml.cs index 8a6d89a..9675a1e 100644 --- a/main/MyFriendsAround.WP7/Views/MainPage.xaml.cs +++ b/main/MyFriendsAround.WP7/Views/MainPage.xaml.cs @@ -1,9 +1,11 @@ using System; +using System.Security; using System.Windows; using GalaSoft.MvvmLight.Messaging; using GalaSoft.MvvmLight.Threading; using Microsoft.Phone.Controls; using Microsoft.Silverlight.Testing; +using MyFriendsAround.WP7.Views; namespace MyFriendsAround.WP7 {