void updateActivityResult(IConstWorkUnit &workunit, unsigned helperFlags, unsigned sequence, const char *logicalFilename, unsigned __int64 recordCount)
{
    Owned<IWorkUnit> wu = &workunit.lock();
    Owned<IWUResult> r;
    r.setown(updateWorkUnitResult(wu, logicalFilename, sequence));
    r->setResultTotalRowCount(recordCount); 
    r->setResultStatus(ResultStatusCalculated);
    if (TDWresult & helperFlags)
        r->setResultFilename(logicalFilename);
    else
        r->setResultLogicalName(logicalFilename);
    r.clear();
    wu.clear();
}
 void addResult(rowcount_t resultCount, MemoryBuffer &resultData, bool complete)
 {
     Owned<IWorkUnit> wu = &container.queryJob().queryWorkUnit().lock();
     Owned<IWUResult> result = updateWorkUnitResult(wu, resultName, resultSeq);
     if (appendOutput)
         result->addResultRaw(resultData.length(), resultData.toByteArray(), ResultFormatRaw);
     else
         result->setResultRaw(resultData.length(), resultData.toByteArray(), ResultFormatRaw);
     result->setResultRowCount(resultCount);
     result->setResultTotalRowCount(resultCount);
     resultData.clear();
     if (complete)
         result->setResultStatus(ResultStatusCalculated);
     appendOutput = true;
 }