public async void ConnectToServer(string server) { var serverDTO = VMDirServerDTO.CreateInstance(); if (!string.IsNullOrWhiteSpace(server)) { serverDTO.Server = server; } serverNode = new VMDirSchemaServerNode(serverDTO); ProgressWindowController pwc = new ProgressWindowController(); IntPtr session = new IntPtr(0); string[] servers = VMDirSchemaSnapInEnvironment.Instance.LocalData.GetServerArray(); LoginWindowController lwc = new LoginWindowController(servers); NSApplication.SharedApplication.BeginSheet(lwc.Window, this.Window, () => { }); nint result = NSApplication.SharedApplication.RunModalForWindow(lwc.Window); try { if (result == VMIdentityConstants.DIALOGOK) { serverNode.ServerDTO.Server = lwc.Server; serverNode.ServerDTO.BindDN = lwc.UserName + "@" + lwc.DomainName; serverNode.ServerDTO.Password = lwc.Password; NSApplication.SharedApplication.BeginSheet(pwc.Window, this.Window as NSWindow, () => { }); session = NSApplication.SharedApplication.BeginModalSession(pwc.Window); await serverNode.DoLogin(); InitialiseViews(); } } catch (Exception e) { UIErrorHelper.ShowAlert(VMIdentityConstants.CONNECTION_NOT_SUCCESSFUL + e.Message, string.Empty); } finally { if (pwc.ProgressBar != null) { pwc.ProgressBar.StopAnimation(pwc.Window); pwc.Window.Close(); NSApplication.SharedApplication.EndModalSession(session); } Window.EndSheet(lwc.Window); lwc.Dispose(); } }
async void AddServer() { try { var ServerDTO = VMDirServerDTO.CreateInstance(); ServerDTO.Server = ""; var node = new VMDirSchemaServerNode(ServerDTO); await node.DoLogin(); if (node.IsLoggedIn) { VMDirSchemaSnapInEnvironment.Instance.LocalData.AddServer(ServerDTO.Server); this.Children.Add(node); } } catch (Exception e) { MMCDlgHelper.ShowException(e); } finally { VMDirSchemaSnapInEnvironment.Instance.SaveLocalData(); } /* * var frm = new SelectComputerUI(); * * // frm.Text = "Add Afd server"; * * if (SnapIn.Console.ShowDialog(frm) == DialogResult.OK) * * { * * var serverDTO = VMDirServerDTO.CreateInstance(); * * serverDTO.Server = frm.ServerName; * * VMDirSchemaSnapInEnvironment.Instance.LocalData.AddServer(serverDTO.Server); * * RefreshMethod(serverDTO); * * }*/ }