public async void ConnectToServer(string server)
        {
            var serverDTO = VMCertStoreServerDTO.CreateInstance();

            Servernode = new VMCertStoreServerNode(serverDTO);
            ProgressWindowController pwc = new ProgressWindowController();
            IntPtr session = new IntPtr(0);

            string[] servers          = VMCertStoreSnapInEnvironment.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 == (nint)VMIdentityConstants.DIALOGOK)
                {
                    Servernode.ServerDTO.Server     = lwc.Server;
                    Servernode.ServerDTO.DomainName = lwc.DomainName;
                    Servernode.ServerDTO.UserName   = lwc.UserName;
                    Servernode.ServerDTO.Password   = lwc.Password;
                    NSApplication.SharedApplication.BeginSheet(pwc.Window, this.Window as NSWindow, () =>
                    {
                    });
                    session = NSApplication.SharedApplication.BeginModalSession(pwc.Window);
                    await Servernode.ServerDTO.LogintoServer(lwc.UserName, lwc.Password, lwc.DomainName);

                    if (Servernode.ServerDTO.IsLoggedIn == true)
                    {
                        InitialiseViews();
                        NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadOutlineView", this);
                        Task.Run(() => Servernode.FillServerInfo());
                    }
                    else
                    {
                        UIErrorHelper.ShowAlert("Please check the login details or the user permissions.", "Unable to Login");
                    }
                }
            }
            catch (Exception e)
            {
                UIErrorHelper.ShowAlert("", e.Message);
            }
            finally
            {
                if (pwc.ProgressBar != null)
                {
                    pwc.ProgressBar.StopAnimation(pwc.Window);
                    pwc.Window.Close();
                    NSApplication.SharedApplication.EndModalSession(session);
                }
                Window.EndSheet(lwc.Window);
                lwc.Dispose();
            }
        }
Exemple #2
0
        async void AddServer()
        {
            try
            {
                var ServerDTO = VMCertStoreServerDTO.CreateInstance();
                ServerDTO.Server = "";
                var node = new VMCertStoreServerNode(ServerDTO);
                await node.DoLogin();

                if (node.ServerDTO.IsLoggedIn)
                {
                    VMCertStoreSnapInEnvironment.Instance.LocalData.AddServer(node.ServerDTO);
                    this.Children.Add(node);
                }
            }
            catch (Exception e)
            {
                MMCDlgHelper.ShowException(e);
            }
        }