You are viewing limited content. For full access, please sign in.

Question

Question

How to copy documents from Repository to another Repository using SDK?

SDK
asked on May 20, 2024

Hello All,

Want help to copy documents from one repository to another repository.

So, I did search for documents needed to be copied and want to copy them to another repository according to document metadata each document will be copied to different path in destination repository.  

Thanks.


                string serchParameters = "{[]:[Verified]=\"Yes\"} & {LF:LOOKIN=\""+br + @"\sample\""}";
                RepositoryRegistration repository = new RepositoryRegistration("server", "reponame");

                using (Session session = new Session())
                {
                    session.LogIn("username", "pasword", repository);
                    Search lfSearch = new Search(session, serchParameters);
                    SearchListingSettings settings = new SearchListingSettings();
                    settings.AddColumn(SystemColumn.Id);
                    lfSearch.Run();
                    SearchResultListing searchResults = 

lfSearch.GetResultListing(settings);
               
                    foreach (EntryListingRow item in searchResults)
                    {
                        Int32 docId = (Int32)item[SystemColumn.Id];
                        EntryInfo currentEntry = Entry.TryGetEntryInfo(docId,session);
                   // copy each document to other repository  
                     }

 

0 0

Replies

replied on May 21, 2024

For transferring between repositories, you would probably want to use the BriefcaseExporter and BriefcaseImporter classes; you'd create a second Session object for the destination repository to use with the briefcase importer.

For the briefcase exporter, you can add individual entries using the .AddEntry() method, however, you can also add search results using the .AddSearch() method meaning you might be able to do this as a batch instead of executing the search first and looping on the results.

The following is just a quick mock-up to show the available methods, so I haven't actually run it, but the methods and constructors are pulled from the documentation.

// create briefcase with session for Source repository
BriefcaseExporter bExp = new BriefcaseExporter(RASession);

// add your search object
bExp.AddSearch(search);

// export briefcase to stream
using (Stream bStream = bExp.Export()){
    // create a briefcase importer for the Destination repository
    BriefcaseImporter bImp = new BriefcaseImporter(altSession);

    // set destination folder
    bImp.DestinationFolder = folderInfo; // you'll need to create this

    // import the briefcase from the stream and close the importer
    bImp.Import(bStream);
    bImp.Close();
}

// close the exporter
bExp.Close();

There's also an overload for the importer so you could set the target folder/volume in the constructor, in which case you'd need to specify a volume.

1 0
You are not allowed to follow up in this post.

Sign in to reply to this post.