Пример #1
0
        /// <summary>
        /// Removes an Oyster Object from the Group
        /// Object must be one of the Oyster Types validated by the OysterObjectType enumeration
        /// </summary>
        /// <param name="AccessingUser"></param>
        /// <param name="OBJ"></param>
        /// <param name="CurrentGroup"></param>
        /// <returns></returns>
        internal bool RemoveObjectFromGroup(OCL.User AccessingUser, object Obj, OCL.Group CurrentGroup)
        {
            if(Obj is OCL.User)
            {
                throw new Exception("Must use the RemoveUser function to Remove a User from a group");
            }

            int ObjectTypeId = 0;
            int ObjectId = 0;

            m_sType = "Unknown Type";

            if(Obj is OCL.User)
            {
                if(!CurrentGroup.CanRemoveUsers(AccessingUser))
                    return false;
                return RemoveUserFromGroup(AccessingUser,(OCL.User)Obj,CurrentGroup);
            }
            else if(Obj is OCL.Recording)
            {
                if(!CurrentGroup.CanRemoveRecordings(AccessingUser))
                    return false;
                m_sType = "Recording";
                OCL.Recording R = (OCL.Recording)Obj;
                ObjectTypeId = (int)R.ObjectType;
                ObjectId = R.ID;
            }
            else if(Obj is OCL.Source)
            {
                if(!CurrentGroup.CanRemoveSources(AccessingUser))
                    return false;
                m_sType = "Source";
                OCL.Source S = (OCL.Source)Obj;
                ObjectTypeId = (int)S.ObjectType;
                ObjectId = S.ID;

            }
            else if(Obj is OCL.Control)
            {
                if(!CurrentGroup.CanRemoveControls(AccessingUser))
                    return false;
                m_sType = "Control";
                OCL.Control C = (OCL.Control)Obj;
                ObjectTypeId = (int)C.ObjectType;
                ObjectId = C.ID;
            }
            else if(Obj is OCL.Scene)
            {
                if(!CurrentGroup.CanRemoveScenes(AccessingUser))
                    return false;
                m_sType = "Scene";
                OCL.Scene S = (OCL.Scene)Obj;
                ObjectTypeId = (int)S.ObjectType;
                ObjectId = S.ID;
            }
            else if(Obj is OCL.Note)
            {
                if(!CurrentGroup.CanRemoveNotes(AccessingUser))
                    return false;
                m_sType = "Note";
                OCL.Note N = (OCL.Note)Obj;
                ObjectTypeId = (int)N.ObjectType;
                ObjectId = N.ID;
            }
            else if(Obj is OCL.RecordingSession)
            {
                if(!CurrentGroup.CanRemoveRecordingSessions(AccessingUser))
                    return false;
                m_sType = "RecordingSession";
                OCL.RecordingSession RS = (OCL.RecordingSession)Obj;
                ObjectTypeId = (int)RS.ObjectType;
                ObjectId = RS.ID;
            }
            else if(Obj is OCL.Attachment)
            {
                if(!CurrentGroup.CanRemoveAttachments(AccessingUser))
                    return false;
                m_sType = "Attachment";
                OCL.Attachment A = (OCL.Attachment)Obj;
                ObjectTypeId = (int)A.ObjectType;
                ObjectId = A.ID;
            }
            else if(Obj is OCL.Group)
            {
                if(!CurrentGroup.CanRemoveGroups(AccessingUser))
                    return false;
                m_sType = "Group";
                OCL.Group G = (OCL.Group)Obj;
                ObjectTypeId = (int)G.ObjectType;
                ObjectId = G.ID;
            }
            else if(Obj is OCL.VideoStorageServer)
            {
                if(!CurrentGroup.CanRemoveVideoStorageServers(AccessingUser))
                    return false;
                m_sType = "VideoStorageServer";
                OCL.VideoStorageServer RS = (OCL.VideoStorageServer)Obj;
                ObjectTypeId = (int)RS.ObjectType;
                ObjectId = RS.ID;
            }
            string sSQL = "DELETE FROM tblGroupTokens WHERE GroupId = " + CurrentGroup.ID +
                " AND ObjectTypeId = " + ObjectTypeId +
                " AND ObjectId = " + ObjectId;

            int numrecs = RF.ExecuteCommandNonQuery(sSQL);

            if(numrecs >0)
                return true;
            else
                return false;
        }