/// <summary> /// 获取好友请求列表 /// <param name="uid">ID</param> /// <returns>请求列表</returns> public static ArrayList getFriendRequestList(String uid) { Object[] parameter = getParameterList(new SqlParameter[] { new SqlParameter("uid", uid) }); ArrayList arr = SQLUtil.rawQuery("Select * From FriendRequest Where AcceptUid = @uid", parameter); if (arr.Count > 0) { ArrayList array = new ArrayList(); foreach (Hashtable table in arr) { array.Add(new FriendRequest(table["id"].ToString().Trim(), table["SendUid"].ToString().Trim(), table["AcceptUid"].ToString().Trim())); } return(array); } else { return(null); } }
/// <summary> /// 获取具体信息 /// </summary> /// <param name="id">ID</param> /// <param name="msgtype">信息类型</param> /// <returns>信息</returns> public static String getMessageContent(String id, MessageType msgtype) { String querystr = "Select * From "; switch (msgtype) { case MessageType.Image: querystr += "ImgMsg"; break; case MessageType.Other: querystr += "OtherMsg"; break; case MessageType.Sound: querystr += "SoundMsg"; break; case MessageType.Text: querystr += "TxtMsg"; break; } querystr += " Where MsgId = @msgid"; ArrayList arr = SQLUtil.rawQuery(querystr, getParameterList(new SqlParameter[] { new SqlParameter("@msgid", id) })); if (arr.Count > 0) { Hashtable table = (Hashtable)arr[0]; if (msgtype != MessageType.Text) { return(Convert.ToBase64String((byte[])table["Msg"])); } else { return(table["Msg"].ToString().Trim()); } } else { return(String.Empty); } }
/// <summary> /// 获取未处理事件列表 /// </summary> /// <param name="uid">ID</param> /// <returns>未处理时间List</returns> public static ArrayList getUnHandlerEvent(String uid) { ArrayList arr = SQLUtil.rawQuery("Select * From UnHandlerEvent Where Uid = @uid", getParameterList(new SqlParameter[] { new SqlParameter("@uid", uid) })); if (arr.Count <= 0) { return(null); } ArrayList eventlist = new ArrayList(); for (int i = 0; i < arr.Count; i++) { Hashtable table = (Hashtable)arr[i]; UnHandlerEvent unhandlerevent = new UnHandlerEvent(uid, (EventType)table["EventType"]); eventlist.Add(unhandlerevent); } //删除未处理事件!!!!!!!!!!!! SQLUtil.excuteSQL("Delete UnHandlerEvent Where Uid = @uid", getParameterList(new SqlParameter[] { new SqlParameter("@uid", uid) })); return(eventlist); }
/// <summary> /// 获取头像 /// </summary> /// <param name="uid">ID</param> /// <returns>Base64形式</returns> public static String getFace(String uid) { if (!exist(uid)) { return(String.Empty); } //查询到用户的FaceID ArrayList arr = SQLUtil.rawQuery("Select FaceID From UserInfo Where Uid = @uid", getParameterList(new SqlParameter[] { new SqlParameter("@uid", uid) })); Hashtable table = (Hashtable)arr[0]; Object face = table["FaceID"]; int faceid = 0; if (face != null) { faceid = (int)face; } //获取Face arr = SQLUtil.rawQuery("Select * From Face Where FaceID = @faceid", getParameterList(new SqlParameter[] { new SqlParameter("@faceid", faceid) })); table = (Hashtable)arr[0]; byte[] data = (byte[])table["Face"]; return(Convert.ToBase64String(data)); }
/// <summary> /// 获取用户信息 /// </summary> /// <param name="uid">ID</param> /// <returns>用户模型实例 获取不到返回null</returns> public static UserInfoModel getUserInfo(String uid) { if (!exist(uid)) { return(null); } Object[] parameter = getParameterList(new SqlParameter[] { new SqlParameter("@uid", uid) }); ArrayList arr = SQLUtil.rawQuery("Select * From UserInfo Where Uid = @uid", parameter); if (arr.Count > 0) { Hashtable table = (Hashtable)arr[0]; //密码 String pwd = table["Pwd"].ToString().Trim(); //注册时间 String regtime = table["RegTime"].ToString().Trim(); //别名 String alias = table["Alias"].ToString().Trim(); //Token String token = table["Token"].ToString().Trim(); //Token注册时间 String generatestr = table["TokenGenerateTime"].ToString().Trim(); //生日 String birthday = table["BirthDay"].ToString().Trim(); //头像ID String faceid = table["FaceID"].ToString().Trim(); //性别 String sexstr = table["Sex"].ToString().Trim(); bool sex = Convert.ToBoolean(sexstr == "" ? "True" : sexstr); //UserInfo对象 UserInfoModel user = new UserInfoModel(uid.Trim(), pwd.Trim(), regtime.Trim(), alias.Trim(), faceid.Trim(), token.Trim(), generatestr.Trim(), birthday.Trim(), sex); return(user); } else { return(null); } }
/// <summary> /// 更新个人资料 /// </summary> /// <param name="uid">ID</param> /// <param name="alias">别名</param> /// <param name="birthday">生日</param> /// <param name="sex">性别</param> /// <returns>更新结果</returns> public static bool updatePersonalData(String uid, String alias, DateTime birthday, bool sex) { int result = SQLUtil.excuteSQL("Update UserInfo set Alias = @alias,Sex = @sex,BirthDay = @birthday Where Uid = @uid", getParameterList(new SqlParameter[] { new SqlParameter("@alias", alias), new SqlParameter("@birthday", birthday), new SqlParameter("@sex", sex), new SqlParameter("@uid", uid) })); return(result > 0); }
/// <summary> /// 上传Log /// </summary> /// <param name="ip">ip地址</param> /// <param name="uid">uid</param> /// <param name="msg">信息</param> public static void updateLog(String ip, String uid, String msg) { Object[] parameter = getParameterList(new SqlParameter[] { new SqlParameter("@uid", uid), new SqlParameter("@ip", ip), new SqlParameter("@msg", msg), new SqlParameter("@time", DateTime.Now) }); int result = SQLUtil.excuteSQL("Insert into dbo.Log Values(@ip,@uid,@msg,@time);", parameter); }