protected override async Task <Action <AsyncCodeActivityContext> > ExecuteAsync(AsyncCodeActivityContext context, CancellationToken cancellationToken) { // Inputs var host = Host.Get(context); var port = Port.Get(context); var userName = UserName.Get(context); var password = Password.Get(context); var localPath = LocalPath.Get(context); var remoteFilePath = RemoteFilePath.Get(context); /////////////////////////// // Add execution logic HERE /////////////////////////// /// using (var sftp = new SftpClient(host, port, userName, password)) { sftp.Connect(); using (var file = File.OpenRead(localPath)) { sftp.UploadFile(file, remoteFilePath); } sftp.Disconnect(); } // Outputs return((ctx) => { }); }
public SourcePackagingInfo(SourceType sourceType, string sourcePath, string destinationPath) { SourcePath = sourcePath; SourceType = sourceType; DestinationPath = new LocalPath(destinationPath); FileFilters = new FilterCollection(); }
private void LoadNewPresentation(string PresentationName) { string localpath = ""; if (LocalPath.GetDirectoryPath(out localpath)) { if (!File.Exists(localpath + "\\" + PresentationName)) { MessageBox.Show(Good_Teacher.Strings.ResStrings.FileNotFound + ": " + Path.Combine(localpath, PresentationName), Good_Teacher.Strings.ResStrings.FileNotFound); } else { Good_Teacher.MainWindow.pathtofile = localpath + "\\" + PresentationName; SaveEditor save = new SaveEditor(); data = save.LoadWithCompression(localpath + "\\" + PresentationName); Good_Teacher.MainWindow.GoodAnswersCount = 0; Good_Teacher.MainWindow.WrongAnswersCount = 0; Border_CanvasSize.Width = data.CanvasW; Border_CanvasSize.Height = data.CanvasH; LoadedPage = 0; maxC = data.pages.Count; Label_Number.Content = "/" + maxC; UpdateNumberLabel(); LoadCanvas(0); } } }
public CopyProcessorTransformation( string sourceId, LocalPath destinationPath, CopyProcessorTransformationOptions options) { this.sourceId = sourceId; this.destinationPath = destinationPath; this.options = options; }
public Window_SetOnClickActions(List <IActions> actionlist, DataStore dataStore, int EditID, int selectedPosition) { InitializeComponent(); data = dataStore; MaxPages.Content = "/" + data.pages.Count; selpos = selectedPosition; Edit(actionlist, EditID); if (LocalPath.GetDirectoryPath(out dirpath)) { TBL_NotSaved.Visibility = Visibility.Collapsed; TBL_NotSavedP.Visibility = Visibility.Collapsed; saved = true; TBL_AddressToFile.Text = dirpath + "\\" + TB_OpenApp.Text; TBL_AddressToPres.Text = dirpath + "\\" + TB_LoadPres.Text; } else { TBL_NotSaved.Visibility = Visibility.Visible; TBL_NotSavedP.Visibility = Visibility.Visible; saved = false; } AddAnimationsToComboBox(); }
// Tests bug #23274 public async Task DeleteWithStagedChanges() { var monitor = new ProgressMonitor(); string added = LocalPath.Combine("testfile"); await AddFileAsync("testfile", "test", true, true); // Test with VCS Remove. File.WriteAllText("testfile", "t"); await Repo.AddAsync(added, false, monitor); await Repo.DeleteFileAsync(added, false, monitor, true); Assert.AreEqual(VersionStatus.Versioned | VersionStatus.ScheduledDelete, (await Repo.GetVersionInfoAsync(added, VersionInfoQueryFlags.IgnoreCache)).Status); // Reset state. await Repo.RevertAsync(added, false, monitor); // Test with Project Remove. File.WriteAllText("testfile", "t"); await Repo.AddAsync(added, false, monitor); await Repo.DeleteFileAsync(added, false, monitor, false); Assert.AreEqual(VersionStatus.Versioned | VersionStatus.ScheduledDelete, (await Repo.GetVersionInfoAsync(added, VersionInfoQueryFlags.IgnoreCache)).Status); }
public void ZipFiles( FileFullPath zipFileName, FullPath baseDir, IEnumerable <FileFullPath> filesToZip, bool optimizeFiles) { _taskContext.LogInfo($"Zipping {zipFileName}"); var zipFileFullPath = zipFileName.ToFullPath(); if (File.Exists(zipFileFullPath)) { File.Delete(zipFileFullPath); } List <FileFullPath> tmpList = filesToZip.ToList(); if (optimizeFiles) { tmpList = RemoveDuplicateFiles(tmpList, baseDir); } using (ZipArchive newFile = ZipFile.Open(zipFileFullPath, ZipArchiveMode.Create)) { foreach (FileFullPath fileToZip in tmpList) { LocalPath debasedFileName = fileToZip.ToFullPath().DebasePath(baseDir); newFile.CreateEntryFromFile(fileToZip.ToString(), debasedFileName, CompressionLevel.Optimal); } } }
public DeploymentProcessSettings(IConfiguration configuration) { var workingDirString = configuration.GetValue <string>("DeploymentProcess:WorkingDir"); WorkingDir = new LocalPath(workingDirString); Shell = new ShellSettings(configuration); }
public void AddItems() { ItemList.Items.Clear(); string path = ""; if (LocalPath.GetDirectoryPath(out path)) { path = System.IO.Path.Combine(path, "Resources\\Media\\"); if (Directory.Exists(path)) { DirectoryInfo dirInfo = new DirectoryInfo(path); FileInfo[] info = dirInfo.GetFiles("*.*"); foreach (FileInfo f in info) { Button button = new Button(); button.FontSize = 14; button.Content = "" + f.Name; button.MinHeight = 35; button.Margin = new Thickness(10); button.Click += ButtonSelect_Click; button.Tag = f.Name; ItemList.Items.Add(button); } } } }
private void SetSoundToBePlayed(string pathPlay, bool SoundLoop) { mediaplayer.Open(new Uri(LocalPath.GetResourcesPath() + "\\Media\\" + pathPlay)); mediaplayer.Play(); MediaLoop = SoundLoop; }
public void EqualsTest() { PathSpec left = new DepotPath("//depot/main/test.txt"); PathSpec rightpos = new DepotPath("//depot/main/test.txt"); PathSpec rightneg1 = new DepotPath("//depot/main/empty.bmp"); PathSpec rightneg2 = new ClientPath("//depot/main/test/txt"); PathSpec rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightneg2)); Assert.IsFalse(left.Equals(rightnull)); left = new ClientPath("//user_workspace/main/test.txt"); rightpos = new ClientPath("//user_workspace/main/test.txt"); rightneg1 = new ClientPath("//user_workspace/main/empty.bmp"); rightneg2 = new DepotPath("//user_workspace/main/test.txt"); rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightneg2)); Assert.IsFalse(left.Equals(rightnull)); left = new LocalPath(@"C:\workspace_root\test.txt"); rightpos = new LocalPath(@"C:\workspace_root\test.txt"); rightneg1 = new LocalPath(@"C:\workspace_root\empty.bmp"); rightneg2 = new DepotPath(@"C:\workspace_root\test.txt"); rightnull = null; Assert.IsTrue(left.Equals(rightpos)); Assert.IsFalse(left.Equals(rightneg1)); Assert.IsFalse(left.Equals(rightneg2)); Assert.IsFalse(left.Equals(rightnull)); }
private bool TryToTransformSingleFileSource(SingleFileSource source, FilesList filesList) { if (!_transformations.ContainsKey(source.Id)) { return(false); } CopyProcessorTransformation transformation = _transformations[source.Id]; if ((transformation.Options & CopyProcessorTransformationOptions.SingleFile) == 0) { return(false); } LocalPath destinationPath = transformation.DestinationPath; PackagedFileInfo sourceFile = source.ListFiles().ToList().First(); FullPath destinationFullPath = _destinationRootDir.CombineWith(destinationPath); FileFullPath destinationFileFullPath = destinationFullPath.ToFileFullPath(); filesList.AddFile(new PackagedFileInfo(destinationFileFullPath)); _copier.Copy(sourceFile.FileFullPath, destinationFileFullPath); return(true); }
private void HashingHelper_GetHashAsyncCompleted(object sender, GetHashEventArgs e) { if (e.Path.ToLower() == LocalPath.ToLower()) { this.Hash = e.Hash; } }
private void DetectLocalPath() { if (File.Exists(LocalPath)) { return; } //try .swz file LocalPath = Path.ChangeExtension(LocalPath, ".swz"); if (File.Exists(LocalPath)) { return; } //try .swc file LocalPath = Path.ChangeExtension(LocalPath, ".swc"); CheckFile(LocalPath, "RSL"); Stream lib = LocalPath.ExtractSwfLibrary(); if (lib == null) { string reason = string.Format(". Unable to extract library.swf from swc file '{0}'", LocalPath); throw Errors.RSL.UnableToResolve.CreateException(this + reason); } LocalPath = Path.ChangeExtension(LocalPath, ".swf"); lib.Save(LocalPath); }
private void GetTwitch() { if (Host == "twitch.tv" || Host == "www.twitch.tv" || Host == "go.twitch.tv") { twitchID = LocalPath.Substring(1); } }
/// <summary> /// Defines a transformation for <see cref="SingleFileSource"/> which copies the file to the destination /// and renames the file in the process. /// </summary> /// <param name="sourceId">ID of the <see cref="SingleFileSource"/>.</param> /// <param name="destinationFileName">The destination directory and file name (local path).</param> /// <returns>This same instance of the <see cref="CopyProcessor"/>.</returns> public CopyProcessor AddSingleFileTransformation(string sourceId, LocalPath destinationFileName) { CopyProcessorTransformation transformation = new CopyProcessorTransformation(sourceId, destinationFileName, CopyProcessorTransformationOptions.SingleFile); _transformations.Add(sourceId, transformation); return(this); }
public PackagedFileInfo(FileFullPath fileFullPath, LocalPath localPath) { //AssertIsFullPath(fullPath); this.localPath = localPath; this.fileFullPath = fileFullPath; }
private void InitializeTextFileTrackingDataSource(string folderPath) { if (string.IsNullOrWhiteSpace(folderPath)) { FolderPath = LocalPath.Instance().PathDirectory; } DirectoryManager.CreateIfDoesNotExist(FolderPath); }
public EncryptFileOperation(LocalPath source, LocalPath target, RecipientCard recipientCard) { this.Title = "Encrypt " + source.AsRelativeToRoot(); this.source = source; this.target = target; this.recipientCard = recipientCard; }
public InMemoryFile(string filePath) { Path = new LocalPath(filePath); Name = System.IO.Path.GetFileName(filePath); NameWithoutExtension = System.IO.Path.GetFileNameWithoutExtension(filePath); CreateNewStream(); LastModifiedTimeUtc = DateTime.Now; }
public CopyProcessor AddTransformationWithDirFlattening(string sourceId, LocalPath destinationDir) { CopyProcessorTransformation transformation = new CopyProcessorTransformation( sourceId, destinationDir, CopyProcessorTransformationOptions.FlattenDirStructure); _transformations.Add(sourceId, transformation); return(this); }
public CopyProcessor AddTransformation(string sourceId, LocalPath destinationDir) { CopyProcessorTransformation transformation = new CopyProcessorTransformation( sourceId, destinationDir, CopyProcessorTransformationOptions.None); _transformations.Add(sourceId, transformation); return(this); }
public bool Equals(IPackageMetadata other) { return(Id.Equals(other.Id) && Version.Equals(other.Version) && LocalPath.Equals(other.LocalPath) && AreTargetFrameworksEqual(TargetFrameworks, other.TargetFrameworks) && AreAssembliesEqual(Assemblies, other.Assemblies)); }
public async Task BlameWithWorkingChanges() { string added = LocalPath.Combine("init"); /* * string1 - #0 * string1 - #0 * string1 - #0 * string2 - #0 * string2 - #0 * string2 - #0 * string3 - #0 * string3 - #0 * string3 - #0 */ var contents = string.Join( Environment.NewLine, Enumerable.Repeat("string1", 3) .Concat(Enumerable.Repeat("string2", 3)) .Concat(Enumerable.Repeat("string3", 3)) ); await AddFileAsync("init", contents, true, true); contents = string.Join( Environment.NewLine, new [] { "string0", // working copy <- deleted 1, added 1 "string1", // #0 "string4", // working copy <- deleted 1, added 3 "string4", // working copy "string4", // working copy "string1", // #0 "string2", // #0 <- deleted 1 "string2", // #0 "string3", // #0 "string4", // working copy }); await AddFileAsync("init", contents, true, false); var annotations = await Repo.GetAnnotationsAsync(added, null); string [] expected = { GettextCatalog.GetString("working copy"), "Commit #0\n", GettextCatalog.GetString("working copy"), GettextCatalog.GetString("working copy"), GettextCatalog.GetString("working copy"), "Commit #0\n", "Commit #0\n", "Commit #0\n", "Commit #0\n", GettextCatalog.GetString("working copy"), }; Assert.That(annotations.Select(x => x.Revision?.Message ?? x.Text), Is.EquivalentTo(expected)); }
public VSProjectWithFileInfo( VSSolution ownerSolution, Guid projectGuid, string projectName, LocalPath projectFileName, Guid projectTypeGuid) : base(ownerSolution, projectGuid, projectName, projectTypeGuid) { this.projectFileName = projectFileName; }
public void TestEncryption() { var cur = Directory.GetCurrentDirectory(); // Random file size up to about 1MB var random = new Random(); var fileSize = random.Next(1 * 1024 * 1024) + 1; // LocalPath holds a path and deletes it in the destructor var rawFile = new LocalPath(Path.GetTempFileName()); using (var ff = File.OpenWrite(rawFile.Path)) { for (var ii = 0; ii < fileSize; ++ii) { var bb = new byte[1]; random.NextBytes(bb); ff.WriteByte(bb[0]); } } byte[] keys = new byte[3 * 32]; random.NextBytes(keys); // Setup a context Context context = new Context { }; context.Key = keys; var encodedFile = new LocalPath(Path.GetTempFileName()); var decodedFile = new LocalPath(Path.GetTempFileName()); // Test aes and compression context.RepoCfg = new RepoConfig(6, 1, "aes"); Assert.IsTrue(CodecRun(context, rawFile.Path, encodedFile.Path, decodedFile.Path)); // Test twofish and compression context.RepoCfg = new RepoConfig(8, 1, "twofish"); Assert.IsTrue(CodecRun(context, rawFile.Path, encodedFile.Path, decodedFile.Path)); // Test twofish, aes chain and compression context.RepoCfg = new RepoConfig(3, 1, "twofish,aes"); Assert.IsTrue(CodecRun(context, rawFile.Path, encodedFile.Path, decodedFile.Path)); // Test serpent, twofish, aes chain and compression context.RepoCfg = new RepoConfig(3, 1, "serpent,twofish,aes"); Assert.IsTrue(CodecRun(context, rawFile.Path, encodedFile.Path, decodedFile.Path)); // Test only compression context.RepoCfg = new RepoConfig(6, 1, "none"); Assert.IsTrue(CodecRun(context, rawFile.Path, encodedFile.Path, decodedFile.Path)); // Test just storing context.RepoCfg = new RepoConfig(0, 1, "none"); Assert.IsTrue(CodecRun(context, rawFile.Path, encodedFile.Path, decodedFile.Path)); }
public void CreatingLocalPaths() { LocalPath localPath = new LocalPath(); localPath.Paths.Add(new Setting("key1", "name1", "description1")); localPath.Paths.Add(new Setting("key2", "name2", "description2")); localPath.Paths.Add(new Setting("key3", "name3", "description3")); ServiceXml.WriteXml <LocalPath>(localPath, "p:\\LocalPaths.xml"); }
private string GetNameSpace() { var relativeNameSpace = LocalPath.Replace(ParentProject.LocalPath, ".").Replace($"{Name}.cs", "").Replace("\\", "."); if (relativeNameSpace.EndsWith(".")) { relativeNameSpace = relativeNameSpace.Substring(0, relativeNameSpace.Length - 1); } return(ParentProject.Name + relativeNameSpace); }
public DecryptFileOperation(LocalPath source, LocalPath target, PersonalCard personalCard, string password) { this.Title = "Decrypt " + source.AsRelativeToRoot(); this.source = source; this.target = target; this.personalCard = personalCard; this.password = password; }
protected async override Task <int> ExecuteAsync(AsyncCodeActivityContext context) { var filename = Filename.Get(context); var id = _id.Get(context); var filepath = LocalPath.Get(context); var ignorepath = IgnorePath.Get(context); await global.webSocketClient.DownloadFileAndSave(filename, id, filepath, ignorepath); return(13); }
public override bool Execute() { if (LocalPath == null) { return(false); } Url = string.Join("/", LocalPath.Split(s_directorySeparators).Select(Uri.EscapeDataString)); return(true); }
public LocalFile(string filePath, Func<DirectoryInfo, IDirectory> directoryFactory) { _filePath = filePath; _directoryFactory = directoryFactory; Path = new LocalPath(filePath); }
public IFile GetFile(string filePath) { var resolviedFilePath = Path.GetFullPath(Path.Combine(CurrentDirectory, filePath)); var pathSegments = new LocalPath(resolviedFilePath).Segments; var ownerFolder = pathSegments .Skip(1).Take(pathSegments.Count()-2) .Aggregate((IDirectory)GetRoot(pathSegments.First()), (current, segment) => current.GetDirectory(segment)); return ownerFolder.GetFile(pathSegments.Last()); }
public IDirectory GetDirectory(string directoryPath) { var resolvedDirectoryPath = Path.GetFullPath(Path.Combine(CurrentDirectory,directoryPath)); var pathSegments = new LocalPath(resolvedDirectoryPath).Segments; return pathSegments .Skip(1) .Aggregate((IDirectory)GetRoot(pathSegments.First()), (current, segment) => current.GetDirectory(segment)); }