Beispiel #1
0
void CMainFrame::OnHelpClientTools()
{
    boost::filesystem::path folder;
    GetProgramFolder(folder);
    boost::filesystem::path file = folder / boost::filesystem::path("ClientTools.pdf", boost::filesystem::native);
    ::ShellExecute(m_hWnd, _T("open"), pathToWString(file).c_str(), 0, pathToWString(folder).c_str(), SW_MAXIMIZE);
}
//bool CBuilderDlg::DoFileOpen(const CString & sPathName) 
//{
//  Help Alligning with BuilderDlg COmpare
//}
bool CAttributeDlg::DoSave(bool attrOnly)
{
    CWaitCursor wait;
    CString ecl;
    m_view.GetText(ecl);

    CString id = m_attribute->GetID();
    CString user = m_attribute->GetModifiedBy();
    CString module = m_attribute->GetModuleQualifiedLabel();
    CString attributeName = m_attribute->GetLabel();
    IAttributeType* attrType = m_attribute->GetType();

    CBookmarksFrame * pFrame = GetBookmarksFrame();
    if (pFrame)
    {
        pFrame->ParseBookmarksEcl((LPCTSTR)ecl, (LPCTSTR)user, (LPCTSTR)id, (LPCTSTR)module, (LPCTSTR)attributeName, attrType);
    }

    if (m_attribute->SetText(ecl))
    {
        //  Save local item for history  ---
        boost::filesystem::path path;
        GetIConfig(QUERYBUILDER_CFG)->GetEnvironmentFolder(path);
        path /= stringToPath(m_attribute->GetModuleQualifiedLabel());
        boost::filesystem::create_directories(path);
        path /= stringToPath(m_attribute->GetLabel());
        boost::filesystem::create_directories(path);

        CTime t = CTime::GetCurrentTime();
        std::_tstring now = t.FormatGmt(_T("%Y-%m-%dT%H_%M_%SZ.ecl"));
        path /= stringToPath(now);

        CUnicodeFile file;
        file.Create(pathToWString(path).c_str());
        file.Write(ecl);
        file.Close();
        //  ---  ---  ---

        m_view.SetSavePoint();
        IAttributeVector attrs;
        Dali::CEclExceptionVector errors;
        m_attribute->PreProcess(PREPROCESS_SAVE, NULL, attrs, errors);
        SendMessage(CWM_SUBMITDONE, Dali::WUActionCheck, (LPARAM)&errors);
        if (attrs.size())
        {
            if (!m_migrator)
                m_migrator = CreateIMigration(::AttachRepository(), false);
            m_migrator->Stop();
            for(IAttributeVector::const_iterator itr = attrs.begin(); itr != attrs.end(); ++itr)
                m_migrator->AddToRep(m_attribute->GetModule()->GetRootModule(), itr->get()->GetAsHistory(), (boost::_tformat(_T("Preprocessed (%1%) from %2%.")) % PREPROCESS_LABEL[PREPROCESS_SAVE] % m_attribute->GetQualifiedLabel()).str().c_str(), true);
            m_migrator->Start();
            SetTimer(0, 200);
        }
        return true;
    }
    return false;
}
Beispiel #3
0
void save(const T &s, const char * filename)
{
	boost::filesystem::path filePath(filename, boost::filesystem::native);
	if ((boost::posix_time::second_clock::local_time() - g_lastBackupTime) > boost::posix_time::time_duration(boost::posix_time::seconds(BACKUP_EVERY)))
	{
		g_lastBackupTime = boost::posix_time::second_clock::local_time();
		for (int i = 9; i > 0; --i)
		{
			boost::filesystem::path bakFilepath = filePath;
			bakFilepath.replace_extension((boost::format("bak00%1%") % i).str());
			boost::filesystem::path prevBakFilepath = filePath;
			if (i > 1)	
				prevBakFilepath.replace_extension((boost::format("bak00%1%") % (i - 1)).str());

			if (boost::filesystem::exists(bakFilepath))
			{
				try {
					boost::filesystem::remove(bakFilepath);
				} catch (const boost::filesystem::filesystem_error & ex) {
					_DBGLOG(LEVEL_WARNING, ex.what());
					_DBGLOG(LEVEL_WARNING, pathToWString(bakFilepath).c_str());
				}
			}

			if (boost::filesystem::exists(prevBakFilepath))
			{
				try
				{
					boost::filesystem::rename(prevBakFilepath, bakFilepath);
				} catch (const boost::filesystem::filesystem_error & ex) {
					_DBGLOG(LEVEL_WARNING, ex.what());
				}
			}
		}
	}
	// make an archive
	std::_tofstream ofs(filename);
	if (ofs.good()) {
		try {
			boost::archive::xml__toarchive oa(ofs);
			oa << BOOST_SERIALIZATION_NVP(s);
		} catch (boost::archive::archive_exception & e) {
			_DBGLOG(LEVEL_WARNING, e.what());
			ATLASSERT(false);  //  TODO:  Why is there an infrequent exception.
		} catch (std::exception & e) {
			_DBGLOG(LEVEL_WARNING, e.what());
			ATLASSERT(false);  //  TODO:  Why is there an infrequent exception.
		}
		ofs.flush();
		ofs.close();
	} else {
		_DBGLOG(LEVEL_WARNING, (boost::format("Faileed to open %1% for writing.") % filename).str().c_str());
	}
}
Beispiel #4
0
 void InitConfigPath(const std::_tstring & cfgName, const std::_tstring & ext)
 {
     clib::recursive_mutex::scoped_lock proc(m_mutex);
     m_CfgName = cfgName;
     ATLASSERT((cfgName.find('.') == std::_tstring::npos));
     ATLASSERT((ext.find('.') == std::_tstring::npos));
     std::_tstring cfgNameExt = cfgName;
     cfgNameExt += _T(".");
     cfgNameExt += ext;
     boost::filesystem::path appFolder;
     m_CfgPath = GetApplicationFolder(appFolder) / stringToPath(cfgNameExt);
     m_Cfg.SetFilename(pathToWString(m_CfgPath).c_str());
 }
Beispiel #5
0
 CConfig(const std::_tstring & id, const boost::filesystem::path & path) : m_id(id), m_CfgPath(path)
 {
     TCHAR szFileName[_MAX_FNAME];
     TCHAR szExt[_MAX_FNAME];
     _tsplitpath(pathToWString(m_CfgPath).c_str(), NULL, NULL, szFileName, szExt);
     if (szExt[0] == '.')
     {
         InitConfigPath(szFileName, &szExt[1]);
     }
     else
     {
         InitConfigPath(szFileName, szExt);
     }
 }
void CDockableDataViews::SetTabEcl(const std::_tstring & localFile, int row, const CUniqueID & id)
{
    std::_tstring label = localFile;
    StringSourceMap::iterator itr = m_sourceTabs.find(localFile);
    if (itr == m_sourceTabs.end())
    {
        StlLinked<CLocalDataView> attributeDataView = new CLocalDataView();
        m_sourceTabs[localFile] = attributeDataView.get();
        attributeDataView->Create(NULL, localFile.c_str(), WS_CHILD | WS_VISIBLE, CRect(0, 0, 0, 0), &m_wndTab, 1);
        attributeDataView->SetFont(&afxGlobalData.fontRegular);
        boost::filesystem::path p = stringToPath(localFile);
        m_wndTab.AddTab(attributeDataView, pathToWString(p.filename()).c_str(), 0, FALSE);
        attributeDataView->SetOwner(m_owner);
        attributeDataView->SetSource(localFile);
    }
    m_sourceTabs[localFile]->SetBreakpointLocation(row, id);
}
Beispiel #7
0
bool CUnicodeFile::Open(const boost::filesystem::path & filePath, int readWriteMode)
{
	std::_tstring _tfilePath = pathToWString(filePath);
	return Open(_tfilePath.c_str(), readWriteMode);
}
Beispiel #8
0
bool CUnicodeFile::Create(const boost::filesystem::path & filePath, int readWriteMode, int createMode, ENCODING encoding)
{
	std::_tstring _tfilePath = pathToWString(filePath);
	return Create(_tfilePath.c_str(), readWriteMode, createMode, encoding);
}