How much radiation is an airline pilot exposed to in a year?
The average additional annual dose for flight crew is 2.19 mSv (milli sieverts).  http://www.hps.org/publicinformation/ate/faqs/commercialflights.html

The typical annual dose from background sources is 4 mSv (this varies enormously on the Earth's surface). However, as a rough order of thumb, the annual radiation dose of a flight crew member increases by about 50% compared to sitting on the ground.

For comparison with other sources, having a chest CT scan provides you with a 7 mSv dose over the period of a few minutes.

The maximum permitted dose in one year for a radiation worker under US Federal Law is 50 mSv.

For more comparisons of radiation dose, see https://xkcd.com/radiation/

On a technical point, the premise of your question is incorrect.

Flying exposes us to additional cosmic background radiation because we are at a greater height above the Earth's surface, not because we are closer to the sun. We are protected from cosmic radiation by the presence of the Earth's magnetic field, which extends far into space and is not an issue here except very close to the poles; and more importantly, by the layer of atmosphere above our heads that tends to absorb cosmic rays before they reach the surface. At 40,000 feet, the bulk of the atmosphere by mass is below you.

It is not presently believed that a substantial fraction of these rays are emitted by the sun. For one, you will continue to be irradiated by them at night.

(For interest, if you could see the cosmic background radiation, it would be approximately as bright on the night sky as star light is; for complex reasons the two energies are in rough equipartition.)