Exemple #1
0
 public LoginViewModel(Views.LoginWindow win)
 {
     LoginWindow = win;
 }
Exemple #2
0
 public MainModuleViewModel(MainModule mainModule)
 {
     Views.LoginWindow loginWnd = new Views.LoginWindow(mainModule);
     loginWnd.Show();
 }
        private void WebSocketClient_OnOpen()
        {
            AutomationHelper.syncContext.Post(async o =>
            {
                var sw = new System.Diagnostics.Stopwatch();
                sw.Start();



                Log.Debug("WebSocketClient_OnOpen::begin " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
                LabelStatusBar.Text = "Connected to " + Config.local.wsurl;
                Interfaces.entity.TokenUser user = null;
                while (user == null)
                {
                    string errormessage = string.Empty;
                    if (!string.IsNullOrEmpty(Config.local.username))
                    {
                        try
                        {
                            LabelStatusBar.Text = "Connected to " + Config.local.wsurl + " signing in as " + Config.local.username + " ...";
                            Log.Debug("Signing in as " + Config.local.username + " " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
                            user = await global.webSocketClient.Signin(Config.local.username, Config.local.UnprotectString(Config.local.password));
                            Log.Debug("Signed in as " + Config.local.username + " " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
                            LabelStatusBar.Text = "Connected to " + Config.local.wsurl + " as " + user.name;
                        }
                        catch (Exception ex)
                        {
                            this.Hide();
                            Log.Error(ex, "");
                            errormessage = ex.Message;
                        }
                    }
                    if (user == null)
                    {
                        if (loginInProgress == false)
                        {
                            loginInProgress = true;
                            var w           = new Views.LoginWindow();
                            w.username      = Config.local.username;
                            w.errormessage  = errormessage;
                            w.fqdn          = new Uri(Config.local.wsurl).Host;
                            this.Hide();
                            if (w.ShowDialog() != true)
                            {
                                this.Show(); return;
                            }
                            Config.local.username = w.username; Config.local.password = Config.local.ProtectString(w.password);
                            Config.Save();
                            loginInProgress = false;
                        }
                        else
                        {
                            return;
                        }
                    }
                }
                try
                {
                    try
                    {
                        Log.Debug("Registering queue for robot " + global.webSocketClient.user._id + " " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
                        await global.webSocketClient.RegisterQueue(global.webSocketClient.user._id);
                        foreach (var role in global.webSocketClient.user.roles)
                        {
                            Log.Debug("Registering queue for role " + role.name + " " + role._id + " " + string.Format("{0:mm\\:ss\\.fff}", sw.Elapsed));
                            await global.webSocketClient.RegisterQueue(role._id);
                        }
                    }
                    catch (Exception ex)
                    {
                        Log.Error("Error RegisterQueue" + ex.ToString());
                    }
                }
                catch (Exception ex)
                {
                    Log.Error(ex, "");
                    MessageBox.Show("WebSocketClient_OnOpen::Sync projects " + ex.Message);
                }
                CloseSplash();
            }, null);
        }
Exemple #4
0
 public WindowServer(IClient client, Views.LoginWindow loginWindow)
 {
     _client      = client;
     _loginWindow = loginWindow;
 }