Esempio n. 1
0
        public void locationUpdate_Elapsed(object sender, System.Timers.ElapsedEventArgs e)
        {
            if (network.checkForNetwork)
            {
                Intent i = new Intent(context, typeof(geolocation));
                context.StartActivity(i);
                LOLConnectClient service = new LOLConnectClient(LOLConstants.DefaultHttpBinding, LOLConstants.LOLConnectEndpoint);
                Task.Factory.StartNew(() => {

                    Task<LOLAccountManagement.GeneralError> task =
                        service.CallAsyncMethod<LOLAccountManagement.GeneralError, UserUpdateLocationCompletedEventArgs>((s, h, b) => {

                        if (b)
                        {
                            s.UserUpdateLocationCompleted += h;
                        } else
                        {
                            s.UserUpdateLocationCompleted -= h;
                        }//end if else

                    }, (s) => {

                        s.UserUpdateLocationAsync(AndroidData.CurrentUser.AccountID,
                                                       AndroidData.GeoLocation [0],
                                                       AndroidData.GeoLocation [1],
                                                       new Guid(AndroidData.ServiceAuthToken));

                    });

                    try
                    {
                        LOLAccountManagement.GeneralError result = task.Result;
                        if (result.ErrorType != LOLCodeLibrary.ErrorsManagement.SystemTypesErrorMessage.NoErrorDetected)
                        {
            #if DEBUG
                            Console.WriteLine("Error updating user's location! {0}", result.ErrorType);
            #endif
                        }

                    } catch (Exception ex)
                    {
            #if DEBUG
                        Console.WriteLine("Exception updating user's location. {0}--{1}", ex.Message, ex.StackTrace);
            #endif
                    } finally
                    {
                        service.Close();
                    }
                });
            }
        }