Moving a file to another directory in Docs Management
A file in Document Management can be moved to another directory using the following code.
NOTE: Here, SecretKey information is also required among the parameters of the MoveObjects method. For this reason, the GetDMObjectsFromPath method was needed. (Used in the GetDMObjectInfo method.)
Required Libraries
using System;
using System.Collections.Generic;
using Bimser.CSP.FormControls.Common;
using Bimser.CSP.FormControls.Controls;
using Bimser.CSP.FormControls.Events;
using Bimser.Synergy.Entities.Shared.Business.Objects;
using Bimser.Synergy.ServiceAPI;
using Bimser.Synergy.ServiceAPI.Models.Authentication;
using Bimser.Synergy.ServiceAPI.Models.Form;
using Newtonsoft.Json;
using Bimser.Synergy.Entities.DocumentManagement.Business.DTOs.Requests;
using Bimser.Synergy.Entities.DocumentManagement.Business.DTOs.Responses;
using Bimser.Framework.Web.Models;
using System.Linq;
using Bimser.Synergy.Entities.DocumentManagement.Business.DTOs;
Required Codes
public GetDMObjectResponse GetDMObjectInfo(string path)
{
WrapResponse```<```GetDMObjectsResponse```>``` dmObject = ServiceApi.DocumentManagement.GetDMObjectsFromPath(
new GetDMObjectsFromPathRequest(path)). Result;
GetDMObjectResponse dMObjectResponse = dmObject.Result.Items.First();
return dMObjectResponse;
}
void Button1_OnClick(object sender, MouseEventArgs e)
{
ServiceApi.DocumentManagement.MoveObjects(
new MoveObjectsRequest(
new List```<```string```>```{
GetDMObjectInfo("The path of the file to be moved"). SecretKey},
GetDMObjectInfo("The path of the folder to be moved"). SecretKey,
"reason"
)
);
}
NOTE: Migration can also be done for multiple files at the same time. The following example can be examined.
ServiceApi.DocumentManagement.MoveObjects(
new MoveObjectsRequest(
new List```<```string```>```{
GetDMObjectInfo("The path of the file to be moved"). SecretKey,
GetDMObjectInfo("The path of the file to be moved"). SecretKey
},
GetDMObjectInfo("The path of the folder to be moved"). SecretKey,
"reason"
)
);