public VerseMessageParticipant addNewParticipantToThread(VerseMessageThread vmt, long participant_id) { DateTime datetime = DateTime.Now; VerseMessageParticipant vmp = new VerseMessageParticipant(-1,vmt.thread_id,participant_id,datetime,DateTime.MinValue); ParticipantTask pt = new ParticipantTask(us, vmp); pt.AddParticipantToThread(); VerseThreadManager.getInstance().addParticipant(vmt,vmp); return vmp; }
public VerseMessageParticipant addParticipantToThread(VerseMessageThread vmt, long participant_id, DateTime datetime_joined, DateTime datetime_last_read) { VerseMessageParticipant vmp = new VerseMessageParticipant(-1, vmt.thread_id, participant_id, datetime_joined, datetime_last_read); ParticipantTask pt = new ParticipantTask(us, vmp); //TODO change this not to be done in thread. pt.AddParticipantToThread(); VerseThreadManager.getInstance().addParticipant(vmt, vmp); return vmp; }
private void loadParticipantsByThreadID() { string sqlQuery = "SELECT participant_row_id, thread_id, user_id, datetime_joined, datetime_last_read " + " FROM versemsgparticipants" + " WHERE thread_id = " + thread_id; MySqlConnection conn = DBManager.getConnection(); MySqlDataReader rdr = null; try { conn.Open(); MySqlCommand cmd = new MySqlCommand(sqlQuery, conn); rdr = cmd.ExecuteReader(); long participant_row_id = -1; long user_id = -1; DateTime datetime_joined; DateTime datetime_last_read; VerseMessageParticipant tmp_vmp = null; while (rdr.Read()) { participant_row_id = long.Parse((rdr[0]).ToString()); user_id = long.Parse(rdr[2].ToString()); datetime_joined = DateTime.Parse((rdr[3]).ToString()); if (!Convert.IsDBNull(rdr[4])) datetime_last_read = DateTime.Parse((rdr[4]).ToString()); else datetime_last_read = DateTime.MinValue; tmp_vmp = new VerseMessageParticipant( participant_row_id, thread_id, user_id, datetime_joined, datetime_last_read); participants.Add(user_id,tmp_vmp); } rdr.Close(); conn.Close(); } catch (Exception ex) { Console.WriteLine(ex.Message); Console.WriteLine(ex.StackTrace); } finally { if (rdr != null) rdr.Close(); conn.Close(); } }
public void removeParticipant(VerseMessageParticipant vmp) { lock (thisLock) { if (!isLoaded) { loadMessagesAndParticipantsFromDB(); } } if (vmp != null && participants.ContainsKey(vmp.user_id)) participants.Remove(vmp.user_id); }
public void addParticipant(VerseMessageParticipant vmp) { lock (thisLock) { if (!isLoaded) { loadMessagesAndParticipantsFromDB(); } } if(vmp != null && !participants.ContainsKey(vmp.user_id)) participants.Add(vmp.user_id, vmp); }
public void updateParticipantThreadLastAccessedTime(VerseMessageParticipant vmp) { if (vmp != null) { DateTime datetime = DateTime.Now; vmp.updateDateTimeLastRead(datetime); ParticipantAccessUpdateTask paut = new ParticipantAccessUpdateTask(us, vmp, datetime); paut.UpdateParticipantLastAccessed(); } }
public void removeParticipant(VerseMessageThread vmt, VerseMessageParticipant vmp) { if (vmp != null && vmt != null) { long u_id = vmp.user_id; if (users_threads.ContainsKey(u_id)) { if (users_threads[u_id].Contains(vmp.thread_id)) { users_threads[u_id].Remove(vmp.thread_id); } } vmt.removeParticipant(vmp); } }
public void addParticipant(VerseMessageThread vmt, VerseMessageParticipant vmp) { if (vmp != null && vmt!= null) { long u_id = vmp.user_id; if (users_threads.ContainsKey(u_id)) { if (!users_threads[u_id].Contains(vmp.thread_id)) { users_threads[u_id].Add(vmp.thread_id); } } else { List<long> list = new List<long>(); users_threads.Add(u_id, list); list.Add(vmp.thread_id); } vmt.addParticipant(vmp); } }
public ParticipantAccessUpdateTask(UserSession us, VerseMessageParticipant vmp, DateTime datetime_last_read) { this.us = us; this.vmp = vmp; this.datetime_last_read = datetime_last_read; }
public ParticipantTask(UserSession us, VerseMessageParticipant vmp) { this.us = us; this.vmp = vmp; }