private void SendBuildFileToRepository() { FileArgs args = new FileArgs() { SessionId = currentBuildRequest.SessionId }; this.CommunicationObject.PostFile(currentBuildRequest.ClientRequestFile, defaultConfigs[Identity.TestHarness].ServiceURL, args); var buildFiles = Directory.GetFiles(currentBuildRequest.SessionDir, "*.exe").ToList(); buildFiles.AddRange(Directory.GetFiles(currentBuildRequest.SessionDir, "*.dll")); CommMessage testharnessmsg = new CommMessage(CommMessage.MessageType.Request); testharnessmsg.Command = CommCommands.TESTFILEREQUEST; testharnessmsg.To = defaultConfigs[Identity.TestHarness].ServiceURL; if (buildFiles.Count > 0) { for (int i = 0; i < buildFiles.Count; i++) { if (this.CommunicationObject.PostFile(buildFiles[i], defaultConfigs[Identity.TestHarness].ServiceURL, args)) { testharnessmsg.Arguments[CommCommands.RepositoryArgs.FILENAME + i] = Path.GetFileName(buildFiles[i]); } } testharnessmsg.Arguments[CommCommands.RepositoryArgs.FILECOUNT] = testharnessmsg.Arguments.Count.ToString(); testharnessmsg.Arguments[CommCommands.RepositoryArgs.SESSIONID] = currentBuildRequest.SessionId; testharnessmsg.Arguments[CommCommands.CLIENTDETAILS] = currentBuildRequest.ClientID; CommunicationObject.PostMessage(testharnessmsg); SendNotification(this.currentBuildRequest.ClientID, "[" + currentBuildRequest.SessionId + "] forwarded to Test Harness."); } SendReadyMessage(); }
/// <summary> /// File received event handler. Used for setting directory so file is written to /// correct directory. /// </summary> /// <param name="fileName"></param> /// <param name="args"></param> private void MessageReceiver_FileRequestReceived(string fileName, FileArgs args) { if (args != null) { string baseDir = Path.Combine(this.defaultConfigs[identity].BaseDirectory, args.SessionId); commObject.SetBaseDirectory(baseDir); } }
public void RelativeFile_Theory(FileArgs args) { if (args.Expected == null) { Trap.Exception(() => new RelativeFilePath(args.Source)) .ShouldNotBeNull(); } else { var file = new RelativeFilePath(args.Source); file.ToString() .ShouldEqual(args.Expected); file.FileExtension.ShouldEqual(args.Extension); } }
/// <summary> /// Internals the save. /// </summary> /// <param name="args">The arguments.</param> /// <returns></returns> protected override FileStorageResultDTO InternalSave(FileArgs args) { var targetRelativePathElements = args.GetRelativePathElements(); var targetFileNameElements = args.GetFileNameElements(); var rootPath = args.TargetRootPath ?? FileSystemStorage.FileSystemBaseStoragePath; var folderPath = (args.BuildRelativePath ?? this.BuildRelativePath)(targetRelativePathElements); var fileName = (args.BuildFileName ?? this.BuildFileName)(targetFileNameElements); fileName += Path.GetExtension(args.UploadedFile.OriginalFileName); var directoryPath = Path.Combine(rootPath, folderPath); var relativeFilePath = Path.Combine(folderPath, fileName); try { if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } var filePath = Path.Combine(directoryPath, fileName); using (var fileStream = File.OpenWrite(filePath)) { using (var streamWriter = new BinaryWriter(fileStream)) { streamWriter.Write(args.FileContent); } } var result = new FileStorageResultDTO { RootPath = rootPath, AccessPath = null, FolderPath = folderPath, FileName = fileName, FileSourceId = Identifier }; return(result); } catch (Exception ex) { throw ex; } }
// Will find a better deisng next time. Time crunch. :( private void OnFileRequestReceived(string filename, FileArgs args) { switch (args?.Identity) { case Identity.Client: this.SetBaseDirectory(this.buildRequestFolder); break; case Identity.ChildProcess: this.SetBaseDirectory(this.buildLogsFolder); break; case Identity.TestHarness: this.SetBaseDirectory(this.testLogsFolder); break; default: this.SetBaseDirectory(this.storagePath); break; } }
/// <summary> /// Internals the save. /// </summary> /// <param name="args">The arguments.</param> /// <returns></returns> protected override FileStorageResultDTO InternalSave(FileArgs args) { string[] targetRelativePathElements = args.GetRelativePathElements(); string[] targetFileNameElements = args.GetFileNameElements(); var relativePath = (args.BuildRelativePath ?? this.BuildRelativePath)(targetRelativePathElements); var fileName = (args.BuildFileName ?? this.BuildFileName)(targetFileNameElements); fileName += Path.GetExtension(args.UploadedFile.OriginalFileName); string FullFileKey = string.Join("/", relativePath, fileName);// Path.Combine(relativePath, fileName); try { using (var client = this.CreateClient(AWSStorage.AWSFileStoreRootURL)) { AWSUploadPublicFileAsync(client, args.UploadedFile.FileContent, AWSStorage.AWSFileRepoBucketName /* ConfigurationManager.AppSettings["AWSFileRepoBucketName"]*/, FullFileKey).Wait(); } var result = new FileStorageResultDTO { RootPath = AWSStorage.AWSFileStoreRootURL, AccessPath = AWSStorage.AWSFileRepoBucketName, FolderPath = relativePath, FileName = fileName, FileSourceId = Identifier }; return(result); } catch (Exception ex) { System.Diagnostics.Debug.WriteLine($"AWSStorage.InternalSave ERROR - [{ex.Message}]"); throw; } }
private void OnFileRequestReceived(string filename, FileArgs args) { }
public bool Enqueue(FileArgs fa) { return(rqueue.Enqueue(fa)); }
/// <summary> /// Internals the save. /// </summary> /// <param name="args">The arguments.</param> /// <returns></returns> protected override FileStorageResultDTO InternalSave <T>(FileArgs <T> args) { var targetRelativePathElements = args.GetRelativePathElements(); var targetFileNameElements = args.GetFileNameElements(); var rootPath = args.TargetRootPath ?? FileSystemStorage.FileSystemBaseStoragePath; var folderPath = (args.BuildRelativePath ?? this.BuildRelativePath)(targetRelativePathElements); var fileName = (args.BuildFileName ?? this.BuildFileName)(targetFileNameElements); fileName += Path.GetExtension(args.UploadedFile.OriginalFileName); var directoryPath = Path.Combine(rootPath, folderPath); var relativeFilePath = Path.Combine(folderPath, fileName); string thumbnailFileNameWithExtension = null; try { if (!Directory.Exists(directoryPath)) { Directory.CreateDirectory(directoryPath); } var filePath = Path.Combine(directoryPath, fileName); using (var fileStream = File.OpenWrite(filePath)) { using (var streamWriter = new BinaryWriter(fileStream)) { streamWriter.Write(args.FileContent); } } string thumbnailFilePath = null; if (args.UploadedFile.ThumbnailContent != null && args.UploadedFile.ThumbnailContent.Length > 0) { // main file name construction var thumbnailFileName = $"{fileName}_thumbnail"; thumbnailFileNameWithExtension = thumbnailFileName + ".png"; thumbnailFilePath = Path.Combine(directoryPath, thumbnailFileNameWithExtension); using (var fileStream = File.OpenWrite(thumbnailFilePath)) { using (var streamWriter = new BinaryWriter(fileStream)) { streamWriter.Write(args.UploadedFile.ThumbnailContent); } } } var result = new FileStorageResultDTO { RootPath = rootPath, AccessPath = null, FolderPath = folderPath, FileName = fileName, ThumbnailFileName = thumbnailFileNameWithExtension, FileSourceId = Identifier, FullFilePath = filePath, ThumbnailFullFilePath = thumbnailFilePath }; return(result); } catch (Exception ex) { this.Logger.Error("Error saving uploaded file", ex); throw ex; } }
/// <summary> /// Set appropriate directory based on file being received. /// </summary> /// <param name="filename"></param> /// <param name="args"></param> private void OnFileRequestReceived(string filename, FileArgs args) { this.SetBaseDirectory(this.StoragePath); }
public virtual FileStorageResultDTO Save(FileArgs args) { var result = this.InternalSave(args); return(result); }
protected abstract FileStorageResultDTO InternalSave <T>(FileArgs <T> args) where T : UploadedFile;
protected void OnCreateFiles(object sender, FileArgs e) { FileCreated.Invoke(sender, e); }
protected void OnRenamedFiles(object sender, FileArgs e) { FileChanged.Invoke(sender, e); }
internal static E_Decision?HashCopy_AskToUser(object sender, EFileResult state, FileArgs fileSrc, FileArgs fileDest) { return(Application.Current.Dispatcher?.Invoke ( () => { DxTBoxCore.Box_Decisions.MBDecision boxDeciz = new DxTBoxCore.Box_Decisions.MBDecision() { Model = new DxTBoxCore.Box_Decisions.M_Decision() { Message = $"Overwrite ? ({state})", Source = fileSrc.Path, Destination = fileDest.Path, SourceInfo = FileSizeFormatter.Convert(fileSrc.Length), DestInfo = FileSizeFormatter.Convert(fileDest.Length), }, Buttons = E_DxConfB.OverWrite | E_DxConfB.Pass | E_DxConfB.Trash, }; if (boxDeciz.ShowDialog() == true) { return boxDeciz.Model.Decision; } return E_Decision.None; } )); }
protected abstract FileStorageResultDTO InternalSave(FileArgs args);
public virtual FileStorageResultDTO Save <T>(FileArgs <T> args) where T : UploadedFile { var result = this.InternalSave(args); return(result); }
protected override FileStorageResultDTO InternalSave(FileArgs args) { throw new NotImplementedException(); }
/// <summary> /// Show a window to ask what to do when there is a file conflict /// </summary> /// <param name="sender"></param> /// <param name="source"></param> /// <param name="destination"></param> /// <param name="buttons"></param> /// <returns></returns> internal static E_Decision?Ask4_FileConflict2(object sender, EFileResult state, FileArgs fileSrc, FileArgs fileDest) { fileSrc.Length = new FileInfo(fileSrc.Path).Length; fileDest.Length = new FileInfo(fileDest.Path).Length; return(Application.Current.Dispatcher?.Invoke ( () => { DxTBoxCore.Box_Decisions.MBDecisionD boxDeciz = new DxTBoxCore.Box_Decisions.MBDecisionD() { Model = new DxTBoxCore.Box_Decisions.M_Decision() { Message = LanguageManager.Instance.Lang.File_Ex, Source = fileSrc.Path, Destination = fileDest.Path, SourceInfo = FileSizeFormatter.Convert(fileSrc.Length), DestInfo = FileSizeFormatter.Convert(fileDest.Length), }, Buttons = E_DxConfB.OverWrite | E_DxConfB.Pass | E_DxConfB.Trash, }; if (boxDeciz.ShowDialog() == true) { return boxDeciz.Model.Decision; } return E_Decision.None; } )); }