Created
January 12, 2018 15:54
This file contains 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
List opportunities = new List(); | |
var sync = new object(); | |
Parallel.ForEach(proxyOpportunities, (proxyOpportunity) => | |
{ | |
try | |
{ | |
Opportunity convertedOpportunity = proxyOpportunity.ConvertToOpportunity(); | |
lock (sync) | |
{ | |
opportunities.Add(convertedOpportunity); | |
} | |
} | |
catch (Exception ex) | |
{ | |
Opportunity failedOpportunity = new Opportunity() | |
{ | |
ExcludeForImport = ExcludeReason.ImportFailed, | |
DocumentNumber = proxyOpportunity.With(x => x.DOC_ID) | |
}; | |
lock (sync) | |
{ | |
opportunities.Add(failedOpportunity); | |
} | |
LoggingWrapper logger = new LoggingWrapper(); | |
logger.LogError(ex); | |
} | |
}); | |
return opportunities; |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment