private MessageListModel GetUnreachedMessage(ReachedMessageList reachedMessageList) { MessageListModel messageList = new MessageListModel(); using (Controller.Message controllerMessage = new Controller.Message()) { List <MessageModel> recordList = controllerMessage.GetUserMessage(aid, Controller.Message.MESSAGE_STATUS.UNREACH); if (recordList != null) { foreach (MessageModel message in recordList) { if (reachedMessageList != null) { if (reachedMessageList.Contains((uint)message.mid)) { continue; } } messageList.Add(message); } } } return(messageList); }
protected override void OnRequest() { base.OnRequest(); uint?talkerID = getParameterUint("talker_id"); //MessageListModel try { if (talkerID == null) { // throw new UnfulfilException(); } MessageListModel chatHistoryList = GetChatMessageHistory(aid, (uint)talkerID); WriteSuccess <MessageListModel>(chatHistoryList); } catch (UnfulfilException ex) { WriteUnfulfil(ex.DisplayMessage); } catch (Database.Exception ex) { WriteException(ex); }catch (Exception ex) { WriteException(ex); } }
public string GetNotifications(int id) // senderId { var messageNotificationListViewModel = new MessageNotificationListModel(MemberSession.GetMemberId()); if (messageNotificationListViewModel.Notifications == null || messageNotificationListViewModel.OrderedMessages.Count == 0) { return(false.ToString()); } messageNotificationListViewModel.CheckNotifications(MemberSession.GetMemberId()); var messageList = new MessageListModel { OrderedMessages = messageNotificationListViewModel.OrderedMessages }; var jsonSerialiser = new JavaScriptSerializer(); var json = jsonSerialiser.Serialize(messageList); // obrisati sve notifikacje od tog Sendera, namenjene receiveru var messageNotification = new MessageNotification(); messageNotification.DeleteAllFrom(id, MemberSession.GetMemberId()); return(json); // vraca listu nedodatih poruka }
protected override void OnRequest() { base.OnRequest(); int PullTimeout = SystemConfig.MessagePullingTimeout; int PullSleep = SystemConfig.MessagePullingSleep; Server.ScriptTimeout = PullTimeout + 10; _startTime = DateTime.Now; ReachedMessageList reachedMessageList = getModel <ReachedMessageList>(); while (_startTime.AddSeconds(PullTimeout) >= DateTime.Now) { if (!Response.IsClientConnected) { WriteEnd(); } MessageListModel messageList = GetUnreachedMessage(reachedMessageList); if (messageList.Count > 0) { WriteSuccess <MessageListModel>(messageList); WriteEnd(); } Thread.Sleep(PullSleep); } WriteUnfulfil("No message"); }
public IActionResult Index() { var result = new List <Message>(); result = MessageListModel.GetListMessage().OrderByDescending(x => x.DataEnvio).ToList(); return(View(result)); }
public ActionResult CheckNewMessages(int?lastCheckedId) { var model = new MessageListModel { Messages = _messageRepo.GetLatestAfterId(lastCheckedId ?? 0).Select(m => new ChatMessageDto(m)) }; return(Json(model)); }
public ActionResult LoadInitialData() { var model = new MessageListModel { Messages = _messageRepo.GetLatest(LatestVisibleMessages).Select(m => new ChatMessageDto(m)) }; return(Json(model)); }
public RouletteBll(ResponseModel response, MessageListModel messageList, List <BetResponseModel> betResponseModelList, BetResponseModel betResponseModel, IRepository <Roulette> rouletteRepo, IRepository <Consumer> consumerRepo, BetRepository betRepo) : base(response, messageList) { this.betResponseModelList = betResponseModelList; this.betResponseModel = betResponseModel; this.rouletteRepo = rouletteRepo; this.consumerRepo = consumerRepo; this.betRepo = betRepo; }
public string Conversation(int id) // receiverId { var messageList = new MessageListModel(id); var jsonSerialiser = new JavaScriptSerializer(); var json = jsonSerialiser.Serialize(messageList); // TODO: postavi da se sve notifikacije obrisu koje su bile za tog usera var messageNotification = new MessageNotification(); messageNotification.DeleteAllFrom(id, MemberSession.GetMemberId()); return(json); }
private MessageListModel GetChatMessageHistory(uint UserID, uint TalkerID) { MessageListModel chatHistoryList = new MessageListModel(); List <MessageModel> messageList = new Controller.Message().GetMessageWithUser(UserID, TalkerID); if (messageList != null) { foreach (MessageModel message in messageList) { chatHistoryList.Add(message); } } return(chatHistoryList); }
public IActionResult GetAllPostMessages(int userId, int postId = 0, int type = 1) { if (!_workContext.CurrentCustomer.IsRegistered()) { return(RedirectToRoute("Login", new { returnUrl = "Harag" })); } var currentUserId = _workContext.CurrentCustomer.Id; ViewBag.UserName = _workContext.CurrentCustomer.Username; var user = _cusService.GetCustomerById(userId); if (user == null) { return(NotFound()); } var messages = _messageService.GetUserMessages(currentUserId, userId); var post = _postService.GetPost(postId, ""); var model = new MessageListModel { MessageType = (MessageType)type, Messages = messages.Select(m => new MessageOutputModel { Message = m.Message, postId = (m.PostId == null? 0: (int)m.PostId), ToUser = m.User.GetFullName(), ToUserId = m.ToUserId, FromUserId = (int)m.FromUserId, FromUser = m.Customer.GetFullName(), Type = (MessageType)m.MessageType, DateTime = (DateTime)m.CreatedTime }).ToList() }; model.ToUserId = userId; model.ToUserName = user.GetFullName(); model.MessageType = (MessageType)type; if (post != null) { model.Post = post.ToPostModel(); } return(View("~/Themes/Pavilion/Views/Harag/Message/PostMessageList.cshtml", model)); }
public ActionResult Send(NewMessageModel chatMessage) { if (ModelState.IsValid) { _messageRepo.Insert(new ChatMessage { SendTime = DateTimeOffset.UtcNow, Text = chatMessage.Message, UserName = chatMessage.UserName }); var model = new MessageListModel { Messages = _messageRepo.GetLatestAfterId(chatMessage.LastCheckedId ?? 0).Select(m => new ChatMessageDto(m)) }; return(Json(model)); } GenericErrorModel errorModel = new GenericErrorModel().SetModelErrors(ViewData); return(Json(errorModel)); }
public ActionResult MessageCenter() { var _allMessages = new List <MessageCollection>(); // all messages var _tripMessages = new List <MessageCollection>(); // trip related messages var _recentMessages = new List <MessageCollection>(); // trip related messages var _oldtMessages = new List <MessageCollection>(); // trip related messages // get all messages for the user from the db var _blError = ThreadManager.GetAllMessages(User.Identity.GetUserId(), out _allMessages); // find the trip related messages and add to collection foreach (var _thread in _allMessages) { if (_thread.Thread.tripthreadid.HasValue && _thread.Thread.tripthreadid.Value > 0) { _tripMessages.Add(_thread); } } // get upto three latest message threads into recent list // rest in the old one if (_allMessages.Count > 3) { _recentMessages.AddRange(_allMessages.GetRange(0, 3)); _oldtMessages.AddRange(_allMessages.GetRange(3, _allMessages.Count - 3)); } else { _recentMessages = _allMessages; } // pass all objects to the view var model = new MessageListModel() { TripMessages = _tripMessages, RecentMessages = _recentMessages, OldMessages = _oldtMessages }; return(View(model)); }
public async Task <MessageListModel> GetMessages(int start = 0, int count = 10) { var ret = new MessageListModel { IsSucceeded = true }; var(user, privilege) = await GetUserPrivilegeAsync(); if (user == null) { ret.IsSucceeded = false; ret.ErrorMessage = "没有登录"; return(ret); } using (var db = new ApplicationDbContext(_dbContextOptions)) { var msgList = db.Message .Where(i => i.FromUserId == user.Id || i.ToUserId == user.Id) .OrderByDescending(i => i.Id) .Skip(start).Take(count); foreach (var i in msgList) { var userId = i.FromUserId == user.Id ? i.ToUserId : i.FromUserId; ret.Messages.Add(new MessageItemModel { Id = i.Id, RawSendTime = i.SendTime, Status = i.Status, ContentId = i.ContentId, Title = i.Title, UserId = userId, Type = i.Type, Direction = i.ToUserId == user.Id ? 2 : 1, UserName = db.Users.Select(j => new { j.Id, j.UserName }).FirstOrDefault(j => j.Id == userId)?.UserName }); } } return(ret); }