private async void Connect() { if (_connector == null) { _connector = new Connector(); } if (!_connector.Connect()) { MessageBox.Show("Please click Connect to try connecting to Dynamics CRM again. A valid connection is required."); return; } IsBusy = true; IsConnected = false; if (_importLogic == null) { _importLogic = new ImportLogic(_connector.OrganizationServiceProxy); } else { _importLogic.OrganizationService = _connector.OrganizationServiceProxy; } ConnectText = "Change from " + _connector.OrganizationFriendlyName; await LoadExportData(); IsConnected = true; IsBusy = false; }
protected override void ProcessRecord() { try { var service = ConnectToCrm(); WriteDebug("Instantiating logic..."); var logic = new ImportLogic(service); WriteDebug("Loading teams..."); var teams = logic.DeserializeTeamsFromFile(FileName); WriteDebug("Upserting teams..."); logic.Import(teams); } catch (Exception ex) { ThrowTerminatingError(new ErrorRecord(ex, ex.GetType().Name, ErrorCategory.NotSpecified, null)); } }