public void Remove(Guid listId, Guid accountId) { try { HashSetBlob <Guid> bAddRmvMsgs = blobFactory.LAddRmvMsgs(listId); if (!bAddRmvMsgs.AddIfNotInWithRetry(accountId, new ListNotFound())) { return; } if (!blobFactory.LFollowedByPublic(accountId).RemoveWithRetry(listId)) { bAddRmvMsgs.RemoveWithRetry(accountId); throw new AccountNotFound(); } blobFactory.LFollowedByAll(accountId).RemoveWithRetry(listId); blobFactory.LFollowedAccounts(listId).RemoveWithRetry(accountId); blobFactory.MListMessages(listId).ExceptWith(blobFactory.MListMessages(blobFactory.LPersonnalList(accountId).Get())); bAddRmvMsgs.RemoveWithRetry(accountId); } catch { } }
public void Add(Guid listId, Guid accountId) { // Set WIP to true HashSetBlob <Guid> bAddRmvMsgs = blobFactory.LAddRmvMsgs(listId); if (!bAddRmvMsgs.AddIfNotInWithRetry(accountId, new ListNotFound())) { return; } // Add list and accounts to the sets if (!blobFactory.LFollowedByAll(accountId).AddWithRetry(listId)) { bAddRmvMsgs.RemoveWithRetry(accountId); throw new AccountNotFound(); } blobFactory.LFollowedAccounts(listId).AddWithRetry(accountId); if (!blobFactory.LInfo(listId).Get().IsPrivate) { blobFactory.LFollowedByPublic(accountId).AddWithRetry(listId); } // add msgs Guid PersonnalListId = blobFactory.LPersonnalList(accountId).Get(); blobFactory.MListMessages(listId).UnionWith(blobFactory.MListMessages(PersonnalListId)); // set WIP to false bAddRmvMsgs.RemoveWithRetry(accountId); }
public Guid Create(Guid ownerId, string name, string description, bool isPrivate) { // Create the data : Guid listId = Guid.NewGuid(); ListInfo info = new ListInfo(name, description, isPrivate, false); HashSet <Guid> followingAccounts = new HashSet <Guid>(); followingAccounts.Add(ownerId); // Creation of blobs in list container Blob <ListInfo> bInfo = blobFactory.LInfo(listId); Blob <Guid> bOwner = blobFactory.LOwner(listId); HashSetBlob <Guid> bOwned = isPrivate ? blobFactory.LOwnedListsPrivate(ownerId) : blobFactory.LOwnedListsPublic(ownerId); Blob <HashSet <Guid> > bFollowingAccounts = blobFactory.LFollowingAccounts(listId); DictionaryBlob <Guid> bFollowedAccounts = blobFactory.LFollowedAccounts(listId); HashSetBlob <Guid> bAddRmvMsgs = blobFactory.LAddRmvMsgs(listId); MsgSetBlobPack bMessages = blobFactory.MListMessages(listId); // store the data blobFactory.LInfo(listId).Set(info); bOwner.Set(ownerId); bFollowingAccounts.Set(followingAccounts); bFollowedAccounts.Set(new Dictionary <Guid, bool>()); bAddRmvMsgs.Set(new HashSet <Guid>()); bMessages.Init(); // add the lists to owned lists and check that the user exists. if he doesn't, delete the data stored if (!bOwned.AddWithRetry(listId)) { bInfo.Delete(); bOwner.Delete(); bFollowingAccounts.Delete(); bFollowedAccounts.Delete(); bMessages.Delete(); bAddRmvMsgs.Delete(); throw new AccountNotFound(); } return(listId); }
public void Add(KeyValuePair<string, string> p) { HashSetBlob<KeyValuePair<string, string>> rootBlob = new HashSetBlob<KeyValuePair<string, string>>(dir.GetBlobReference("root")); rootBlob.AddWithRetry(p); }