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); }
public FileAttrForm(ChannelSftp.LsEntry file, SshUser user, String dir) { InitializeComponent(); SkinUtil.SetFormSkin(this); this.file = file; this.user = user; this.dir = dir; }
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()); }
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"); }
public bool AddSshUser(SshUser sshUser) { try { context.SshUsers.Add(sshUser); context.SaveChanges(); return(true); } catch //(Exception ex) { return(false); } }
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()); }
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(); }
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"); }); }
// 打开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"); } }
public SftpLinuxForm(SftpForm sftpForm, SshUser user) { InitializeComponent(); this.sftpForm = sftpForm; this.user = user; }
public SftpForm(SshUser user) { InitializeComponent(); SkinUtil.SetFormSkin(this); this.user = user; }