예제 #1
0
        /// <summary>
        /// �ƶ����ѵ���ѡ��
        /// </summary>
        public string ChangeUserGroup(string userId, string relationshiper, string groupName)
        {
            UserGroup userGroup = new UserGroup();
            string strGroupId = null;
            if (groupName == "����")
            {
                strGroupId = userGroup.GetStrangerGroupId();
            }
            else if(groupName == "�Լ�")
            {
                WriteMessage("self");
                return null;
            }
            else
            {
                strGroupId = userGroup.ExistGroupByName(groupName, userId);
            }

            if (strGroupId == null || strGroupId == "") // ��������ڸ��飬���ȴ�������
            {
                string createGroupId = userGroup.CreateGroup(groupName, userId);
                if (createGroupId == "")
                {
                    WriteMessage("��������ʧ�ܣ����Ժ����ԣ�");
                    return null;
                }

                strGroupId = createGroupId;
            }

            bool flag = false;
            GroupRelation groupRelation = new GroupRelation();
            if (groupRelation.ExistGroupRelation(userId, relationshiper))
            {// ����Ѿ��ӹ��˺���
                bool existGroupRelation = groupRelation.ExistGroupRelation(userId, relationshiper, strGroupId);
                if (existGroupRelation == false)
                {// �ú��Ѳ��ڸ�����,���ƶ��ú��ѵ�������
                    flag = groupRelation.UpdateGroupRelation(userId, relationshiper, strGroupId);
                }
                else
                {
                    flag = true;
                }
            }
            else
            {// û�мӹ��˺��ѣ���Ӹú���
                flag = groupRelation.InsertGroupRelation(userId, relationshiper, strGroupId);
            }

            if (flag)
            {
                return strGroupId;
            }
            return null;
        }
예제 #2
0
        /// <summary>
        /// �ƶ����ѵ���ѡ��
        /// </summary>
        public void ChangeUserGroup()
        {
            string userId = Request.Params["userId"];
            string relationshiper = Request.Params["relationshiper"];
            string groupName = Request.Params["groupName"];

            UserGroup userGroup = new UserGroup();

            string strGroupId;
            if (groupName == "����")
            {
                strGroupId = userGroup.GetStrangerGroupId();
            }
            else if (groupName == "�Լ�")
            {
                WriteMessage("�������������Ϊ���Լ������飡");
                return;
            }
            else
            {
                strGroupId = userGroup.ExistGroupByName(groupName, userId);
            }

            if (strGroupId == null || strGroupId == "") // ��������ڸ��飬���ȴ�������
            {
                string createGroupId = userGroup.CreateGroup(groupName, userId);
                if (createGroupId == "")
                {
                    WriteMessage("��������ʧ�ܣ����Ժ����ԣ�");
                    return;
                }

                strGroupId = createGroupId;
            }

            GroupRelation groupRelation = new GroupRelation();
            bool existGroupRelation = groupRelation.ExistGroupRelation(userId, relationshiper, strGroupId);
            if (existGroupRelation == true)// ����ú����Ѿ��ڸ����У���ֱ�ӷ���
            {
                return;
            }

            // �ú��Ѳ��ڸ�����,���ƶ��ú��ѵ�������
            bool flag = groupRelation.UpdateGroupRelation(userId, relationshiper, strGroupId);
            if (flag == true)
            {
                WriteMessage("�ƶ��ɹ���");
            }
            else
            {
                WriteMessage("�ƶ�ʧ�ܣ����Ժ����ԣ�");
            }
        }