disable working
This commit is contained in:
@@ -622,3 +622,8 @@ void Controller::shutdown()
|
|||||||
auto& dataStore = DataStore::getInstance();
|
auto& dataStore = DataStore::getInstance();
|
||||||
dataStore.shutdown();
|
dataStore.shutdown();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Controller::registerEvents(HANDLE accountDisabledEvent, HANDLE notificationAvailableEvent)
|
||||||
|
{
|
||||||
|
m_authenticationManagementService.registerEvents(accountDisabledEvent, notificationAvailableEvent);
|
||||||
|
}
|
||||||
|
|||||||
@@ -8,6 +8,7 @@ Date:19-May-2026
|
|||||||
*/
|
*/
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include <windows.h>
|
||||||
#include <string>
|
#include <string>
|
||||||
#include "AuthenticationManagementService.h"
|
#include "AuthenticationManagementService.h"
|
||||||
#include "Enums.h"
|
#include "Enums.h"
|
||||||
@@ -72,4 +73,5 @@ public:
|
|||||||
void configureNotifications(bool paymentNotifications, bool serviceNotifications);
|
void configureNotifications(bool paymentNotifications, bool serviceNotifications);
|
||||||
bool initialize();
|
bool initialize();
|
||||||
void shutdown();
|
void shutdown();
|
||||||
|
void registerEvents(HANDLE accountDisabledEvent, HANDLE notificationAvailableEvent);
|
||||||
};
|
};
|
||||||
+14
-7
@@ -16,6 +16,8 @@ Date:19-May-2026
|
|||||||
|
|
||||||
User* AuthenticationManagementService::m_authenticatedUser = nullptr;
|
User* AuthenticationManagementService::m_authenticatedUser = nullptr;
|
||||||
EventManager AuthenticationManagementService::m_eventManager;
|
EventManager AuthenticationManagementService::m_eventManager;
|
||||||
|
HANDLE AuthenticationManagementService::m_accountDisabledEvent = NULL;
|
||||||
|
HANDLE AuthenticationManagementService::m_notificationsAvailableEvent = NULL;
|
||||||
|
|
||||||
/*
|
/*
|
||||||
Function: login
|
Function: login
|
||||||
@@ -43,20 +45,17 @@ bool AuthenticationManagementService::login(const std::string& username, const s
|
|||||||
user->getId(),
|
user->getId(),
|
||||||
[]()
|
[]()
|
||||||
{
|
{
|
||||||
HANDLE eventHandle = OpenEventA(EVENT_MODIFY_STATE, FALSE, "VehicleServiceSystem_AccountDisabled");
|
if (m_accountDisabledEvent)
|
||||||
if (eventHandle)
|
|
||||||
{
|
{
|
||||||
SetEvent(eventHandle);
|
SetEvent(m_accountDisabledEvent);
|
||||||
CloseHandle(eventHandle);
|
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
[]()
|
[]()
|
||||||
{
|
{
|
||||||
HANDLE eventHandle = OpenEventA(EVENT_MODIFY_STATE, FALSE, "VehicleServiceSystem_NotificationAvailable");
|
HANDLE eventHandle = OpenEventA(EVENT_MODIFY_STATE, FALSE, "VehicleServiceSystem_NotificationAvailable");
|
||||||
if (eventHandle)
|
if (m_notificationsAvailableEvent)
|
||||||
{
|
{
|
||||||
SetEvent(eventHandle);
|
SetEvent(m_notificationsAvailableEvent);
|
||||||
CloseHandle(eventHandle);
|
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
return true;
|
return true;
|
||||||
@@ -89,6 +88,8 @@ void AuthenticationManagementService::logout()
|
|||||||
{
|
{
|
||||||
m_eventManager.shutdown();
|
m_eventManager.shutdown();
|
||||||
m_authenticatedUser = nullptr;
|
m_authenticatedUser = nullptr;
|
||||||
|
m_accountDisabledEvent = NULL;
|
||||||
|
m_notificationsAvailableEvent = NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
/*
|
/*
|
||||||
@@ -115,3 +116,9 @@ void AuthenticationManagementService::changePassword(const std::string& newPassw
|
|||||||
trackedUsersMap.getValueAt(index).state = RecordState::MODIFIED;
|
trackedUsersMap.getValueAt(index).state = RecordState::MODIFIED;
|
||||||
m_dataStore.saveUsers();
|
m_dataStore.saveUsers();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void AuthenticationManagementService::registerEvents(HANDLE accountDisabledEvent, HANDLE notifictionAvailableEvent)
|
||||||
|
{
|
||||||
|
m_accountDisabledEvent = accountDisabledEvent;
|
||||||
|
m_notificationsAvailableEvent = notifictionAvailableEvent;
|
||||||
|
}
|
||||||
|
|||||||
+4
@@ -9,6 +9,7 @@ Date:19-May-2026
|
|||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
#include <string>
|
#include <string>
|
||||||
|
#include <windows.h>
|
||||||
#include "EventManager.h"
|
#include "EventManager.h"
|
||||||
#include "DataStore.h"
|
#include "DataStore.h"
|
||||||
|
|
||||||
@@ -19,6 +20,8 @@ class AuthenticationManagementService
|
|||||||
private:
|
private:
|
||||||
static User* m_authenticatedUser;
|
static User* m_authenticatedUser;
|
||||||
static EventManager m_eventManager;
|
static EventManager m_eventManager;
|
||||||
|
static HANDLE m_accountDisabledEvent;
|
||||||
|
static HANDLE m_notificationsAvailableEvent;
|
||||||
DataStore& m_dataStore;
|
DataStore& m_dataStore;
|
||||||
public:
|
public:
|
||||||
AuthenticationManagementService() : m_dataStore(DataStore::getInstance()) {}
|
AuthenticationManagementService() : m_dataStore(DataStore::getInstance()) {}
|
||||||
@@ -26,4 +29,5 @@ public:
|
|||||||
void logout();
|
void logout();
|
||||||
void changePassword(const std::string& newPassword);
|
void changePassword(const std::string& newPassword);
|
||||||
User* getAuthenticatedUser();
|
User* getAuthenticatedUser();
|
||||||
|
void registerEvents(HANDLE accountDisabledEvent, HANDLE notificationAvailableEvent);
|
||||||
};
|
};
|
||||||
|
|||||||
@@ -85,6 +85,11 @@ Return type: bool - true if menu continues, false if logout
|
|||||||
*/
|
*/
|
||||||
bool AdminMenu::handleOperation(int choice)
|
bool AdminMenu::handleOperation(int choice)
|
||||||
{
|
{
|
||||||
|
if (!m_isMenuActive)
|
||||||
|
{
|
||||||
|
logout();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
switch (choice)
|
switch (choice)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ Date:19-May-2026
|
|||||||
class AdminMenu : Menu
|
class AdminMenu : Menu
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Controller m_controller;
|
|
||||||
bool handleOperation(int choice);
|
bool handleOperation(int choice);
|
||||||
public:
|
public:
|
||||||
void showMenu();
|
void showMenu();
|
||||||
|
|||||||
@@ -80,6 +80,11 @@ Return type: bool - true if menu continues, false if logout
|
|||||||
*/
|
*/
|
||||||
bool CustomerMenu::handleOperation(int choice)
|
bool CustomerMenu::handleOperation(int choice)
|
||||||
{
|
{
|
||||||
|
if (!m_isMenuActive)
|
||||||
|
{
|
||||||
|
logout();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
switch (choice)
|
switch (choice)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
|
|||||||
@@ -15,7 +15,6 @@ Date:19-May-2026
|
|||||||
class CustomerMenu : Menu
|
class CustomerMenu : Menu
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Controller m_controller;
|
|
||||||
bool handleOperation(int choice);
|
bool handleOperation(int choice);
|
||||||
public:
|
public:
|
||||||
void showMenu();
|
void showMenu();
|
||||||
|
|||||||
@@ -21,9 +21,10 @@ void Menu::startEventListener()
|
|||||||
}
|
}
|
||||||
m_isMenuActive.store(true);
|
m_isMenuActive.store(true);
|
||||||
m_hasNewNotifications.store(false);
|
m_hasNewNotifications.store(false);
|
||||||
m_accountDisabledEvent = CreateEventA(NULL, FALSE, FALSE, "VehicleServiceSystem_AccountDisabled");
|
m_accountDisabledEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
|
||||||
m_notificationAvailableEvent = CreateEventA(NULL, FALSE, FALSE, "VehicleServiceSystem_NotificationAvailable");
|
m_notificationAvailableEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
|
||||||
m_shutdownEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
|
m_shutdownEvent = CreateEventA(NULL, FALSE, FALSE, NULL);
|
||||||
|
m_controller.registerEvents(m_accountDisabledEvent, m_notificationAvailableEvent);
|
||||||
m_eventListenerThread = std::thread(&Menu::eventListenerLoop, this);
|
m_eventListenerThread = std::thread(&Menu::eventListenerLoop, this);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -11,10 +11,12 @@ Date:16-Jun-2026
|
|||||||
#include <windows.h>
|
#include <windows.h>
|
||||||
#include <atomic>
|
#include <atomic>
|
||||||
#include <thread>
|
#include <thread>
|
||||||
|
#include "Controller.h"
|
||||||
|
|
||||||
class Menu
|
class Menu
|
||||||
{
|
{
|
||||||
protected:
|
protected:
|
||||||
|
Controller m_controller;
|
||||||
std::atomic<bool> m_isMenuActive;
|
std::atomic<bool> m_isMenuActive;
|
||||||
std::atomic<bool> m_hasNewNotifications;
|
std::atomic<bool> m_hasNewNotifications;
|
||||||
HANDLE m_accountDisabledEvent;
|
HANDLE m_accountDisabledEvent;
|
||||||
|
|||||||
@@ -70,6 +70,11 @@ Return type: bool - true if menu continues, false if logout
|
|||||||
*/
|
*/
|
||||||
bool TechnicianMenu::handleOperation(int choice)
|
bool TechnicianMenu::handleOperation(int choice)
|
||||||
{
|
{
|
||||||
|
if (!m_isMenuActive)
|
||||||
|
{
|
||||||
|
logout();
|
||||||
|
return false;
|
||||||
|
}
|
||||||
switch (choice)
|
switch (choice)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
|
|||||||
@@ -14,7 +14,6 @@ Date:19-May-2026
|
|||||||
class TechnicianMenu : Menu
|
class TechnicianMenu : Menu
|
||||||
{
|
{
|
||||||
private:
|
private:
|
||||||
Controller m_controller;
|
|
||||||
bool handleOperation(int choice);
|
bool handleOperation(int choice);
|
||||||
public:
|
public:
|
||||||
void showMenu();
|
void showMenu();
|
||||||
|
|||||||
Reference in New Issue
Block a user