예제 #1
0
        public static string[] GetAllGroupLocations()
        {
            var groupIDs  = TBRGroupRoot.GetAllGroupIDs();
            var groupLocs = groupIDs.Select(grpID => "grp/" + grpID + "/");

            return(groupLocs.ToArray());
        }
 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();
 }
예제 #3
0
        public static void EnsureAndRefreshMasterCollections()
        {
            var accountIDs = TBRAccountRoot.GetAllAccountIDs();

            foreach (string accountID in accountIDs)
            {
                string       acctLocation = "acc/" + accountID + "/";
                VirtualOwner owner        = VirtualOwner.FigureOwner(acctLocation);
                //CoreDomain.EnsureMasterCollections(owner);
                //CoreDomain.RefreshMasterCollections(owner);
                OIPDomain.EnsureMasterCollections(owner);
                OIPDomain.RefreshMasterCollections(owner);
            }
            var groupIDs = TBRGroupRoot.GetAllGroupIDs();

            foreach (string groupID in groupIDs)
            {
                string       grpLocation = "grp/" + groupID + "/";
                VirtualOwner owner       = VirtualOwner.FigureOwner(grpLocation);
                //CoreDomain.EnsureMasterCollections(owner);
                //CoreDomain.RefreshMasterCollections(owner);
                OIPDomain.EnsureMasterCollections(owner);
                OIPDomain.RefreshMasterCollections(owner);
            }
        }
        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 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 GetTarget_GroupRoot(string groupID)
 {
     TBRGroupRoot groupRoot = new TBRGroupRoot();
     groupRoot.ID = groupID;
     groupRoot.UpdateRelativeLocationFromID();
     groupRoot.Group = new TBCollaboratingGroup();
     groupRoot.Group.ID = groupID;
     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;
                                                })
                );
        }
예제 #8
0
        private static void FixGroupMastersAndCollections(string groupID)
        {
            TBRGroupRoot    groupRoot = TBRGroupRoot.RetrieveFromDefaultLocation(groupID);
            IContainerOwner owner     = groupRoot.Group;

            owner.InitializeAndConnectMastersAndCollections();
            //OIPDomain.EnsureMasterCollections(groupRoot.Group);
            //OIPDomain.RefreshMasterCollections(groupRoot.Group);
            //groupRoot.Group.ReconnectMastersAndCollectionsForOwner();
        }
예제 #9
0
        private static void AddLegacyGroupWithInitiator(string groupID, string initiatorEmailAddress)
        {
            var groupRoot = TBRGroupRoot.CreateLegacyNewWithGroup(groupID);

            groupRoot.Group.JoinToGroup(initiatorEmailAddress, TBCollaboratorRole.InitiatorRoleValue);
            //groupRoot.Group.JoinToGroup("*****@*****.**", "moderator");
            StorageSupport.StoreInformation(groupRoot);
            OIPDomain.EnsureMasterCollections(groupRoot.Group);
            OIPDomain.RefreshMasterCollections(groupRoot.Group);
            groupRoot.Group.ReconnectMastersAndCollectionsForOwner();
        }
 public static void ExecuteMethod_RemoveGroupMemberships(string emailAddress, TBRGroupRoot[] groupRoots)
 {
     foreach(var groupRoot in groupRoots)
     {
         RemoveMemberFromGroup.Execute(new RemoveMemberFromGroupParameters
                                           {
                                               EmailAddress = emailAddress,
                                               GroupID = groupRoot.ID
                                           });
     }
 }
 public static void ExecuteMethod_RemoveMemberFromGroup(string memberEmailAddress, TBRGroupRoot groupRoot)
 {
     groupRoot.Group.Roles.CollectionContent.
         RemoveAll(role =>
                       {
                           bool toRemove = role.Email.EmailAddress == memberEmailAddress;
                           if(toRemove && TBCollaboratorRole.HasInitiatorRights(role.Role))
                               throw new InvalidOperationException("Cannot remove initiator from group");
                           return toRemove;
                       });
 }
 public static string GetTarget_MemberEmailAddress(string emailAddress, TBRAccountRoot accountRoot, TBRGroupRoot groupRoot)
 {
     if (emailAddress != null)
         return emailAddress;
     var groupEmails = groupRoot.Group.Roles.CollectionContent.Select(role => role.Email.EmailAddress).ToArray();
     var matchingEmail =
         accountRoot.Account.Emails.CollectionContent.FirstOrDefault(
             email => groupEmails.Contains(email.EmailAddress));
     if(matchingEmail == null)
         throw new InvalidDataException("Account email not found on group in RemoveMemberFromGroupImplementation");
     return matchingEmail.EmailAddress;
 }
예제 #13
0
 private static void refreshAllGroupTemplates(bool useWorker, params string[] viewTypesToRefresh)
 {
     string[] groupIDs = TBRGroupRoot.GetAllGroupIDs();
     foreach (var grpID in groupIDs)
     {
         RefreshGroupTemplates(grpID, useWorker, viewTypesToRefresh);
     }
     //       RenderWebSupport.SyncTemplatesToSite(StorageSupport.CurrActiveContainer.Name,
     //String.Format("grp/f8e1d8c6-0000-467e-b487-74be4ad099cd/{0}/", privateSiteLocation),
     //StorageSupport.CurrAnonPublicContainer.Name,
     //                String.Format("grp/default/{0}/", publicSiteLocation), true, true);
 }
 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);
 }
예제 #15
0
파일: Program.cs 프로젝트: michlG/Caloom
        private static TBCollaboratingGroup InitializeDefaultOIPWebGroup()
        {
            TBRGroupRoot groupRoot = TBRGroupRoot.RetrieveFromDefaultLocation(FixedGroupID);

            if (groupRoot == null)
            {
                groupRoot    = TBRGroupRoot.CreateDefault();
                groupRoot.ID = FixedGroupID;
                groupRoot.UpdateRelativeLocationFromID();
                groupRoot.Group.JoinToGroup("*****@*****.**", "moderator");
                groupRoot.Group.JoinToGroup("*****@*****.**", "moderator");
                StorageSupport.StoreInformation(groupRoot);
            }
            return(groupRoot.Group);
        }
 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 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);
     }
 }
예제 #18
0
        private static void UpdateAccountAndGroups(string accountEmail)
        {
            string         emailID     = TBREmailRoot.GetIDFromEmailAddress(accountEmail);
            TBREmailRoot   emailRoot   = TBREmailRoot.RetrieveFromDefaultLocation(emailID);
            TBRAccountRoot accountRoot = TBRAccountRoot.RetrieveFromDefaultLocation(emailRoot.Account.ID);

            foreach (var groupRole in accountRoot.Account.GroupRoleCollection.CollectionContent)
            {
                TBRGroupRoot groupRoot = TBRGroupRoot.RetrieveFromDefaultLocation(groupRole.GroupID);
                RefreshAccountGroupMemberships.Execute(new RefreshAccountGroupMembershipsParameters
                {
                    AccountID = accountRoot.Account.ID,
                    GroupRoot = groupRoot
                });
                InformationContext.ProcessAndClearCurrent();
                InformationContext.Current.InitializeCloudStorageAccess(Properties.Settings.Default.CurrentActiveContainerName);
            }
        }
 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);
 }
예제 #20
0
파일: WorkerRole.cs 프로젝트: michlG/Caloom
        private void RefreshStockCompanyData()
        {
            InformationContext.Current.InitializeCloudStorageAccess(CURRENT_HARDCODED_CONTAINER_NAME);
            var oldDay = -1;

            while (true)
            {
                var refreshCharts = oldDay != DateTime.Now.DayOfYear || oldDay == -1;
                oldDay = DateTime.Now.Day;
                foreach (var groupId in TBRGroupRoot.GetAllGroupIDs())
                {
                    var group     = TBRGroupRoot.RetrieveFromDefaultLocation(groupId).Group;
                    var titanLock = GetLock(group);
                    if (titanLock.IsLocked && titanLock.LastLocked > DateTime.Now.AddHours(-1) || titanLock.LastLocked > DateTime.Now.AddMinutes(-5))
                    {
                        continue;
                    }
                    try
                    {
                        titanLock.IsLocked   = true;
                        titanLock.LastLocked = DateTime.Now;
                        titanLock.StoreInformation();
                        RefreshStockCompaniesOfOwner(group);
                        if (refreshCharts)
                        {
                            UpdateChartsOfOwner(group);
                        }
                    }
                    catch (Exception ex)
                    {
                        ErrorSupport.ReportException(ex);
                    }
                    finally
                    {
                        titanLock.IsLocked = false;
                        titanLock.StoreInformation();
                    }
                }
                Thread.Sleep(60000);
            }
        }
예제 #21
0
파일: Program.cs 프로젝트: michlG/Caloom
        private static void DeleteAllAccountAndGroupContents(bool useWorker)
        {
            var           accountIDs         = TBRAccountRoot.GetAllAccountIDs();
            var           groupIDs           = TBRGroupRoot.GetAllGroupIDs();
            List <string> referenceLocations = new List <string>();

            foreach (var accountID in accountIDs)
            {
                string referenceLocation = "acc/" + accountID + "/";
                referenceLocations.Add(referenceLocation);
            }
            foreach (var groupID in groupIDs)
            {
                string referenceLocation = "grp/" + groupID + "/";
                referenceLocations.Add(referenceLocation);
            }
            if (useWorker)
            {
                referenceLocations.ForEach(refLoc =>
                {
                    VirtualOwner owner = VirtualOwner.FigureOwner(refLoc);
                    QueueSupport.PutToOperationQueue(
                        new OperationRequest
                    {
                        DeleteOwnerContent = new DeleteOwnerContentOperation
                        {
                            ContainerName  = owner.ContainerName,
                            LocationPrefix = owner.LocationPrefix
                        }
                    }
                        );
                });
            }
            else
            {
                referenceLocations.ForEach(refLoc => StorageSupport.DeleteContentsFromOwner(refLoc));
            }
        }
 public static UpdateGroupContainersGroupMembershipParameters UpdateGroupContainers_GetParameters(TBRGroupRoot groupRoot)
 {
     return new UpdateGroupContainersGroupMembershipParameters {GroupRoot = groupRoot};
 }
 public static RefreshAccountGroupMembershipsParameters RefreshAccountAndGroupContainers_GetParameters(TBRGroupRoot groupRoot, string accountID)
 {
     return new RefreshAccountGroupMembershipsParameters {AccountID = accountID, GroupRoot = groupRoot};
 }
 public static UpdateAccountContainersGroupMembershipParameters UpdateAccountContainers_GetParameters(TBRGroupRoot groupRoot, string accountID)
 {
     return new UpdateAccountContainersGroupMembershipParameters {AccountID = accountID, GroupRoot = groupRoot};
 }
 public static void ExecuteMethod_StoreObjects(TBRGroupRoot groupRoot)
 {
     groupRoot.StoreInformation();
 }
 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;
 }
예제 #27
0
        private async Task HandleWebSocket(WebSocketContext wsContext)
        {
            const int maxMessageSize = 16 * 1024;

            byte[]    receiveBuffer = new byte[maxMessageSize];
            WebSocket socket        = wsContext.WebSocket;

            Func <InformationContext, WebSocketContext, WebSocket, byte[], string, Task> OnReceiveMessage = HandleDeviceNegotiations;
            Action <WebSocketContext, WebSocket> OnClose = HandleCloseMessage;
            InformationContext informationContext        = new InformationContext();
            var    request      = HttpContext.Current.Request;
            string accountEmail = request.Params["accountemail"];
            string groupID      = request.Params["groupID"];

            if (String.IsNullOrEmpty(accountEmail) == false)
            {
                string emailRootID = TBREmailRoot.GetIDFromEmailAddress(accountEmail);
                var    emailRoot   = TBREmailRoot.RetrieveFromDefaultLocation(emailRootID);
                if (emailRoot == null)
                {
                    throw new SecurityException("No such email defined: " + accountEmail);
                }
                informationContext.Owner = emailRoot.Account;
            }
            else if (String.IsNullOrEmpty(groupID) == false)
            {
                TBRGroupRoot groupRoot = TBRGroupRoot.RetrieveFromDefaultLocation(groupID);
                if (groupRoot == null)
                {
                    throw new SecurityException("No such groupID defined: " + groupID);
                }
                informationContext.Owner = groupRoot.Group;
            }

            while (socket.State == WebSocketState.Open)
            {
                WebSocketReceiveResult receiveResult =
                    await socket.ReceiveAsync(new ArraySegment <byte>(receiveBuffer), CancellationToken.None);

                if (receiveResult.MessageType == WebSocketMessageType.Close)
                {
                    await socket.CloseAsync(WebSocketCloseStatus.NormalClosure, string.Empty, CancellationToken.None);

                    OnClose(wsContext, socket);
                }
                else if (receiveResult.MessageType == WebSocketMessageType.Binary)
                {
                    //await
                    //    socket.CloseAsync(WebSocketCloseStatus.InvalidMessageType, "Cannot accept binary frame",
                    //                      CancellationToken.None);

                    int count = receiveResult.Count;

                    while (receiveResult.EndOfMessage == false)
                    {
                        if (count >= maxMessageSize)
                        {
                            string closeMessage = string.Format("Maximum message size: {0} bytes.", maxMessageSize);
                            await
                            socket.CloseAsync(WebSocketCloseStatus.MessageTooBig, closeMessage,
                                              CancellationToken.None);

                            return;
                        }
                        receiveResult =
                            await
                            socket.ReceiveAsync(new ArraySegment <byte>(receiveBuffer, count, maxMessageSize - count),
                                                CancellationToken.None);

                        count += receiveResult.Count;
                    }
                    //var receivedString = Encoding.UTF8.GetString(receiveBuffer, 0, count);
                    byte[] binaryMessage = new byte[count];
                    Array.Copy(receiveBuffer, binaryMessage, count);
                    await OnReceiveMessage(informationContext, wsContext, socket, binaryMessage, null);
                }
                else
                {
                    int count = receiveResult.Count;

                    while (receiveResult.EndOfMessage == false)
                    {
                        if (count >= maxMessageSize)
                        {
                            string closeMessage = string.Format("Maximum message size: {0} bytes.", maxMessageSize);
                            await
                            socket.CloseAsync(WebSocketCloseStatus.MessageTooBig, closeMessage,
                                              CancellationToken.None);

                            return;
                        }
                        receiveResult =
                            await
                            socket.ReceiveAsync(new ArraySegment <byte>(receiveBuffer, count, maxMessageSize - count),
                                                CancellationToken.None);

                        count += receiveResult.Count;
                    }
                    var textMessage = Encoding.UTF8.GetString(receiveBuffer, 0, count);
                    await OnReceiveMessage(informationContext, wsContext, socket, null, textMessage);
                }
            }
        }
 public static void ExecuteMethod_InitializeGroupContentAndMasters(TBRGroupRoot groupRoot)
 {
     var grp = groupRoot.Group;
     RenderWebSupport.RefreshGroupTemplates(grp.ID, false);
     OwnerInitializer.InitializeAndConnectMastersAndCollections(grp);
 }
 public static GroupContainer GetTarget_GroupContainer(TBRGroupRoot groupRoot)
 {
     string groupID = groupRoot.Group.ID;
     VirtualOwner owner = new VirtualOwner("grp", groupID);
     var groupContainer = GroupContainer.RetrieveFromOwnerContent(owner, "default");
     if (groupContainer == null)
     {
         groupContainer = GroupContainer.CreateDefault();
         groupContainer.SetLocationAsOwnerContent(owner, "default");
         groupContainer.GroupProfile.GroupName = groupRoot.Group.Title;
         groupContainer.StoreInformation();
     }
     return groupContainer;
 }
 public static TBCollaboratorRole GetTarget_TBCollaboratorRole(TBRGroupRoot groupRoot, string emailAddress)
 {
     return groupRoot.Group.Roles.CollectionContent.FirstOrDefault(collRole => collRole.Email.EmailAddress == emailAddress);
 }
예제 #31
0
        private static void executeOperationWithFormValues(IContainerOwner containerOwner, string operationName, NameValueCollection form, HttpFileCollection fileContent)
        {
            var filterFields = new string[] { "ExecuteOperation", "ObjectDomainName", "ObjectName", "ObjectID" };

            switch (operationName)
            {
            case "CreateInformationInput":
            {
                CreateInformationInputParameters parameters = new CreateInformationInputParameters
                {
                    InputDescription = form["InputDescription"],
                    LocationURL      = form["LocationURL"],
                    Owner            = containerOwner
                };
                var createdInformationInput      = CreateInformationInput.Execute(parameters);
                var owningAccount                = containerOwner as TBAccount;
                TBCollaboratingGroup owningGroup = null;
                if (owningAccount == null)
                {
                    TBRGroupRoot groupRoot =
                        TBRGroupRoot.RetrieveFromDefaultLocation(containerOwner.LocationPrefix);
                    owningGroup = groupRoot.Group;
                }
                CreateAndSendEmailValidationForInformationInputConfirmationParameters emailParameters = new CreateAndSendEmailValidationForInformationInputConfirmationParameters
                {
                    OwningAccount    = owningAccount,
                    OwningGroup      = owningGroup,
                    InformationInput = createdInformationInput.InformationInput,
                };
                CreateAndSendEmailValidationForInformationInputConfirmation.Execute(emailParameters);
                break;
            }

            case "CreateSpecifiedInformationObjectWithValues":
            {
                CreateSpecifiedInformationObjectWithValuesParameters parameters = new CreateSpecifiedInformationObjectWithValuesParameters
                {
                    Owner            = containerOwner,
                    ObjectDomainName = form["ObjectDomainName"],
                    ObjectName       = form["ObjectName"],
                    HttpFormData     = filterForm(form, filterFields),
                    HttpFileData     = fileContent,
                };
                CreateSpecifiedInformationObjectWithValues.Execute(parameters);
                break;
            }

            case "DeleteSpecifiedInformationObject":
            {
                DeleteSpecifiedInformationObjectParameters parameters = new DeleteSpecifiedInformationObjectParameters
                {
                    Owner            = containerOwner,
                    ObjectDomainName = form["ObjectDomainName"],
                    ObjectName       = form["ObjectName"],
                    ObjectID         = form["ObjectID"],
                };
                DeleteSpecifiedInformationObject.Execute(parameters);
                break;
            }

            case "SetIsFavouriteStatus":
            {
                bool isFavourite;
                bool.TryParse(form["IsFavourite"], out isFavourite);
                SetFavouriteStatusOfStockCompany.Execute(new SetFavouriteStatusOfStockCompanyParameters
                    {
                        Id          = form["Id"],
                        IsFavourite = isFavourite
                    });
                break;
            }

            case "SetAlarmPrice":
            {
                double alarmPrice;
                double.TryParse(form["AlarmPrice"], out alarmPrice);
                SetAlarmPriceOfStockCompany.Execute(new SetAlarmPriceOfStockCompanyParameters
                    {
                        Id         = form["Id"],
                        AlarmPrice = alarmPrice
                    });
                break;
            }

            case "AddOrUpdatePortfolio":
            {
                AddOrUpdatePortfolio.Execute(new AddOrUpdatePortfolioParameters
                    {
                        Id   = form["Id"],
                        Name = form["Name"]
                    });
                break;
            }

            case "DeletePortfolio":
            {
                RemovePortfolio.Execute(new RemovePortfolioParameters
                    {
                        Id = form["Id"]
                    });
                break;
            }

            case "AddStockCompanyToPortfolio":
            {
                AddStockCompanyToPortfolio.Execute(new AddStockCompanyToPortfolioParameters
                    {
                        PortfolioId    = form["Id"],
                        StockCompanyId = form["StockCompanyId"]
                    });
                break;
            }

            case "RemoveStockCompanyFromPortfolio":
            {
                RemoveStockCompanyFromPortfolio.Execute(new RemoveStockCompanyFromPortfolioParameters
                    {
                        PortfolioId    = form["Id"],
                        StockCompanyId = form["StockCompanyId"]
                    });
                break;
            }

            default:
                throw new NotSupportedException("Operation not (yet) supported: " + operationName);
            }
        }
 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 GroupContainer GetTarget_GroupContainer(TBRGroupRoot groupRoot)
 {
     VirtualOwner groupOwner = new VirtualOwner("grp", groupRoot.Group.ID);
     var groupContainer = GroupContainer.RetrieveFromOwnerContent(groupOwner, "default");
     return groupContainer;
 }
 public static void ExecuteMethod_StoreObjects(TBRGroupRoot groupRoot, GroupContainer groupContainer)
 {
     groupRoot.StoreInformation();
     groupContainer.StoreInformation();
 }
 public static void ExecuteMethod_SetGroupInitiatorAccess(TBRGroupRoot groupRoot, GroupContainer groupContainer)
 {
 }