public static AccountRootAndContainer[] GetTarget_AccountRootsAndContainers(TBRGroupRoot groupRoot) { var accountIDs = groupRoot.Group.Roles.CollectionContent. Select(role => role.Email.EmailAddress). Select(email => { string emailRootID = TBREmailRoot.GetIDFromEmailAddress(email); TBREmailRoot emailRoot = TBREmailRoot.RetrieveFromDefaultLocation(emailRootID); return(emailRoot.Account.ID); }).Distinct().ToArray(); List <AccountRootAndContainer> result = new List <AccountRootAndContainer>(); foreach (var accountID in accountIDs) { TBRAccountRoot accountRoot = TBRAccountRoot.RetrieveFromDefaultLocation(accountID); VirtualOwner owner = new VirtualOwner("acc", accountID); var accountContainer = AccountContainer.RetrieveFromOwnerContent(owner, "default"); AccountRootAndContainer accountRootAndContainer = new AccountRootAndContainer { AccountContainer = accountContainer, AccountRoot = accountRoot }; result.Add(accountRootAndContainer); } return(result.ToArray()); }
public static TBRGroupRoot GetTarget_GroupRoot(string groupName) { TBRGroupRoot groupRoot = TBRGroupRoot.CreateNewWithGroup(); groupRoot.Group.Title = groupName; return(groupRoot); }
public static void ExecuteMethod_InitializeGroupContentAndMasters(TBRGroupRoot groupRoot) { var grp = groupRoot.Group; RenderWebSupport.RefreshGroupTemplates(grp.ID, false); OwnerInitializer.InitializeAndConnectMastersAndCollections(grp); }
public static void DeleteEntireGroup(string groupID) { TBRGroupRoot groupToDelete = TBRGroupRoot.RetrieveFromDefaultLocation(groupID); throw new NotImplementedException("Call remove group membership for each member, then delete to recycle bin"); foreach (var member in groupToDelete.Group.Roles.CollectionContent) { string emailRootID = TBREmailRoot.GetIDFromEmailAddress(member.Email.EmailAddress); TBREmailRoot emailRoot = TBREmailRoot.RetrieveFromDefaultLocation(emailRootID); emailRoot.Account.GroupRoleCollection.CollectionContent.RemoveAll( candidate => candidate.GroupID == groupToDelete.Group.ID); emailRoot.Account.StoreAccountToRoot(); } StorageSupport.DeleteInformationObject(groupToDelete); //WorkerSupport.DeleteEntireOwner(groupToDelete.Group); OperationRequest operationRequest = new OperationRequest { DeleteEntireOwner = DeleteEntireOwnerOperation.CreateDefault() }; operationRequest.DeleteEntireOwner.ContainerName = groupToDelete.Group.ContainerName; operationRequest.DeleteEntireOwner.LocationPrefix = groupToDelete.Group.LocationPrefix; //QueueSupport.PutToOperationQueue(operationRequest); InformationContext.Current.AddOperationRequestToFinalizingQueue(operationRequest); }
public static TBRGroupRoot CreateNewWithGroup() { TBRGroupRoot groupRoot = TBRGroupRoot.CreateDefault(); groupRoot.Group.ID = groupRoot.ID; return(groupRoot); }
public static GroupContainer GetTarget_GroupContainer(TBRGroupRoot groupRoot) { VirtualOwner groupOwner = new VirtualOwner("grp", groupRoot.Group.ID); var groupContainer = GroupContainer.RetrieveFromOwnerContent(groupOwner, "default"); return(groupContainer); }
public static string GetTarget_EmailAddress(TBRGroupRoot groupRoot, TBRAccountRoot accountRoot) { var emailAddresses = accountRoot.Account.Emails.CollectionContent.Select(email => email.EmailAddress).ToArray(); var emailAddress = emailAddresses.First( email => groupRoot.Group.Roles.CollectionContent.Any(role => role.Email.EmailAddress == email)); return(emailAddress); }
public static TBRGroupRoot CreateLegacyNewWithGroup(string legacyID) { TBRGroupRoot groupRoot = TBRGroupRoot.CreateDefault(); groupRoot.ID = legacyID; groupRoot.UpdateRelativeLocationFromID(); groupRoot.Group.ID = groupRoot.ID; return(groupRoot); }
public static void ExecuteMethod_UpdateGroupContainerMembership(TBRGroupRoot groupRoot, AccountRootAndContainer[] accountRootsAndContainers, GroupContainer groupContainer) { string groupID = groupRoot.Group.ID; var collaborators = accountRootsAndContainers. Select(acctR => new { Account = acctR.AccountRoot.Account, AccountContainer = acctR.AccountContainer, Profile = acctR.AccountContainer.AccountModule.Profile, GroupRole = acctR.AccountRoot.Account.GroupRoleCollection.CollectionContent.First( role => role.GroupID == groupID) }); var moderators = collaborators.Where(coll => TBCollaboratorRole.HasModeratorRights(coll.GroupRole.GroupRole)).ToArray(); var pendingCollaborators = collaborators.Where( coll => TBCollaboratorRole.IsRoleStatusValidMember(coll.GroupRole.RoleStatus) == false); var fullCollaborators = collaborators.Where( coll => TBCollaboratorRole.IsRoleStatusValidMember(coll.GroupRole.RoleStatus) == true); groupContainer.GroupProfile.Moderators.CollectionContent.Clear(); groupContainer.GroupProfile.Moderators.CollectionContent. AddRange(moderators. Select(mod => { var moderator = Moderator.CreateDefault(); moderator.ModeratorName = mod.Profile.FirstName + " " + mod.Profile.LastName; return(moderator); }).OrderBy(mod => mod.ModeratorName)); groupContainer.Collaborators.CollectionContent.Clear(); groupContainer.Collaborators.CollectionContent.AddRange( fullCollaborators.Select(coll => { Collaborator collaborator = Collaborator.CreateDefault(); collaborator.AccountID = coll.Account.ID; collaborator.CollaboratorName = coll.Profile.FirstName + " " + coll.Profile.LastName; collaborator.Role = coll.GroupRole.GroupRole; return(collaborator); }) ); groupContainer.PendingCollaborators.CollectionContent.Clear(); groupContainer.PendingCollaborators.CollectionContent.AddRange( pendingCollaborators.Select(coll => { Collaborator collaborator = Collaborator.CreateDefault(); collaborator.AccountID = coll.Account.ID; collaborator.CollaboratorName = coll.Profile.FirstName + " " + coll.Profile.LastName; collaborator.Role = coll.GroupRole.GroupRole; return(collaborator); }) ); }
public static TBRGroupRoot[] GetTarget_GroupRoots(TBRAccountRoot accountRoot, string emailAddress) { var groupIDs = accountRoot.Account.GroupRoleCollection.CollectionContent.Select(grpRole => grpRole.GroupID).ToArray(); var groups = groupIDs.Select(groupID => TBRGroupRoot.RetrieveFromDefaultLocation(groupID)).ToArray(); var groupsContainingEmail = groups.Where( grp => grp.Group.Roles.CollectionContent.Any(role => role.Email.EmailAddress == emailAddress)). ToArray(); return(groupsContainingEmail); }
public static void Execute(ConfirmInviteToJoinGroupParameters parameters) { PrepareParameters(parameters); TBRGroupRoot GroupRoot = ConfirmInviteToJoinGroupImplementation.GetTarget_GroupRoot(parameters.GroupID); string AccountID = ConfirmInviteToJoinGroupImplementation.GetTarget_AccountID(parameters.MemberEmailAddress); ConfirmInviteToJoinGroupImplementation.ExecuteMethod_ConfirmPendingInvitationToGroupRoot(parameters.MemberEmailAddress, GroupRoot); ConfirmInviteToJoinGroupImplementation.ExecuteMethod_StoreObjects(GroupRoot); { // Local block to allow local naming RefreshAccountGroupMembershipsParameters operationParameters = ConfirmInviteToJoinGroupImplementation.RefreshAccountAndGroupContainers_GetParameters(GroupRoot, AccountID); RefreshAccountGroupMemberships.Execute(operationParameters); } // Local block closing }
public static void Execute(InviteMemberToGroupParameters parameters) { PrepareParameters(parameters); TBRGroupRoot GroupRoot = InviteMemberToGroupImplementation.GetTarget_GroupRoot(parameters.GroupID); TBEmailValidation EmailValidation = InviteMemberToGroupImplementation.GetTarget_EmailValidation(parameters.MemberEmailAddress, parameters.GroupID); string AccountID = InviteMemberToGroupImplementation.GetTarget_AccountID(parameters.MemberEmailAddress); InviteMemberToGroupImplementation.ExecuteMethod_AddAsPendingInvitationToGroupRoot(parameters.MemberEmailAddress, GroupRoot); InviteMemberToGroupImplementation.ExecuteMethod_StoreObjects(GroupRoot, EmailValidation); InviteMemberToGroupImplementation.ExecuteMethod_SendEmailConfirmation(EmailValidation, GroupRoot); { // Local block to allow local naming RefreshAccountGroupMembershipsParameters operationParameters = InviteMemberToGroupImplementation.RefreshAccountAndGroupContainers_GetParameters(GroupRoot, AccountID); RefreshAccountGroupMemberships.Execute(operationParameters); } // Local block closing }
public static void Execute(CreateGroupParameters parameters) { PrepareParameters(parameters); TBRGroupRoot GroupRoot = CreateGroupImplementation.GetTarget_GroupRoot(parameters.GroupName); TBRAccountRoot AccountRoot = CreateGroupImplementation.GetTarget_AccountRoot(parameters.AccountID); TBEmail[] AccountEmails = CreateGroupImplementation.GetTarget_AccountEmails(AccountRoot); CreateGroupImplementation.ExecuteMethod_AddAsInitiatorToGroupRoot(GroupRoot, AccountEmails); CreateGroupImplementation.ExecuteMethod_StoreObjects(GroupRoot); CreateGroupImplementation.ExecuteMethod_InitializeGroupContentAndMasters(GroupRoot); { // Local block to allow local naming RefreshAccountGroupMembershipsParameters operationParameters = CreateGroupImplementation.RefreshAccountAndGroupContainers_GetParameters(parameters.AccountID, GroupRoot); RefreshAccountGroupMemberships.Execute(operationParameters); } // Local block closing }
public static void Execute(RemoveMemberFromGroupParameters parameters) { PrepareParameters(parameters); TBRGroupRoot GroupRoot = RemoveMemberFromGroupImplementation.GetTarget_GroupRoot(parameters.GroupID); string AccountIDOfEmail = RemoveMemberFromGroupImplementation.GetTarget_AccountIDOfEmail(parameters.EmailAddress, parameters.AccountID); TBRAccountRoot AccountRoot = RemoveMemberFromGroupImplementation.GetTarget_AccountRoot(AccountIDOfEmail); string MemberEmailAddress = RemoveMemberFromGroupImplementation.GetTarget_MemberEmailAddress(parameters.EmailAddress, AccountRoot, GroupRoot); RemoveMemberFromGroupImplementation.ExecuteMethod_RemoveMemberFromGroup(MemberEmailAddress, GroupRoot); RemoveMemberFromGroupImplementation.ExecuteMethod_StoreObjects(GroupRoot); { // Local block to allow local naming RefreshAccountGroupMembershipsParameters operationParameters = RemoveMemberFromGroupImplementation.RefreshAccountAndGroupContainers_GetParameters(GroupRoot, AccountIDOfEmail); RefreshAccountGroupMemberships.Execute(operationParameters); } // Local block closing }
public static void ExecuteMethod_AddAsInitiatorToGroupRoot(TBRGroupRoot groupRoot, TBEmail[] accountEmails) { var group = groupRoot.Group; foreach (TBEmail email in accountEmails) { var groupRole = new TBCollaboratorRole() { Email = email, Role = TBCollaboratorRole.InitiatorRoleValue, RoleStatus = TBCollaboratorRole.RoleStatusMemberValue, }; //account.JoinGroup(this, groupRole); //account.StoreAndPropagate(); group.Roles.CollectionContent.Add(groupRole); } }
public static void ExecuteMethod_UpdateGroupSummaryContainerMemberships(TBRGroupRoot groupRoot, Group currGroup, TBRAccountRoot accountRoot, GroupSummaryContainer groupSummaryContainer) { string currRootId = groupRoot.Group.ID; string currGroupID = currGroup.ID; bool isMember = accountRoot.Account.GroupRoleCollection.CollectionContent.Exists( grp => grp.GroupID == currRootId); groupSummaryContainer.GroupCollection.CollectionContent.RemoveAll( grp => grp.ID == currGroupID); if (isMember) { groupSummaryContainer.GroupCollection.CollectionContent.Add(currGroup); currGroup.UpdateReferenceToInformation(currRootId); } groupSummaryContainer.GroupCollection.CollectionContent.Sort(Group.CompareByGroupName); }
public static void Execute(AssignCollaboratorRoleParameters parameters) { PrepareParameters(parameters); TBRGroupRoot GroupRoot = AssignCollaboratorRoleImplementation.GetTarget_GroupRoot(parameters.GroupID); Collaborator Collaborator = AssignCollaboratorRoleImplementation.GetTarget_Collaborator(parameters.GroupContainer, parameters.CollaboratorID); string AccountID = AssignCollaboratorRoleImplementation.GetTarget_AccountID(Collaborator); TBRAccountRoot AccountRoot = AssignCollaboratorRoleImplementation.GetTarget_AccountRoot(AccountID); string EmailAddress = AssignCollaboratorRoleImplementation.GetTarget_EmailAddress(GroupRoot, AccountRoot); TBCollaboratorRole TBCollaboratorRole = AssignCollaboratorRoleImplementation.GetTarget_TBCollaboratorRole(GroupRoot, EmailAddress); AssignCollaboratorRoleImplementation.ExecuteMethod_AssignCollaboratorRole(parameters.RoleToAssign, TBCollaboratorRole); AssignCollaboratorRoleImplementation.ExecuteMethod_StoreObjects(GroupRoot); { // Local block to allow local naming RefreshAccountGroupMembershipsParameters operationParameters = AssignCollaboratorRoleImplementation.RefreshAccountAndGroupContainers_GetParameters(GroupRoot, AccountID); RefreshAccountGroupMemberships.Execute(operationParameters); } // Local block closing }
public static void ExecuteMethod_UpdateAccountRootGroupMemberships(TBRGroupRoot groupRoot, TBRAccountRoot accountRoot) { string[] accountEmailAddresses = accountRoot.Account.Emails.CollectionContent.Select(email => email.EmailAddress).ToArray(); var accountRoles = groupRoot.Group.Roles.CollectionContent.Where( role => accountEmailAddresses.Contains(role.Email.EmailAddress)).ToArray(); accountRoot.Account.GroupRoleCollection.CollectionContent.RemoveAll( currRole => currRole.GroupID == groupRoot.Group.ID); var acctCollaborationRoles = accountRoles. Select(grpRole => { TBAccountCollaborationGroup acctGroup = TBAccountCollaborationGroup.CreateDefault(); acctGroup.GroupID = groupRoot.Group.ID; acctGroup.GroupRole = grpRole.Role; acctGroup.RoleStatus = grpRole.RoleStatus; return(acctGroup); }); accountRoot.Account.GroupRoleCollection.CollectionContent.AddRange(acctCollaborationRoles); }
public static void ExecuteMethod_UpdateAccountContainerMemberships(TBRGroupRoot groupRoot, Group currGroup, GroupSummaryContainer groupSummaryContainer, TBRAccountRoot accountRoot, AccountContainer accountContainer) { string currRootId = groupRoot.Group.ID; string currReferenceUrlPrefix = String.Format("/auth/grp/{0}/", currRootId); var currRoles = accountContainer.AccountModule.Roles; currRoles.MemberInGroups.CollectionContent.RemoveAll( refToInfo => refToInfo.URL.StartsWith(currReferenceUrlPrefix)); currRoles.ModeratorInGroups.CollectionContent.RemoveAll( refToInfo => refToInfo.URL.StartsWith(currReferenceUrlPrefix)); foreach (var acctRole in accountRoot.Account.GroupRoleCollection.CollectionContent.Where(role => role.GroupID == currRootId)) { ReferenceToInformation reference = ReferenceToInformation.CreateDefault(); reference.URL = string.Format("/auth/grp/{0}/website/oip-group/oip-layout-groups-edit.phtml", currRootId); reference.Title = currGroup.GroupName + " - " + acctRole.GroupRole; switch (acctRole.GroupRole.ToLower()) { case "initiator": case "moderator": currRoles.ModeratorInGroups.CollectionContent.Add(reference); break; case "collaborator": case "viewer": currRoles.MemberInGroups.CollectionContent.Add(reference); break; } } currRoles.ModeratorInGroups.CollectionContent.Sort(ReferenceToInformation.CompareByReferenceTitle); currRoles.MemberInGroups.CollectionContent.Sort(ReferenceToInformation.CompareByReferenceTitle); // TODO: Update account summary //accountContainer.AccountSummary.GroupSummary }
public static RefreshAccountGroupMembershipsParameters RefreshAccountAndGroupContainers_GetParameters(TBRGroupRoot groupRoot, string accountID) { return(new RefreshAccountGroupMembershipsParameters() { AccountID = accountID, GroupRoot = groupRoot }); }
public static void ExecuteMethod_SendEmailConfirmation(TBEmailValidation emailValidation, TBRGroupRoot groupRoot) { EmailSupport.SendGroupJoinEmail(emailValidation, groupRoot.Group); }
public static void ExecuteMethod_StoreObjects(TBRGroupRoot groupRoot, TBEmailValidation emailValidation) { groupRoot.StoreInformation(); emailValidation.StoreInformation(); }
public static void ExecuteMethod_AddAsPendingInvitationToGroupRoot(string memberEmailAddress, TBRGroupRoot groupRoot) { TBCollaboratorRole role = groupRoot.Group.Roles.CollectionContent.FirstOrDefault( candidate => candidate.Email.EmailAddress == memberEmailAddress); if (role != null) { throw new InvalidDataException("Person to be invited is already member (or pending) of the group"); } role = TBCollaboratorRole.CreateDefault(); role.Email.EmailAddress = memberEmailAddress; role.Role = TBCollaboratorRole.CollaboratorRoleValue; role.SetRoleAsInvited(); groupRoot.Group.Roles.CollectionContent.Add(role); }
public static TBRGroupRoot GetTarget_GroupRoot(string groupID) { return(TBRGroupRoot.RetrieveFromDefaultLocation(groupID)); }
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_ConfirmPendingInvitationToGroupRoot(string memberEmailAddress, TBRGroupRoot groupRoot) { var groupRole = groupRoot.Group.Roles.CollectionContent.First(role => role.Email.EmailAddress == memberEmailAddress); groupRole.RoleStatus = TBCollaboratorRole.RoleStatusMemberValue; }
public static void ExecuteMethod_StoreObjects(TBRGroupRoot groupRoot) { groupRoot.StoreInformation(); }
public static TBCollaboratorRole GetTarget_TBCollaboratorRole(TBRGroupRoot groupRoot, string emailAddress) { return(groupRoot.Group.Roles.CollectionContent.FirstOrDefault(collRole => collRole.Email.EmailAddress == emailAddress)); }
public static UpdateAccountRootGroupMembershipParameters UpdateAccountRoot_GetParameters(TBRGroupRoot groupRoot, string accountID) { return(new UpdateAccountRootGroupMembershipParameters { AccountID = accountID, GroupRoot = groupRoot }); }
public static UpdateGroupContainersGroupMembershipParameters UpdateGroupContainers_GetParameters(TBRGroupRoot groupRoot) { return(new UpdateGroupContainersGroupMembershipParameters { GroupRoot = groupRoot }); }