Exemple #1
0
bool PlatformAssert::process(Type         assertType,
                             const char  *filename,
                             U32          lineNumber,
                             const char  *message)
{
   // If we're somehow recursing, just die.
   if(processing)
      Platform::debugBreak();

   processing = true;
   bool ret = true;

   // always dump to the Assert to the Console
   /*if (Log::isActive())
   {
      if (assertType == Warning)
         Log::warnf(LogEntry::Assert, "%s(%ld) : %s - %s", filename, lineNumber, typeName[assertType], message);
      else
	      Log::errorf(LogEntry::Assert, "%s(%ld) : %s - %s", filename, lineNumber, typeName[assertType], message);
   }*/

   // if not a WARNING pop-up a dialog box
   if (assertType != Warning)
   {
      char buffer[2048];
      dSprintf(buffer, 2048, "%s(%ld) : %s", filename, lineNumber, typeName[assertType] );

#ifdef LIBDTSHAPE_DEBUG
      // In debug versions, allow a retry even for ISVs...
      bool retry = displayMessageBox(buffer, message, true);
#else
      bool retry = displayMessageBox(buffer, message, ((assertType == Fatal) ? true : false) );
#endif
      if(!retry)
         Platform::onFatalError(1);
      
      ret = askToEnterDebugger(message);
   }

   processing = false;

   return ret;
}
BOOL COcsNotifyUserApp::InitInstance()
{
    HANDLE hMutexOneInstance = NULL;

    try
    {
        // InitCommonControlsEx() is required on Windows XP if an application
        // manifest specifies use of ComCtl32.dll version 6 or later to enable
        // visual styles.  Otherwise, any window creation will fail.
        INITCOMMONCONTROLSEX InitCtrls;
        InitCtrls.dwSize = sizeof(InitCtrls);
        // Set this to include all the common control classes you want to use
        // in your application.
        InitCtrls.dwICC = ICC_WIN95_CLASSES;
        InitCommonControlsEx(&InitCtrls);

        if (!CWinApp::InitInstance())
            return FALSE; // terminates the application

        // Logger
        CTime	cStartTime;		// Start time of the inventory check
        cStartTime = CTime::GetCurrentTime();
        m_pLogger			= getOcsLogger();
        m_pLogger->setApplication( AfxGetAppName());

        /*****
        *
        * Parse command line
        *
        ****/
        if (!parseCommandLine())
            return FALSE;

        m_pLogger->log( LOG_PRIORITY_DEBUG, _T( "=============================================================================="));
        m_pLogger->log( LOG_PRIORITY_DEBUG, _T( "Starting OCS Inventory NG User Notification Tool on %s."), cStartTime.Format( _T( "%#c")));

        /*****
         *
         *	Checks wether another instance of ocsinventory.exe is
         *	already running.
         *
         ****/

        hMutexOneInstance = ::CreateMutex( NULL, TRUE, _T("OCSNOTIFYUSER-088FA840-B10D-11D3-BC36-006067709674"));
        if ( GetLastError() == ERROR_ALREADY_EXISTS )
        {
            m_nExitCode = OCS_NOTIFY_APP_ALREADY_RUNNING_ERROR;
            m_pLogger->log( LOG_PRIORITY_DEBUG, _T("Notification Tool => already running"));
            return FALSE; // terminates the application
        }

        /*****
         *
         *	Gets Download version
         *
         ****/
        CString csMessage = getVersion();
        if (csMessage == _T( ""))
        {
            m_pLogger->log( LOG_PRIORITY_DEBUG, _T("Notification Tool => Failed to retrieve Notification Tool version from file. Version 0.0.0.1 assumed"));
            csMessage=_T( "0.0.0.1");
        }
        m_pLogger->log( LOG_PRIORITY_DEBUG, _T("Notification Tool => Running OCS Inventory NG Notification Tool Version %s"), csMessage);
        m_pLogger->log( LOG_PRIORITY_DEBUG, _T("Notification Tool => Using OCS Inventory NG FrameWork Version %s"), getFrameworkVersion());

        /*****
         *
         *	Main initinstance block
         *
         ****/
        AfxEnableControlContainer();

        switch (m_uNotifcation)
        {
        case NOTIFY_TYPE_PREINSTALL:
            // Display preinstallation dialogbox
            if (!displayPreinstallDialogBox())
                m_pLogger->log( LOG_PRIORITY_DEBUG, _T("Notification Tool => failed to display preinstall DialogBox"));
            break;
        case NOTIFY_TYPE_POSTINSTALL:
            // Display postinstallation dialogbox
            if (!displayPostinstallDialogBox())
                m_pLogger->log( LOG_PRIORITY_DEBUG, _T("Notification Tool => failed to display postinstall DialogBox"));
            break;
        case NOTIFY_TYPE_MSGBOX:
            // Display standard messagebox
            if (!displayMessageBox())
                m_pLogger->log( LOG_PRIORITY_DEBUG, _T("Notification Tool => failed to display standard MessageBox!"));
            break;
        case NOTIFY_TYPE_ASKTAG:
            // Display standard messagebox
            if (!askTagDialogBox())
                m_pLogger->log( LOG_PRIORITY_DEBUG, _T("Notification Tool => failed to display AskTag DialogBox!"));
            break;
        default:
            m_pLogger->log( LOG_PRIORITY_DEBUG, _T("Notification Tool => wrong notification type!"));
            break;
        }
    }
    catch( CException *pEx)
    {
        m_pLogger->log( LOG_PRIORITY_DEBUG, _T( "Notification Tool => %s"), LookupError( pEx));
        pEx->Delete();
    }

    /*****
     *
     *	Releasing mutex and terminate
     *
     ****/
    if (hMutexOneInstance != NULL)
    {
        ::ReleaseMutex( hMutexOneInstance);
    }
    // Since the dialog has been closed, return FALSE so that we exit the
    //  application, rather than start the application's message pump.
    return FALSE;
}