Until I read the latter part of your OP the symptoms suggested to me an overheating issue, now however I`m thinking you may have a bad power jack at the rear of your laptop and that it has possibly come away from the MB (a common occurrence) and is causing a short hence the shutdowns, is there any sign of movement from the power jack?
Unfortunately to check this out the laptop will need to be almost completely dismantled, a job best left to a suitably qualified or at least competent person, the attached links may help you decide on the way you wish to proceed;
or for me an easier to follow guide http://www.insidemyl...n-dv7-notebook/
if you take the task on yourself take the opportunity to clean out any heat trapping dust that causes overheating/shutdowns, pay particular attention to the CPU cooler and fan.
Just a FYI the dv7 laptop batteries are known to not last very long before needing to be recharged but avoid prolonged use whilst being both connected to the mains electricity and having the battery in place.