Return Type | Function name | Arguments |
---|---|---|
hzEcode | hdsExec::SrchRepos | (hzChain&,hzHttpEvent*,) |
Declared in file: hzDissemino.h
Defined in file : hdsExec.cpp
Function Logic:
Function body:
hzEcode hdsExec::SrchRepos (hzChain& errorReport, hzHttpEvent* pE) { _hzfunc("hdsExec::DocSearch") ; hzVect<hdsPage*> Result ; hzVect<uint32_t> res ; hzChain Z ; hzToken T ; hdbIdset R ; hdsResource* pRes ; hdsPage* pPage ; hdbObjRepos* pRepos ; hzString m_Action ; hzString m_Source ; hzString m_Criteria ; hzString m_Count ; hzString m_Found ; hzString S ; uint32_t nCount ; uint32_t nStart ; hzEcode bSelect ; hzEcode rc = E_OK ; char buf [20]; if (!pE) Fatal("No HTTP event supplied\n") ; errorReport.Printf("DocSearch ...\n") ; Result.Clear() ; m_Criteria = m_pApp->m_ExecParams[m_FstParam] ; if (!pE->m_mapStrings.Exists(m_Criteria)) { errorReport.Printf("%s. No such field as %s\n", __func__, *m_Criteria) ; pE->m_appError = "Due to an Internal Error (Field name mismatch) we could not process your request" ; return E_NOTFOUND ; } S = pE->m_mapStrings[m_Criteria] ; if (m_Source == "pages") { errorReport.Printf("%s. Search page index for [%s]\n", __func__, *S) ; rc = m_pApp->m_PageIndex.Eval(R, S) ; if (rc != E_OK) { pE->m_appError = "Due to an Internal Error (Evaluation of page index) we could not process your request" ; return E_NOTFOUND ; } } else { pRepos = m_pApp->m_ADP.GetObjRepos(m_Source) ; if (!pRepos) { pE->m_appError = "Due to an Internal Error (Repos not located) we could not process your request" ; return E_NOTFOUND ; } rc = pRepos->Select(R, *S) ; if (rc != E_OK) { pE->m_appError = "Due to an Internal Error (Evaluation of select on cache) we could not process your request" ; return E_NOTFOUND ; } } if (!R.Count()) { Z.Printf("Your search for %s found 0 results. Please try again", *S) ; pE->m_appError = Z ; return E_NOTFOUND ; } errorReport.Printf("%s. Results are %d pages, error=%s\n", __func__, R.Count(), Err2Txt(rc)) ; sprintf(buf, "%d", R.Count()) ; S = buf ; rc = pE->SetVarString(m_Count, S) ; if (rc != E_OK) errorReport.Printf("%s. Could not set var %s to %s\n", __func__, *m_Count, buf) ; Z << "<div id="stdlist">\n" ; Z << "<table align="center" border="0" cellspacing="0" cellpadding="0">\n" ; for (nStart = 0;;) { R.Fetch(res, nStart, 20); errorReport.Printf("%s: Fetched %d records (total)\n", __func__, res.Count()) ; for (nCount = 0; nCount < res.Count() ; nCount++) { pRes = m_pApp->m_ResourcesName.GetObj(res[nCount]) ; pPage = dynamic_cast<hdsPage*>(pRes) ; if (!pPage) continue ; errorReport.Printf("%s: Page No %d is page %p\n", __func__, res[nCount], pPage) ; Result.Add(pPage) ; Z.Printf("<tr><td><a href="%s">%s</a></td><td> </td><td><a href="%s">%s</a></td></tr>\n" , *pPage->m_Url, *pPage->m_Title, *pPage->m_Url, *pPage->m_Desc) ; } if (res.Count() < 20) break ; nStart += 20; } Z << "</table>\n" ; Z << "</div>\n" ; rc = pE->SetVarChain(m_Found, Z) ; if (rc != E_OK) errorReport.Printf("%s. Could not set var %s to chain of %d bytes\n", __func__, *m_Found, Z.Size()) ; errorReport.Printf("%s: Site scanned. %d pages\n", __func__, Result.Count()) ; return rc ; }