Example #1
0
void COnlineSearch::SaveProfile()
{
    int sel = m_cboProfiles.GetCurSel();
    if (sel == -1)
        return;
    CSearchProfile* profile = (CSearchProfile*)m_cboProfiles.GetItemDataPtr(sel);
    if (profile == NULL)
        return;

    CString s;
    m_editHost.GetWindowText(s);
    profile->m_Host = s;
    m_editPort.GetWindowText(s);
    profile->m_Port = _ttoi(s);
    m_editProxy.GetWindowText(s);
    profile->m_Proxy = s;
    m_editUser.GetWindowText(s);
    profile->m_User = s;
    m_editGroup.GetWindowText(s);
    profile->m_Group = s;
    m_editDatabase.GetWindowText(s);
    profile->m_Database = s;
    profile->m_QueryType = GetQueryType();
    m_editPass.GetWindowText(s);
    profile->m_Password = s;
    int i = m_chkSavePass.GetCheck();
    profile->m_SavePass = (BOOL)i;
}
Example #2
0
void Query::AddCondition(void)
{
	// Delete last comma on update queries.
	if (GetQueryType() == _QB_QUERY_TYPE_UPDATE)
		m_strQuery.pop_back();

	if (!m_strCondition.empty())
		m_strQuery.append(" WHERE " + m_strCondition);
}
Example #3
0
void COnlineSearch::DoSearch()
{
    CWaitCursor wait;

    // Save the infos to the profile
    SaveProfile();

#ifdef _DEBUG
    m_editRawData.Clear();
#endif

    m_lstResults.SetRedraw(FALSE);
    m_lstResults.DeleteAllItems();
    m_staticResults.SetWindowText(AfxLoadString(IDS_STRING_SEARCHRESULT));

    CString str;
    try {
        m_editHost.GetWindowText(str);
        CString port;
        m_editPort.GetWindowText(port);
        CYazConn conn(str, _ttoi(port));
        if (!conn.GetConnected()) {
            // Connection failed
            ShowError(conn.GetLastError());
        } else {
            // Connection established
            conn.SetOption(_T("implementationName"), _T("BibEdt Version ") + CAboutDlg::GetAppVersion());
            m_editUser.GetWindowText(str);
            if (!str.IsEmpty())
                conn.SetOption(_T("user"), str);
            m_editGroup.GetWindowText(str);
            if (!str.IsEmpty())
                conn.SetOption(_T("group"), str);
            m_editPass.GetWindowText(str);
            if (!str.IsEmpty())
                conn.SetOption(_T("password"), str);
            m_editProxy.GetWindowText(str);
            if (!str.IsEmpty())
                conn.SetOption(_T("proxy"), str);
            m_editDatabase.GetWindowText(str);
            if (!str.IsEmpty())
                conn.SetOption(_T("databaseName"), str);
            conn.SetOption(_T("preferredRecordSyntax"), m_RecordSyntax);
//			conn.SetOption(_T("preferredRecordSyntax"), "OPAC");

            m_editSearchFor.GetWindowText(str);

            CYazQuery* q = NULL;
            switch (GetQueryType()) {
            case QT_PREFIX:
                q = new CYazPrefixQuery();
                break;
            case QT_CQL:
                q = new CYazCQLQuery();
                break;
            case QT_CCL:
                q = new CYazCCLQuery();
                break;
            default:
                ShowError(IDS_STRING_STRANGEQUERYTYPE);
                return;
            }
            ASSERT(q);
            q->SetQueryString(str);
            CYazResultSet rs = conn.Search(q);

            m_editRecStart.GetWindowText(str);
            int recstart = _ttoi(str);
            m_editRecEnd.GetWindowText(str);
            int recend = _ttoi(str);
            int n = rs.GetCount();
            str.Format(AfxLoadString(IDS_STRING_SEARCHRESULTSNUM), n);
            m_staticResults.SetWindowText(str);
            if (recend > 0)
                n = min(n, recend);
            int ix = -1;
#ifdef _DEBUG
            CFile dbgfile;
            try {
                dbgfile.Open(COptions::AddBackslash(COptions::GetAppPath()) + _T("result.xml"), CFile::modeWrite | CFile::shareExclusive | CFile::modeCreate);
            } catch (...) {
            }
#endif
            for (int i = recstart - 1; i < n; i++) {
                CYazRecord rec = rs.GetRecord(i);
                CString rawdata = rec.GetRaw();

#ifdef _DEBUG
                try {
                    dbgfile.Write(rawdata, rawdata.GetLength());
                } catch (...) {
                }

                int selstart = m_editRawData.GetWindowTextLength();
                m_editRawData.SetSel(selstart, selstart, TRUE);
                m_editRawData.ReplaceSel(rawdata + _T("\r\n"));
#endif

                // Add the item to m_Results list
                CBibItem* item = m_Results.New();
                item->SetType(rec.GetType());
                item->Add(_T("raw"), rawdata);

                str = rec.GetValue(STR_AUTHOR);
                if (!str.IsEmpty())
                    item->Add(STR_AUTHOR, str);
                str = rec.GetValue(STR_EDITOR);
                if (!str.IsEmpty())
                    item->Add(STR_EDITOR, str);
                str = rec.GetValue(STR_TITLE);
                if (!str.IsEmpty())
                    item->Add(STR_TITLE, str);
                str = rec.GetValue(STR_EDITION);
                if (!str.IsEmpty())
                    item->Add(STR_EDITION, str);
                str = rec.GetValue(STR_SERIES);
                if (!str.IsEmpty())
                    item->Add(STR_SERIES, str);
                str = rec.GetValue(_T("Performer"));
                if (!str.IsEmpty())
                    item->Add(_T("Performer"), str);
                str = rec.GetValue(STR_YEAR);
                if (!str.IsEmpty())
                    item->Add(STR_YEAR, str);
                str = rec.GetValue(_T("ISBN"));
                if (!str.IsEmpty())
                    item->Add(_T("ISBN"), str);
                str = rec.GetValue(_T("Topic"));
                if (!str.IsEmpty())
                    item->Add(_T("Topic"), str);
                str = rec.GetValue(_T("Contents"));
                if (!str.IsEmpty())
                    item->Add(_T("Contents"), str);

                // Add it to the listview
                CField* field = item->Find(STR_AUTHOR);
                if (!field)
                    field = item->Find(STR_EDITOR);
                if (!field)
                    field = item->Find(_T("Performer"));
                if (field)
                    ix = m_lstResults.InsertItem(ix+1, field->GetValue(), -1);
                else
                    ix = m_lstResults.InsertItem(ix+1, NULL, -1);
                m_lstResults.SetItemData(ix, (DWORD)item);
                field = item->Find(STR_TITLE);
                if (field)
                    m_lstResults.SetItemText(ix, 1, field->GetValue());
                field = item->Find(STR_YEAR);
                if (field)
                    m_lstResults.SetItemText(ix, 2, field->GetValue());
            }

            delete q;

#ifdef _DEBUG
            try {
                dbgfile.Close();
            } catch (...) {
            }
#endif
        } // if (conn.GetConnected())
    } catch (...) {
        ShowError(IDS_STRING_YAZEXCEPTION);
    }
    m_lstResults.SetRedraw();
    m_staticResults.Invalidate();
}