Near-field thermodynamics: Useful work, efficiency, and energy harvesting