public Object getNotifcations(string appID, int empID, int max_notification_id) { var result = NotificationEngineDataService.GetNotifcations(appID, empID, max_notification_id); long maxId = 0; int unReadCount = 0; if (result.Count > 0) { maxId = result.Max(p => p.NotificationID); unReadCount = result.Count(p => p.IsRead == false); } return(new { Notifications = result.Select(p => new { NotificationID = p.NotificationID, NotificationDetail = p.NotificationDetail, IsRead = p.IsRead, CreatedOn = p.CreatedOn.ToString("MM/dd/yyyy hh:mm tt"), extraDataAsJson = p.extraDataAsJson }).ToList(), MaxID = maxId, UnReadCount = unReadCount }); }
public Object getNotifcations(long max_notification_id) { var myConnData = new CustomConnectionData(); if (!GlobalDataManager._userIdentity.TryGetValue(Context.ConnectionId, out myConnData)) { return(null); } var result = NotificationEngineDataService.GetNotifcations(myConnData.AppID, myConnData.UserID, max_notification_id); long maxId = 0; int unReadCount = 0; if (result.Count > 0) { maxId = result.Max(p => p.ID); unReadCount = result.Count(p => p.IsRead == false); } return(new { Notifications = result.Select(p => new { NotificationID = p.NotificationID, NotificationDetail = p.NotificationDetail, IsRead = p.IsRead, CreatedOn = p.CreatedOn.ToString("MM/dd/yyyy hh:mm tt"), extraDataAsJson = p.extraDataAsJson }).ToList(), MaxID = maxId, UnReadCount = unReadCount }); }
public void markNotification(String pNotificationID, Boolean isRead, Boolean markAll) { var myConnData = new CustomConnectionData(); if (!GlobalDataManager._userIdentity.TryGetValue(Context.ConnectionId, out myConnData)) { return; } NotificationEngineDataService.UpdateNotificationReadStatus(pNotificationID, myConnData.AppID, myConnData.UserID, isRead, markAll, DateTime.UtcNow); }
public override Task OnDisconnected(bool stopCalled) { var empConn = new CustomConnectionData(); if (GlobalDataManager._userIdentity.TryGetValue(Context.ConnectionId, out empConn)) { GlobalDataManager._connections.Remove(empConn.ToString(), Context.ConnectionId); GlobalDataManager._userIdentity.TryRemove(Context.ConnectionId, out empConn); } NotificationEngineDataService.UpdateConnectionDetail(Context.ConnectionId, DateTime.UtcNow); return(base.OnDisconnected(stopCalled)); }
private Int64 SaveNotification(string ReceiverAppId, int to, string message, DateTime messageTime, String extraDataAsJson) { RealTimeNotifications obj = new RealTimeNotifications(); obj.NotificationID = 0; obj.receiverAppID = ReceiverAppId; obj.SenderID = 0; obj.ReceiverID = to; obj.NotificationDetail = message; obj.IsRead = false; obj.CreatedOn = messageTime; obj.extraDataAsJson = extraDataAsJson; var result = NotificationEngineDataService.SaveNotification(obj); return(result); }
public override Task OnConnected() { try { String userid = Context.QueryString["uid"]; String appid = Context.QueryString["appid"]; String requesterAppUrl = Context.Headers["Origin"]; /* * Perform Employee ID, App ID validation, URL validation */ var obj = GlobalDataManager.NotificationApplicationsList.Where(a => a.AppId == appid && a.AppBaseUrl == requesterAppUrl).FirstOrDefault(); if (obj == null) { Clients.Caller.stopConnection("Invalid Request or Unregistered App!"); return(null); } var empConn = new CustomConnectionData() { UserID = userid, AppID = appid }; GlobalDataManager._userIdentity.TryAdd(Context.ConnectionId, empConn); // add conection with reference to employee(key : 'employeeID_appID') IEnumerable <string> employeeConnections = GlobalDataManager._connections.GetConnections(empConn.ToString()); if (!employeeConnections.Contains(Context.ConnectionId)) { GlobalDataManager._connections.Add(empConn.ToString(), Context.ConnectionId); } NotificationEngineDataService.SaveConnectionDetail(Context.ConnectionId, userid.ToString(), appid, requesterAppUrl, this.CallerIPAddress, DateTime.UtcNow); } catch (Exception ex) { PUCIT.AIMRL.Common.Logger.LogHandler.WriteLog("App", ex.ToString(), PUCIT.AIMRL.Common.Logger.LogType.ErrorMsg); Clients.Caller.stopConnection("Invalid Request"); } return(base.OnConnected()); }
private long SaveNotification(CustomConnectionData src, CustomConnectionData target, String message, DateTime messageTime, String extraDataAsJson, out String uniqueNotificationID) { uniqueNotificationID = Guid.NewGuid().ToString(); RealTimeNotifications obj = new RealTimeNotifications(); obj.NotificationID = uniqueNotificationID; obj.SenderAppID = src.AppID; obj.SenderID = src.UserID; obj.ReceiverAppID = target.AppID; obj.ReceiverID = target.UserID; obj.NotificationDetail = message; obj.IsRead = false; obj.CreatedOn = messageTime; obj.extraDataAsJson = extraDataAsJson; var result = NotificationEngineDataService.SaveNotification(obj); return(result); }
public void markNotification(Int64 pNotificationID, string receiverAppID, int empID, Boolean isRead, Boolean markAll) { NotificationEngineDataService.UpdateNotificationReadStatus(pNotificationID, receiverAppID, empID, isRead, markAll, DateTime.UtcNow); }