This post is more than 5 years old
3 Posts
0
2108
How to write multiple files to centera
I'm a .net developer new to working with the centera sdk. Basically what I am trying to do is loop through blobs of data stored in a database and send them off to a centera device. I was able to get this working but only by opening and closing the connection for each blob. With millions of files to loop through this in not efficient since it takes a few seconds to open the connection and authenticate. Is there any documentation or code examples of how to open the connection once, write all files, then close connection at the end?
gstuartemc
417 Posts
0
March 30th, 2011 05:00
You have (wrongly) included your XSystem connection in a using clause - this causes the object to be disposed at the end of the block. So the next time around you are trying to create an XSet using an XSystem connection that is (effectively) null.
The .NET wrapper Test Harness creates the connection in a using clause for each test iteration. This is done simply to exerecise the functionality and show that the object implements IDisposable (allow for the use of a using clause). The Best Practice is to create it once and keep it open.
mckeown_paul
409 Posts
0
March 29th, 2011 13:00
You absolutely should not have to close the connection and reopen to do this, could you explain why you are having to do this? what's forcing this behaviour?
rgoodenb
3 Posts
0
March 29th, 2011 14:00
Here is a snippet of what I'm attempting to do. Basically I keep getting the error "Attempted to read or write protected memory. This is often an indication that other memory is corrupt" at the marked line of code below unless I create a new xsys object/ connection each time.
.
.
.
xlib = XAMLibrary.Instance;
xlib.LogLevel = Constants.LOG_OFF;
xsys = xlib.CreateXSystem(connectString);
if (!xsys.Authenticated)
// Authenticate - can provide an authentication string or use default of ANONYMOUS
xsys.Authenticate();
.
.
.
//outside loop through documents
using (xsys) //centera connection
{
xset = xsys.CreateXSet(); //***bombs here on second time through loop with error: Attempted to read or write protected memory. This is often an indication that other memory is corrupt.***
xstream = xset.CreateXStream("docData", Constants.DEFAULT_MIME_TYPE);
xstream.Write(csiDocument.DocData, 0, int.Parse( csiDocument.DocData.Length.ToString()));
xstream.Dispose();
xuid = xset.Commit();
xset.Dispose();
ArchiveID = (string)xuid;
}
rgoodenb
3 Posts
0
March 30th, 2011 06:00
Thanks Graham. This makes sense and fixed the issue.