public long?Add(byte[] file, string filename, long?newFileId) { // If we have a new file to upload. if (file != null) { var depFile = Add(file, filename); RequirementCheck.Check(true, true, "The file is missing a file id from the DEP Document Management Service.", depFile.fileId); newFileId = depFile.fileId; } // Else if we have the file id of the file in the Document Management Service Web Service // and we have the file name then update the file in this webservice with this name. else if (!string.IsNullOrWhiteSpace(filename) && newFileId.HasValue) { // 'Update' the file with the correct file name. // The way we update here is to get the file contencts and save it as a new // record with the Document Management Service with its updated filename // then delete the old record. var oldFile = GetFile((int)newFileId.Value); var depFile = Add(oldFile.fileStream, filename); Remove((int)oldFile.fileId); newFileId = depFile.fileId; } return(newFileId); }
public void Remove(string filename) { var fileId = _documentManagementServiceFacade.DoesFileExistFileId(ParentFolderName, filename); if (!RequirementCheck.Check(true, false, null, fileId)) { ((List <Error>)Errors).Add(new Error { Description = "Unable to find " + filename + " in the " + ParentFolderName + " folder.", Property = "filename" }); return; } _documentManagementServiceFacade.DeleteFile(fileId); }
public DEPFile Add(byte[] file, string fileName, long parentFolderId) { if (!RequirementCheck.Check(true, false, null, file)) { ((List <Error>)Errors).Add(new Error { Description = "The file is missing a file id from the DEP Document Management Service", Property = "file" }); return(null); } RequirementCheck.Check(true, true, "The file is missing a file name.", fileName); var depFile = new Objects.DEPFile { fileName = fileName, fileStream = file, childFolderId = parentFolderId }; depFile = this.Add(depFile); RequirementCheck.Check(true, true, "The file is missing a file id from the DEP Document Management Service.", depFile.fileId); return(depFile); }