The high intensity and high repetition rate of the XFEL, the European X-ray Free-Electron Laser presently under construction in Hamburg, results in X-ray doses of up to 1 GGy in silicon sensors for 3 years of operation. Within the AGIPD Collaboration the Hamburg group has systematically studied X-ray-radiation damage using test structures and segmented sensors fabricated on high-ohmic n-type silicon. MOS Capacitors and Gate- Controlled Diodes from 4 vendors with different crystal orientations and different technological parameters, as well as strip sensors have been irradiated in the dose range between 10 kGy and 1 GGy. Current-Voltage, Capacitance/Conductance-Voltage and Thermal Dielectric Relaxation Current measurements were used to extract oxide-charge densities, interface-trap densities and surface-current densities as function of dose and annealing conditions. The results have been implemented into TCAD simulations, and the radiation performance of strip sensors and guard-ring structures simulated and compared to experimental results. Finally, with the help of detailed TCAD simulations, the layout and technological parameters of the AGIPD pixel sensor have been optimized. It is found that the optimization for sensors exposed to high X-ray doses is significantly different than for non-irradiated sensors, and that the specifications of the AGIPD sensor can be met. In 2012 sensors have been ordered, the first batch has been delivered recently, and first results on a comparison between simulations and measurements will be presented.