Whenever we are publishing any item from CMS its status is not showing success. It is stuck on to ready for transport. But actually items are getting published to CDS. Because of this status issue that code is not working well which checks the publish status of items.
Got the solution. On publisher in the Tridion bin folder there is a transaction folder. It was containing thousands of files. Every time when publishing done It seems these failed transactions were processed by publisher which was the issue of not showing the publishing status as Success. We deleted those files and now the things are getting success.