private void OnShowEditModal()
        {
            this.editSessionArgs = new EditSessionArgs()
            {
                Name      = this.session?.Name,
                SessionId = this.SessionId,
                AutoStop  = this.session?.AutoStop == true,
                Bulletin  = new Bulletin(this.bulletin)
            };

            var onConfirm = new EventCallbackFactory().Create <EditSessionArgs>(this, this.HandleEditSessionConfirmAsync);

            EditSessionDialog.Show(this.DialogService, UIResources.EditSessionDialogTitle, this.editSessionArgs, onConfirm);
        }
Example #2
0
        public SessionDataStartInfo ToSessionStartInfo()
        {
            SessionDataStartInfo ssi = null;

            if (SessionId != null)
            {
                // first try to resolve by sessionId
                SessionData session = SuperPuTTY.GetSessionById(SessionId);
                if (session == null)
                {
                    Log.WarnFormat("Session from command line not found, id={0}", SessionId);
                }
                else
                {
                    ssi = new SessionDataStartInfo
                    {
                        Session = session,
                        UseScp  = UseScp
                    };
                }
            }
            else if (Host != null || PuttySession != null)
            {
                // Host or puttySession provided
                string sessionName;
                if (Host != null)
                {
                    // Decode URL type host spec, if provided (e.g. ssh://localhost:2020)
                    HostConnectionString connStr = new HostConnectionString(Host);
                    Host        = connStr.Host;
                    Protocol    = connStr.Protocol.GetValueOrDefault(Protocol.GetValueOrDefault(ConnectionProtocol.SSH));
                    Port        = connStr.Port.GetValueOrDefault(Port.GetValueOrDefault(EditSessionDialog.GetDefaultPort(Protocol.GetValueOrDefault())));
                    sessionName = Host;
                }
                else
                {
                    // no host provided so assume sss
                    sessionName = PuttySession;
                }

                ssi = new SessionDataStartInfo
                {
                    Session = new SessionData
                    {
                        Host         = Host,
                        SessionName  = sessionName,
                        SessionId    = SuperPuTTY.MakeUniqueSessionId(SessionData.CombineSessionIds("CLI", Host)),
                        Port         = Port.GetValueOrDefault(22),
                        Proto        = Protocol.GetValueOrDefault(ConnectionProtocol.SSH),
                        Username     = UserName,
                        Password     = Password,
                        PuttySession = PuttySession
                    },
                    UseScp = UseScp
                };
            }

            if (ssi == null)
            {
                Log.WarnFormat("Could not determine session or host to connect.  SessionId or Host or PuttySession must be provided");
            }

            return(ssi);
        }