/// <summary> /// ��ӷ��� /// </summary> public void AddGroup() { string groups = Request.Params["groups"]; string userId = Request.Params["userId"]; groups = groups.Replace("��",","); string[] groupNames = groups.Split(','); UserGroup userGroup = new UserGroup(); string groupIds = ""; string changedGroupNames = ""; for(int i=0;i<groupNames.Length;i++){ string groupName = groupNames[i]; string tempGroupName = groupName; string strGroupId = null; if (groupName == "İ����") { //strGroupId = userGroup.GetStrangerGroupId(); WriteMessage("�������������Ϊ��İ���ˡ����飡"); return; } else if (groupName == "�Լ�") { WriteMessage("�������������Ϊ���Լ������飡"); return; } else { strGroupId = userGroup.ExistGroupByName(tempGroupName, userId); while (strGroupId != null && strGroupId != "") { // ������ڸ��飬���������һ�����ּ�1��û�����֣�������Ϊ1 tempGroupName += "(1)"; strGroupId = userGroup.ExistGroupByName(tempGroupName, userId); } } // �������� string createGroupId = userGroup.CreateGroup(tempGroupName, userId); if (createGroupId == "") { WriteMessage("��������ʧ�ܣ����Ժ����ԣ�"); return; } changedGroupNames += i + ":" + tempGroupName + ","; groupIds += createGroupId + ","; } WriteMessage(groupIds.TrimEnd(',') + "��" + changedGroupNames.TrimEnd(',')); }
/// <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; }
/// <summary> /// ���������� /// </summary> public void ChangeGroupName() { string groupName = Request.Params["groupName"]; string groupId = Request.Params["groupId"]; string userId = Request.Params["userId"]; UserGroup userGroup = new UserGroup(); if (groupName == "İ����" || groupName == "�Լ�" || userGroup.ExistGroupByName(groupName, userId) != null) { WriteMessage("0"); return; } if (userGroup.ChangeGroupName(groupId, groupName)) {// ���������Ƴɹ� WriteMessage("���³ɹ���"); } else { WriteMessage("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("�ƶ�ʧ�ܣ����Ժ����ԣ�"); } }