Praise be to Allaah.
One of the things that should be understood is that Islam means submitting to the command of Allah, adhering to His laws and accepting His wisdom, because the essence of Islam is based on showing true servitude (‘uboodiyyah) to Allah, the One, the Subduer. The more a person submits in servitude to Allah, the more Allah will raise him in status and guide him and accept his deeds.
So the heart of the matter is love of Allah and love of His Messengers and Prophets (blessings and peace be upon them), as Allah, may He be exalted, says (interpretation of the meaning):
“Say (O Muhammad SAW to mankind): ‘If you (really) love Allâh then follow me (i.e. accept Islâmic Monotheism, follow the Qur'ân and the Sunnah), Allâh will love you and forgive you your sins. And Allâh is Oft-Forgiving, Most Merciful.’”
[Aal ‘Imraan 3:31].
The whole of the heavens and the earth is based on the concept of this love; with it the heart of the Muslim comes alive as he seeks the pleasure of Allah. Indeed it is what differentiates between the Muslim and non-Muslim, because the Muslim submits to the law and decree of Allah out of love, respect and veneration of Allah, may He be exalted, whereas the non-Muslim thinks that “servitude to Allah” means being forced to follow the letter of the law, devoid of spirit and meaning, even though Allah, may He be glorified and exalted, says (interpretation of the meaning):
“There is no compulsion in religion. Verily, the Right Path has become distinct from the wrong path”
Once the Muslim understands that love of Allah must take precedence over love of anyone else, and that obedience to Him must take precedence over all whims and desires of the self or any wish that goes against seeking the pleasure of Allah and loving Him, and that the sign of true love is obedience to Allah and following His command in all matters both great and small, then it will be easy for him to go against his own whims and desires and to give up all worldly matters, if by doing so he may attain the pleasure of the Lord of the Worlds. It will be easy for him to sacrifice himself and his wealth for the sake of Allah, may He be glorified and exalted, so long as that sacrifice is beloved by Allah and brings him closer to attaining His pleasure. Allah, may He be exalted, says (interpretation of the meaning):
“Verily, Allâh has purchased of the believers their lives and their properties for (the price) that theirs shall be the Paradise. They fight in Allâh's Cause, so they kill (others) and are killed. It is a promise in truth which is binding on Him in the Taurât (Torah) and the Injeel (Gospel) and the Qur'ân. And who is truer to his covenant than Allâh? Then rejoice in the bargain which you have concluded. That is the supreme success”
Keeping a dog for no reason is haraam for the Muslim and detracts from his reward. Although it does not invalidate his good deeds altogether, and his prayers and good deeds will not be rejected because of that, the reward for his good deeds is reduced by a large amount that the Muslim loses every day because of it.
It was narrated that Abu Hurayrah (may Allah be pleased with him) said: The Messenger of Allah (blessings and peace of Allah be upon him) said: “Whoever keeps a dog, one qiraat (i.e., a certain amount) will be deducted from his good deeds every day, except a dog for watching the fields or herding livestock.”
Narrated by al-Bukhaari, 3324: Muslim, 1575
See also the answer to question no.
To sum up:
The long time that you have had the dog is not a justification for keeping it when the Prophet (blessings and peace of Allah be upon him) has forbidden us to do so and warned us of this great reduction in a person’s reward for good deeds because of that, even if it does not render one’s prayers invalid.
With regard to what is past, if you did not know of the prohibition on keeping dogs at that time, there is no blame on you in sha Allah and there will be no reduction in the reward for your good deeds because of that.
And Allah knows best.