Index: src/ch/MainWnd.cpp =================================================================== diff -u -rb26ced3298e3e7e51d91f3ac70b56746786da83b -r9ddf8fdd5f641491dd30c49eb90f8f740314b6af --- src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision b26ced3298e3e7e51d91f3ac70b56746786da83b) +++ src/ch/MainWnd.cpp (.../MainWnd.cpp) (revision 9ddf8fdd5f641491dd30c49eb90f8f740314b6af) @@ -32,17 +32,16 @@ #include "ClipboardMonitor.h" #include #include "../common/TShellExtMenuConfig.h" -#include "../libchcore/TConfig.h" #include "../libchcore/TCoreException.h" -#include "../libchcore/TTaskManagerStatsSnapshot.h" -#include "../libchcore/TSQLiteSerializerFactory.h" #include "TRecentPathsTools.h" #include "DirectoryChooser.h" #include "FeedbackHandlerFactory.h" -#include "../libchcore/TTask.h" #include "TTaskManagerWrapper.h" #include "CfgProperties.h" #include "resource.h" +#include "../liblogger/TAsyncMultiLogger.h" +#include "../libchengine/TConfigSerializers.h" +#include "../libserializer/TSQLiteSerializerFactory.h" #ifdef _DEBUG #define new DEBUG_NEW @@ -80,7 +79,7 @@ ///////////////////////////////////////////////////////////////////////////// // CMainWnd construction/destruction CMainWnd::CMainWnd() : - m_spTaskMgrStats(new chcore::TTaskManagerStatsSnapshot), + m_spTaskMgrStats(new chengine::TTaskManagerStatsSnapshot), m_spLog(logger::MakeLogger(GetLogFileData(), L"MainWnd")) { } @@ -237,12 +236,16 @@ CString strError; CString strTasksDir = GetTasksDirectory(); - TSQLiteSerializerFactoryPtr spSerializerFactory(new TSQLiteSerializerFactory(PathFromString(strTasksDir))); - IFeedbackHandlerFactoryPtr spFeedbackFactory(new CFeedbackHandlerFactory); + TSmartPath pathEngineLog = PathFromString(strTasksDir) + PathFromString(_T("engine.log")); + logger::TLogFileDataPtr spLogFileData = logger::TAsyncMultiLogger::GetInstance()->CreateLoggerData(pathEngineLog.ToString(), GetApp().GetEngineLoggerConfig()); + + serializer::TSQLiteSerializerFactoryPtr spSerializerFactory(new serializer::TSQLiteSerializerFactory(PathFromString(strTasksDir), spLogFileData)); + chengine::IFeedbackHandlerFactoryPtr spFeedbackFactory(new CFeedbackHandlerFactory); + try { - m_spTasks.reset(new chcore::TTaskManager(spSerializerFactory, spFeedbackFactory, PathFromString(strTasksDir), GetApp().GetEngineLoggerConfig())); + m_spTasks.reset(new chengine::TTaskManager(spSerializerFactory, spFeedbackFactory, PathFromString(strTasksDir), GetApp().GetEngineLoggerConfig(), spLogFileData)); } catch(const std::exception& e) { @@ -253,7 +256,7 @@ { if(MsgBox(IDS_TASKMANAGER_LOAD_FAILED, MB_ICONERROR | MB_OKCANCEL) == IDOK) { - m_spTasks.reset(new chcore::TTaskManager(spSerializerFactory, spFeedbackFactory, PathFromString(strTasksDir), GetApp().GetEngineLoggerConfig(), true)); + m_spTasks.reset(new chengine::TTaskManager(spSerializerFactory, spFeedbackFactory, PathFromString(strTasksDir), GetApp().GetEngineLoggerConfig(), spLogFileData, true)); } else return false; @@ -358,7 +361,7 @@ ///////////////////////////////////////////////////////////////////////////// // CMainWnd/CTrayIcon menu message handlers -void CMainWnd::ShowStatusWindow(const chcore::TTaskPtr& spSelect) +void CMainWnd::ShowStatusWindow(const chengine::TTaskPtr& spSelect) { m_pdlgStatus=new CStatusDlg(m_spTasks.get(), this); // self deleting m_pdlgStatus->m_spInitialSelection = spSelect; @@ -407,7 +410,7 @@ fmt.SetFormat(GetResManager().LoadString(IDS_FINALIZE_CH_ERROR)); fmt.SetParam(_T("%reason"), strMessage); - AfxMessageBox(fmt, MB_OK | MB_ICONERROR); + AfxMessageBox(fmt.ToString(), MB_OK | MB_ICONERROR); } CWnd::OnClose(); @@ -433,7 +436,7 @@ fmt.SetFormat(_T("Failed to autosave task. Error: %err.")); fmt.SetParam(_T("%err"), (PCTSTR)strError); - LOG_ERROR(m_spLog) << fmt; + LOG_ERROR(m_spLog) << fmt.ToString(); } SetTimer(eTimer_Autosave, GetPropValue(GetConfig()), nullptr); @@ -490,11 +493,11 @@ if(!pszBuffer || ulLen == 0 || pszBuffer[ulLen - 1] != L'\0') return FALSE; - chcore::TString wstrData(pszBuffer); + string::TString wstrData(pszBuffer); LOG_DEBUG(m_spLog) << L"Received task definition to process: " << wstrData; - chcore::TTaskDefinition tTaskDefinition; + chengine::TTaskDefinition tTaskDefinition; CString strError; try { @@ -516,17 +519,17 @@ fmt.SetParam(_T("%xml"), wstrData.c_str()); fmt.SetParam(_T("%err"), (PCTSTR)strError); - LOG_ERROR(m_spLog) << fmt; + LOG_ERROR(m_spLog) << fmt.ToString(); fmt.SetFormat(GetResManager().LoadString(IDS_SHELLEXT_XML_IMPORT_FAILED)); fmt.SetParam(_T("%err"), (PCTSTR)strError); - AfxMessageBox(fmt, MB_OK | MB_ICONERROR); + AfxMessageBox(fmt.ToString(), MB_OK | MB_ICONERROR); break; } // apply current options from global config; in the future we might want to merge the incoming options with global ones instead of overwriting... - chcore::TConfig& rConfig = GetConfig(); + chengine::TConfig& rConfig = GetConfig(); rConfig.ExtractSubConfig(BRANCH_TASK_SETTINGS, tTaskDefinition.GetConfiguration()); // special operation - modify stuff @@ -536,10 +539,10 @@ GetPropValue(rConfig, dlg.m_vRecent); - INT_PTR iModalResult; - if((iModalResult = dlg.DoModal()) == IDCANCEL) + INT_PTR iModalResult = dlg.DoModal(); + if(iModalResult == IDCANCEL) return CWnd::OnCopyData(pWnd, pCopyDataStruct); - else if(iModalResult == -1) // windows has been closed by a parent + if(iModalResult == -1) // windows has been closed by a parent return TRUE; TRecentPathsTools::AddNewPath(dlg.m_vRecent, dlg.m_tTaskDefinition.GetDestinationPath().ToString()); @@ -603,7 +606,7 @@ try { - chcore::TTaskPtr spTask = m_spTasks->ImportTask(strPath); + chengine::TTaskPtr spTask = m_spTasks->ImportTask(strPath); if(spTask) spTask->Store(true); bImported = true; @@ -624,11 +627,11 @@ fmt.SetParam(_T("%path"), strPath.ToString()); fmt.SetParam(_T("%err"), szBuffer.get()); - LOG_ERROR(m_spLog) << fmt; + LOG_ERROR(m_spLog) << fmt.ToString(); fmt.SetFormat(GetResManager().LoadString(IDS_TASK_IMPORT_FAILED)); fmt.SetParam(_T("%path"), strPath.ToString()); - AfxMessageBox(fmt, MB_OK | MB_ICONERROR); + AfxMessageBox(fmt.ToString(), MB_OK | MB_ICONERROR); } } } @@ -644,7 +647,7 @@ void CMainWnd::OnPopupCustomCopy() { - chcore::TConfig& rConfig = GetConfig(); + chengine::TConfig& rConfig = GetConfig(); CCustomCopyDlg dlg; @@ -656,7 +659,7 @@ SetPropValue(rConfig, dlg.m_vRecent); - chcore::TTaskDefinition tTaskDefinition = dlg.m_tTaskDefinition; + chengine::TTaskDefinition tTaskDefinition = dlg.m_tTaskDefinition; TTaskManagerWrapper tTaskManager(m_spTasks); tTaskManager.CreateTask(tTaskDefinition); @@ -669,7 +672,7 @@ { case WM_MINIVIEWDBLCLK: { - chcore::TTaskPtr spTask = m_spTasks->GetTaskByTaskID(boost::numeric_cast(lParam)); + chengine::TTaskPtr spTask = m_spTasks->GetTaskByTaskID(boost::numeric_cast(lParam)); ShowStatusWindow(spTask); break; } @@ -851,7 +854,7 @@ pDlg->m_bAutoDelete = true; pDlg->Create(); - chcore::TConfig& rConfig = GetConfig(); + chengine::TConfig& rConfig = GetConfig(); try { SetPropValue(rConfig, _time64(nullptr));