예제 #1
0
        private string getFileOwner(string str)
        {
            string user = "";

            if (null != str && str.Length > 5 && str.IndexOf(" ") != -1)
            {
                string[] arrs = str.Split(' ');
                if (arrs.Length > 3)
                {
                    int i = 0, j = 0;
                    foreach (string s in arrs)
                    {
                        if (!string.IsNullOrWhiteSpace(s))
                        {
                            i++;
                            if (i >= 3)
                            {
                                user = arrs[j];
                                break;
                            }
                        }
                        j++;
                    }
                }
            }
            return(user);
        }
예제 #2
0
 public FileAttrForm(ChannelSftp.LsEntry file, SshUser user, String dir)
 {
     InitializeComponent();
     SkinUtil.SetFormSkin(this);
     this.file = file;
     this.user = user;
     this.dir  = dir;
 }
예제 #3
0
        public ActionResult GetSshConnecton(int sshUserId, string uid)
        {
            SshUser sshUser = ManagerDB.GetSshUser(sshUserId);

            if (sshUser.UserId == uid)
            {
                var connectionString = $"{sshUser.Username}@{sshUser.Server.Host}";
                var port             = sshUser.Server.Port == 22 ? "" : $"-p {sshUser.Server.Port}";
                return(new JsonResult(connectionString + port));
            }
            return(Unauthorized());
        }
예제 #4
0
파일: SftpForm.cs 프로젝트: sy26856/AMShell
        public void LoadRightForm(SshUser sshUser)
        {
            rightForm = new SftpLinuxForm(this, sshUser);
            rightForm.FormBorderStyle = FormBorderStyle.None;
            rightForm.TopLevel        = false;
            rightForm.Dock            = DockStyle.Fill;
            rightForm.Show();

            panel2.Controls.Add(rightForm);

            WriteLog2("Start Connect...\n");
        }
예제 #5
0
 public bool AddSshUser(SshUser sshUser)
 {
     try
     {
         context.SshUsers.Add(sshUser);
         context.SaveChanges();
         return(true);
     }
     catch //(Exception ex)
     {
         return(false);
     }
 }
예제 #6
0
        public ActionResult AddSshUser(string uid, string username, int serverId)
        {
            if (!ManagerDB.UsernameAvaible(username, serverId))
            {
                return(BadRequest("Username unavailable"));
            }
            var sshUser = new SshUser
            {
                ServerId = serverId,
                Username = username,
                UserId   = uid
            };

            ManagerDB.AddSshUser(sshUser);
            return(new OkResult());
        }
예제 #7
0
        static void Main(string[] args)
        {
            if (null != args && args.Length > 3)
            {
                initUser          = new SshUser();
                initUser.Host     = args[0];
                initUser.UserName = args[1];
                initUser.Password = args[2];
                initUser.Port     = Convert.ToInt32(args[3]);
            }

            /*AllocConsole();
             * windowHandle = FindWindow(null, Process.GetCurrentProcess().MainModule.FileName);
             *
             * IntPtr closeMenu = GetSystemMenu(windowHandle, IntPtr.Zero);
             * uint SC_CLOSE = 0xF060;
             * RemoveMenu(closeMenu, SC_CLOSE, 0x0);
             * SetConsoleTitle("调试信息");*/

            try
            {
                //处理未捕获的异常
                Application.SetUnhandledExceptionMode(UnhandledExceptionMode.CatchException);
                //处理UI线程异常
                Application.ThreadException += new System.Threading.ThreadExceptionEventHandler(Application_ThreadException);
                //处理非UI线程异常
                AppDomain.CurrentDomain.UnhandledException += new UnhandledExceptionEventHandler(CurrentDomain_UnhandledException);


                Application.EnableVisualStyles();
                Application.SetCompatibleTextRenderingDefault(false);

                MAIN = new MainForm();
                Application.Run(MAIN);

                //Application.Run(new SftpForm(initUser));
            }
            catch (Exception ex)
            {
                string str = GetExceptionMsg(ex, string.Empty);
                MessageBox.Show(str, "系统错误", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }

            //FreeConsole();
        }
예제 #8
0
파일: SftpForm.cs 프로젝트: sy26856/AMShell
        public void HideTool()
        {
            this.BeginInvoke((MethodInvoker) delegate()
            {
                text_host.Enabled        = false;
                text_pass.Enabled        = false;
                text_username.Enabled    = false;
                text_port.Enabled        = false;
                toolStripButton7.Enabled = false;

                if (null != rightForm)
                {
                    SshUser user = rightForm.getSshUser();
                    if (null != user)
                    {
                        status_info.Text = user.Host + "@" + user.UserName;
                    }
                }
                WriteLog2("Connect Success...\n");
            });
        }
예제 #9
0
파일: MainForm.cs 프로젝트: sy26856/AMShell
        // 打开ftp窗口
        private void tool_ftp_Click(object sender, EventArgs e)
        {
            SshUser        user = null;
            FATabStripItem tab  = (FATabStripItem)faTab.SelectedItem;

            if (tab != null)
            {
                SessionConfig sessionConfig = (SessionConfig)tab.Tag;
                if (null != sessionConfig)
                {
                    user          = new SshUser();
                    user.Host     = sessionConfig.Host;
                    user.UserName = sessionConfig.UserName;
                    user.Password = sessionConfig.Password;
                    user.Port     = sessionConfig.Port;
                }
            }
            //new SftpForm(user).Show();
            if (null != user)
            {
                string host     = "\"" + user.Host + "\"";
                string username = "******"" + user.UserName + "\"";
                string password = "******"" + user.Password + "\"";
                string port     = "\"" + user.Port + "\"";

                Process process = new Process();
                process.StartInfo.FileName        = APP_DIR + "\\AMSftp.exe";
                process.StartInfo.Arguments       = host + " " + username + " " + password + " " + port;
                process.StartInfo.UseShellExecute = true;
                //启动
                process.Start();
            }
            else
            {
                Process.Start(APP_DIR + "\\AMSftp.exe");
            }
        }
예제 #10
0
 public SftpLinuxForm(SftpForm sftpForm, SshUser user)
 {
     InitializeComponent();
     this.sftpForm = sftpForm;
     this.user     = user;
 }
예제 #11
0
파일: SftpForm.cs 프로젝트: sy26856/AMShell
 public SftpForm(SshUser user)
 {
     InitializeComponent();
     SkinUtil.SetFormSkin(this);
     this.user = user;
 }