X-ray emission of the nitrogen molecule following photon or electron impact. A theoretical study using configuration-interaction wavefunctions