Moved Shared logic to DataSource Class.

Most of code used to manage lastId stored in a file is now used by leads and users data source and getConnection is also used across most datasources too