/// <summary> /// Upload workspace package then write output /// </summary> /// <param name="taskId">Task id </param> /// <param name="filePath">Local file path to the workspace</param> /// <param name="packageName">Package name</param> /// <returns></returns> private async Task UploadAndWriteWorkspacePackage(long taskId, string filePath, string packageName) { await UploadWorkspacePackage(taskId, filePath, packageName); LibraryResource packageInfo = await this.SynapseAnalyticsClient.GetPackageAsync(packageName); PSSynapseWorkspacePackage workspacePackage = new PSSynapseWorkspacePackage(packageInfo, this.WorkspaceName); OutputStream.WriteObject(taskId, workspacePackage); }
public ActionResult Create(LibraryResource libraryResource) { if (!ModelState.IsValid) { return(View(libraryResource)); } _libraryResourceService.Create(libraryResource); _unitOfWork.Commit(); return(RedirectToAction("Index")); }
public PSSynapseWorkspacePackage(LibraryResource packageInfo, string workspaceName) : base(packageInfo.Id, packageInfo.Name, packageInfo.Type, packageInfo.Etag) { this.Path = packageInfo?.Properties?.Path; this.ContainerName = packageInfo?.Properties?.ContainerName; this.UploadedTimestamp = packageInfo?.Properties?.UploadedTimestamp; this.PackageType = packageInfo?.Properties?.Type; this.ProvisioningStatus = packageInfo?.Properties?.ProvisioningStatus; this.CreatorId = packageInfo?.Properties?.CreatorId; this.WorkspaceName = workspaceName; }
public async Task <IActionResult> Upload(List <IFormFile> files, string category) { long size = files.Sum(f => f.Length); var filePaths = new List <string>(); foreach (var formFile in files) { if (formFile.Length > 0) { //Create the new filename var new_filename = category.ToString() + "_" + category.ToString() + "_" + formFile.FileName; var library_resource = new LibraryResource { Original_Name = formFile.FileName, Generated_Name = new_filename, Category = category }; _context.LibraryResources.Add(library_resource); _context.SaveChanges(); var filePath = Path.Combine(Directory.GetCurrentDirectory(), "wwwroot\\Repository\\" + category, new_filename); filePaths.Add(filePath); using var stream = new FileStream(filePath, FileMode.Create); await formFile.CopyToAsync(stream); } } // process uploaded files // Don't rely on or trust the FileName property without validation. return(RedirectToAction("Repository", "Library", new { category = category })); }
public void Create(LibraryResource resource) { _unitOfWork.Add(resource); }
public void AddResource(LibraryResource resource) { _resources.Add(resource); }
public PSSynapseWorkspacePackage(LibraryResource packageInfo) : this(packageInfo, null) { }