Exemplo n.º 1
0
std::string JPetTreeHeader::stringify() const
{
  std::ostringstream tmp;
  tmp<<"-----------------------------------------------------------------\n";
  tmp<<"------------------------- General Info --------------------------\n";
  tmp<<"-----------------------------------------------------------------\n";
  tmp<< "Run number              : " << JPetCommonTools::Itoa(fRunNo) <<"\n";
  tmp<< "Base file name          : "<<getBaseFileName()<<"\n";
  tmp<< "Source (if any) position: "<< Form("%lf",getSourcePosition())<<"\n";
  tmp<< "Created with:" << "\n";   
  tmp<< "  framework version     : "<< getFrameworkVersion()          <<"\n";
  tmp<< "  git revision          : "<< getFrameworkRevision()         <<"\n";
  
tmp << stringifyHistory();
tmp << stringifyDictionary();

return tmp.str();
}
Exemplo n.º 2
0
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;
}