public async void ConnectToServer(string server) { var serverDTO = VMDirServerDTO.CreateInstance(); if (!string.IsNullOrWhiteSpace(server)) { serverDTO.Server = server; } ProgressWindowController pwc = new ProgressWindowController(); IntPtr session = new IntPtr(0); ConnectToLdapWindowController awc = new ConnectToLdapWindowController(serverDTO); NSApplication.SharedApplication.BeginSheet(awc.Window, this.Window, () => { }); nint result = NSApplication.SharedApplication.RunModalForWindow(awc.Window); try { if (result == VMIdentityConstants.DIALOGOK) { NSApplication.SharedApplication.BeginSheet(pwc.Window, this.Window as NSWindow, () => { }); session = NSApplication.SharedApplication.BeginModalSession(pwc.Window); serverNode = new VMDirServerInfo(serverDTO); await serverNode.DoLogin(); InitialiseViews(); } } catch (Exception e) { UIErrorHelper.ShowAlert("Connection is not successful. " + e.Message, "Alert"); } finally { if (pwc.ProgressBar != null) { pwc.ProgressBar.StopAnimation(pwc.Window); pwc.Window.Close(); NSApplication.SharedApplication.EndModalSession(session); } Window.EndSheet(awc.Window); awc.Dispose(); } }
public async void ConnectToServer(List <VMDirServerDTO> server) { ProgressWindowController pwc = new ProgressWindowController(); IntPtr session = new IntPtr(0); ConnectToLdapWindowController awc = new ConnectToLdapWindowController(server); NSApplication.SharedApplication.BeginSheet(awc.Window, this.Window, () => { }); nint result = NSApplication.SharedApplication.RunModalForWindow(awc.Window); try { if (result == VMIdentityConstants.DIALOGOK) { NSApplication.SharedApplication.BeginSheet(pwc.Window, this.Window as NSWindow, () => { }); session = NSApplication.SharedApplication.BeginModalSession(pwc.Window); serverNode = awc.ServerDTO; await serverNode.DoLogin(); InitialiseViews(); } } catch (Exception e) { serverNode.IsLoggedIn = false; UIErrorHelper.ShowAlert(VMDirConstants.ERR_LOGIN_FAILED + " : " + e.Message, "Login not successful!"); } finally { if (pwc.ProgressBar != null) { pwc.ProgressBar.StopAnimation(pwc.Window); pwc.Window.Close(); NSApplication.SharedApplication.EndModalSession(session); } Window.EndSheet(awc.Window); awc.Dispose(); } }
public async void ConnectToServer (string server) { var serverDTO = VMDirServerDTO.CreateInstance (); if (!string.IsNullOrWhiteSpace (server)) serverDTO.Server = server; ProgressWindowController pwc = new ProgressWindowController (); IntPtr session = new IntPtr (0); ConnectToLdapWindowController awc = new ConnectToLdapWindowController (serverDTO); NSApplication.SharedApplication.BeginSheet (awc.Window, this.Window, () => { }); nint result = NSApplication.SharedApplication.RunModalForWindow (awc.Window); try { if (result == VMIdentityConstants.DIALOGOK) { NSApplication.SharedApplication.BeginSheet (pwc.Window, this.Window as NSWindow, () => { }); session = NSApplication.SharedApplication.BeginModalSession (pwc.Window); serverNode = new VMDirServerInfo (serverDTO); await serverNode.DoLogin (); InitialiseViews (); } } catch (Exception e) { UIErrorHelper.ShowAlert ("Connection is not successful. " + e.Message, "Alert"); } finally { if (pwc.ProgressBar != null) { pwc.ProgressBar.StopAnimation (pwc.Window); pwc.Window.Close (); NSApplication.SharedApplication.EndModalSession (session); } Window.EndSheet (awc.Window); awc.Dispose (); } }