private void mgr_ConnectionCheckComplete(object sender, ServerConnectStatusEventArgs e) { ((CrmConnectionManager)sender).ConnectionCheckComplete -= mgr_ConnectionCheckComplete; ((CrmConnectionManager)sender).ServerConnectionStatusUpdate -= mgr_ServerConnectionStatusUpdate; if (!e.Connected) { if (e.MultiOrgsFound) { MessageBox.Show("Unable to Login to CRM using cached credentials. Org Not found", "Login Failure"); } else { MessageBox.Show("Unable to Login to CRM using cached credentials", "Login Failure"); } resetUiFlag = true; CrmLoginCtrl.GoBackToLogin(); Dispatcher.Invoke(DispatcherPriority.Normal, new System.Action(() => { this.Title = "Failed to Login with cached credentials."; MessageBox.Show(this.Title, "Notification from ConnectionManager", MessageBoxButton.OK, MessageBoxImage.Error); CrmLoginCtrl.IsEnabled = true; } )); resetUiFlag = false; } else { if (e.Connected && !bIsConnectedComplete) { ProcessSuccess(); } } }
private void Mgr_ConnectionCheckComplete(object sender, ServerConnectStatusEventArgs e) { ((CrmConnectionManager)sender).ConnectionCheckComplete -= Mgr_ConnectionCheckComplete; ((CrmConnectionManager)sender).ServerConnectionStatusUpdate -= Mgr_ServerConnectionStatusUpdate; if (!e.Connected) { if (e.MultiOrgsFound) { MessageBox.Show("Unable to Login to CRM using cached credentials. Org Not found", "Login Failure"); } else { MessageBox.Show("Unable to Login to CRM using cached credentials", "Login Failure"); } resetUiFlag = true; CrmLoginCtrl.GoBackToLogin(); ThreadHelper.JoinableTaskFactory.Run(async delegate { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); this.Title = "Failed to Login with cached credentials."; MessageBox.Show(this.Title, "Notification from ConnectionManager", MessageBoxButton.OK, MessageBoxImage.Error); CrmLoginCtrl.IsEnabled = true; }); resetUiFlag = false; } else { if (e.Connected && !bIsConnectedComplete) { ProcessSuccess(); } } }
/// <summary> /// This raises and processes Success /// </summary> private void ProcessSuccess() { resetUiFlag = true; bIsConnectedComplete = true; CrmSvc = mgr.CrmSvc; CrmLoginCtrl.GoBackToLogin(); Dispatcher.Invoke(DispatcherPriority.Normal, new System.Action(() => { this.Title = "Notification from Parent"; CrmLoginCtrl.IsEnabled = true; } )); //here we should be connected to crm and we need connection info to generate model if requested! if (CrmConnectionMgr != null && CrmConnectionMgr.CrmSvc != null && CrmConnectionMgr.CrmSvc.IsReady) { connectionStringService.ApplyDBInfoInfoFromClientService(CrmConnectionMgr.CrmSvc, cxInfo.DatabaseInfo); } this.DialogResult = true; // Notify Caller that we are done with success. ContextClassSelectionCompleted?.Invoke(this, null); resetUiFlag = false; }
private void ProcessSuccess() { resetUiFlag = true; bIsConnectedComplete = true; CrmLoginCtrl.GoBackToLogin(); ThreadHelper.JoinableTaskFactory.Run(async delegate { await ThreadHelper.JoinableTaskFactory.SwitchToMainThreadAsync(); this.Title = "Notification from Parent"; CrmLoginCtrl.IsEnabled = true; }); ConnectionToCrmCompleted?.Invoke(this, null); resetUiFlag = false; }
private void ProcessSuccess() { resetUiFlag = true; bIsConnectedComplete = true; CrmLoginCtrl.GoBackToLogin(); Dispatcher.Invoke(DispatcherPriority.Normal, new System.Action(() => { this.Title = "Notification from Parent"; CrmLoginCtrl.IsEnabled = true; } )); ConnectionToCrmCompleted?.Invoke(this, null); resetUiFlag = false; }
private void mgr_ConnectionCheckComplete(object sender, ServerConnectStatusEventArgs e) { // The Status event will contain information about the current login process, if Connected is false, then there is not yet a connection. // Unwire events that we are not using anymore, this prevents issues if the user uses the control after a failed login. ((CrmConnectionManager)sender).ConnectionCheckComplete -= mgr_ConnectionCheckComplete; ((CrmConnectionManager)sender).ServerConnectionStatusUpdate -= mgr_ServerConnectionStatusUpdate; if (!e.Connected) { // if its not connected pop the login screen here. if (e.MultiOrgsFound) { MessageBox.Show("Unable to Login to CRM using cached credentials. Org Not found", "Login Failure"); } else { MessageBox.Show("Unable to Login to CRM using cached credentials", "Login Failure"); } _resetUiFlag = true; CrmLoginCtrl.GoBackToLogin(); // Bad Login Get back on the UI. Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { Title = "Failed to Login with cached credentials."; MessageBox.Show(Title, "Notification from ConnectionManager", MessageBoxButton.OK, MessageBoxImage.Error); CrmLoginCtrl.IsEnabled = true; })); _resetUiFlag = false; } else { // Good Login Get back on the UI if (e.Connected && !_bIsConnectedComplete) { ProcessSuccess(); } OutputLogger.WriteToOutputWindow(HostWindow.GetCaption(string.Empty, _mgr.CrmSvc).Substring(3), MessageType.Info); } }
private void ProcessSuccess() { _resetUiFlag = true; _bIsConnectedComplete = true; _crmSvc = _mgr.CrmSvc; CrmLoginCtrl.GoBackToLogin(); Dispatcher.Invoke(DispatcherPriority.Normal, new Action(() => { Title = "Notification from Parent"; CrmLoginCtrl.IsEnabled = true; } )); // Notify Caller that we are done with success. ConnectionToCrmCompleted?.Invoke(this, null); _resetUiFlag = false; }
/// <summary> /// Complete Event from the Auto Login process /// </summary> /// <param name="sender"></param> /// <param name="e"></param> private void mgr_ConnectionCheckComplete(object sender, ServerConnectStatusEventArgs e) { // The Status event will contain information about the current login process, if Connected is false, then there is not yet a connection. // Unwire events that we are not using anymore, this prevents issues if the user uses the control after a failed login. ((CrmConnectionManager)sender).ConnectionCheckComplete -= mgr_ConnectionCheckComplete; ((CrmConnectionManager)sender).ServerConnectionStatusUpdate -= mgr_ServerConnectionStatusUpdate; if (!e.Connected) { // if its not connected pop the login screen here. if (e.MultiOrgsFound) { MessageBox.Show("Unable to sign in to CRM using cached credentials. Org Not found", "Sign In failed"); } else { MessageBox.Show("Unable to sign in to CRM using cached credentials", "Sign In failed"); } resetUiFlag = true; CrmLoginCtrl.GoBackToLogin(); // Bad Login Get back on the UI. Dispatcher.Invoke(DispatcherPriority.Normal, new System.Action(() => { this.Title = "Failed to sign in with cached credentials."; MessageBox.Show(this.Title, "Notification from ConnectionManager", MessageBoxButton.OK, MessageBoxImage.Error); CrmLoginCtrl.IsEnabled = true; } )); resetUiFlag = false; } else { // On successful sign in, return to the UI if (e.Connected && !bIsConnectedComplete) { ProcessSuccess(); } } }
/// <summary> /// This raises and processes Success /// </summary> private void ProcessSuccess() { resetUiFlag = true; bIsConnectedComplete = true; CrmSvc = mgr.CrmSvc; CrmLoginCtrl.GoBackToLogin(); Dispatcher.Invoke(DispatcherPriority.Normal, new System.Action(() => { this.Title = "Notification from Parent"; CrmLoginCtrl.IsEnabled = true; } )); // Notify Caller that we are done with success. //if (ConnectionToCrmCompleted != null) ConnectionToCrmCompleted(this, null); //Michael: just cancel in case of success: this.Close(); resetUiFlag = false; }