Ejemplo n.º 1
0
//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;
}
Ejemplo n.º 2
0
    CModFileRepository(const TCHAR* url, const TCHAR* label) : m_label(label), m_url(url)
    {
        m_path = stringToPath(url);

        CUnicodeFile file;
        if (file.Open(pathToWString(m_path).c_str()))
        {
            file.Read(m_modFile);
            file.Close();
        }
        boost::algorithm::replace_all(m_modFile, _T("\r\n\r\n"), _T("\r\n \r\n"));	//Hack to stop blank lines being eaten by the tokenizer.
    }
Ejemplo n.º 3
0
 const TCHAR *GetText(bool refresh, bool noBroadcast = false) const
 {
     clib::recursive_mutex::scoped_lock proc(m_mutex);
     if (!m_eclFetched || refresh)
     {
         CUnicodeFile file;
         file.Open(m_path);
         std::_tstring ecl;
         file.Read(ecl);
         file.Close();
         m_ecl = ecl.c_str();
         m_eclFetched = true;
     }
     return m_ecl;
 }
Ejemplo n.º 4
0
    bool Save(IAttributeVector & attributes, bool noBroadcast = false)
    {
        clib::recursive_mutex::scoped_lock proc(m_mutex);
        for(IAttributeVector::iterator itr = attributes.begin(); itr != attributes.end(); ++itr)
        {
            std::_tstring newModFile;
            bool inCurrentAttr = false;
            bool alreadyExisted = false;

            typedef std::vector<std::_tstring> split_vector_type;
            split_vector_type SplitVec; 
            boost::algorithm::split(SplitVec, m_modFile, boost::algorithm::is_any_of("\r\n"), boost::algorithm::token_compress_on);

            for (split_vector_type::const_iterator itr2 = SplitVec.begin(); itr2 != SplitVec.end(); ++itr2)
            {
                std::_tstring line = *itr2;
                std::_tstring origline = line;
                if (boost::algorithm::istarts_with(line, IMPORT_MARKER))
                {
                    boost::algorithm::ireplace_first(line, IMPORT_MARKER, _T(""));
                    boost::algorithm::trim(line);
                    inCurrentAttr = boost::algorithm::iequals(line, itr->get()->GetQualifiedLabel());
                    if (inCurrentAttr)
                    {
                        newModFile += (boost::_tformat(_T("%1%%2%\r\n%3%\r\n")) % IMPORT_MARKER % itr->get()->GetQualifiedLabel() % itr->get()->GetText(true, noBroadcast)).str();
                        alreadyExisted = true;
                        continue;
                    }
                }
                if (!inCurrentAttr)
                {
                    newModFile += origline + _T("\r\n");
                }
            }
            if (!alreadyExisted)
                newModFile += (boost::_tformat(_T("%1%%2%\r\n%3%\r\n")) % IMPORT_MARKER % itr->get()->GetQualifiedLabel() % itr->get()->GetText(true, noBroadcast)).str();
            m_modFile = newModFile.c_str();
        }

        CUnicodeFile file;
        if (file.Create(pathToWString(m_path).c_str()))
        {
            file.Write(m_modFile);
            file.Close();
        }

        return true;
    }
Ejemplo n.º 5
0
void CBookmarksView::OnLoadFile(bool mergeFlag)
{
    if (m_list.GetItemCount() > 0)
    {
        if (mergeFlag) {
            if (MessageBox(LOAD_MERGE_BOOKMARKS_MSG, _T("Warning"), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) != IDYES)
            {
                return;
            }
        }
        else if (MessageBox(LOAD_BOOKMARKS_MSG, _T("Warning"), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) != IDYES)
        {
            return;
        }
    }

    CUnicodeFile file;
    std::_tstring xmlStr;
    file.Open(BookmarksFilePath());
    if (file.IsOpen())
    {
        file.Read(xmlStr);
        file.Close();

        BOOL bResult = FALSE;
        std::_tstring bookmarks;
        int index = 0;

        bookmarks = FindTag(xmlStr, _T("bookmarks"), index);

        if (index >= 0)
        {
            index = 0;
            int col = 0;

            if (!mergeFlag)
            {
                m_listMaster.DeleteAllItems();
            }

            std::_tstring bookmark, line, type, user, lineNum, column, module, attribute, attributeType, description;

            while (index >= 0)
            {
                bookmark = FindTag(bookmarks, _T("bookmark"), index);

                if (index >= 0)
                {
                    int bookmarkIndex = 0;

                    lineNum = FindTag(bookmark, _T("line"), bookmarkIndex);
                    type = FindTag(bookmark, _T("type"), bookmarkIndex);
                    column = FindTag(bookmark, _T("column"), bookmarkIndex);
                    user = FindTag(bookmark, _T("user"), bookmarkIndex);
                    module = FindTag(bookmark, _T("module"), bookmarkIndex);
                    attribute = FindTag(bookmark, _T("attribute"), bookmarkIndex);
                    attributeType = FindTag(bookmark, _T("attrtype"), bookmarkIndex);
                    description = FindTag(bookmark, _T("description"), bookmarkIndex);

                    bool foundDupe = false;
                    for (int i = 0; i < m_listMaster.GetItemCount(); ++i)
                    {
                        std::_tstring lineDupe = m_listMaster.GetItemText(i, 0);
                        std::_tstring moduleDupe = m_listMaster.GetItemText(i, 3);
                        std::_tstring attributeDupe = m_listMaster.GetItemText(i, 4);

                        if (lineDupe == lineNum && moduleDupe == module && attributeDupe == attribute)
                        {
                            foundDupe = true;
                        }
                    }

                    if (!foundDupe) {
                        if (lineNum.length() > 0 && attribute.length() > 0 && description.length() > 0)
                        {
                            int row = 0;
                            col = 0;
                            row = m_listMaster.InsertItem(col++, lineNum.c_str());
                            m_listMaster.SetItemText(row, col++, type.c_str());
                            m_listMaster.SetItemText(row, col++, user.c_str());
                            m_listMaster.SetItemText(row, col++, module.c_str());
                            m_listMaster.SetItemText(row, col++, attribute.c_str());
                            m_listMaster.SetItemText(row, col++, attributeType.c_str());
                            m_listMaster.SetItemText(row, col++, description.c_str());
                            BookmarkItemData *data = new BookmarkItemData;
                            data->marked = true;
                            data->bookmarkType = m_listMaster.StringToType(type);
                            data->column = boost::lexical_cast<int>(column);
                            m_listMaster.SetItemData(row, (DWORD_PTR)data);
                        }
                    }
                }
            }

            for (int i = 0; i < col; ++i) {
                m_list.SetColumnWidth(i, LVSCW_AUTOSIZE_USEHEADER);
            }
        }

        DoRefresh(NULL, 0);
    }
    else
    {
        MessageBox(LOAD_UNFOUND_BOOKMARKS_MSG, _T("Warning"));
    }
}
Ejemplo n.º 6
0
void CBookmarksView::OnSaveFile()
{
    if (m_list.GetItemCount() > 0)
    {
        if (MessageBox(SAVE_BOOKMARKS_MSG, _T("Warning"), MB_YESNO | MB_ICONQUESTION | MB_DEFBUTTON2) != IDYES) {
            return;
        }

        CComPtr<IXMLWriter> writer = CreateIXMLWriter(true);

        writer->PushElement(_T("bookmarks"));

        std::_tstring bookmarks;

        for (int i = 0; i < m_list.GetItemCount(); ++i)
        {
            std::_tstring line = m_list.GetItemText(i, 0);
            std::_tstring type = m_list.GetItemText(i, 1);
            std::_tstring user = m_list.GetItemText(i, 2);
            std::_tstring module = m_list.GetItemText(i, 3);
            std::_tstring attribute = m_list.GetItemText(i, 4);
            std::_tstring attributeType = m_list.GetItemText(i, 5);
            std::_tstring description = m_list.GetItemText(i, 6);

            BookmarkItemData *data = reinterpret_cast<BookmarkItemData *>(m_list.GetItemData(i));

            std::wstringstream col;
            col << (data->column);
            std::_tstring column = col.str();

            writer->PushElement(_T("bookmark"));
            writer->PushElement(_T("line"), line);
            writer->PopElement();
            writer->PushElement(_T("type"), type);
            writer->PopElement();
            writer->PushElement(_T("column"), column);
            writer->PopElement();
            writer->PushElement(_T("user"), user);
            writer->PopElement();
            writer->PushElement(_T("module"), module);
            writer->PopElement();
            writer->PushElement(_T("attribute"), attribute);
            writer->PopElement();
            writer->PushElement(_T("attrtype"), attributeType);
            writer->PopElement();
            writer->PushElement(_T("description"), description);
            writer->PopElement();
            writer->PopElement(); // bookmark
        }

        writer->PopElement();
        writer->EndDocument(bookmarks);

        CUnicodeFile file;
        file.Create(BookmarksFilePath(), GENERIC_WRITE, CREATE_ALWAYS);
        if (file.IsOpen())
        {
            file.Write(bookmarks.c_str());
            file.Close();
        }
    }
}