Resonant charge exchange involving electronically excited states of nitrogen atoms and ions