/// <summary> /// Get the list of connections pending on an account. /// </summary> /// <param name="Account">The account identifier to get the connections pending for.</param> /// <returns>The pendiong connections.</returns> public ConnectionsPending GetPending(Account Account) { // Get the pending connections record for the account var ConnectionsDataItem = PortalByPrimary.Get( ConnectionsPending.PrimaryKey(Account.UserProfileUDF)); if (ConnectionsDataItem == null) return null; var Result = ConnectionsPending.FromTagged(ConnectionsDataItem.Text); return Result; }
/// <summary> /// Create an account with the specified account name and profile. /// <para>The profile is validated for consistency and rejected if /// validation fails.</para> /// <para>The new account is registered in the Portal log under /// AccountName@Domain as the unique identifier. The profile is /// registered in the mesh under the </para> /// </summary> /// <param name="AccountID">The requested account name.</param> /// <param name="Profile">A signed Personal Profile.</param> /// <returns>True if the transaction was successful, otherwise false. </returns> public bool CreateAccount(string AccountID, SignedProfile Profile) { // Validate the signed profile if (!Profile.Validate()) throw new Throw ("Profile not valid"); // Create the new account on the portal (fail if already exists) var Account = new Account(); Account.AccountID = AccountID; Account.Status = "Open"; Account.Created = DateTime.Now; Account.Modified = Account.Created; Account.UserProfileUDF = Profile.Identifier; //// Allow accounts to be searched by the profile they link to: //var KeyData = new IndexTerm(KeyUserProfile, Account.UniqueID); //var KeyDatas = new List<IndexTerm> { KeyData }; PortalStore.New(Account, Account.PrimaryKey(Account.UniqueID), null); // Push the profile out to the Mesh MeshStore.New(Profile, Profile.Identifier, null); return true; }
/// <summary> /// Deserialize a tagged stream /// </summary> /// <param name="JSONReader"></param> public static new Account FromTagged (JSONReader JSONReader) { Account Out = null; JSONReader.StartObject (); if (JSONReader.EOR) { return null; } string token = JSONReader.ReadToken (); switch (token) { case "Account" : { var Result = new Account (); Result.Deserialize (JSONReader); Out = Result; break; } case "AccountProfile" : { var Result = new AccountProfile (); Result.Deserialize (JSONReader); Out = Result; break; } case "ConnectionsPending" : { var Result = new ConnectionsPending (); Result.Deserialize (JSONReader); Out = Result; break; } default : { //Ignore the unknown data //throw new Exception ("Not supported"); break; } } JSONReader.EndObject (); return Out; }
/// <summary> /// Construct an instance from the specified tagged JSONReader stream. /// </summary> public static void Deserialize(JSONReader JSONReader, out JSONObject Out) { JSONReader.StartObject (); if (JSONReader.EOR) { Out = null; return; } string token = JSONReader.ReadToken (); Out = null; switch (token) { case "PortalEntry" : { Out = null; throw new Exception ("Can't create abstract type"); } case "Account" : { var Result = new Account (); Result.Deserialize (JSONReader); Out = Result; break; } case "AccountProfile" : { var Result = new AccountProfile (); Result.Deserialize (JSONReader); Out = Result; break; } case "ConnectionsPending" : { var Result = new ConnectionsPending (); Result.Deserialize (JSONReader); Out = Result; break; } default : { throw new Exception ("Not supported"); } } JSONReader.EndObject (); }
/// <summary> /// Construct a connection request to attach a device to the /// personal profile of the specified account. /// </summary> /// <param name="Account">Account to request connection to.</param> /// <param name="Device">Device to connect.</param> public ConnectionRequest (Account Account, SignedDeviceProfile Device) { ParentUDF = Account.UserProfileUDF; this.Device = Device; }