Proactive and Real-Time Optimal Control of Water Quality in Water Distribution Networks