Ejections on the Sun and their Relationship with Flares and Magnetic