Пример #1
0
        internal void DisconnectAccount()
        {
            mobileService.Logout();
            LiveAuthenticator.Logout();
            this.user            = null;
            this.data.LogInKnown = false;
            this.data.User.AuthenticationUserId = "";
            this.data.User.Id     = 0;
            this.data.User.UserId = "";
            this.data.Queries.Clear();
            this.data.FriendsCache = new ObservableCollection <Person>();
            AcquirePushChannelAsync();

            foreach (var taskAssignedTo in this.data.TaskAssignedToRelationship)
            {
                taskAssignedTo.PersonUserId = this.data.User.UserId;
            }
            foreach (var task in this.data.Tasks)
            {
                task.CreatorUserId = this.data.User.UserId;
            }
            NotifyPropertyChanged("LogInKnown");
            NotifyPropertyChanged("Friends");

            this.Save();
        }
Пример #2
0
        private async System.Threading.Tasks.Task AuthenticateSilent()
        {
            if (this.LogInKnown &&
                Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType !=
                Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None && this.user == null)
            {
                //LogIn bekannt aber Fehlschlag braucht keine Reaktion, dann geht die App einfach in den Offline Modus.
                this.user = await LiveAuthenticator.AuthenticateSilent(this.mobileService);
            }

            if (this.user != null)
            {
                await LogInSuccessful();
            }

            this.StartSyncing();
        }
Пример #3
0
        internal async System.Threading.Tasks.Task Authenticate()
        {
            if (Microsoft.Phone.Net.NetworkInformation.NetworkInterface.NetworkInterfaceType !=
                Microsoft.Phone.Net.NetworkInformation.NetworkInterfaceType.None)
            {
                if (this.user == null)
                {
                    this.user = await LiveAuthenticator.Authenticate(this.mobileService);

                    if (this.user != null)
                    {
                        await LogInSuccessful();
                    }
                }
            }

            this.StartSyncing();
        }
Пример #4
0
        private async System.Threading.Tasks.Task LogInSuccessful()
        {
            Diagnostics.ProfilingTakeTime("LogInSuccessful Start");

            //Userdaten checken.
            var personTable = this.mobileService.GetTable <Person>();
            var results     = await personTable.Where(p => p.UserId == this.user.UserId).ToEnumerableAsync();

            if (results.Any())
            {
                //Online Userinformationen weitgehend übernehmen.
                var oldUser = this.data.User;
                this.data.User = results.First();

                //Übernehme immer den höheren Score :D
                if (oldUser.Score > this.data.User.Score)
                {
                    this.data.User.Score = oldUser.Score;
                }
            }
            else
            {
                //FirstLogin, User unbekannt oder gelöscht.
                //Nicht weiter drum kümmern ob bestehende Daten hochgeladen werden oder nicht.
                //Notifikation Channel steht.
                this.data.User = await LiveAuthenticator.GetNewUserData(this.user.UserId, "", this.User.Score, this.User.AccountCreatedDate);

                await personTable.InsertAsync(this.data.User);
            }
            Diagnostics.ProfilingTakeTime("LogInSuccessful User Update");

            //Fertig eingeloggt
            data.LogInKnown = true;
            NotifyPropertyChanged("LogInKnown");
            NotifyPropertyChanged("LoggedIn");
            NotifyPropertyChanged("User");

            //Push Notification Channel
            AcquirePushChannelAsync();
            Diagnostics.ProfilingTakeTime("LogInSuccessful Ended");
        }