An "integrating factor" for \(\displaystyle x\frac{dy}{dx}+ (x+ 1)y\) is a function, u(x), such that \(\displaystyle \frac{d(u(x)xy}{dx}= ux\frac{dy}{dx}+ (x\frac{du}{dx}+ u)y= u(x\frac{dy}{dx}+ (x+ 1)y)= ux\frac{dy}{dx}+ u(x+ 1)y\). That is, we must have \(\displaystyle \frac{du}{dx}+ xu= xu+ u\). \(\displaystyle \frac{du}{dx}= u\) so \(\displaystyle u(x)= e^x\).

Checking, \(\displaystyle \frac{xe^xy}{dx}= e^xy+ xe^xy+ xe^x\frac{dy}{dx}= xe^x\frac{dy}{dx}+ e^x(x+1)y= e^x(x\frac{dy}{dx}+ (x+ 1)y)\).

Once you have that, \(\displaystyle e^x\left(\frac{dy}{dx}+ (x+ 1)y\right)= xe^x\), \(\displaystyle \frac{d(xe^xy)}{dy}= xe^x\). Integrating the left side gives, of course, \(\displaystyle xe^xy\). Integrating the right side, using "integration by parts", let u= x and \(\displaystyle dv= e^xdx\) so that \(\displaystyle du= dx\) and \(\displaystyle v= e^x\) so \(\displaystyle \int u dv= uv- \int vdu= xe^x- \int e^xdx= xe^x- e^x\). Integrating both sides gives \(\displaystyle xe^xy= xe^x- e^x+ C\). Divide both side by \(\displaystyle xe^x\) to get \(\displaystyle y= 1- \frac{1}{x}+ \frac{C}{x}e^{-x}\).