public void getAllMessages() { MessageDAO messageDAO = new MessageDAO(); //这里到时候要改为根据餐厅id来 List<MessageEntity> messageList = messageDAO.getMessageByRestaurantId(1); StringBuilder sb = new StringBuilder(); for (int i = messageList.Count-1; i >= 0; i--) { MessageEntity message = messageList[i]; DateTime todaydate = new DateTime(Convert.ToInt64(message.ctime)); String date = todaydate.ToString("hh:mm:ss"); if (message.to_id != -1) { sb.Append("<div class='item dblue out'>"); sb.Append("<div class='arrow'></div>"); sb.Append("<div class='text'>" + message.message_text + "</div>"); sb.Append("<div class='date'>" + date + "</div>"); sb.Append("</div> "); } else { sb.Append("<div class='item blue'>"); sb.Append("<div class='arrow'></div>"); sb.Append("<div class='text'>" + message.message_text + "</div>"); sb.Append("<div class='date'>" + date + "</div>"); sb.Append("</div>"); } } messagePart = sb.ToString(); }
public void ProcessRequest(HttpContext context) { context.Response.ContentType = "text/plain"; String content = context.Request.QueryString["content"]; MessageDAO messageDAO = new MessageDAO(); MessageEntity message = new MessageEntity(); message.ctime = System.DateTime.Now.ToString(); message.from_id = -1; message.to_id = 1; message.status = 0; message.message_text = content; message.restaurant_id = 1; messageDAO.addOneMessage(message); context.Response.Write(content); }