void Client_IsUserRegisteredCompleted(object sender, Services.TrackService.IsUserRegisteredCompletedEventArgs e) { try { if ((bool)e.Result == true) { ProxyTracker.GetInstance().Client.IsUserActivatedCompleted += Client_IsUserActivatedCompleted; ProxyTracker.GetInstance().Client.IsUserActivatedAsync(ProxyTracker.GetInstance().GetDeviceId().ToString()); } else { this.NavigationService.Navigate(new Uri("/Registration.xaml", UriKind.Relative)); } } catch (Exception ex) { SetMessage(MessageType.Error, "❎ Sorry, we couldnt process your request at this time. Please check your internet connection or try again later"); btnRetry.Visibility = Visibility.Visible; } }
private void btnSendActivation_Click_1(object sender, RoutedEventArgs e) { if (txtName.Text.Trim() != "" && txtEmailAddress.Text.Trim() != "") { if (!Regex.IsMatch(txtEmailAddress.Text.Trim(), "^[_A-Za-z0-9-\\+]+(\\.[_A-Za-z0-9-]+)*@[A-Za-z0-9-]+(\\.[A-Za-z0-9]+)*(\\.[A-Za-z]{2,})$")) { SetMessage(MessageType.Error, "❎ Email Address is not valid, please enter valid email address"); btnSendActivation.IsEnabled = true; return; } } else { SetMessage(MessageType.Error, "❎ Name and Email Address cannot be empty, please enter correct information"); btnSendActivation.IsEnabled = true; return; } btnSendActivation.IsEnabled = false; if (btnSendActivation.Content.ToString().Equals("Register")) { txtMessage.Text = "Registering..."; ProxyTracker.GetInstance().Client.RegisterUserCompleted += Client_RegisterUserCompleted; ProxyTracker.GetInstance().Client.RegisterUserAsync(ProxyTracker.GetInstance().GetDeviceId(), "", txtName.Text.Trim(), txtEmailAddress.Text.Trim()); } else { try { txtMessage.Text = "Resending activation code..."; ProxyTracker.GetInstance().Client.ResendCodeCompleted += Client_ResendCodeCompleted; ProxyTracker.GetInstance().Client.ResendCodeAsync(deviceId, txtEmailAddress.Text.Trim()); } catch (Exception ex) { SetMessage(MessageType.Error, "❎ Sorry, we couldnt process your request at this time. Please check your internet connection or try again later"); } } btnSendActivation.IsEnabled = true; }
void Client_StartTrackingCompleted(object sender, Services.TrackService.StartTrackingCompletedEventArgs e) { long trackNo = (long)e.Result; if (trackNo > 0) { ProxyTracker.GetInstance().Client.GetUserInfoCompleted += Client_GetUserInfoCompleted; ProxyTracker.GetInstance().Client.GetUserInfoAsync(ProxyTracker.GetInstance().GetDeviceId()); txtMyTrackId.Text = "Your TrackViewer ID is " + trackNo.ToString(); txtTrackId.Visibility = Visibility.Visible; btnTrack.Visibility = Visibility.Visible; txtEnterUserTrackID.Visibility = Visibility.Visible; chkTracking.Visibility = Visibility.Visible; txtMyTrackId.Visibility = Visibility.Visible; imgLoading.Visibility = Visibility.Collapsed; ProxyTracker.GetInstance().MyTrackId = Convert.ToInt64(trackNo); PostTrackingInfo(); FetchTrackingInfo(); } }
void timer_TickFetch(object sender, object e) { try { long trackId = 0; if (txtTrackId.Text != "" && btnTrack.Content.ToString().Equals("❌")) { ProxyTracker.GetInstance().Client.GetTrackingInfoCompleted += Client_GetTrackingInfoCompleted; if (Int64.TryParse(txtTrackId.Text, out trackId)) { ProxyTracker.GetInstance().Client.GetTrackingInfoAsync(Convert.ToInt64(txtTrackId.Text)); } else { SetMessage(MessageType.Error, "❎ TrackViewer ID entered is invalid"); btnTrack_Click(sender, null); } } } catch { } }
async void timer_Tick(object sender, object e) { try { if (chkTracking.IsChecked == true) { Geoposition pos = await _geolocator.GetGeopositionAsync().AsTask(token); System.Device.Location.GeoCoordinate location = new System.Device.Location.GeoCoordinate(pos.Coordinate.Latitude, pos.Coordinate.Longitude); ProxyTracker.GetInstance().MyTrackLocation = new Services.TrackService.TrackLocation { Latitude = location.Latitude, Longitude = location.Longitude }; ProxyTracker.GetInstance().Client.PublishTrackingInfoAsync(ProxyTracker.GetInstance().MyTrackId, ProxyTracker.GetInstance().MyTrackLocation); } if (!btnTrack.Content.ToString().Equals("❌")) { SetCurrentLocation(); } } catch { } }
public Registration() { InitializeComponent(); deviceId = ProxyTracker.GetInstance().GetDeviceId().ToString(); CheckIfUserActivated(); }
async void SetCurrentLocation() { try { if (!btnTrack.Content.Equals("➤")) { return; } foreach (var children in trvMap.Children) { if (children.GetType().Name == "LocationIcon100m") { trvMap.Children.Remove(children); break; } } // Get the cancellation token. _cts = new CancellationTokenSource(); token = _cts.Token; // Get the location. var asyncResult = _geolocator.GetGeopositionAsync(); var task = asyncResult.AsTask(); var readyTask = await Task.WhenAny(task, Task.Delay(10000)); if (readyTask != task) { SetMessage(MessageType.Error, "❎ Unable to find your location, trying again..."); SetCurrentLocation(); } Geoposition pos = await task; //Geoposition pos = await _geolocator.GetGeopositionAsync().AsTask(token); // MessageTextbox.Text = ""; System.Device.Location.GeoCoordinate location = new System.Device.Location.GeoCoordinate(pos.Coordinate.Latitude, pos.Coordinate.Longitude); ProxyTracker.GetInstance().MyTrackLocation = new Services.TrackService.TrackLocation { Latitude = pos.Coordinate.Latitude, Longitude = pos.Coordinate.Longitude }; // Now set the zoom level of the map based on the accuracy of our location data. // Default to IP level accuracy. We only show the region at this level - No icon is displayed. double zoomLevel = 13.0f; //// if we have GPS level accuracy Callout callout = new Callout(); callout.Text = "My Location"; callout.Lon = "Lon (λ): " + location.Longitude.ToString().Substring(0, 7); callout.Lat = "Lat (φ): " + location.Latitude.ToString().Substring(0, 7); _locationIcon100m.DataContext = callout; // Add the 100m icon and zoom a little closer. trvMap.Children.Add(_locationIcon100m); MapLayer.SetPosition(_locationIcon100m, location); zoomLevel = 17.0f; // Set the map to the given location and zoom level. trvMap.SetView(location, zoomLevel); try { ProxyTracker.GetInstance().Client.StartTrackingCompleted += Client_StartTrackingCompleted; ProxyTracker.GetInstance().Client.StartTrackingAsync(ProxyTracker.GetInstance().GetDeviceId(), ProxyTracker.GetInstance().MyTrackLocation); } catch (Exception ex) { MapCurrentLocation(); } } catch { } }