Since the problem has happened on two different sources of shore power, the problem will likely be somewhere from the power cord end plugged to the shore power to the inverter.
If the power cord connectors seem firm, then initially I would look at my on board Surge Protection device. Mine has green led's that indicate that the power entering the coach is OK. It is connected to the shore power just ahead of the transfer switch. You may not have a surge protector installed.
I would think the Transfer Switch would be ok since initially you have shore power. That means it switched from Generator to Shorepower successfully. There should be nothing that occurs to cause it to switch back to generator.
The inverter probably has a transfer switch in it as well. So the problem could be in the inverter/charger/convertor device. I cannot help you with that one.
If you have a surge protector and when the power is mysteriously off, check the indicator lights to see if the power cord is passing electricity correctly. If not, it is likely that your power cord has a problem. That usually occurs at the connectors.
If nothing is visibly wrong with the cord end connectors you might test the power cord with the Ohm tester on your multimeter to determine if you have a broken wire in the cord.
Since power is restored when you replug the power cord to the shore power, my bet is that you have a loose connection at the shore power source on your cord. Or you may have a loose connector at the coach end of the cord.
1995 CC Magna #5280
C8.3L 300hp Cummins, 31,000lbs