/// <summary> /// 获取数据库,单例 /// </summary> /// <param name="userId">用户ID</param> /// <returns>数据库引用</returns> public static MsgDB OpenMsgDB(string userId) { if (null == uniqueInstance) { uniqueInstance = new MsgDB(userId); } return(uniqueInstance); }
/// <summary> /// 获取数据库,单例 /// </summary> /// <param name="userId">用户ID</param> /// <returns>数据库引用</returns> public static MsgDB OpenMsgDB(string userId) { if (null == uniqueInstance) { uniqueInstance = new MsgDB(userId); } return uniqueInstance; }
public bool readSessionMsg(int sessionId) { MsgDB msgdb = MsgDB.OpenMsgDB(userId); msgdb.readMsg(sessionId); msgdb.Close(); return(true); }
private void Form_Chat_Load(object sender, EventArgs e) { //连接数据库 msgDB = MsgDB.OpenMsgDB(myInfo.ID.ToString()); //取出聊天记录 List<Msg> msgs = msgDB.readMsg(contactInfo.ID.ToString(), myInfo.ID.ToString()); ChatBoxContent content = new ChatBoxContent(); foreach (Msg msg in msgs) { AppendChatBoxContent(msg); displayPicture(); } }