public static TBRLoginRoot[] GetTarget_AccountLogins(TBRAccountRoot accountRoot) { var loginRootIDs = accountRoot.Account.Logins.CollectionContent.Select( login => TBLoginInfo.GetLoginIDFromLoginURL(login.OpenIDUrl)).ToArray(); var loginRoots = loginRootIDs.Select(loginID => TBRLoginRoot.RetrieveFromDefaultLocation(loginID)).ToArray(); return(loginRoots); }
public static TBRLoginRoot GetOrCreateLoginRootWithAccount(string loginUrl, bool isAccountRequest) { string loginRootID = TBLoginInfo.GetLoginIDFromLoginURL(loginUrl); var loginRoot = RetrieveFromDefaultLocation(loginRootID); if (loginRoot == null) { // Storing loginroot loginRoot = TBRLoginRoot.CreateDefault(); loginRoot.ID = loginRootID; loginRoot.UpdateRelativeLocationFromID(); StorageSupport.StoreInformation(loginRoot); // Creating login info for account and storing the account TBLoginInfo loginInfo = TBLoginInfo.CreateDefault(); loginInfo.OpenIDUrl = loginUrl; TBRAccountRoot accountRoot = TBRAccountRoot.CreateAndStoreNewAccount(); accountRoot.Account.Logins.CollectionContent.Add(loginInfo); string accountID = accountRoot.ID; accountRoot.StoreInformation(); UpdateAccountRootToReferences.Execute(new UpdateAccountRootToReferencesParameters { AccountID = accountID }); UpdateAccountContainerFromAccountRoot.Execute(new UpdateAccountContainerFromAccountRootParameters { AccountID = accountID }); // If this request is for account, we propagate the pages immediately bool useBackgroundWorker = isAccountRequest == false; RenderWebSupport.RefreshAccountTemplates(accountRoot.ID, useBackgroundWorker); if (isAccountRequest) { accountRoot.Account.InitializeAndConnectMastersAndCollections(); } } loginRoot = RetrieveFromDefaultLocation(loginRootID); return(loginRoot); }
public static void ExecuteMethod_SynchronizeLoginGroupRoots(TBRAccountRoot accountRoot, TBRLoginGroupRoot[] loginGroupRoots) { //throw new NotImplementedException(); //TBRLoginGroupRoot loginGroupRoot = TBRLoginGroupRoot.CreateDefault(); //string loginGroupID = TBRLoginGroupRoot.GetLoginGroupID(groupRoleItem.GroupID, loginRootID); var accountLogins = accountRoot.Account.Logins.CollectionContent; var accountGroupRoles = accountRoot.Account.GroupRoleCollection.CollectionContent; List <TBRLoginGroupRoot> currentLoginGroupRoots = new List <TBRLoginGroupRoot>(); foreach (var groupRoleItem in accountGroupRoles.Where(agr => TBCollaboratorRole.IsRoleStatusValidMember(agr.RoleStatus))) { foreach (var loginItem in accountLogins) { string loginRootID = TBLoginInfo.GetLoginIDFromLoginURL(loginItem.OpenIDUrl); string loginGroupID = TBRLoginGroupRoot.GetLoginGroupID(groupRoleItem.GroupID, loginRootID); TBRLoginGroupRoot loginGroupRoot = loginGroupRoots.FirstOrDefault(lgr => lgr.ID == loginGroupID); if (loginGroupRoot == null) { loginGroupRoot = TBRLoginGroupRoot.CreateDefault(); loginGroupRoot.ID = loginGroupID; loginGroupRoot.UpdateRelativeLocationFromID(); } loginGroupRoot.GroupID = groupRoleItem.GroupID; loginGroupRoot.Role = groupRoleItem.GroupRole; currentLoginGroupRoots.Add(loginGroupRoot); } } var loginRootsToDelete = loginGroupRoots. Where(lgr => currentLoginGroupRoots.Exists(currLgr => currLgr.ID == lgr.ID) == false); foreach (var loginRootToDelete in loginRootsToDelete) { loginRootToDelete.DeleteInformationObject(); } foreach (var currLoginRoot in currentLoginGroupRoots) { currLoginRoot.StoreInformation(); } }
public void StoreAccountToRoot() { TBRAccountRoot accountRoot = TBRAccountRoot.RetrieveFromDefaultLocation(this.ID); accountRoot.Account = this; StorageSupport.StoreInformation(accountRoot); return; AccountContainer accountContainer = AccountContainer.RetrieveFromOwnerContent(this, "default"); if (accountContainer == null) { accountContainer = AccountContainer.CreateDefault(); accountContainer.SetLocationAsOwnerContent(this, "default"); } accountContainer.AccountModule.Security.LoginInfoCollection = this.Logins; foreach (var loginItem in this.Logins.CollectionContent) { string loginRootID = TBLoginInfo.GetLoginIDFromLoginURL(loginItem.OpenIDUrl); TBRLoginRoot loginRoot = TBRLoginRoot.RetrieveFromDefaultLocation(loginRootID); loginRoot.Account = this; StorageSupport.StoreInformation(loginRoot); // TODO: Remove invalid group role logins at this stage foreach (var groupRoleItem in this.GroupRoleCollection.CollectionContent.Where(grpRole => TBCollaboratorRole.IsRoleStatusValidMember(grpRole.RoleStatus))) { string loginGroupID = TBRLoginGroupRoot.GetLoginGroupID(groupRoleItem.GroupID, loginRootID); TBRLoginGroupRoot loginGroupRoot = TBRLoginGroupRoot.RetrieveFromDefaultLocation(loginGroupID); if (loginGroupRoot == null) { loginGroupRoot = TBRLoginGroupRoot.CreateDefault(); loginGroupRoot.ID = loginGroupID; loginGroupRoot.UpdateRelativeLocationFromID(); } loginGroupRoot.GroupID = groupRoleItem.GroupID; loginGroupRoot.Role = groupRoleItem.GroupRole; StorageSupport.StoreInformation(loginGroupRoot); } } //accountContainer.AccountModule.Security.EmailCollection = this.Emails; foreach (var emailItem in this.Emails.CollectionContent) { string emailRootID = TBREmailRoot.GetIDFromEmailAddress(emailItem.EmailAddress); TBREmailRoot emailRoot = TBREmailRoot.RetrieveFromDefaultLocation(emailRootID); if (emailRoot == null) { emailRoot = TBREmailRoot.CreateDefault(); emailRoot.ID = emailRootID; emailRoot.UpdateRelativeLocationFromID(); } emailRoot.Account = this; StorageSupport.StoreInformation(emailRoot); } var roles = accountContainer.AccountModule.Roles; roles.MemberInGroups.CollectionContent.Clear(); roles.ModeratorInGroups.CollectionContent.Clear(); foreach (var groupRoleItem in this.GroupRoleCollection.CollectionContent) { var groupRoot = TBRGroupRoot.RetrieveFromDefaultLocation(groupRoleItem.GroupID); if (groupRoot == null) { continue; } var grp = groupRoot.Group; ReferenceToInformation reference = ReferenceToInformation.CreateDefault(); reference.URL = string.Format("/auth/grp/{0}/website/oip-group/oip-layout-groups-edit.phtml", groupRoot.ID); reference.Title = grp.Title + " - " + groupRoleItem.GroupRole; switch (groupRoleItem.GroupRole.ToLower()) { case "initiator": case "moderator": roles.ModeratorInGroups.CollectionContent.Add(reference); break; case "collaborator": case "viewer": roles.MemberInGroups.CollectionContent.Add(reference); break; } } StorageSupport.StoreInformation(accountContainer); }
public static void ExecuteMethod_AddLoginsToPrimaryAccount(TBRAccountRoot primaryAccountToStay, TBLoginInfo[] loginAccessToBeMerged) { primaryAccountToStay.Account.Logins.CollectionContent.AddRange(loginAccessToBeMerged); }