Index: src/ch/MiniViewDlg.cpp =================================================================== diff -u -r2fe97a93f21771d75901d4b6559057d1ea055104 -rc9092a6f41bed1c132d5d5ddfe430e8b3ddd70ca --- src/ch/MiniViewDlg.cpp (.../MiniViewDlg.cpp) (revision 2fe97a93f21771d75901d4b6559057d1ea055104) +++ src/ch/MiniViewDlg.cpp (.../MiniViewDlg.cpp) (revision c9092a6f41bed1c132d5d5ddfe430e8b3ddd70ca) @@ -208,7 +208,7 @@ chcore::TTaskStatsSnapshotPtr spTaskStats = m_spTaskMgrStats->GetTaskStatsAt(stIndex); chcore::ETaskCurrentState eTaskState = spTaskStats->GetTaskState(); - if(eTaskState != chcore::eTaskState_Finished && eTaskState != chcore::eTaskState_Cancelled) + if(eTaskState != chcore::eTaskState_Finished && eTaskState != chcore::eTaskState_Cancelled && eTaskState != chcore::eTaskState_LoadError) { pItem = m_ctlStatus.GetItemAddress(index++); Index: src/ch/StatusDlg.cpp =================================================================== diff -u -r2fe97a93f21771d75901d4b6559057d1ea055104 -rc9092a6f41bed1c132d5d5ddfe430e8b3ddd70ca --- src/ch/StatusDlg.cpp (.../StatusDlg.cpp) (revision 2fe97a93f21771d75901d4b6559057d1ea055104) +++ src/ch/StatusDlg.cpp (.../StatusDlg.cpp) (revision c9092a6f41bed1c132d5d5ddfe430e8b3ddd70ca) @@ -292,34 +292,46 @@ // set status of buttons pause/resume/cancel if (spSelectedTask != NULL) { - GetDlgItem(IDC_RESTART_BUTTON)->EnableWindow(true); - GetDlgItem(IDC_SHOW_LOG_BUTTON)->EnableWindow(true); - GetDlgItem(IDC_DELETE_BUTTON)->EnableWindow(true); - - if (spSelectedTask->GetTaskState() == chcore::eTaskState_Finished || spSelectedTask->GetTaskState() == chcore::eTaskState_Cancelled) + if(spSelectedTask->GetTaskState() == chcore::eTaskState_LoadError) { - GetDlgItem(IDC_CANCEL_BUTTON)->EnableWindow(false); + GetDlgItem(IDC_SHOW_LOG_BUTTON)->EnableWindow(true); GetDlgItem(IDC_PAUSE_BUTTON)->EnableWindow(false); GetDlgItem(IDC_RESUME_BUTTON)->EnableWindow(false); - } + GetDlgItem(IDC_RESTART_BUTTON)->EnableWindow(false); + GetDlgItem(IDC_CANCEL_BUTTON)->EnableWindow(false); + GetDlgItem(IDC_DELETE_BUTTON)->EnableWindow(true); + } else { - // pause/resume - if (spSelectedTask->GetTaskState() == chcore::eTaskState_Paused) + GetDlgItem(IDC_RESTART_BUTTON)->EnableWindow(true); + GetDlgItem(IDC_SHOW_LOG_BUTTON)->EnableWindow(true); + GetDlgItem(IDC_DELETE_BUTTON)->EnableWindow(true); + + if (spSelectedTask->GetTaskState() == chcore::eTaskState_Finished || spSelectedTask->GetTaskState() == chcore::eTaskState_Cancelled) { + GetDlgItem(IDC_CANCEL_BUTTON)->EnableWindow(false); GetDlgItem(IDC_PAUSE_BUTTON)->EnableWindow(false); - GetDlgItem(IDC_RESUME_BUTTON)->EnableWindow(true); + GetDlgItem(IDC_RESUME_BUTTON)->EnableWindow(false); } else { - GetDlgItem(IDC_PAUSE_BUTTON)->EnableWindow(true); - if (spSelectedTask->GetTaskState() == chcore::eTaskState_Waiting) + // pause/resume + if (spSelectedTask->GetTaskState() == chcore::eTaskState_Paused) + { + GetDlgItem(IDC_PAUSE_BUTTON)->EnableWindow(false); GetDlgItem(IDC_RESUME_BUTTON)->EnableWindow(true); + } else - GetDlgItem(IDC_RESUME_BUTTON)->EnableWindow(false); + { + GetDlgItem(IDC_PAUSE_BUTTON)->EnableWindow(true); + if (spSelectedTask->GetTaskState() == chcore::eTaskState_Waiting) + GetDlgItem(IDC_RESUME_BUTTON)->EnableWindow(true); + else + GetDlgItem(IDC_RESUME_BUTTON)->EnableWindow(false); + } + + GetDlgItem(IDC_CANCEL_BUTTON)->EnableWindow(true); } - - GetDlgItem(IDC_CANCEL_BUTTON)->EnableWindow(true); } } else @@ -455,14 +467,17 @@ if(spTask) { chcore::ETaskCurrentState eTaskState = spTask->GetTaskState(); - if(eTaskState != chcore::eTaskState_Finished && eTaskState != chcore::eTaskState_Cancelled) + switch(eTaskState) { - // ask if cancel + case chcore::eTaskState_Finished: + case chcore::eTaskState_Cancelled: + case chcore::eTaskState_LoadError: + break; // allow processing as-is + + default: + // ask to cancel if(MsgBox(IDS_CONFIRMCANCEL_STRING, MB_OKCANCEL | MB_ICONQUESTION) == IDOK) - { - // cancel spTask->CancelProcessing(); - } else return; } @@ -544,6 +559,7 @@ case chcore::eTaskState_Paused: return 2; case chcore::eTaskState_Error: + case chcore::eTaskState_LoadError: return 1; default: return 0; @@ -886,6 +902,12 @@ strStatusText += _T("/"); break; } + case chcore::eTaskState_LoadError: + { + strStatusText = GetResManager().LoadString(IDS_STATUS_LOADERROR_STRING); + strStatusText += _T("/"); + break; + } case chcore::eTaskState_Paused: { strStatusText = GetResManager().LoadString(IDS_STATUS_PAUSED_STRING); Index: src/ch/ch.rc =================================================================== diff -u -r8b7479db2ee71a3d00779c67fe6a1b1d9ec414b8 -rc9092a6f41bed1c132d5d5ddfe430e8b3ddd70ca --- src/ch/ch.rc (.../ch.rc) (revision 8b7479db2ee71a3d00779c67fe6a1b1d9ec414b8) +++ src/ch/ch.rc (.../ch.rc) (revision c9092a6f41bed1c132d5d5ddfe430e8b3ddd70ca) @@ -874,6 +874,7 @@ IDS_STATUS_MOVING_STRING "Moving" IDS_STATUS_FINISHED_STRING "Finished" IDS_STATUS_ERROR_STRING "Error" + IDS_STATUS_LOADERROR_STRING "Load error" IDS_STATUS_PAUSED_STRING "Paused" IDS_STATUS_DELETING_STRING "Deleting" IDS_STATUS_UNKNOWN_STRING "Unknown" Index: src/ch/resource.h =================================================================== diff -u -r8b7479db2ee71a3d00779c67fe6a1b1d9ec414b8 -rc9092a6f41bed1c132d5d5ddfe430e8b3ddd70ca --- src/ch/resource.h (.../resource.h) (revision 8b7479db2ee71a3d00779c67fe6a1b1d9ec414b8) +++ src/ch/resource.h (.../resource.h) (revision c9092a6f41bed1c132d5d5ddfe430e8b3ddd70ca) @@ -641,6 +641,7 @@ #define IDS_STATUS_INITIALIZING_STRING 21552 #define IDS_STATUS_FASTMOVE_STRING 21553 #define IDS_EMPTYSUBTASKNAME_STRING 21554 +#define IDS_STATUS_LOADERROR_STRING 21555 #define ID_POPUP_SHOW_STATUS 32773 #define ID_POPUP_TIME_CRITICAL 32774 #define ID_POPUP_HIGHEST 32775 Index: src/libchcore/ETaskCurrentState.h =================================================================== diff -u -ra5f396da5ed5ffb3fcd9fdf22afb5a7fd07e1ab8 -rc9092a6f41bed1c132d5d5ddfe430e8b3ddd70ca --- src/libchcore/ETaskCurrentState.h (.../ETaskCurrentState.h) (revision a5f396da5ed5ffb3fcd9fdf22afb5a7fd07e1ab8) +++ src/libchcore/ETaskCurrentState.h (.../ETaskCurrentState.h) (revision c9092a6f41bed1c132d5d5ddfe430e8b3ddd70ca) @@ -33,6 +33,7 @@ eTaskState_Cancelled, eTaskState_Error, eTaskState_Finished, + eTaskState_LoadError, // insert new values before this one eTaskState_Max Index: src/libchcore/TSQLiteStatement.cpp =================================================================== diff -u -r2fe97a93f21771d75901d4b6559057d1ea055104 -rc9092a6f41bed1c132d5d5ddfe430e8b3ddd70ca --- src/libchcore/TSQLiteStatement.cpp (.../TSQLiteStatement.cpp) (revision 2fe97a93f21771d75901d4b6559057d1ea055104) +++ src/libchcore/TSQLiteStatement.cpp (.../TSQLiteStatement.cpp) (revision c9092a6f41bed1c132d5d5ddfe430e8b3ddd70ca) @@ -176,7 +176,6 @@ BindValue(iColumn, path.ToString()); } - bool TSQLiteStatement::GetBool(int iCol) { return GetInt(iCol) != 0; Index: src/libchcore/TTask.cpp =================================================================== diff -u -r2fe97a93f21771d75901d4b6559057d1ea055104 -rc9092a6f41bed1c132d5d5ddfe430e8b3ddd70ca --- src/libchcore/TTask.cpp (.../TTask.cpp) (revision 2fe97a93f21771d75901d4b6559057d1ea055104) +++ src/libchcore/TTask.cpp (.../TTask.cpp) (revision c9092a6f41bed1c132d5d5ddfe430e8b3ddd70ca) @@ -131,12 +131,20 @@ { using namespace chcore; + bool bLogPathLoaded = false; + bool bLoadFailed = false; + const size_t stMaxSize = 1024; + wchar_t szErr[stMaxSize]; + + try { boost::unique_lock lock(m_lock); ISerializerContainerPtr spContainer = m_spSerializer->GetContainer(_T("task")); m_tBaseData.Load(spContainer); + bLogPathLoaded = true; + spContainer = m_spSerializer->GetContainer(_T("base_paths")); m_spSrcPaths->Load(spContainer); @@ -158,10 +166,47 @@ m_tSubTaskContext.SetDestinationPath(m_tBaseData.GetDestinationPath()); m_tSubTaskContext.SetOperationType(m_tSubTasksArray.GetOperationType()); } + catch(const chcore::TBaseException& e) + { + SetTaskState(eTaskState_LoadError); + bLoadFailed = true; + + _tcscpy_s(szErr, stMaxSize, _T("Task load error: ")); + size_t stLen = _tcslen(szErr); + + e.GetDetailedErrorInfo(szErr + stLen, stMaxSize - stLen); + } + catch(const std::exception& e) + { + SetTaskState(eTaskState_LoadError); + bLoadFailed = true; + _snwprintf_s(szErr, stMaxSize, _TRUNCATE, _T("Task load error. %hs"), e.what()); + } + + if(bLoadFailed) + { + try + { + if(bLogPathLoaded) + { + m_log.init(m_tBaseData.GetLogPath().ToString(), 262144, icpf::log_file::level_debug, false, false); + m_log.loge(szErr); + } + } + catch(const std::exception&) + { + } + } } void TTask::Store() { + if(GetTaskState() == eTaskState_LoadError) + { + DBTRACE0(_T("Task::Store() - not storing task as it was not loaded correctly\n")); + return; + } + TSimpleTimer timer(true); DBTRACE0(_T("###### Task::Store() - starting\n")); @@ -208,8 +253,8 @@ void TTask::BeginProcessing() { boost::unique_lock lock(m_lock); - - m_workerThread.StartThread(DelegateThreadProc, this, GetTaskPropValue(m_tConfiguration)); + if(m_tBaseData.GetCurrentState() != eTaskState_LoadError) + m_workerThread.StartThread(DelegateThreadProc, this, GetTaskPropValue(m_tConfiguration)); } void TTask::ResumeProcessing() @@ -225,12 +270,18 @@ bool TTask::RetryProcessing() { // retry used to auto-resume, after loading - if(GetTaskState() != eTaskState_Paused && GetTaskState() != eTaskState_Finished && GetTaskState() != eTaskState_Cancelled) + switch(GetTaskState()) { + case eTaskState_Paused: + case eTaskState_Finished: + case eTaskState_Cancelled: + case eTaskState_LoadError: + return false; + + default: BeginProcessing(); return true; } - return false; } void TTask::RestartProcessing() Index: src/libchcore/TTaskManager.cpp =================================================================== diff -u -r2fe97a93f21771d75901d4b6559057d1ea055104 -rc9092a6f41bed1c132d5d5ddfe430e8b3ddd70ca --- src/libchcore/TTaskManager.cpp (.../TTaskManager.cpp) (revision 2fe97a93f21771d75901d4b6559057d1ea055104) +++ src/libchcore/TTaskManager.cpp (.../TTaskManager.cpp) (revision c9092a6f41bed1c132d5d5ddfe430e8b3ddd70ca) @@ -155,7 +155,9 @@ THROW_CORE_EXCEPTION(eErr_InvalidPointer); // delete only when the thread is finished - if((spTask->GetTaskState() == eTaskState_Finished || spTask->GetTaskState() == eTaskState_Cancelled)) + ETaskCurrentState eState = spTask->GetTaskState(); + + if((eState == eTaskState_Finished || eState == eTaskState_Cancelled || eState == eTaskState_LoadError)) { spTask->KillThread(); @@ -191,14 +193,19 @@ THROW_CORE_EXCEPTION(eErr_InvalidPointer); // delete only when the thread is finished - if(spTask == spSelTask && (spTask->GetTaskState() == eTaskState_Finished || spTask->GetTaskState() == eTaskState_Cancelled)) + if(spTask == spSelTask) { - spTask->KillThread(); + ETaskCurrentState eState = spTask->GetTaskState(); - spTask->OnUnregisterTask(); + if(eState == eTaskState_Finished || eState == eTaskState_Cancelled || eState == eTaskState_LoadError) + { + spTask->KillThread(); - vTasksToRemove.push_back(rEntry.GetTaskSerializeLocation()); - m_tTasks.RemoveAt(stIndex); + spTask->OnUnregisterTask(); + + vTasksToRemove.push_back(rEntry.GetTaskSerializeLocation()); + m_tTasks.RemoveAt(stIndex); + } break; } } @@ -346,7 +353,7 @@ THROW_CORE_EXCEPTION(eErr_InvalidPointer); ETaskCurrentState eState = spTask->GetTaskState(); - bFlag = (eState == eTaskState_Finished || eState == eTaskState_Cancelled || eState == eTaskState_Paused || eState == eTaskState_Error); + bFlag = (eState == eTaskState_Finished || eState == eTaskState_Cancelled || eState == eTaskState_Paused || eState == eTaskState_Error || eState == eTaskState_LoadError); if(!bFlag) break;