diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp index 52545dd..3dfd581 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.cpp @@ -153,6 +153,12 @@ bool AdminMenu::handleOperation(int choice) return true; } +void AdminMenu::handleNotificationEvent() +{ + auto notifications = m_controller.getNotifications(); + displayNewNotification(notifications); +} + /* Function: logout Description: Logs out the currently authenticated admin user. diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.h index 7db9c4a..ee91a70 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/AdminMenu.h @@ -15,6 +15,7 @@ class AdminMenu : Menu { private: bool handleOperation(int choice); + void handleNotificationEvent() override; public: void showMenu(); void logout(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp index d4c329e..c8094a8 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.cpp @@ -124,6 +124,12 @@ bool CustomerMenu::handleOperation(int choice) return true; } +void CustomerMenu::handleNotificationEvent() +{ + auto notifications = m_controller.getNotifications(); + displayNewNotification(notifications); +} + /* Function: logout Description: Logs out the currently authenticated customer user. diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.h index 5366023..caa1dfd 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/CustomerMenu.h @@ -16,6 +16,7 @@ class CustomerMenu : Menu { private: bool handleOperation(int choice); + void handleNotificationEvent(); public: void showMenu(); void logout(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/Menu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/Menu.cpp index d624432..c8a4c19 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/Menu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/Menu.cpp @@ -3,7 +3,6 @@ Menu::Menu() : m_isMenuActive(false), - m_hasNewNotifications(false), m_accountDisabledEvent(NULL), m_notificationAvailableEvent(NULL), m_shutdownEvent(NULL) {} @@ -20,7 +19,6 @@ void Menu::startEventListener() return; } m_isMenuActive.store(true); - m_hasNewNotifications.store(false); m_accountDisabledEvent = CreateEventA(NULL, FALSE, FALSE, NULL); m_notificationAvailableEvent = CreateEventA(NULL, FALSE, FALSE, NULL); m_shutdownEvent = CreateEventA(NULL, FALSE, FALSE, NULL); @@ -43,7 +41,7 @@ void Menu::eventListenerLoop() handleAccountDisabledEvent(); break; case WAIT_OBJECT_0 + 1: - m_hasNewNotifications.store(true); + handleNotificationEvent(); break; case WAIT_OBJECT_0 + 2: return; @@ -82,11 +80,6 @@ void Menu::stopEventListener() void Menu::handleAccountDisabledEvent() { m_isMenuActive.store(false); - /*MessageBoxA( - NULL, - "Your account has been disabled.", - "Account Disabled", - MB_OK | MB_ICONWARNING);*/ MessageBoxA( GetConsoleWindow(), "Your account has been disabled.", diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/Menu.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/Menu.h index 5cfdde7..146efa8 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/Menu.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/Menu.h @@ -18,7 +18,6 @@ class Menu protected: Controller m_controller; std::atomic m_isMenuActive; - std::atomic m_hasNewNotifications; HANDLE m_accountDisabledEvent; HANDLE m_notificationAvailableEvent; HANDLE m_shutdownEvent; @@ -27,6 +26,7 @@ protected: void stopEventListener(); void eventListenerLoop(); void handleAccountDisabledEvent(); + virtual void handleNotificationEvent() = 0; public: Menu(); virtual ~Menu(); diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h index c6ebaa6..15a1ae4 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/MenuHelper.h @@ -1407,4 +1407,30 @@ inline std::string selectComboPackage(util::Map notifications) +{ + const Notification* notification = nullptr; + size_t numberOfNotifications = notifications.getSize(); + for (int index = 0; index < numberOfNotifications; index++) + { + if (!notification) + { + notification = notifications[index]; + } + else + { + if (notification->getId() < notifications[index]->getId()) + { + notification = notifications[index]; + } + } + } + MessageBoxA( + GetConsoleWindow(), + notification->getMessage().c_str(), + notification->getTitle().c_str(), + MB_OK | + MB_ICONINFORMATION); } \ No newline at end of file diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp index d026bfc..07b1461 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.cpp @@ -99,6 +99,12 @@ bool TechnicianMenu::handleOperation(int choice) return true; } +void TechnicianMenu::handleNotificationEvent() +{ + auto notifications = m_controller.getNotifications(); + displayNewNotification(notifications); +} + /* Function: displayJobs Description: Displays all Jobs assigned to a Technician diff --git a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.h b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.h index ed3b5fb..9ba36e9 100644 --- a/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.h +++ b/Trenser.VehicleServiceSystem/Trenser.VehicleServiceSystem/views/TechnicianMenu.h @@ -15,6 +15,7 @@ class TechnicianMenu : Menu { private: bool handleOperation(int choice); + void handleNotificationEvent(); public: void showMenu(); void displayJobs();