Goedel.Mesh.MeshClient.CreatePersonalProfile C# (CSharp) Method

CreatePersonalProfile() public method

Create a new account and set the personal profile
public CreatePersonalProfile ( string AccountID, SignedPersonalProfile SignedCurrentProfile ) : CreateResponse
AccountID string The requested account identifier.
SignedCurrentProfile SignedPersonalProfile The personal profile to use.
return CreateResponse
        public CreateResponse CreatePersonalProfile(string AccountID,
                            SignedPersonalProfile SignedCurrentProfile) {

            var CreateRequest = new CreateRequest();
            CreateRequest.Profile = SignedCurrentProfile;
            CreateRequest.Account = AccountID;
            var CreateResponse = MeshService.CreateAccount(CreateRequest);

            this.AccountID = AccountID;
            //Register.Write(Constants.RegistryAccounts, AccountID, SignedCurrentProfile.UDF);

            return CreateResponse;
            }

Usage Example

        public void MeshStoreAPI() {

            if (DoLocal) {
                File.Delete(Store);
                File.Delete(Portal);
                MeshPortal.Default = new MeshPortalDirect(Store, Portal);
                }
            else {
                JPCProvider.LocalLoopback = false;
                var Portal = new MeshPortalRemote();
                MeshPortal.Default = Portal;
                }


            MeshClient1 = new MeshClient(Service);
            var valid = MeshClient1.Validate(AccountID);
            if (!valid.Status.StatusSuccess()) {
                Console.WriteLine("Validate failed");
                }

            var DevProfile = new SignedDeviceProfile(Device1, Device1Description);
            var UserProfile = new PersonalProfile(DevProfile);
            var SignedProfile = UserProfile.Signed;

            MeshClient1.CreatePersonalProfile(AccountID, SignedProfile);

            // Create a password profile
            //var PasswordProfile = new PasswordProfile(UserProfile);
            //var SignedPasswordProfile = PasswordProfile.Signed;
            //SignedProfile = UserProfile.Signed;

            //MeshClient1.Publish(SignedPasswordProfile);
            //MeshClient1.Publish(SignedProfile);


            MeshClient2 = new MeshClient(Service, AccountID);
            MeshClient2.SignedDeviceProfile = DevProfile;
            MeshClient2.GetPersonalProfile();

            // Read back the password profile and add entry 
            var AccountPasswordProfile = MeshClient2.GetPasswordProfile();
            AccountPasswordProfile.Add(PWDSite, PWDUser, PWDPassword);
            var AccountSignedPassword = AccountPasswordProfile.Signed;



            // Publish updates to both profiles.
            MeshClient2.Publish(AccountSignedPassword);

            // Create a new device profile.
            var DevProfile2 = new SignedDeviceProfile(Device2, Device2Description);

            MeshClient3 = new MeshClient(Service, AccountID);

            MeshClient3.ConnectRequest(DevProfile2);
            MeshClient2.ConnectStatus(DevProfile2.UniqueID);

            var PendingResponse = MeshClient1.ConnectPending();

            foreach (var Request in PendingResponse.Pending) {
                MeshClient1.ConnectClose(Request, ConnectionStatus.Accepted);
                }

            MeshClient3.ConnectStatus(DevProfile2.UniqueID);

            MeshClient3.GetPasswordProfile();

            }