コード例 #1
0
        private void FindMatchingDocs_DoWork(object sender, DoWorkEventArgs e)
        {
            MatchDocsResult mdResult = new MatchDocsResult();
            e.Result = mdResult;
            BackgroundWorker worker = sender as BackgroundWorker;
            List<ScanDocInfo> sdiList = _scanDocHandler.GetListOfScanDocs();
            int docsFound = 0;

            // Get args - document type to match and start position for filling list (this is
            // so we don't swamp the list by including all results)
            object[] args = (object[])e.Argument;
            DocType docTypeToMatch = (DocType)args[0];
            int includeInListFromIdx = (int)args[1];

            // Match results
            mdResult.bNotAllResultsShow = false;
            mdResult.totalFilesScanned = sdiList.Count;
            mdResult.bMatchedResultsOnly = (docTypeToMatch != null);
            mdResult.indexOfFirstFileDisplayed = -1;

            // Start index in list
            int nStartIdx = (docTypeToMatch == null) ? includeInListFromIdx : 0;
            int nEndIdx = includeInListFromIdx + MAX_NUM_DOCS_TO_ADD_TO_LIST - 1;
            if ((docTypeToMatch != null) || (nEndIdx > sdiList.Count - 1))
                nEndIdx = sdiList.Count - 1;
            for (int nDocIdx = nStartIdx; nDocIdx <= nEndIdx; nDocIdx++)
            {
                if ((worker.CancellationPending == true))
                {
                    e.Cancel = true;
                    break;
                }

                ScanDocInfo sdi = sdiList[nDocIdx];

                // Check if all docs required
                DocCompareRslt rslt = new DocCompareRslt();
                bool bShowDoc = false;
                if (docTypeToMatch == null)
                {
                    ScanPages scanPages = _scanDocHandler.GetScanPages(sdi.uniqName);
                    // See if doc has been filed - result maybe null
                    FiledDocInfo fdi = _scanDocHandler.GetFiledDocInfo(sdi.uniqName);
                    bShowDoc = true;
                    rslt.uniqName = sdi.uniqName;
                    rslt.bMatches = true;
                    rslt.bMatchesButShouldnt = false;
                    rslt.docTypeFiled = (fdi == null) ? "" : fdi.filedAs_docType;
                    rslt.matchStatus = (fdi == null) ? "NOT-FILED" : "FILED";
                    rslt.scanPages = scanPages;
                    mdResult.totalMatchesFound++;
                }
                else
                {
                    rslt = CheckIfDocMatches(sdi, docTypeToMatch);
                    if (rslt.bMatches)
                        mdResult.totalMatchesFound++;
                    if (rslt.bDoesntMatchButShould)
                        mdResult.totalDoesntMatchButShould++;
                    if (rslt.bMatchesButShouldnt)
                        mdResult.totalMatchesButShouldnt++;
                    if (rslt.bMatches || rslt.bDoesntMatchButShould)
                        bShowDoc = true;
                }
                mdResult.totalFilesSearched++;
                _lastFindNumFound = mdResult.totalFilesSearched;
                if (bShowDoc)
                {
                    // Check for a limit to avoid swamping list
                    docsFound++;
                    if ((docsFound > includeInListFromIdx-nStartIdx) && (docsFound <= includeInListFromIdx - nStartIdx + MAX_NUM_DOCS_TO_ADD_TO_LIST))
                    {
                        if (mdResult.indexOfFirstFileDisplayed == -1)
                            mdResult.indexOfFirstFileDisplayed = nDocIdx;
                        this.Dispatcher.BeginInvoke((Action)delegate()
                        {
                            _docCompareRslts.Add(rslt);
                        });
                    }
                    else
                    {
                        // Indicate that not all results are shown
                        mdResult.bNotAllResultsShow = true;
                    }
                }

                // Update status
                worker.ReportProgress((int)(nDocIdx * 100 / sdiList.Count));
                if (((nDocIdx % 10) == 0) || (nDocIdx == nEndIdx))
                {
                    string rsltStr = DocMatchFormatResultStr(mdResult);
                    this.Dispatcher.BeginInvoke((Action)delegate()
                    {
                        SetDocMatchStatusText(rsltStr);
                    });
                }
            }
            e.Result = mdResult;
        }
コード例 #2
0
        private DocCompareRslt CheckIfDocMatches(ScanDocInfo sdi, DocType docTypeToMatch)
        {
            DocCompareRslt compRslt = new DocCompareRslt();
            ScanDocAllInfo scanDocAllInfo = _scanDocHandler.GetScanDocAllInfoCached(sdi.uniqName);

            // Check for a match
            DocTypeMatchResult matchResult = _docTypesMatcher.CheckIfDocMatches(scanDocAllInfo.scanPages, docTypeToMatch, false, null);
            if (matchResult.matchCertaintyPercent == 100)
            {
                compRslt.bMatches = true;
                compRslt.bMatchesButShouldnt = (scanDocAllInfo.filedDocInfo != null) && TestForMatchesButShouldnt(scanDocAllInfo.filedDocInfo.filedAs_docType, docTypeToMatch);
                compRslt.uniqName = sdi.uniqName;
                compRslt.docTypeFiled = (scanDocAllInfo.filedDocInfo == null) ? "" : scanDocAllInfo.filedDocInfo.filedAs_docType;
                compRslt.matchStatus = (scanDocAllInfo.filedDocInfo == null) ? "NOT-FILED" : (compRslt.bMatchesButShouldnt ? "MATCH-BUT-SHOULDN'T" : "OK");
                compRslt.scanPages = scanDocAllInfo.scanPages;
            }
            else
            {
                compRslt.bDoesntMatchButShould = (scanDocAllInfo.filedDocInfo != null) && (scanDocAllInfo.filedDocInfo.filedAs_docType == docTypeToMatch.docTypeName);
                if (compRslt.bDoesntMatchButShould)
                {
                    compRslt.uniqName = sdi.uniqName;
                    compRslt.docTypeFiled = (scanDocAllInfo.filedDocInfo == null) ? "" : scanDocAllInfo.filedDocInfo.filedAs_docType;
                    compRslt.matchStatus = "SHOULD-BUT-DOESN'T";
                    compRslt.scanPages = scanDocAllInfo.scanPages;
                }
            }
            compRslt.matchFactorStr = matchResult.matchCertaintyPercent.ToString() + " + " + matchResult.matchFactor.ToString() + "%";
            return compRslt;
        }