Ejemplo n.º 1
0
        public static string GetNewNotificationsForUser(string user)
        {
            DataAccess.MongoDB mdb = new DataAccess.MongoDB("RoutineManagement");
            List<BsonDocument> notifications = new List<BsonDocument>();
            string ret = "null";

            for (int i = 0; i < 600; i++)
            {

                notifications = mdb.Get(NOTIFICATION_COL_NAME, new BsonDocument("user", user).Add("sent", "false"));

                if (notifications.Count > 0)
                {
                    //convert new notifications to JSON string
                    ret = ParseNotifications(notifications, (item) =>
                    {

                        BsonDocument updated = (BsonDocument)item.Clone();
                        updated["sent"] = "true";
                        //mark notification as sent
                        mdb.Update(NOTIFICATION_COL_NAME, item, updated);

                    });

                    break;
                }

                System.Threading.Thread.Sleep(200);
            }

            return ret;
        }
Ejemplo n.º 2
0
        public static void ReadNotifications(string user)
        {
            List<BsonDocument> notifications = new List<BsonDocument>();

            DataAccess.MongoDB mdb = new DataAccess.MongoDB("RoutineManagement");

            notifications = mdb.Get(NOTIFICATION_COL_NAME, new BsonDocument("user", user).Add("seen", "false"));

            foreach (BsonDocument doc in notifications)
            {
                BsonDocument updated = (BsonDocument)doc.Clone();
                updated["seen"] = "true";
                mdb.Update(NOTIFICATION_COL_NAME, doc, updated);
            }
        }
Ejemplo n.º 3
0
        public static string GetNotificationsForUser(string user)
        {
            List<BsonDocument> notifications = new List<BsonDocument>();
            DataAccess.MongoDB mdb = new DataAccess.MongoDB("RoutineManagement");

            notifications = mdb.Get(NOTIFICATION_COL_NAME, new BsonDocument("user", user).Add("sent", "true"), "date");

            return ParseNotifications(notifications);
        }