Example #1
0
 public RPAMessage(string command, string windowsusername, Interfaces.entity.TokenUser user, string openrpapath) : base()
 {
     this.command         = command;
     this.windowsusername = windowsusername;
     this.user            = user;
     this.openrpapath     = openrpapath;
 }
Example #2
0
 private void Client_Signedin(Interfaces.entity.TokenUser user)
 {
     if (pipe != null)
     {
         return;
     }
     try
     {
         pipe                = new OpenRPA.NamedPipeWrapper.NamedPipeClient <RPAMessage>("openrpa_service");
         pipe.Connected     += Pipe_Connected;
         pipe.Disconnected  += Pipe_Disconnected;
         pipe.Error         += Pipe_Error;
         pipe.ServerMessage += Pipe_ServerMessage;
         pipe.Start();
     }
     catch (Exception ex)
     {
         Log.Error(ex.ToString());
     }
 }
        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);
        }