コード例 #1
0
        void Client_GetUserInfoCompleted(object sender, GetUserInfoCompletedEventArgs e)
        {
            try {
                ProxyTracker.GetInstance().Name = e.Result.Name;

                txtWelcome.Text = "Welcome " + e.Result.Name + ", you're connected!";
            }
            catch { }
        }
コード例 #2
0
 private void btnSendActivation_Click(object sender, RoutedEventArgs e)
 {
     if (txtName.Text.Trim() != "" && txtEmailAddress.Text.Trim() != "")
     {
         ProxyTracker.GetInstance().Client.RegisterUserCompleted += Client_RegisterUserCompleted;
         ProxyTracker.GetInstance().Client.RegisterUserAsync(ProxyTracker.GetInstance().GetDeviceId(), "", txtName.Text.Trim(), txtEmailAddress.Text.Trim());
     }
     else
     {
         SetMessage(MessageType.Error, "❎ Name and Email Address cannot be set empty, please enter complete information");
     }
 }
コード例 #3
0
 void CheckAccountStatus()
 {
     try {
         ProxyTracker.GetInstance().Client.IsUserRegisteredCompleted += Client_IsUserRegisteredCompleted;
         ProxyTracker.GetInstance().Client.IsUserRegisteredAsync(ProxyTracker.GetInstance().GetDeviceId());
     }
     catch (Exception)
     {
         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;
     }
 }
コード例 #4
0
 private void ApplicationBarMenuItemDeactivateAccount_Click(object sender, EventArgs e)
 {
     try
     {
         MessageBoxResult result = MessageBox.Show("Are you sure to deactivate your account. Next time when you reopen the application, it will ask you to register again?", "Confirmation", MessageBoxButton.OKCancel);
         if (result == MessageBoxResult.OK)
         {
             ProxyTracker.GetInstance().Client.DeactivateUserAccountCompleted += Client_DeactivateUserAccountCompleted;
             ProxyTracker.GetInstance().Client.DeactivateUserAccountAsync(ProxyTracker.GetInstance().GetDeviceId());
         }
     }
     catch { MessageBox.Show("❎ Sorry, we couldnt process your request at this time. Please check your internet connection or try again later", "Error", MessageBoxButton.OK); }
 }
コード例 #5
0
        void Client_IsUserActivatedCompleted(object sender, IsUserActivatedCompletedEventArgs e)
        {
            if (e.Result == false)
            {
                txtName.IsEnabled = false;
                // txtEmailAddress.IsEnabled = false;
                btnSendActivation.Content = "Resend Code";
                // txtActivationCode.IsEnabled = true;
                btnCompleteRegistration.IsEnabled = true;

                ProxyTracker.GetInstance().Client.GetUserInfoCompleted += Client_GetUserInfoCompleted;
                ProxyTracker.GetInstance().Client.GetUserInfoAsync(deviceId);
            }
        }
コード例 #6
0
 void CheckIfUserActivated()
 {
     try
     {
         ProxyTracker.GetInstance().Client.IsUserRegisteredCompleted += Client_IsUserRegisteredCompleted;
         ProxyTracker.GetInstance().Client.IsUserRegisteredAsync(deviceId);
     }
     catch (Exception ex)
     {
         ProxyTracker.GetInstance().Client.IsUserRegisteredCompleted -= Client_IsUserRegisteredCompleted;
         SetMessage(MessageType.Warning, "❎ Sorry, we couldn't connect to the service at this time. Trying again...");
         CheckIfUserActivated();
     }
 }
コード例 #7
0
 void Client_IsUserRegisteredCompleted(object sender, IsUserRegisteredCompletedEventArgs e)
 {
     try
     {
         if (e.Result == true)
         {
             ProxyTracker.GetInstance().Client.IsUserActivatedCompleted += Client_IsUserActivatedCompleted;
             ProxyTracker.GetInstance().Client.IsUserActivatedAsync(deviceId);
         }
     }
     catch
     {
         ProxyTracker.GetInstance().Client.IsUserRegisteredCompleted -= Client_IsUserRegisteredCompleted;
         SetMessage(MessageType.Warning, "❎ Sorry, we couldn't connect to the service at this time. Trying again...");
         CheckIfUserActivated();
     }
 }
コード例 #8
0
 private void btnSendCompleteRegistration_Click(object sender, RoutedEventArgs e)
 {
     try
     {
         if (txtActivationCode.Text.Trim() != "")
         {
             txtMessage.Text = "Finalizing Registration process...";
             ProxyTracker.GetInstance().Client.UpdateIsActivatedCompleted += Client_UpdateIsActivatedCompleted;
             ProxyTracker.GetInstance().Client.UpdateIsActivatedAsync(deviceId, txtActivationCode.Text.Trim());
         }
         else
         {
             SetMessage(MessageType.Error, "❎ Please enter valid activation code");
         }
     }
     catch (Exception)
     {
         SetMessage(MessageType.Error, "❎ Sorry, we couldnt process your request at this time. Please check your internet connection or try again later");
     }
 }
コード例 #9
0
 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;
     }
 }
コード例 #10
0
 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;
 }
コード例 #11
0
        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();
            }
        }
コード例 #12
0
        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 { }
        }
コード例 #13
0
        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 { }
        }
コード例 #14
0
 public Registration()
 {
     InitializeComponent();
     deviceId = ProxyTracker.GetInstance().GetDeviceId().ToString();
     CheckIfUserActivated();
 }
コード例 #15
0
 public static ProxyTracker GetInstance()
 {
     lock (_lock) {
         return(_instance = (_instance == null) ? new ProxyTracker() : _instance);
     }
 }
コード例 #16
0
        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 { }
        }