private void InformCaregivers(string enduserURI, string type, string severity, string msg, string desc) { var caregivers = storeAPI.GetCaregivers(enduserURI); foreach (string caregiverURIPath in caregivers) { int caregiverID = GetIdFromURI(caregiverURIPath); Console.WriteLine("[MeasurmentHandler] Informing caregiver: " + caregiverURIPath + " of: " + msg); storeAPI.PushJournalEntry(caregiverURIPath, type, severity, msg, desc); insertionAPI.InsertPushNotification(msg, caregiverID); } }
public void Handle(string json) { Console.WriteLine("Fuzzy inference invoked (Fall detection)..."); //Console.WriteLine("Object handled by fall: " + json ); var obj = JsonConvert.DeserializeObject <Event>(json); Queue.Refresh(); Queue.Push(obj, 15); var inferenceResult = Fuzzy.Infer(Queue.ToNormal()); Console.WriteLine("FALL RESULT: "); if (inferenceResult.Count == 0) { Console.WriteLine("NO RESULTS"); } else { Console.WriteLine("Final decision: " + inferenceResult.Count); } foreach (var item in inferenceResult) { Console.WriteLine("---------------"); Console.WriteLine(item); insertionAPI.InsertPushNotification(JsonConvert.SerializeObject(new DSS.RMQ.INS.PushNotification() { message = item, user_id = 2 })); } }
private void SendBPMeasurementNotification(string userURIPath) { var LANG = storeAPI.GetLang(userURIPath); string enduser_msg = Loc.Get(LANG, Loc.MSG, Loc.REMINDER_SENT, Loc.USR); string enduser_desc = Loc.Get(LANG, Loc.DES, Loc.REMINDER_SENT, Loc.USR); string caregiver_msg = Loc.Get(LANG, Loc.MSG, Loc.REMINDER_SENT, Loc.CAREGVR); string caregiver_desc = Loc.Get(LANG, Loc.DES, Loc.REMINDER_SENT, Loc.CAREGVR); string notification_type = "appointment"; // get the user data to retrieve caregiver uri as well var userData = storeAPI.GetUserData(userURIPath); if (userData != null) { // send notification for end user int enduserID = GetIdFromURI(userURIPath); JournalEntry endUserJournalEntry = storeAPI.PushJournalEntry(userURIPath, notification_type, "low", enduser_msg, enduser_desc); insertionAPI.InsertPushNotification(JsonConvert.SerializeObject(new DSS.RMQ.INS.PushNotification() { message = enduser_msg, user_id = enduserID })); // send notification to all caregivers List <int> caregiverJournalEntryIDs = new List <int>(); var profile = userData["enduser_profile"]; if (profile["caregivers"] != null) { foreach (var caregiverURIPath in profile["caregivers"]) { int caregiverID = GetIdFromURI((string)caregiverURIPath); var caregiverJournalEntry = storeAPI.PushJournalEntry((string)caregiverURIPath, notification_type, "low", caregiver_msg, caregiver_desc); insertionAPI.InsertPushNotification(JsonConvert.SerializeObject(new DSS.RMQ.INS.PushNotification() { message = caregiver_msg, user_id = caregiverID })); caregiverJournalEntryIDs.Add(caregiverJournalEntry.id); } } // generate reminder event var reminderEvent = new Event() { category = "USER_NOTIFICATIONS", content = new Content() { uuid = Guid.NewGuid().ToString(), name = "reminder_sent", value_type = "complex", val = new Dictionary <string, dynamic>() { { "user", new Dictionary <string, int>() { { "id", enduserID } } }, { "journal", new Dictionary <string, dynamic>() { { "id_enduser", endUserJournalEntry.id }, { "id_caregivers", caregiverJournalEntryIDs.ToArray <int>() } } }, } }, annotations = new Annotations() { timestamp = (long)DateTime.UtcNow.Subtract(new DateTime(1970, 1, 1)).TotalSeconds, source = "DSS" } }; Console.WriteLine("[MotionEventHandler] Inserting new reminderEvent: " + reminderEvent); insertionAPI.InsertEvent(JsonConvert.SerializeObject(reminderEvent)); } else { Console.WriteLine("[MotionEventHandler] Error - no information available on user with uri: " + userURIPath + ". Cannot send notification to end user and caregivers."); } }