public override void RegisterRealTasks(PhysicalServer site) { var path = _path; path = RemotePathHelper.Convert(site, path); var task = new GrantReadTask(path, _group, new DotNetPath()); site.AddTask(task); }
public override void RegisterRealTasks(PhysicalServer site) { string target = _target; string newName = _newName; target = RemotePathHelper.Convert(site, target); var o = new RenameTask(target, newName, new DotNetPath()); site.AddTask(o); }
public void CopyFileToUncPath() { var sourceUncPath = RemotePathHelper.Convert(Environment.MachineName, _path.GetFullPath(_sourceFilePath)); var destinationUncPath = RemotePathHelper.Convert(Environment.MachineName, _path.GetFullPath(_destinationFolderPath)); var t = new CopyFileTask(sourceUncPath, destinationUncPath, null, new DotNetPath()); t.Execute(); string s = File.ReadAllText(_path.Combine(destinationUncPath, "test.txt")); Assert.AreEqual("the test\r\n", s); }
public CopyRemoteOut(PhysicalServer server) { _server = server; //copy remote out //TODO: make this path configurable var remotePath = RemotePathHelper.Convert(server, @"C:\Temp\dropkick.remote"); if (!Directory.Exists(remotePath)) { Directory.CreateDirectory(remotePath); } _path = remotePath; var ewd = Assembly.GetExecutingAssembly().Location; var local = Path.GetDirectoryName(ewd); if (local == null) { throw new Exception("shouldn't be null"); } var filesToCopy = new[] { "dropkick.remote.exe", "dropkick.dll", "log4net.dll", "Magnum.dll" }; foreach (var file in filesToCopy) { var dest = Path.Combine(remotePath, file); var src = Path.Combine(local, file); _fineLog.DebugFormat("[msmq][remote] '{0}'->'{1}'", src, dest); try { if (!File.Exists(dest)) { File.Copy(src, dest, true); } } catch (IOException ex) { _fineLog.DebugFormat("[msmq][remote][file] Error copying '{0}' to '{1}'", file, remotePath); throw; } } }
public override void RegisterRealTasks(PhysicalServer s) { string scrubbedPath; if (RemotePathHelper.IsUncPath(PathOnServer)) { scrubbedPath = _path.ConvertUncShareToLocalPath(s, PathOnServer); } else { scrubbedPath = PathOnServer; } if (Version == IisVersion.Six) { s.AddTask(new Iis6Task { PathOnServer = scrubbedPath, ServerName = s.Name, VdirPath = VdirPath, WebsiteName = WebsiteName, AppPoolName = AppPoolName }); return; } s.AddTask(new Iis7Task { PathOnServer = scrubbedPath, ServerName = s.Name, VdirPath = VdirPath, WebsiteName = WebsiteName, AppPoolName = AppPoolName, UseClassicPipeline = ClassicPipelineRequested, ManagedRuntimeVersion = this.ManagedRuntimeVersion, PathForWebsite = this.PathForWebsite, PortForWebsite = this.PortForWebsite, Enable32BitAppOnWin64 = Bit32Requested }); }
public override void RegisterRealTasks(PhysicalServer site) { string location; if (RemotePathHelper.IsUncPath(_location)) { location = _path.ConvertUncShareToLocalPath(site, _location); } else { location = _location; } if (site.IsLocal) { site.AddTask(new LocalNServiceBusInstallTask(_exeName, location, _instanceName, _username, _password, _serviceName, _displayName, _description, _startManualy)); } else { site.AddTask(new RemoteNServiceBusInstallTask(_exeName, location, _instanceName, site, _username, _password, _serviceName, _displayName, _description, _startManualy)); } }
public override void RegisterRealTasks(PhysicalServer server) { string location; if (RemotePathHelper.IsUncPath(this.location)) { location = path.ConvertUncShareToLocalPath(server, this.location); } else { location = this.location; } if (server.IsLocal) { server.AddTask(new LocalNServiceBusUninstallTask(exeName, location, instance, serviceName)); } else { server.AddTask(new RemoteNServiceBusUninstallTask(exeName, location, instance, server, serviceName)); } }
public async Task CopyAsync(string source, string destination) { if (!ResourceHelper.TryParseResource(source, out (string?bucket, string resource, LocationType locationType, ResourceType resourceType)parsedSource)) { throw new CommandException(ErrorType.Argument, $"Failed to parse source: {source}"); } if (!ResourceHelper.TryParseResource(destination, out (string?bucket, string resource, LocationType locationType, ResourceType resourceType)parsedDestination)) { throw new CommandException(ErrorType.Argument, $"Failed to parse destination: {destination}"); } if (parsedSource.bucket == null) { throw new S3Exception("Unable to parse bucket in source"); } if (parsedDestination.bucket == null) { throw new S3Exception("Unable to parse bucket in destination"); } if (parsedSource.locationType == LocationType.Local && parsedDestination.locationType == LocationType.Remote) { switch (parsedSource.resourceType) { case ResourceType.File: { string objectKey; switch (parsedDestination.resourceType) { //Source: Local file - Destination: remote file case ResourceType.File: objectKey = parsedDestination.resource; break; //Source: Local file - Destination: remote directory case ResourceType.Directory: objectKey = RemotePathHelper.Combine(parsedDestination.resource, LocalPathHelper.GetFileName(parsedSource.resource)); break; //We don't support expand on the destination default: throw new ArgumentOutOfRangeException(); } using (FileStream fs = File.OpenRead(parsedSource.resource)) await RequestHelper.ExecuteRequestAsync(_client, c => c.PutObjectAsync(parsedDestination.bucket, objectKey, fs)).ConfigureAwait(false); return; } case ResourceType.Directory: { switch (parsedDestination.resourceType) { //Source: Local directory - Destination: remote directory case ResourceType.Directory: foreach (string file in Directory.GetFiles(parsedSource.resource)) { string?directory = LocalPathHelper.GetDirectoryName(file); string name = LocalPathHelper.GetFileName(file); string objectKey = RemotePathHelper.Combine(parsedDestination.resource, directory, name); using (FileStream fs = File.OpenRead(file)) await RequestHelper.ExecuteRequestAsync(_client, c => c.PutObjectAsync(parsedDestination.bucket, objectKey, fs)).ConfigureAwait(false); } return; //We don't support files or expand on the destination default: throw new ArgumentOutOfRangeException(); } } default: throw new ArgumentOutOfRangeException(); } } if (parsedSource.locationType == LocationType.Remote && parsedDestination.locationType == LocationType.Local) { switch (parsedSource.resourceType) { case ResourceType.File: { string localFile; switch (parsedDestination.resourceType) { //Source: remote file - Destination: local file case ResourceType.File: localFile = parsedDestination.resource; break; //Source: remote file - Destination: local directory case ResourceType.Directory: localFile = LocalPathHelper.Combine(parsedDestination.resource, RemotePathHelper.GetFileName(parsedSource.resource)); break; //We don't support expand on the destination default: throw new ArgumentOutOfRangeException(); } GetObjectResponse resp = await RequestHelper.ExecuteRequestAsync(_client, c => c.GetObjectAsync(parsedSource.bucket, parsedSource.resource)).ConfigureAwait(false); using (Stream s = resp.Content) using (FileStream fs = File.OpenWrite(localFile)) await s.CopyToAsync(fs).ConfigureAwait(false); return; } case ResourceType.Directory: { switch (parsedDestination.resourceType) { //Source: remote directory - Destination: local directory case ResourceType.Directory: await foreach (S3Object s3Object in RequestHelper.ExecuteAsyncEnumerable(_client, c => c.ListAllObjectsAsync(parsedSource.bucket, config: req => { req.Prefix = parsedSource.resource; }))) { string destFolder = parsedDestination.resource; string destFile = LocalPathHelper.Combine(destFolder, parsedDestination.resource, s3Object.ObjectKey); GetObjectResponse resp = await RequestHelper.ExecuteRequestAsync(_client, c => c.GetObjectAsync(parsedSource.bucket, s3Object.ObjectKey)).ConfigureAwait(false); await resp.Content.CopyToFileAsync(destFile).ConfigureAwait(false); } return; //We don't support file or expand on the destination default: throw new ArgumentOutOfRangeException(); } } default: throw new ArgumentOutOfRangeException(); } } }
public void TildaUncPath() { var path = RemotePathHelper.Convert("SrvTopeka02", @"~\bob\bill"); Assert.AreEqual(@"\\SrvTopeka02\bob\bill", path); }
public void Bob() { var path = RemotePathHelper.Convert("SrvTopeka02", @"E:\bob\bill"); Assert.AreEqual(@"\\SrvTopeka02\E$\bob\bill", path); }
public string MapPath(string path) { return(RemotePathHelper.Convert(this, path)); }