Example #1
0
        public static void TestNotification()
        {
            var store = new DocumentStore {ConnectionStringName = "RavenServer"};


            store.Initialize();
            using (var orgSession = store.OpenSession())
            {

                //alert! Alert!
                var simpleUser = new SimpleUser {FullName = "andy"};
                var recipients = new NotificationRecipient[] {new NotificationRecipient(),};
                var notify = new Notification
                                 {
                                     Body = "body",

                                     SendDate = DateTime.Now,
                                     Title = "HIG Alert",
                                     NotificationRecipients = new NotificationRecipient[]
                                                                  {
                                                                      new NotificationRecipient
                                                                          {

                                                                              NotificationDeliveryTypes =
                                                                                  NotificationDeliveryTypes
                                                                                      .Toast |
                                                                                  NotificationDeliveryTypes
                                                                                      .Email,
                                                                              Users = new SimpleUser[]
                                                                                          {
                                                                                              new SimpleUser
                                                                                                  {
                                                                                                      FullName
                                                                                                          =
                                                                                                          "andy"
                                                                                                  }
                                                                                          }
                                                                          }
                                                                  },
                                 };
                orgSession.Store(notify);
                orgSession.SaveChanges();


            }
        }
Example #2
0
            void AddNotificationsToDB()
        {
            var notifications = new List<Notification>();
            for (var i = 0; i < 30; i++)
            {
                var notification = new Notification {Title = "notification"};
                var about = new SimpleUser
                                {
                                    FullName = "Andy Evans",
                                    EmailAddress = "*****@*****.**",
                                    UserId = "user_293ebdcf-d47c-4e63-9c12-3fbb6603b644"
                                };
                notification.About = about;
                notification.Body = "you have a notification";
                notification.Id = i + "notification";
                var notificationrecipients = new List<NotificationRecipient>();
                var notificationrecipient = new NotificationRecipient();
                notification.NotificationRecipients = new[] {new NotificationRecipient { NotificationDeliveryTypes =
                                      NotificationDeliveryTypes.Email,
                                   Users =
                                       new []
                                           {
                                               new SimpleUser {EmailAddress = "*****@*****.**",FullName = "Andy Evans",UserId = "user_293ebdcf-d47c-4e63-9c12-3fbb6603b644"}
                                               
                                           }}};
                notification.Read = true;
                notification.Sent = true;
                notification.SendDate = DateTime.Now;
                notification.ActualSentDate = DateTime.Now;
                notification.From = null;
                //notificationrecipient.Users = new IEnumerable<SimpleUser>();
                //var recipient = new SimpleUser();
                //recipient.EmailAddress= "*****@*****.**";
                //recipient.UserId = "user_293ebdcf-d47c-4e63-9c12-3fbb6603b644"
                //var recipients = new IEnumerable<SimpleUser>();
                //notificationrecipient.Users = new IEnumerable<recipient>();
                ////notification.NotificationRecipients
                notifications.Add(notification);
            }
            var store = new DocumentStore { ConnectionStringName = "RavenServer" };
            store.Initialize();
            using (var session = store.OpenSession())
            {
                foreach (var notification in notifications)
                {
                    session.Store(notification);
                }

                session.SaveChanges();
            }
        }