Differential equations (second edition) - William E. Boyce & Richard C. Diprima (#$31$, page $142$) 
In many physical problems, non-homogeneous term may differ from one
  time interval to another. By example, determine the solution $y =  \phi(t)$ at 
$$y'' + y =  \begin{cases} 
     t      & \quad \text{if } 0 \leq t \leq \pi \\
    \pi e^{\pi - t}  & \quad \text{if } t > \pi \\   \end{cases} $$ with the initial contitions $y(0) = 0$ and $y'(0)=1$
Suppose also that $y$ and $y'$ are continuous at $t = \pi$. Hint :
  First, resolve the problem at initial value for $t \leq \pi$. After,
  resolve for $t > \pi$ in determining the constantes of the last
  solution and in supposing the continuity at $t = \pi$

I obtain as solution 
$$y(t) =  \begin{cases} 
    t      & \quad \text{if } 0 \leq t \leq \pi \\
    \pi e^{\pi - t}  & \quad \text{if } t > \pi \\   \end{cases} $$
but the solution of the book is 
$$y(t) =  \begin{cases} 
    t      & \quad \text{if } 0 \leq t \leq \pi \\
   -(1+\frac{\pi}{2}) \sin(t) - (\frac{\pi}{2}) \cos(t) + \frac{\pi}{2} e^{\pi - t}  & \quad \text{if } t > \pi \\   \end{cases} $$
I'm trying for quite a while to resolve my problem, but without result. Does someone could explain to me how could I correct my solution?
This is the exercise #$28$, page $178$ of this link.

By the characteristic equation, we get the general solution
$$y_c=c_1\cos t+c_2\sin t$$
For the first part, we try the particular solution
$$y_p=At+B$$
Since you got your first part correctly, I think you know how to get 
$$y=t, 0\leq t\leq \pi$$
Now for the second interval, you still have the general solution
$$y_c=c_1\cos t+c_2\sin t$$
For the particular solution, since right hand side is $\pi e^{\pi} e^{-t}$, we try $Ae^{-t}$:
$$y_p=Ae^{-t}$$
This gives 
$$y_p''=Ae^{-t}$$
Plugging these into the second part of the differential equation gives us
$$y_p''+y_p=2Ae^{-t}=\pi e^{\pi-t}$$
So $A=\frac{\pi}{2}e^{\pi}$.
Now we still don't know what are $c_1$ and $c_2$. Since $y$ and $y'$ have to be continuous at $\pi$, we set $y(\pi)=\pi$, and $y'(\pi)=1$ for
$$y=c_1\cos t+c_2\sin t+\frac{\pi}{2}e^{\pi-t}$$
which you can see easily comes from the first part of the solution. This will give us the desired solution.
