notification works
This commit is contained in:
@@ -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.
|
||||
|
||||
@@ -15,6 +15,7 @@ class AdminMenu : Menu
|
||||
{
|
||||
private:
|
||||
bool handleOperation(int choice);
|
||||
void handleNotificationEvent() override;
|
||||
public:
|
||||
void showMenu();
|
||||
void logout();
|
||||
|
||||
@@ -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.
|
||||
|
||||
@@ -16,6 +16,7 @@ class CustomerMenu : Menu
|
||||
{
|
||||
private:
|
||||
bool handleOperation(int choice);
|
||||
void handleNotificationEvent();
|
||||
public:
|
||||
void showMenu();
|
||||
void logout();
|
||||
|
||||
@@ -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.",
|
||||
|
||||
@@ -18,7 +18,6 @@ class Menu
|
||||
protected:
|
||||
Controller m_controller;
|
||||
std::atomic<bool> m_isMenuActive;
|
||||
std::atomic<bool> 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();
|
||||
|
||||
@@ -1407,4 +1407,30 @@ inline std::string selectComboPackage(util::Map<std::string, const ComboPackage*
|
||||
std::cout << "Enter a valid choice.\n";
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
inline void displayNewNotification(util::Vector<const Notification*> 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);
|
||||
}
|
||||
@@ -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
|
||||
|
||||
@@ -15,6 +15,7 @@ class TechnicianMenu : Menu
|
||||
{
|
||||
private:
|
||||
bool handleOperation(int choice);
|
||||
void handleNotificationEvent();
|
||||
public:
|
||||
void showMenu();
|
||||
void displayJobs();
|
||||
|
||||
Reference in New Issue
Block a user