Beispiel #1
0
        private void OnCompleteLookupName(NameRegistrationResult result)
        {
            NameRegistration nameRegistration = (NameRegistration)result.NameRegistration;

            if (result.Status == Status.Success)
            {
                this.Dispatcher.BeginInvoke(
                    delegate
                {
                    System.Diagnostics.Debug.WriteLine("Found the name!: " + nameRegistration.Id);
                    hID = nameRegistration.Id;
                    SendRequest(this.RelayContext.Endpoint, nameRegistration.Id);
                });
            }
            else
            {
                this.Dispatcher.BeginInvoke(
                    delegate
                {
                    ((ApplicationBarIconButton)ApplicationBar.Buttons[0]).IsEnabled = true;
                    ProgressBar.IsVisible = false;
                    NameBox.IsEnabled     = true;
                    UsernameBox.IsEnabled = true;
                });
                this.DisplayMessage("Name lookup failed. Check your wifi/cellular connection.", "Error");
            }
        }
Beispiel #2
0
        public void OnCompleteAssociateId(NameRegistrationResult result)
        {
            System.Diagnostics.Debug.WriteLine(this.RelayContext.Endpoint.RegistrationId);
            if (result.Status == Status.Success)
            {
                NameRegistration nameRegistration = (NameRegistration)result.StateObject;
                this.Dispatcher.BeginInvoke(
                    delegate
                {
                    this.NameRegistrationContext = new NameRegistrationContext(nameRegistration);
                    settings["MyUsername"]       = nameRegistration.Name;
                    ((ObservableCollection <Person>)settings["ContactsList"]).Add(new Person
                    {
                        name     = "Me",
                        username = nameRegistration.Name,
                        hawaiiID = this.RelayContext.Endpoint.RegistrationId,
                        reqSent  = true,
                        accepted = true
                    });
                    foreach (MyProject search in ((ObservableCollection <MyProject>)settings["ProjectList"]))
                    {
                        search.creator = ((ObservableCollection <Person>)settings["ContactsList"])[0];
                        foreach (MyTask searchTask in search.tasks)
                        {
                            searchTask.assignedTo = ((ObservableCollection <Person>)settings["ContactsList"])[0];
                        }
                        foreach (MyTask searchTask in search.doneTasks)
                        {
                            searchTask.assignedTo = ((ObservableCollection <Person>)settings["ContactsList"])[0];
                        }
                    }
                });

                DisplayMessage("You have successfully registered the name " + nameRegistration.Name, "Success!");
                this.Dispatcher.BeginInvoke(
                    delegate
                {
                    ProgressBar.IsVisible = false;
                    NavigationService.GoBack();
                });
            }
            else
            {
                this.DisplayMessage("Associating a registration id with a name failed. Check your wifi/cellular connection.", "Error");
                error();
            }
        }
Beispiel #3
0
        private void OnCompleteRegisterName(NameRegistrationResult result)
        {
            if (result.Status == Status.Success)
            {
                this.Dispatcher.BeginInvoke(
                    delegate
                {
                    this.NameRegistrationContext = new NameRegistrationContext(result.NameRegistration);

                    // Store the secret key in isolated storage.
                    RendezvousStorage.SetSecretKey(result.NameRegistration.Name, result.NameRegistration.SecretKey);

                    string name           = result.NameRegistration.Name;
                    string registrationId = this.RelayContext.Endpoint.RegistrationId;
                    System.Diagnostics.Debug.WriteLine("Registered a name!: " + name + registrationId);

                    if (!string.IsNullOrEmpty(name) &&
                        !string.IsNullOrEmpty(registrationId))
                    {
                        string secretKey = result.NameRegistration.SecretKey;
                        if (string.IsNullOrEmpty(secretKey))
                        {
                            this.DisplayMessage("You are not the owner of this name or the name ownership details are lost. You can't perform this operation.", "Error");
                            error();
                            return;
                        }

                        NameRegistration nameRegistration = new NameRegistration()
                        {
                            Name      = name,
                            Id        = registrationId,
                            SecretKey = secretKey
                        };

                        RendezvousService.AssociateIdAsync(HawaiiClient.HawaiiApplicationId, nameRegistration, this.OnCompleteAssociateId, nameRegistration);
                    }
                });
            }
            else
            {
                this.DisplayMessage("Name registration failed. Check your wifi/cellular connection.", "Error");
                error();
            }
        }