public async Task <JsonResult> Insert()
        {
            try {
                var id    = Guid.NewGuid();
                var text  = Request.Form["text"];
                var mtype = Guid.Parse(Request.Form["mtype"]);
                var sid   = Request.Form["sid"];
                var rid   = Guid.Parse(Request.Form["rid"]);
                var api   = Guid.Parse(Request.Form["api"]);
                if (MessagingConversationService.Insert(id, text, mtype, sid, rid, DateTime.Now))
                {
                    //add notification to users that this user sent a message
                    //do not include the uid that sent the message
                    var receipents = MessagingRoomParticipantService.GetByRoomIDExceptUID(rid, sid);
                    var nid        = Guid.NewGuid();
                    NotificationService.Insert(nid, text, api, "New Message");
                    foreach (var r in receipents)
                    {
                        var nrID = Guid.NewGuid();
                        NotificationService.InsertNR(nrID, nid, r.UserID, api);
                        //invoke signal r that there is a new message notification for the users
                        //nrID=id for notificationReceipent so that if its confirmed received this id will be passed back to the
                        //server to remove the notificationreceipent

                        var textToSend = this.IdentifyMessageNotification(mtype.ToString(), text);
                        NotificationManagerHub.SendNotification(nrID.ToString(), api.ToString(), r.UserID, "New Message", textToSend);
                        MessagingAppHub.SendNotification(id.ToString(), api.ToString(), rid.ToString());
                    }
                    return(Success(id.ToString()));
                }
                return(Failed(MessageUtility.ServerError()));
            } catch { return(Failed(MessageUtility.ServerError())); }
        }
 public async Task <JsonResult> Test()
 {
     try {
         NotificationManagerHub.Test();
         return(Success(""));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
示例#3
0
 public async Task <JsonResult> InsertReceipent()
 {
     try {
         var id        = Guid.NewGuid();
         var notifInfo = Guid.Parse(Request.Form["nid"]);
         var rid       = Request.Form["rid"];
         var api       = Guid.Parse(Request.Form["api"]);
         if (NotificationService.InsertNR(id, notifInfo, rid, api))
         {
             var data = NotificationService.GetByID_N(notifInfo, api);
             NotificationManagerHub.SendNotification(id.ToString(), api.ToString(), rid, data.Title, data.Message);
             return(Success(id.ToString()));
         }
         return(Failed(MessageUtility.ServerError()));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }
 public async Task <JsonResult> NMCheckUserNotification()
 {
     try {
         var uid     = Guid.Parse(Request.Form["id"]);
         var aid     = Guid.Parse(Request.Form["aid"]);
         var gdCatID = Guid.Parse(Request.Form["gdcid"]);
         var notificationsReceipent = GroupingsDataService.GetBySIDCIDAID(uid, gdCatID, aid, false);
         foreach (var notif in notificationsReceipent)
         {
             var sid = SignalRDataService.GetByOIDAPI(notif.SourceID, aid);
             NotificationManagerHub.NewNotification(notif.OwnerID.ToString(), sid.SignalRID.ToString());
             //remove the receipent from database after it sents the notification to the receiver
             GroupingsDataService.Remove(notif.ID, notif.OwnerID, notif.API);
         }
         return(Success(""));
     } catch { return(Failed(MessageUtilityService.ServerError())); }
 }
示例#5
0
 public async Task <JsonResult> CheckOwnerNotification()
 {
     try {
         var api = Guid.Parse(Request.Form["api"]);
         var cid = Guid.Parse(Request.Form["cid"]);
         var uid = Request.Form["uid"];
         //check user receipent
         var receipents = NotificationService.GetByUIDAPI_NR(uid, api);
         if (receipents.Count > 0)
         {
             foreach (var r in receipents)
             {
                 var data = NotificationService.GetByID_N(r.NotificationInfo, r.API);
                 //receipent Notification ID so it can be removed
                 NotificationManagerHub.SendNotification(r.ID.ToString(), data.apiKey.ToString(), r.ReceiverID, data.Title, data.Message);
             }
         }
         return(Success(""));
     } catch { return(Failed(MessageUtility.ServerError())); }
 }