private void GetConnection(Action<MyDynamicsServiceContext> action) { _logger.Info("Connecting to CRM...", this); var connection = new CrmConnection("CRMServiceConnection"); using (var org = new OrganizationService(connection)) { try { var context = new MyDynamicsServiceContext(org); action(context); } catch (Exception ex) { //Log the exception, then let the business layer handle the error scenario _logger.Error("There was a problem connecting to CRM", ex, this); throw ex; } } }
private void GetConnection(Action <MyDynamicsServiceContext> action) { _logger.Info("Connecting to CRM...", this); var connection = new CrmConnection("CRMServiceConnection"); using (var org = new OrganizationService(connection)) { try { var context = new MyDynamicsServiceContext(org); action(context); } catch (Exception ex) { //Log the exception, then let the business layer handle the error scenario _logger.Error("There was a problem connecting to CRM", ex, this); throw ex; } } }