예제 #1
0
        public void getUserNotifications()
        {
            MessagingCenter.Subscribe <UserLoggedIn>(this, "UserLoggedIn", async message =>
            {
                var userManagementServiceNotification = IoCContainer.GetInstance <IUserManagementService>();
                var serverNotifi = await userManagementServiceNotification.GetNotifications();

                //var serverNotiList = userManagementServiceNotification;
                using (SQLiteConnection conn = new SQLiteConnection(App.FilePath))
                {
                    conn.DropTable <NotificationDB>();
                    conn.CreateTable <NotificationDB>();
                    var notifications = conn.Table <NotificationDB>().ToList();

                    foreach (var n in serverNotifi)
                    {
                        NotificationDB passingNotification = new NotificationDB();
                        passingNotification.Body           = n.Body;
                        passingNotification.Time           = n.Time;

                        conn.Insert(passingNotification);
                    }
                    conn.Close();
                }
            });
        }
예제 #2
0
 /// <summary>
 /// When sending a notification finished, Update UI.
 /// </summary>
 /// <param name="sender"></param>
 /// <param name="e"></param>
 private void BackgroundWorker_ProgressChanged(object sender, ProgressChangedEventArgs e)
 {
     if (sendingSucceeded)
     {
         NotificationDB.UpdateSubscriberNotification(
             notification.NotificationId,
             sendingAccountId,
             succeeded: true,
             cancelled: false,
             errorMessage: null
             );
         succeededCount++;
     }
     else
     {
         NotificationDB.UpdateSubscriberNotification(
             notification.NotificationId,
             sendingAccountId,
             succeeded: false,
             cancelled: false,
             errorMessage: sendingErrorMessage
             );
         failedCount++;
     }
     if (sendingNotificationCount < subscribers.Count)
     {
         sendingNotificationCount++;
     }
     succeededNotificationsLabel.Text = "Succeeded: " + succeededCount;
     failedNotificationsLabel.Text    = "Failed: " + failedCount;
     sendingEmailsLabel.Text          = "Sending notifications... ( " + sendingNotificationCount + " / " + subscribers.Count + " )";
 }
예제 #3
0
 public ActionResult Create(Notifications notifications)
 {
     if (ModelState.IsValid)
     {
         NotificationDB.AddNotification(db, notifications);
         return(RedirectToAction("Notifications"));
     }
     return(View(notifications));
 }
예제 #4
0
        public ActionResult Delete(int id)
        {
            Notifications Notification = NotificationDB.FindNotification(db, id);

            if (Notification != null)
            {
                NotificationDB.DeleteNotification(db, Notification);
                return(RedirectToAction("Notifications"));
            }
            return(View());
        }
예제 #5
0
        public async Task <int> AddNotification(Models.Notification notification)
        {
            var dbModel = new NotificationDB()
            {
                Link = notification.Link,
                Id   = notification.Id,
                Text = notification.Text,
            };
            await _databaseContext.Notifications.AddAsync(dbModel);

            await _databaseContext.SaveChangesAsync();

            return(dbModel.Id);
        }
예제 #6
0
        // Allows a search of the database by both message content and time
        private void findTimeMessageButton_Click(object sender, EventArgs e)
        {
            using (Form3 form3 = new Form3())
            {
                if (form3.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    String input = form3.SelectedText;

                    DateTime startTime = TimeReset.ResetTimeToStartOfDay(firstDateTimePicker.Value);
                    DateTime endTime   = TimeReset.ResetTimeToEndOfDay(secondDateTimePicker.Value);

                    if (endTime < startTime)
                    {
                        MessageBox.Show("The first date must be before the second date!", "Error!", MessageBoxButtons.OK, MessageBoxIcon.Error);
                    }
                    else
                    {
                        List <Notification> notifications = new List <Notification>();
                        NotificationDB.SearchTimeMessage(input, startTime, endTime, ref notifications);
                        DataTable datatable = new DataTable();
                        datatable.Columns.Add("Sender");
                        datatable.Columns.Add("Subject");
                        datatable.Columns.Add("Message");
                        datatable.Columns.Add("Date Sent");
                        datatable.Columns.Add("Number Sent");

                        foreach (Notification notification in notifications)
                        {
                            datatable.Rows.Add(
                                notification.SenderName,
                                notification.Subject,
                                notification.Message,
                                notification.SentDate.ToString("MM/dd/yyyy HH:mm"),
                                notification.NumberSent
                                );
                        }

                        notificationDataGridView.DataSource = datatable;

                        notificationDataGridView.Columns[0].Width = 75;
                        notificationDataGridView.Columns[1].Width = 105;
                        notificationDataGridView.Columns[2].Width = 585;
                        notificationDataGridView.Columns[3].Width = 100;
                        notificationDataGridView.Columns[4].Width = 50;
                    }
                }
            }
        }
예제 #7
0
        static void TestAdd()
        {
            Notification notif = new Notification();

            notif.Name               = "First One!";
            notif.Latitude           = -19.936220;
            notif.Longitude          = -43.935169;
            notif.Description        = "Test notifiation";
            notif.DateAdded          = DateTime.Now;
            notif.UserID             = 2;
            notif.ExpiresOn          = DateTime.Now.AddDays(1);
            notif.NotificationTypeId = 1;

            NotificationDB db = new NotificationDB();

            db.Add(notif);
        }
예제 #8
0
        public App(string filePath)
        {
            CrossSecureStorage.Current.SetValue("RememberMe", "false");
            Application.Current.Properties["RememberMe"] = "false";
            IoCContainer = new Container();
            // Dependancy Injections:
            IoCContainer.Register <IBackgroundLocationService, BackgroundLocationService>(Lifestyle.Singleton);
            IoCContainer.Register <ILocationService, LocationService>(Lifestyle.Singleton);
            IoCContainer.Register <IUserManagementService, UserManagementService>(Lifestyle.Singleton);
            IoCContainer.Register <IItineraryService, ItineraryService>(Lifestyle.Singleton);
            //Register Syncfusion license
            InitializeComponent();
            Syncfusion.Licensing.SyncfusionLicenseProvider.RegisterLicense(syncfusionLicense);

            MessagingCenter.Subscribe <object, string>(this, App.FirebaseTokenKey, OnKeyReceived);

            // MainPage = new LoginWithSocialIconPage();

            FilePath = filePath;

            MessagingCenter.Subscribe <object, string[]>(this, App.NotificationBodyReceivedKey, (object sender, string[] msg) =>
            {
                BottomNavigationPage temp     = new BottomNavigationPage();
                NotificationDB notificationDB = new NotificationDB();
                Device.BeginInvokeOnMainThread(() =>
                {
                    DependencyService.Get <NotificationServices>().CreateNotification(msg[0], msg[1]);
                    notificationDB.Title = msg[0];
                    notificationDB.Body  = msg[1];


                    using (SQLiteConnection conn = new SQLiteConnection(App.FilePath))
                    {
                        conn.CreateTable <NotificationDB>();
                        var notificaitons = conn.Table <NotificationDB>().ToList();
                        int rowsAdded     = conn.Insert(notificationDB);
                        //notificaitons = conn.Table<NotificationDB>().ToList();
                        conn.Close();
                    }
                    //me.loadNotifications();
                });
            });

            getUserNotifications();
        }
예제 #9
0
        protected override void OnStart()
        {
            LoadPersistentValues();
            var data = new EncounterDataService();

            this.BindingContext = data.NotificationViewModel;
            var status = CrossSecureStorage.Current.GetValue("SignedIn", null);

            if (status != null && status == "True")
            {
                MainPage = new NavigationPage(new BottomNavigationPage());
                var name    = CrossSecureStorage.Current.GetValue("Name");
                var surname = CrossSecureStorage.Current.GetValue("Surname");
                var email   = CrossSecureStorage.Current.GetValue("Email");
                MessagingCenter.Subscribe <UserLoggedIn>(this, "UserLoggedIn", async message =>
                {
                    var userManagementServiceNotification = IoCContainer.GetInstance <IUserManagementService>();
                    var serverNotifi = await userManagementServiceNotification.GetNotifications();

                    //var serverNotiList = userManagementServiceNotification;
                    using (SQLiteConnection conn = new SQLiteConnection(App.FilePath))
                    {
                        conn.DropTable <NotificationDB>();
                        conn.CreateTable <NotificationDB>();
                        var notifications = conn.Table <NotificationDB>().ToList();

                        foreach (var n in serverNotifi)
                        {
                            NotificationDB passingNotification = new NotificationDB();
                            passingNotification.Body           = n.Body;
                            passingNotification.Time           = n.Time;

                            conn.Insert(passingNotification);
                        }
                        conn.Close();
                    }
                });
                IoCContainer.GetInstance <IUserManagementService>().UserLoggedIn(name, surname, email);
            }
            else
            {
                MainPage = new LoginWithSocialIconPage();
            }
        }
예제 #10
0
        /// <summary>
        /// When clicked, sends the notification.
        /// </summary>
        /// <param name="sender"></param>
        /// <param name="e"></param>
        private void SendButton_Click(object sender, EventArgs e)
        {
            // get and validate Notification data from controls
            notification = GetNotification();
            if (!ValidateNotification(notification))
            {
                return;
            }

            // make a confirmation to prevent the accidentally button click
            DialogResult dialogResult = ShowConfirmMessageBox(
                "Send Notification Confirmation",
                "Do you want to send the notification?"
                );

            if (dialogResult != DialogResult.OK)
            {
                return;
            }

            // insert and get subscribers
            SendNotificationResult result = NotificationDB.SendNotification(notification, ref subscribers);

            switch (result)
            {
            case SendNotificationResult.NoSubscribers:
                ShowInfoMessageBox("Sent Notification Terminated", "No any subscriber");
                return;

            case SendNotificationResult.DatabaseError:
                ShowErrorMessageBox(DatabaseError, "Insert notification failed!");
                return;
            }

            // lock controls until finished
            SetControlsEnabledRecursion(this, false);

            sendingNotificationCount         = 1;
            succeededNotificationsLabel.Text = "Succeeded: 0";
            failedNotificationsLabel.Text    = "Failed: 0";
            sendingEmailsLabel.Text          = "Sending notifications... ( 1 / " + subscribers.Count + " )";
            backgroundWorker.RunWorkerAsync();
        }
예제 #11
0
        // Allows a search of the database by both message content
        private void findMessageButton_Click(object sender, EventArgs e)
        {
            using (Form3 form3 = new Form3())
            {
                if (form3.ShowDialog() == System.Windows.Forms.DialogResult.OK)
                {
                    String input = form3.SelectedText;

                    List <Notification> notifications = new List <Notification>();
                    NotificationDB.Search(input, ref notifications);
                    DataTable datatable = new DataTable();
                    datatable.Columns.Add("Sender");
                    datatable.Columns.Add("Subject");
                    datatable.Columns.Add("Message");
                    datatable.Columns.Add("Date Sent");
                    datatable.Columns.Add("Number Sent");

                    foreach (Notification notification in notifications)
                    {
                        datatable.Rows.Add(
                            notification.SenderName,
                            notification.Subject,
                            notification.Message,
                            notification.SentDate.ToString("MM/dd/yyyy HH:mm"),
                            notification.NumberSent
                            );
                    }

                    notificationDataGridView.DataSource = datatable;

                    notificationDataGridView.Columns[0].Width = 75;
                    notificationDataGridView.Columns[1].Width = 105;
                    notificationDataGridView.Columns[2].Width = 585;
                    notificationDataGridView.Columns[3].Width = 100;
                    notificationDataGridView.Columns[4].Width = 50;
                }
            }
        }
예제 #12
0
 /// <summary>
 /// lists all notifications with buttons to create and delete
 /// </summary>
 /// <returns></returns>
 public ActionResult Notifications()
 {
     return(View(NotificationDB.GetNotifications(db)));
 }
예제 #13
0
 public void notificationToDB(NotificationDB notificationObj)
 {
     throw new NotImplementedException();
 }
예제 #14
0
 public PartialViewResult UserNotifications()
 {
     return(PartialView(NotificationDB.GetNotifications(db)));
 }
예제 #15
0
 static void TestGetNearBy(double Latitude, double Longitude)
 {
     NotificationDB db   = new NotificationDB();
     var            list = db.Get(Latitude, Longitude);
 }
예제 #16
0
 static void TestGet()
 {
     NotificationDB db   = new NotificationDB();
     var            list = db.Get();
 }