Hello Everyone,
I wish to seek your guidance on how to call the aaApi_CreateDocument function using the C# wrappers of MostOfDavesClasses-CSharp-Wrappers-For-ProjectWise.
I can create abstract document in a specified location without issue. However, I am keep getting the error, "Error Creating New Document", when I attach a file to a new document.
Here is the current implementation:
[DllImport("dmscli.dll", CharSet = CharSet.Unicode)] public static extern bool aaApi_CreateDocument(ref int documentID, int vaultID, int storageID, int fileType, DocumentType itemType, int applicationID, int departmentID, int workspaceProfileID, string sourceFilePath, string fileName, string name, string description, string version, bool leaveCheckedOut, DocumentCreationFlag creationFlags, StringBuilder workingFile, int workingFileBufferSize, ref int attributeID); // Calling this method int documentID = 0; int vaultID = folderID; int storageID = 0; int fileType = 0; DocumentType itemType = DocumentType.Normal; int applicationID = 0; int departmentID = 0; int workspaceProfileID = 0; string sourceFilePath = @"C:\workspace\"; string fileName = "test.xls"; string name = "test.xls"; string description = "test document"; string version = null; bool leaveCheckOut = false; DocumentCreationFlag creationFlags = DocumentCreationFlag.Default; StringBuilder workingFile = null; // new StringBuilder() int workingFileBufferSize = 1000; int attributeID = 0; var result = PWWrapper.aaApi_CreateDocument(ref documentID, vaultID, storageID, fileType, itemType, applicationID, departmentID, workspaceProfileID, sourceFilePath, fileName, name, description, version, leaveCheckedOut, creationFlags, workingFile, workingFileBufferSize, int attributeID); // output result = false error = "Error Creating New Document"
Greatly appreciate your time and inputs!
Tim
My apology, the calling method should be:
var result = PWWrapper.aaApi_CreateDocument(ref documentID, vaultID, storageID, fileType, itemType, applicationID, departmentID, workspaceProfileID, sourceFilePath, fileName, name, description, version, leaveCheckedOut, creationFlags, workingFile, workingFileBufferSize, ref attributeID);
Try something like this:
// create document int iTargetDocID = 0; StringBuilder workingFileBuffer = new StringBuilder(1024); int attributeID = 0; if (!PWWrapper.aaApi_CreateDocument( ref iTargetDocID, iTargetProjectId, 0, 0, PWWrapper.DocumentType.Normal, PWWrapper.aaApi_GetFExtensionApplication(System.IO.Path.GetExtension(sSourceFullPath)), 0, 0, sSourceFullPath, sName, sName, sName, null, false, PWWrapper.DocumentCreationFlag.NoAttributeRecord, workingFileBuffer, workingFileBuffer.Capacity, ref attributeID))
Thank you very much! This works perfectly.