dmsimanage

Create a folder in IManage desksite C#


I want to create a folder in DeskSite using the IManage API. can someone please give example. Any help will be appreciated.


Solution

  • I got answer and hope this will help someone out there.

    public void CreateFolder(string matterNo, string clientNo, string dbName, string serviceAccountName)
        {
            var folderName = "new folder name";
            var folderDesc = "new folder description";
            var workSpaceName = string.Format("{0}-{1}*", clientNo, matterNo);
            if (DMSSession.Connected)
            {
                IManWorkArea imanWorkArea = DMSSession.WorkArea;
                IManDatabase imanDatabase = DMSSession.Databases.ItemByName(dbName);
                //workspace search profile values
                IManProfileSearchParameters profileParameters = imanWorkArea.Session.DMS.CreateProfileSearchParameters();
                profileParameters.Add(IManage.imProfileAttributeID.imProfileAuthor, "*");
    
                //workspace search property values
                IManWorkspaceSearchParameters workSpaceParameters = imanWorkArea.Session.DMS.CreateWorkspaceSearchParameters();
                workSpaceParameters.Add(IManage.imFolderAttributeID.imFolderOwner, "*");
                workSpaceParameters.Add(IManage.imFolderAttributeID.imFolderName, workSpaceName);
                IManWorkspace imanWorkSpace = (IManWorkspace)imanDatabase.SearchWorkspaces(profileParameters, workSpaceParameters).ItemByIndex(1);
                var workSpaceId= imanWorkSpace.ObjectID;
    
                IManDMS mDms = DMSSession.DMS;
                IManWorkspace mWorkSpace = (IManWorkspace)mDms.GetObjectByID(workSpaceId);
                IManDocumentFolders mDocFolders = mWorkSpace.DocumentFolders;
                IManDocumentFolder mDocFolder = mDocFolders.AddNewDocumentFolder(folderName, folderDesc);
                //setting additional prpoerties
    
                mDocFolder.AdditionalProperties.Add("iMan___25", clientNo);
                mDocFolder.AdditionalProperties.Add("IMan___26", matterNo);
    
                //setting security
                mDocFolder.Security.DefaultVisibility = imSecurityType.imView;
                mDocFolder.Security.UserACLs.Add("userName", imAccessRight.imRightAll);
                mDocFolder.Update();
            }
        }