Ejemplo n.º 1
0
        private List <int> OldGetItemRepositoryMembersID(int CommunityID, long ItemID, int Permission)
        {
            List <int> iResponse = new List <int>();

            using (ISession session = NHSessionHelper.GetSession())
            {
                DataContext dc = new DataContext(session);
                try
                {
                    CommunityFile oItem = dc.GetById <CommunityFile>(ItemID);
                    if (oItem != null && ((CommunityID == 0 && oItem.CommunityOwner == null) || (CommunityID > 0 && oItem.CommunityOwner != null)))
                    {
                        List <int> AssignedCommunity = new List <int>();
                        AssignedCommunity = (from ca in session.Linq <CommunityFileCommunityAssignment>() where ca.AssignedTo == oItem.CommunityOwner && ca.File == oItem && ca.Inherited select ca.AssignedTo.Id).ToList <int>();
                        if (AssignedCommunity.Count > 0)
                        {
                            iResponse = GetPermissionMembersID(session, CommunityID, Services_File.Codex, Permission);
                        }
                        else
                        {
                            List <int> AssignedUsers      = new List <int>();
                            List <int> AssignedRoles      = new List <int>();
                            List <int> AssignedUsersTypes = new List <int>();
                            if (oItem.CommunityOwner == null)
                            {
                                AssignedUsersTypes = (from ca in session.Linq <CommunityFilePersonTypeAssignment>() where ca.File == oItem && ca.Inherited select ca.AssignedTo).ToList <int>();
                                if (AssignedUsersTypes.Count > 0)
                                {
                                    iResponse.AddRange(GetByRolePermissionMembersID(session, 0, Services_File.Codex, AssignedUsersTypes, Permission));
                                }
                            }
                            else
                            {
                                AssignedRoles = (from ca in session.Linq <CommunityFileRoleAssignment>() where ca.File == oItem && ca.Inherited select ca.AssignedTo.Id).ToList <int>();
                                if (AssignedRoles.Count > 0)
                                {
                                    iResponse.AddRange(GetByRolePermissionMembersID(session, oItem.CommunityOwner.Id, Services_File.Codex, AssignedRoles, Permission));
                                }
                            }
                            AssignedUsers = (from ca in session.Linq <CommunityFilePersonAssignment>() where ca.File == oItem && !iResponse.Contains <int>(ca.AssignedTo.Id) select ca.AssignedTo.Id).ToList <int>();
                            AssignedUsers = EvaluateRepositoryUsers(session, AssignedUsers, oItem.FolderId, oItem.CommunityOwner, Services_File.Codex, Permission);
                            if (AssignedUsers.Count > 0)
                            {
                                iResponse.AddRange(AssignedUsers);
                            }
                        }
                        if (PermissionHelper.CheckPermissionSoft((long)(Services_File.Base2Permission.AdminService) | (int)(Services_File.Base2Permission.Moderate), Permission))
                        {
                            List <int> AvailableMembersID = GetPermissionMembersID(session, CommunityID, Services_File.Codex, (int)(Services_File.Base2Permission.AdminService) | (int)(Services_File.Base2Permission.Moderate));
                            iResponse.AddRange((from Id in AvailableMembersID where iResponse.Contains(Id) == false select Id).ToList <int>());
                        }
                    }
                }
                catch (Exception ex)
                {
                }
            }
            return((from UserID in iResponse select UserID).Distinct().ToList <int>());
        }
Ejemplo n.º 2
0
        public List <int> GetCommunityMembersID(int CommunityID)
        {
            using (ISession session = NHSessionHelper.GetSession())
            {
                DataContext dc        = new DataContext(session);
                iCommunity  community = dc.GetById <Community>(CommunityID);
                List <int>  Members   = (from sub in session.Linq <Subscription>() where sub.Community == community && sub.Enabled && sub.Enabled && sub.Role.Id > 0  select sub.Person.Id).ToList <int>();

                return(Members);
            }
        }
Ejemplo n.º 3
0
        public List <int> GetCommunityRoleMembersID(int CommunityID, int RoleID)
        {
            using (ISession session = NHSessionHelper.GetSession())
            {
                DataContext dc      = new DataContext(session);
                List <int>  Members = new List <int>();
                if (CommunityID == 0)
                {
                    Members = (from p in session.Linq <Person>() where p.TypeID == RoleID && p.isDisabled == false select p.Id).ToList <int>();
                }
                else
                {
                    iCommunity community = dc.GetById <Community>(CommunityID);
                    Members = (from sub in session.Linq <Subscription>() where sub.Community == community && sub.Enabled && sub.Enabled && sub.Role.Id == RoleID select sub.Person.Id).ToList <int>();
                }

                return(Members);
            }
        }
Ejemplo n.º 4
0
        public List <int> GetItemIntMembersID(int CommunityID, string ModuleCode, int ItemID, int objectTypeID, int Permission)
        {
            List <int> iResponse   = new List <int>();
            string     ServiceCode = "";

            using (ISession session = NHSessionHelper.GetSession())
            {
                DataContext dc = new DataContext(session);
                try
                {
                    //ServiceCode = (from cModule in session.Linq<ModuleDefinition>()
                    //where cModule.Available && cModule.Id == ModuleID
                    //select cModule.Code).FirstOrDefault<string>();
                }
                catch (Exception ex) { }

                if (ServiceCode != "")
                {
                }
            }
            return(iResponse);
        }
Ejemplo n.º 5
0
        public List <int> GetPortalPermissionMembersID(int ServiceID, int Permission)
        {
            List <int> iResponse   = new List <int>();
            string     ServiceCode = "";

            using (ISession session = NHSessionHelper.GetSession())
            {
                DataContext dc = new DataContext(session);
                try
                {
                    ServiceCode = (from cModule in session.Linq <ModuleDefinition>()
                                   where cModule.Available && cModule.Id == ServiceID
                                   select cModule.Code).FirstOrDefault <string>();
                }
                catch (Exception ex) {}

                if (ServiceCode != "")
                {
                    iResponse = GetPortalPermissionMembersID(session, ServiceCode, Permission);
                }
            }

            return(iResponse);
        }
Ejemplo n.º 6
0
        public List <int> GetPermissionMembersID(int CommunityID, int ServiceID, int Permission)
        {
            using (ISession session = NHSessionHelper.GetSession())
            {
                DataContext dc        = new DataContext(session);
                iCommunity  community = dc.GetById <Community>(CommunityID);
                if (community == null && CommunityID == 0)
                {
                    return(GetPortalPermissionMembersID(ServiceID, Permission));
                }
                else if (community == null)
                {
                    return(new List <int>());
                }

                iModuleDefinition CommunityModule;
                try{
                    CommunityModule = (from cModule in session.Linq <CommunityModuleAssociation>()
                                       where cModule.Enabled && cModule.Service.Available && cModule.Community == community && cModule.Service.Id == ServiceID
                                       select cModule.Service).FirstOrDefault <ModuleDefinition>();
                }
                catch (Exception ex) {
                    CommunityModule = null;
                }

                if (CommunityModule == null)
                {
                    return(new List <int>());
                }
                else
                {
                    //Find all Role perission for the input community and the input service
                    List <CommunityRoleModulePermission> RolePermissionList = (from crmp in session.Linq <CommunityRoleModulePermission>()
                                                                               where crmp.Community == community && crmp.Service == CommunityModule
                                                                               select crmp).ToList <CommunityRoleModulePermission>();
                    // Find ONLY roles !
                    List <int> RolesList = (from o in RolePermissionList
                                            where PermissionHelper.CheckPermissionSoft(Permission, o.PermissionInt)
                                            select o.Role.Id).ToList <int>();

                    if (RolesList.Count == 0)
                    {
                        return(new List <int>());
                    }
                    else
                    {
                        //List<int> UsersID = (from r in RolesList
                        //                     join Subscription sub in session.Linq<Subscription>() on r equals sub.Role
                        //                     where sub.Community == community && sub.Accepted && sub.Enabled && sub.Role.Id > 0
                        //                     select sub.Person.Id)..ToList<int>();

                        List <SmallRolePerson> rpList = (from Subscription sub in session.Linq <Subscription>()
                                                         where sub.Community == community && sub.Accepted && sub.Enabled && sub.Role.Id > 0 && RolesList.Contains(sub.Role.Id)
                                                         select new SmallRolePerson(sub.Role.Id, sub.Person.Id)).ToList <SmallRolePerson>();

                        List <int> UsersID = (from Subscription sub in session.Linq <Subscription>()
                                              where sub.Community == community && sub.Accepted && sub.Enabled && sub.Role.Id > 0 && RolesList.Contains(sub.Role.Id)
                                              select sub.Person.Id).ToList <int>();

                        //(from roleID in RolesList
                        //                 join SmallRolePerson rp in rpList on roleID equals rp.RoleID
                        //                 select rp.PersonID).ToList<int>();
                        return(UsersID);
                    }
                }
            }
        }