.net - TPL dataflow preserving input -
i using .net tpl dataflow operation. using match list of resumes job category. final block gives me matched resumes/candidates. want associate matched candidate initial input category. have find list of matching candidates list of job categories. however, unable preserve original input. want final output this
{category, list< matchedcandidates >} 1 category if searching mutiple categories, want output be
list of {category, list< matchedcandidates >}
here code:
var transformblock = new transformblock<int, category_keywordstomatch>(x => { return getkeywordstomatch(x); }); var matchedcandidates_dataflow = new list<matchedcandidate>(); var finalblock = new actionblock<category_keywordstomatch>(x => { list<resume> resumes = new list<resume>(); using (var context = new indepthrecruitdbcontext()) { resumes = context.resumes.include("candidate").tolist(); } foreach (var res in resumes) { var keywords = findkeywords(x.keywordstomatch, res); if (keywords.count > 0) { matchedcandidates_dataflow.add(new matchedcandidate { id = res.candidateid, name = res.candidate.name, url = res.url, uploaded = res.dateuploaded.toshortdatestring(), matchedkeywordslist = keywords }); } } }); var linkoptions = new dataflowlinkoptions { propagatecompletion = true }; transformblock.linkto(finalblock, linkoptions); transformblock.post(1); transformblock.complete(); finalblock.completion.wait();
Comments
Post a Comment