/// <summary>
        /// Connects to server.
        /// </summary>
        /// <returns>The to server.</returns>
        /// <param name="server">Server.</param>
        public ServerDto ConnectToServer(string server)
        {
            var form = new LoginWindowController()
            {
                Server = server
            };
            var serverDto = new ServerDto {
                Server = server
            };

            NSApplication.SharedApplication.BeginSheet(form.Window, this.Window, () => {
            });
            try {
                nint result = NSApplication.SharedApplication.RunModalForWindow(form.Window);
                if (result == VMIdentityConstants.DIALOGOK)
                {
                    serverDto = new ServerDto {
                        Server     = form.Server,
                        UserName   = form.UserName,
                        Password   = form.Password,
                        DomainName = form.DomainName,
                        Upn        = form.Upn
                    };
                }
            } finally {
                Window.EndSheet(form.Window);
                form.Close();
                form.Dispose();
            }
            return(serverDto);
        }
Ejemplo n.º 2
0
        public async void ConnectToServer(string server)
        {
            var serverDTO = VMDNSServerDTO.CreateInstance();

            serverNode = new VMDNSServerNode(serverDTO);
            string[] servers             = VMDNSSnapInEnvironment.instance.LocalData.GetServerArray();
            ProgressWindowController pwc = new ProgressWindowController();
            IntPtr session            = new IntPtr(0);
            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);
                    //use await here and make it async
                    await serverNode.ServerDTO.LoginToServer();

                    if (serverNode.ServerDTO.IsLoggedIn == true)
                    {
                        serverNode.FillZonesInfo();
                        InitialiseViews();
                        ReloadOutlineView(null);
                    }
                    else
                    {
                        UIErrorHelper.ShowAlert(string.Empty, VMIdentityConstants.SERVER_CONNECT_ERROR);
                    }
                }
            }
            catch (Exception e)
            {
                UIErrorHelper.ShowAlert(string.Empty, 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();
            }
        }
Ejemplo n.º 3
0
        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();
            }
        }
Ejemplo n.º 4
0
        protected override void OnStartup(StartupEventArgs e)
        {
            base.OnStartup(e);
            LoginWindowController loginWindowController = new LoginWindowController();

            loginWindowController.Initialize();

            QuickConverter.EquationTokenizer.AddNamespace(typeof(object));
            QuickConverter.EquationTokenizer.AddNamespace(typeof(Mode));
        }
        /// <summary>
        /// Gets the server dto.
        /// </summary>
        /// <returns>The server dto.</returns>
        /// <param name="controller">Controller.</param>
        private ServerDto GetServerDto(LoginWindowController controller)
        {
            var serverDto = new ServerDto {
                Server     = controller.Server,
                UserName   = controller.UserName,
                Password   = controller.Password,
                DomainName = controller.DomainName,
                Upn        = controller.Upn
            };

            return(serverDto);
        }
        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();
            }
        }
Ejemplo n.º 7
0
        public async void ConnectToServer(string server)
        {
            ProgressWindowController pwc = new ProgressWindowController();
            IntPtr session            = new IntPtr(0);
            LoginWindowController lwc = new LoginWindowController(server);

            NSApplication.SharedApplication.BeginSheet(lwc.Window, this.Window, () => {
            });
            nint result = NSApplication.SharedApplication.RunModalForWindow(lwc.Window);

            try {
                if (result == (nint)Constants.DIALOGOK)
                {
                    this.Initialise(lwc.Server);
                    Servernode.ServerDTO.Server = lwc.Server;
                    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)
                    {
                        Servernode.Initialise();
                        InitialiseViews();
                        NSNotificationCenter.DefaultCenter.PostNotificationName("ReloadOutlineView", this);
                    }
                    else
                    {
                        UIErrorHelper.ShowAlert("", "Unable to login! Please validate the connection details.");
                    }
                }
            } 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();
            }
        }
        /// <summary>
        /// Connects to server.
        /// </summary>
        public async void ConnectToServer()
        {
            _serverState = ServerState.Disconnected;
            ProgressWindowController pwc = new ProgressWindowController();
            IntPtr session = new IntPtr(0);
            var    servers = PscHighAvailabilityAppEnvironment.Instance.LocalData.GetServerArray();
            var    lwc     = new LoginWindowController(servers);

            NSApplication.SharedApplication.BeginSheet(lwc.Window, this.Window, () => {
            });
            nint result = NSApplication.SharedApplication.RunModalForWindow(lwc.Window);

            try {
                if (result == (nint)VMIdentityConstants.DIALOGOK)
                {
                    _serverDto = GetServerDto(lwc);
                    if (PingHost(_serverDto.Server))
                    {
                        NSApplication.SharedApplication.BeginSheet(pwc.Window, this.Window as NSWindow, () => {
                        });
                        session = NSApplication.SharedApplication.BeginModalSession(pwc.Window);

                        var task = new Task(LoginToServer);
                        task.Start();
                        if (task == await Task.WhenAny(task, Task.Delay(VMIdentityConstants.ServerTimeoutInSeconds * Constants.MilliSecsMultiplier)))
                        {
                            await task;
                            if (!_isLoggedIn)
                            {
                                UIErrorHelper.ShowAlert(VMIdentityConstants.SERVER_CONNECT_ERROR, VMIdentityConstants.SERVER_CONNECT_ERROR);
                            }
                            else
                            {
                                PscHighAvailabilityAppEnvironment.Instance.LocalData.AddServer(lwc.Server);
                                this.LoggedInLabel.StringValue = _serverDto.Upn;
                                _serverState = ServerState.Connected;
                            }
                        }
                        else
                        {
                            UIErrorHelper.ShowAlert(VMIdentityConstants.SERVER_TIMED_OUT, VMIdentityConstants.SERVER_TIMED_OUT);
                        }
                    }
                    else
                    {
                        UIErrorHelper.ShowAlert(VMIdentityConstants.HOST_OR_IP_ADDRESS_NOT_REACHABLE, VMIdentityConstants.HOST_NOT_REACHABLE);
                    }
                }
            } 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();
            }

            SetConnectToolbar(_serverState);
            if (_isLoggedIn)
            {
                Initialize();
                AsyncRefresh();
            }
        }
Ejemplo n.º 9
0
        protected override void OnStartup(StartupEventArgs e)
        {
            var loginWindow = new LoginWindowController();

            loginWindow.Initialize();
        }
Ejemplo n.º 10
0
 public LogInForm()
 {
     InitializeComponent();
     loginController = new LoginWindowController();
 }