diff --git a/source/Client/BugTrapNet.h b/source/Client/BugTrapNet.h index b72aac0..5bb2dbf 100644 --- a/source/Client/BugTrapNet.h +++ b/source/Client/BugTrapNet.h @@ -47,7 +47,8 @@ namespace IntelleSoft ShowUI = BTA_SHOWUI, SaveReport = BTA_SAVEREPORT, MailReport = BTA_MAILREPORT, - SendReport = BTA_SENDREPORT + SendReport = BTA_SENDREPORT, + Custom = BTA_CUSTOM }; [Flags] @@ -373,6 +374,8 @@ namespace IntelleSoft public delegate void UnhandledExceptionDelegate(Object^ sender, UnhandledExceptionEventArgs^ args); + public delegate void CustomActivityDelegate(Object^ sender, String^ reportFilePath); + public ref class ExceptionHandler { private: @@ -391,6 +394,7 @@ namespace IntelleSoft static void ValidateIoResult(BOOL bResult); + static event CustomActivityDelegate^ customActivityEvent; internal: static property System::Exception^ Exception { @@ -418,7 +422,7 @@ namespace IntelleSoft static void FireBeforeUnhandledExceptionEvent(void); static void FireAfterUnhandledExceptionEvent(void); - + static void FireCustomActivityEvent(String^ reportFilePath); public: static const int HttpPort = BUGTRAP_HTTP_PORT; @@ -434,6 +438,12 @@ namespace IntelleSoft void remove(UnhandledExceptionDelegate^ value); } + static event CustomActivityDelegate^ CustomActivity + { + void add(CustomActivityDelegate^ value); + void remove(CustomActivityDelegate^ value); + } + static property String^ AppName { String^ get(void); @@ -596,6 +606,11 @@ namespace IntelleSoft afterUnhandledExceptionEvent(Sender, Arguments); } + inline void ExceptionHandler::FireCustomActivityEvent(String^ reportFilePath) + { + customActivityEvent(Sender, reportFilePath); + } + inline void ExceptionHandler::BeforeUnhandledException::add(UnhandledExceptionDelegate^ value) { beforeUnhandledExceptionEvent += value; @@ -616,6 +631,16 @@ namespace IntelleSoft afterUnhandledExceptionEvent -= value; } + inline void ExceptionHandler::CustomActivity::add(CustomActivityDelegate^ value) + { + customActivityEvent += value; + } + + inline void ExceptionHandler::CustomActivity::remove(CustomActivityDelegate^ value) + { + customActivityEvent -= value; + } + inline String^ ExceptionHandler::AppName::get(void) { return gcnew String(BT_GetAppName()); diff --git a/source/Client/BugTrapUI.cpp b/source/Client/BugTrapUI.cpp index 7daa75e..756bcc3 100644 --- a/source/Client/BugTrapUI.cpp +++ b/source/Client/BugTrapUI.cpp @@ -28,6 +28,10 @@ #include "MemStream.h" #include "VersionInfoString.h" +#ifdef _MANAGED +#include "NetThunks.h" +#endif + #ifdef _DEBUG #define new DEBUG_NEW #endif @@ -1359,8 +1363,12 @@ static void ExecuteHandlerAction(void) } break; case BTA_CUSTOM: - if (g_pfnCustomActivityHandler != NULL) - (*g_pfnCustomActivityHandler)(g_szInternalReportFilePath, g_nCustomActivityHandlerParam); +#ifdef _MANAGED + NetThunks::FireCustomActivityEvent(g_szInternalReportFilePath); +#else + if (g_pfnCustomActivityHandler != NULL) + (*g_pfnCustomActivityHandler)(g_szInternalReportFilePath, g_nCustomActivityHandlerParam); +#endif // _MANAGED break; } diff --git a/source/Client/NetThunks.cpp b/source/Client/NetThunks.cpp index 082f666..3dc69f3 100644 --- a/source/Client/NetThunks.cpp +++ b/source/Client/NetThunks.cpp @@ -504,6 +504,18 @@ namespace NetThunks } } + void FireCustomActivityEvent(LPCTSTR pszReportFilePath) + { + try + { + ExceptionHandler::FireCustomActivityEvent(gcnew String(pszReportFilePath)); + } + catch (Exception^ exception) + { + Debug::WriteLine(exception); + } + } + void FlushTraceListeners(void) { try diff --git a/source/Client/NetThunks.h b/source/Client/NetThunks.h index 4170959..acb81fc 100644 --- a/source/Client/NetThunks.h +++ b/source/Client/NetThunks.h @@ -146,6 +146,8 @@ namespace NetThunks void FireAfterUnhandledExceptionEvent(void); + void FireCustomActivityEvent(LPCTSTR pszReportFilePath); + void FlushTraceListeners(void); inline gcroot GetCurrentThread(void)