Example #1
0
 void FillDictionary(Group key, GroupRelation value, Dictionary <Group, List <GroupRelation> > arrows)
 {
     if (!arrows.ContainsKey(key))
     {
         var list = new List <GroupRelation>();
         list.Add(value);
         arrows.Add(key, list);
     }
     else
     {
         var list = arrows[key];
         list.Add(value);
     }
 }
Example #2
0
        public async static Task <IDTO> DeleteGroupRelationAsync(GroupRelation groupRelation)
        {
            OracleDynamicParameters oracleParams = new OracleDynamicParameters();
            ComplateOperation <int> complate     = new ComplateOperation <int>();
            var dyParam = new OracleDynamicParameters();

            dyParam.Add(GroupRelationSpParams.PARAMETER_ID, OracleDbType.Int64, ParameterDirection.Input, (object)groupRelation.ID ?? DBNull.Value);

            if (await NonQueryExecuter.ExecuteNonQueryAsync(GroupRelationSpName.SP_DELETE_GROUP_RELATION, dyParam) == -1)
            {
                complate.message = "Operation Successed";
            }
            else
            {
                complate.message = "Operation Failed";
            }

            return(complate);
        }
Example #3
0
        public async static Task <IDTO> AddUpdateMode(GroupRelation groupRelation)
        {
            string SPName  = "";
            string message = "";
            ComplateOperation <int> complate = new ComplateOperation <int>();

            for (int i = 0; i < groupRelation.RefrenceIDs.Length; i++)
            {
                OracleDynamicParameters oracleParams = new OracleDynamicParameters();
                if (groupRelation.ID.HasValue)
                {
                    oracleParams.Add(GroupRelationSpParams.PARAMETER_ID, OracleDbType.Int64, ParameterDirection.Input, (object)groupRelation.ID ?? DBNull.Value);
                    SPName  = GroupRelationSpName.SP_UPADTE_GROUP_RELATION;
                    message = "Updated Successfully";
                }
                else
                {
                    oracleParams.Add(GroupRelationSpParams.PARAMETER_ID, OracleDbType.Int64, ParameterDirection.Output);
                    SPName  = GroupRelationSpName.SP_INSERT_GROUP_RELATION;
                    message = "Inserted Successfully";
                }
                oracleParams.Add(GroupRelationSpParams.PARAMETER_ST_GRP_ID, OracleDbType.Int64, ParameterDirection.Input, (object)groupRelation.GroupID ?? DBNull.Value);
                oracleParams.Add(GroupRelationSpParams.PARAMETER_GRPNAME, OracleDbType.Varchar2, ParameterDirection.Input, (object)groupRelation.GroupName ?? DBNull.Value, 1000);
                oracleParams.Add(GroupRelationSpParams.PARAMETER_LOCK_GRP_CAT, OracleDbType.Int64, ParameterDirection.Input, (object)groupRelation.LockUpGroupCat ?? DBNull.Value);
                oracleParams.Add(GroupRelationSpParams.PARAMETER_REF_ID, OracleDbType.Int64, ParameterDirection.Input, (object)groupRelation.RefrenceIDs[i] ?? DBNull.Value);

                if (await NonQueryExecuter.ExecuteNonQueryAsync(SPName, oracleParams) == -1)
                {
                    complate.message = message;
                }
                else
                {
                    complate.message = "Operation Failed";
                }
            }

            return(complate);
        }
Example #4
0
 public string GetRelationships(string userId)
 {
     string relationships = "";
     GroupRelation groupRelation = new GroupRelation();
     DataTable dtRelations = groupRelation.GetGroupRelation(userId);
     for (int i = 0; i < dtRelations.Rows.Count; i++)
     {
         DataRow dt = dtRelations.Rows[i];
         relationships += "'" + dt["relationshiper"] + "',";
     }
     relationships += "'" + userId + "',";
     return relationships.TrimEnd(',');
 }
Example #5
0
        /// <summary>
        /// ɾ������
        /// </summary>
        public void DeleteFriend()
        {
            string userId = Request.Params["userId"];
            string relationshiper = Request.Params["relationshiper"];

            GroupRelation groupRelation = new GroupRelation();
            if (!groupRelation.DeleteGroupRelation(userId, relationshiper))
            {
                WriteMessage("0");
            }
            else
            {
                WriteMessage("ɾ���ɹ���");
            }
        }
Example #6
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;
        }
Example #7
0
        private void BindUser()
        {
            if (Application["online"] == null)
            {
                bl_top.InnerHtml = "IM";
            }
            else
            {
                hidSender.Value = StringHelper.DesDecrypt(Request.Params["login"]);

                Users users = new Users();
                DataTable userTree = users.GetUserTree();

                UserGroup userGroup = new UserGroup();
                DataTable groupList = userGroup.GetUserGroup(hidSender.Value);

                DataRow[] userRow = userTree.Select(
                    string.Format("id = '{0}'", hidSender.Value)
                    );

                if (userRow.Length == 0)
                {
                    hidCnSender.Attributes["outter"] = "1";
                    changepassword.Attributes["outter"] = "1";
                    hidCnSender.Value = StringHelper.DesDecrypt(Request.Params["userName"]);
                    hidCnSender.Attributes["lname"] = StringHelper.DesDecrypt(Request.Params["loginName"]);
                }
                else
                {
                    if (userRow[0]["theme"].ToString().Length > 0)
                    {
                        theme = userRow[0]["theme"].ToString();
                    }

                    hidCnSender.Value = userRow[0]["username"].ToString();
                    hidrevertMessage.Value = userRow[0]["revertMessage"].ToString();
                    hidCnSender.Attributes["lname"] = userRow[0]["loginname"].ToString();
                    hidCnSender.Attributes["outter"] = userRow[0]["isoutter"].ToString();
                    changepassword.Attributes["outter"] = userRow[0]["isoutter"].ToString();
                }

                GroupRelation groupRelation = new GroupRelation();
                DataTable relationList = groupRelation.GetGroupRelation(hidSender.Value);

                userTreeBuilder = new StringBuilder();
                OnLineUser onLineUser = new OnLineUser();

                foreach (DataRow group in groupList.Rows)
                {
                    bool flag = false;

                    if (group["groupname"].ToString().Equals(Profile.unknowGroup))
                    {
                        flag = true;
                        hidSender.Attributes["unknow"] = group["id"].ToString();
                    }

                    CreateGroupTop(group["id"].ToString(), group["groupname"].ToString(), true, flag);

                    DataRow[] relationshiperList = relationList.Select(
                        string.Format("usergroup = '{0}'", group["id"])
                        );

                    userTreeBuilder.AppendFormat(
                           "<ul class=\"group\" id=\"ul{0}Group\" groupid=\"{0}\" style=\"display : none;\">",
                           group["id"]
                           );

                    foreach (DataRow relationshiper in relationshiperList)
                    {
                        DataRow[] user = userTree.Select(
                            string.Format("id = '{0}'", relationshiper["relationshiper"]),
                            "username"
                            );

                        if (user.Length == 1)
                        {
                            int userStatus = onLineUser.GetUserStatus(user[0]["id"].ToString(), Application["online"]);

                            CreateBuddyList(
                                user[0]["id"].ToString(),
                                user[0]["username"].ToString(),
                                user[0]["scratch"].ToString(),
                                user[0]["headImg"].ToString(),
                                userStatus,
                                true
                                );
                        }
                    }

                    userTreeBuilder.Append("</ul>");
                }

                //����Ԥ�����Լ�����
                CreateGroupTop("owner", Profile.ownerGroup, true, true);
                userTreeBuilder.Append("<ul class=\"group\" id=\"ulownerGroup\" groupid=\"owner\" style=\"display : none;\">");

                int status = onLineUser.GetUserStatus(hidSender.Value, Application["online"]);
                statusSettings.Attributes["userstatus"] = status.ToString();

                CreateBuddyList(
                                hidSender.Value,
                                hidCnSender.Value,
                                (userRow.Length > 0 ? userRow[0]["scratch"].ToString() : string.Empty),
                                (userRow.Length > 0 ? userRow[0]["headImg"].ToString() : string.Empty),
                                status,
                                false
                                );

                userTreeBuilder.Append("</ul>");
                buddylist.InnerHtml = userTreeBuilder.ToString();
            }

            if (hidCnSender.Attributes["outter"].Equals("1"))
            {
                imgLogout.Attributes["style"] += "display: none;";
                changepassword.Attributes["style"] = "display:none";
            }

            hidSender.Attributes["theme"] = theme;
            bl_top.InnerHtml = string.Format("IM {0}", hidCnSender.Value);
            hidSender.Attributes["current"] = DateTime.Now.ToString("yyyy-MM-dd");
            imgLogout.Src = string.Format("../include/themes/{0}/window/signoff.png", theme);
            joinroom.Src = string.Format("../include/themes/{0}/window/joinroom.png", theme);
            addbuddy.Src = string.Format("../include/themes/{0}/window/addbuddy.png", theme);
            changepassword.Src = string.Format("../include/themes/{0}/window/changepassword.png", theme);
        }
Example #8
0
        /// <summary>
        /// ɾ����
        /// </summary>
        public void DeleteGroup()
        {
            string groupId = Request.Params["groupId"];
            string userId = Request.Params["userId"];

            GroupRelation groupRelation = new GroupRelation();
            if (groupRelation.ExistGroupUser(groupId, userId))
            {// ���û����»������û�
                groupRelation.MoveToStrangerGroup(groupId);
            }

            UserGroup userGroup = new UserGroup();
            if (userGroup.DeleteGroup(groupId))
            {// ɾ����ɹ�
                WriteMessage("ɾ���ɹ���");
            }
            else
            {
                WriteMessage("0");
            }
        }
Example #9
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("�ƶ�ʧ�ܣ����Ժ����ԣ�");
            }
        }