public bool DownLoad(Server server) { DeployUtil.CleanTransferFolder(); if (!string.IsNullOrEmpty(server.UserName)) { AppDomain.CurrentDomain.SetPrincipalPolicy(PrincipalPolicy.WindowsPrincipal); WindowsIdentity idnt = new WindowsIdentity(server.UserName, server.Password); WindowsImpersonationContext context = idnt.Impersonate(); } File.Copy(server.Uri, DeployUtil.TransferFolder, true); return true; }
public bool ExecuteScript(Server server, string script) { var current = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(server.Uri); Process process = new Process();//TODO create a file on remote server // Configure the process using the StartInfo properties. process.StartInfo.FileName = script; process.StartInfo.UseShellExecute = false; process.StartInfo.RedirectStandardOutput = true; process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; process.Start(); string output = process.StandardOutput.ReadToEnd(); process.WaitForExit();// Waits here for the process to exit. Directory.SetCurrentDirectory(current); return true; }
public bool ExecuteScript(Server server, string script) { //nothing to do here return true; }
public bool ExecuteScript(Server server, string script) { using (SshClient cSSH = new SshClient(server.Uri, server.Port.Value, server.UserName, server.Password)) { cSSH.Connect(); var commands = script.Split(Environment.NewLine.ToCharArray(), StringSplitOptions.RemoveEmptyEntries); foreach (var command in commands) { SshCommand x = cSSH.RunCommand(command); var reader = new StreamReader(x.OutputStream); string output = reader.ReadToEnd(); Console.WriteLine("$:" + output); } cSSH.Disconnect(); } return true; }
public bool DownLoad(Server server) { DeployUtil.CleanTransferFolder(); var current = Directory.GetCurrentDirectory(); Directory.SetCurrentDirectory(DeployUtil.TransferFolder); // Configure the process using the StartInfo properties. var exePath = ConfigurationManager.AppSettings["svn_exe_path"]; var param = string.Format("checkout {0} --username {1} --password {2}", server.Uri, server.UserName, server.Password); ProcessStartInfo processInfo = new ProcessStartInfo(exePath, param); processInfo.CreateNoWindow = true; processInfo.UseShellExecute = false; processInfo.RedirectStandardError = true; processInfo.RedirectStandardOutput = true; var process = Process.Start(processInfo); process.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; process.Start(); string output = process.StandardOutput.ReadToEnd(); process.WaitForExit();// Waits here for the process to exit. Directory.SetCurrentDirectory(current); return true; }
public bool DownLoad(Server server) { DeployUtil.CleanTransferFolder(); using (SftpClient client = new SftpClient(server.Uri, server.UserName, server.Password)) { client.Connect(); DownloadDirectory(client, server.FileLocation, DeployUtil.TransferFolder); } return true; }
static void CreateServer(Server ser) { if (Data.Servers == null) { Data.Servers = new List<Server>(); } if (string.IsNullOrEmpty(ser.Id)) ser.Id = Guid.NewGuid().ToString(); Data.Servers.Add(ser); save(); }
public static void UpdateServer(Server ser) { if (Data.Servers == null || Data.Servers.Count == 0) { CreateServer(ser); return; } var old = Data.Servers.FirstOrDefault(x => x.Id == ser.Id); if (old == null) { CreateServer(ser); return; } else { old = ser; save(); } }
void getData() { if (instance == null) { instance = new Server(); } instance.UserName = txtUserName.Text; instance.Password = txtPassword.Text; instance.Uri = txtUri.Text; int port = -1; if (!string.IsNullOrEmpty(txtPort.Text) && int.TryParse(txtPort.Text, out port)) instance.Port = port; else instance.Port = null; instance.Remarks = rtbRemarks.Text; instance.SourceServerType = cmbServerType.SelectedItem.ToString(); instance.FileLocation = txtFileLocation.Text; }
public void SetInstance(Server ser) { instance = ser; }