public int CopyFromRealtimeDB(string business_id, string thread_id, Paging page) { int count = 0; foreach (var tt in _fbMessageRepository.GetMessagesByThread(business_id, page, thread_id).Result) { FbMessage t = tt.Object; count++; Message m = new Message(); m.id = t.id; m.created_time = t.created_time; m.updated_time = t.updated_time <= DateTime.MinValue ? null : t.updated_time; m.ext_id = t.ext_id; m.url = t.url; m.file_name = t.file_name; m.size = t.size; m.subject = t.subject; m.message = t.message; m.agent_id = t.agent_id; m.thread_id = t.thread_id; m.conversation_ext_id = t.conversation_ext_id; m.sender_id = t.sender_id; m.sender_ext_id = t.sender_ext_id; m.sender_name = t.sender_name; m.sender_avatar = t.sender_avatar; m.recipient_id = t.recipient_id; m.recipient_ext_id = t.recipient_ext_id; m.recipient_avatar = t.recipient_avatar; m.recipient_name = t.recipient_name; m.author = t.author; m.customer_id = t.customer_id; m.type = t.type; m.timestamp = t.timestamp > 9999999999 ? t.timestamp / 1000 : t.timestamp; m.business_id = t.business_id; m.channel_id = t.channel_id; m.channel_ext_id = t.channel_ext_id; m.channel_type = t.channel_type; //m.urls = JsonConvert.SerializeObject(t.urls); _messageRepository.Upsert(m); } return(count); }
public Task <dynamic> GetByThread(string business_id, Paging page, string id) { var rs = _messageRepository.GetMessagesByThread(business_id, page, id); return(rs); }