Пример #1
0
def retrieveSfdcAccounts(user_id=None, company_id=None, job_id=None, run_type=None, sinceDateTime=None):
    try:
        if sinceDateTime is None:
            sinceDateTime = (datetime.now() - timedelta(days=1)).date()
        sfdc = Salesforce()
        accountList = sfdc.get_accounts_delta(user_id, company_id, _str_from_date(sinceDateTime), run_type)
        print 'got back accounts ' + str(len(accountList['records']))
        saveSfdcAccounts(user_id=user_id, company_id=company_id, accountList=accountList, job_id=job_id, run_type=run_type)
        try:
            message = 'Accounts retrieved from Salesforce'
            notification = Notification()
            #notification.company_id = company_id
            notification.owner = user_id
            notification.module = 'Accounts'
            notification.type = 'Background task' 
            notification.method = os.path.basename(__file__)
            notification.message = message
            notification.success = True
            notification.read = False
            notification.save()
        except Exception as e:
            send_notification(dict(
                 type='error',
                 success=False,
                 message=str(e)
                ))    
        return accountList
    except Exception as e:
        send_notification(dict(type='error', success=False, message=str(e)))