Created
June 17, 2015 16:34
-
-
Save miragedeb/63d5046482006d226d8b to your computer and use it in GitHub Desktop.
ProcessTerlerikEmail
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
global class ProcessTelerikEmail implements Messaging.InboundEmailHandler { | |
global Messaging.InboundEmailResult handleInboundEmail(Messaging.InboundEmail email, | |
Messaging.InboundEnvelope envelope) { | |
Messaging.InboundEmailResult result = new Messaging.InboundEmailresult(); | |
List<Account> allAccountsToUpdate = new List<Account>(); | |
for( Account acc: [SELECT Id, Burn_Test_runtime__c , Pass_Fail__c | |
FROM Account WHERE Account_Status__c = 'Client' | |
AND Hosted__c != 'Client-Internal' | |
AND DR_Server__c ='s3.emea2']) | |
{ | |
if(email.plainTextBody.contains(acc.Id)) { | |
allAccountsToUpdate.add( | |
new Account( | |
Id= acc.Id, | |
Pass_Fail__c = 'Fail', | |
Burn_Test_runtime__c = String.valueOf(Datetime.now()) | |
) | |
); | |
} | |
else { | |
allAccountsToUpdate.add( | |
new Account( | |
Id= acc.Id, | |
Pass_Fail__c = 'Pass', | |
Burn_Test_runtime__c = String.valueOf(Datetime.now()) | |
) | |
); | |
} | |
} | |
System.debug('Processing for emea complete'); | |
for( Account acc: [SELECT Id, Burn_Test_runtime__c , Pass_Fail__c | |
FROM Account WHERE Account_Status__c = 'Client' | |
AND Hosted__c != 'Client-Internal' | |
AND DR_Server__c !='s3.emea2']) | |
{ | |
if(email.plainTextBody.contains(acc.Id)) { | |
allAccountsToUpdate.add( | |
new Account( | |
Id= acc.Id, | |
Pass_Fail__c = 'Fail', | |
Burn_Test_runtime__c = String.valueOf(Datetime.now()) | |
) | |
); | |
} | |
else { | |
allAccountsToUpdate.add( | |
new Account( | |
Id= acc.Id, | |
Pass_Fail__c = 'Pass', | |
Burn_Test_runtime__c = String.valueOf(Datetime.now()) | |
) | |
); | |
} | |
} | |
System.debug('Processing for US complete'); | |
if(!allAccountsToUpdate.isEmpty()){ | |
UPDATE allAccountsToUpdate; | |
} | |
return result; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment