LOwnedListsPrivate() public method

public LOwnedListsPrivate ( System.Guid accountId ) : HashSetBlob
accountId System.Guid
return HashSetBlob
コード例 #1
0
ファイル: AccountStorage.cs プロジェクト: xuedong/Tigwi
        public Guid Create(Guid adminId, string name, string description, bool bypassNameReservation = false)
        {
            Blob <Guid> bIdByName = blobFactory.AIdByName(name);

            // lock the name
            if (!bypassNameReservation)
            {
                if (!bIdByName.SetIfNotExists(Guid.Empty))
                {
                    throw new AccountAlreadyExists();
                }
            }

            Guid accountId = Guid.NewGuid();

            // TODO : we could do it without a lock - or at least store the data before
            using (blobFactory.UAccountsLock(adminId))
            {
                Guid personnalListId = Guid.NewGuid();

                // store the data
                HashSet <Guid> users = new HashSet <Guid>();
                users.Add(adminId);
                blobFactory.AUsers(accountId).Set(users);

                HashSet <Guid> followedByAll = new HashSet <Guid>();
                followedByAll.Add(personnalListId);
                blobFactory.LFollowedByAll(accountId).Set(followedByAll);

                blobFactory.AInfo(accountId).Set(new AccountInfo(name, description));
                blobFactory.AAdminId(accountId).Set(adminId);
                blobFactory.LOwnedListsPublic(accountId).Set(new HashSet <Guid>());
                blobFactory.LOwnedListsPrivate(accountId).Set(new HashSet <Guid>());
                blobFactory.LFollowedListsData(accountId).Set(new HashSet <Guid>());
                blobFactory.LFollowedByPublic(accountId).Set(new HashSet <Guid>());
                blobFactory.LFollowedListsLockInit(accountId);
                blobFactory.MTaggedMessages(accountId).Init();
                blobFactory.AAutocompletion().Add(new KeyValuePair <string, string>(name.GenerateDoubleMetaphone(), name));

                // Setup the personnal list
                blobFactory.LPersonnalList(accountId).Set(personnalListId);
                blobFactory.LInfo(personnalListId).Set(new ListInfo("", "", true, true));
                blobFactory.LOwner(personnalListId).Set(accountId);
                blobFactory.MListMessages(personnalListId).Init();
                blobFactory.LFollowedAccounts(personnalListId).Set(new Dictionary <Guid, bool>());

                // we finish by unlocking the name
                bIdByName.Set(accountId);

                // we make this account accessible
                blobFactory.UAccountsData(adminId).Add(accountId);
            }

            return(accountId);
        }
コード例 #2
0
ファイル: ListStorage.cs プロジェクト: xuedong/Tigwi
        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);
        }