  In this paper, we give a construction of the global Chern-Simons functions
for toric Calabi-Yau stacks of dimension three using strong exceptional
collections. The moduli spaces of sheaves on such stacks can be identified with
critical loci of these functions. We give two applications of these functions.
First, we prove Joyce's integrality conjecture of generalized DT invariants on
local surfaces. Second, we prove a dimension reduction formula for virtual
motives, which leads to two recursion formulas for motivic Donaldson-Thomas
invariants.
