I am using a windows service to insert tiff images and its metadata into documentum content server. The windows service is running in the same PC where the tiff images exist. The documentum content server is on another unix system. The documentum content server version is 6.5sp1. The tiff file sizes vary from 40-90 kb. The DFC API code has been implemented in the windows service to import the tiff files.
The rate of insertion is only 4-6 images/minute. Please let me know if there is any way to increase the number of images to insert into documentum. I need atleast 12-15 images to be inserted into documentum otherwise it will lead to a big problem. Please help.
Please find the snippet to import the files used in the windows service:
SessionCode:
------------------------------------------------------------------------------------------------------
using System;
using System.Collections.Generic;
using System.Text;
using Documentum.Interop.DFC;
using System.Runtime.InteropServices;
using System.IO;
namespace ExportDctm{
public class SessionManager
{
DfClientX mDfClientX = null;
public SessionManager()
{
mDfClientX = new DfClientX();
}
public SessionManager(DfClientX obj)
{
mDfClientX = obj;
}
public IDfSessionManager createSessionManager(String mUser, String mPwd, String mDocBase)
{
IDfSessionManager mIDfSessionManager = null;
IDfClient mIDfClient = null;
IDfLoginInfo mIDfLoginInfo = null;
try
{
mIDfClient = mDfClientX.getLocalClient();
if (mIDfClient != null)
{
mIDfSessionManager = mIDfClient.newSessionManager();
if (mIDfSessionManager != null)
{
mIDfLoginInfo = mDfClientX.getLoginInfo();
if (mIDfLoginInfo != null)
{
mIDfLoginInfo.setUser(mUser);
mIDfLoginInfo.setPassword(mPwd);
mIDfSessionManager.setIdentity(mDocBase, mIDfLoginInfo);
return mIDfSessionManager;
}
else
{
throw new System.Exception("Couldn't obtain login info.");
}
}
else
{
throw new System.Exception("Couldn't obtain session mgr.");
}
}
else
{
throw new System.Exception("Couldn't obtain client.");
}
}
catch (System.Exception err)
{
throw err;
}
finally
{
if (mIDfClient != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(mIDfClient);
mIDfClient = null;
}
if (mIDfLoginInfo != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(mIDfLoginInfo);
mIDfLoginInfo = null;
}
}
}
public IDfSession createSession(IDfSessionManager mIDfSessionManager, String mDocBase)
{
if (mIDfSessionManager != null)
{
IDfSession mIDfSession = mIDfSessionManager.getSession(mDocBase);
if (mIDfSession == null)
{
throw new System.Exception("mIDfSession is NULL");
}
else
{
return mIDfSession;
}
}
else
{
throw new System.Exception("mIDfSessionManager is NULL");
}
}
public void cleanupSession(IDfSessionManager mIDfSessionManager, IDfSession mIDfSession)
{
try
{
if (mIDfSessionManager != null)
{
if (mIDfSession != null)
{
mIDfSessionManager.release(mIDfSession);
}
}
}
catch (System.Exception err)
{
err.ToString();
}
finally
{
if (mIDfSessionManager != null)
{
System.Runtime.InteropServices.Marshal.ReleaseComObject(mIDfSessionManager);
mIDfSessionManager = null;
}
}
}
}
}
------------------------------------------------------------------------------------------------------
Import Code:
------------------------------------------------------------------------------------------------------
private void ExportToDctm(DataTable dtExport) {
IDfSession loSession = null;
IDfSessionManager idmanager = null;
SessionManager sm = null;
DfClientX _m_DfClientX = null;
DataSet DatasetPrevilege = exDctm.GetDocumentumPriviledge();
Username = Convert.ToString(DatasetPrevilege.Tables[0].Rows[0]["CIDP_DOCUMENTUM_USERNAME"]);
Password = CreateConnection.Decrypt(Convert.ToString(DatasetPrevilege.Tables[0].Rows[0]["CIDP_DOCUMENTUM_PASSWORD"]));
DocBasename = Convert.ToString(DatasetPrevilege.Tables[0].Rows[0]["CIDP_DOCUMENTUM_DOCBASE"]);
try
{
_m_DfClientX = new DfClientX();
sm = new SessionManager(_m_DfClientX);
idmanager = sm.createSessionManager(Username, Password, DocBasename);
loSession = sm.createSession(idmanager, DocBasename);
for(int rowCount = 0; rowCount < dtExportReady.Rows.Count; rowCount++)
{
//Insert Metadata Code
//Insert Image Code [Snippet Given Below]
}
}
catch (Exception ex) { ex.StackTrace; }
finally { sm.cleanupSession(idmanager, loSession) ;}
}
------------------------------------------------------------------------------------------------------
Insert Image Code:
------------------------------------------------------------------------------------------------------
public String insertImage(String trans_id, String product_name, String prod_cat_name, String imagepath, String eflow_batch_no, String batch_no, String clotno, string client_code, string client_name, string client_refno, string full_batch_no, string BaseNo, string Deposit_Slip_Count, string Base_Transaction_Id, string Upload_date)
{
String flag = "";
IDfQuery img_objid_qry = null;
IDfCollection imgobjid_coll = null;
int intreturnSuccess = 1;
try {
createFolder(trans_id, product_name, batch_no, ref intreturnSuccess);
if (intreturnSuccess != 1)
{
flag = "failed in image insertion ";
return flag;
}
} catch (Exception e) {
flag = "failed in image insertion with exception of" + e.Message;
return flag;
}
try {
img_objid_qry = _m_DfClientX.getQuery();
img_objid_qry.setDQL("select r_object_id from ctb_main_img where trans_id ='" + trans_id + "' and prod_name ='" + product_name + "' and prod_cat_name ='" + prod_cat_name + "' and eflow_batch_no ='" + eflow_batch_no + "' and batch_no='" + batch_no + "' and clot_no='" + clotno + "'");
imgobjid_coll = img_objid_qry.execute(loSession, (int)tagDfQueryTypes.DF_READ_QUERY);
while (imgobjid_coll.next()) {
imgobj_id = imgobjid_coll.getString("r_object_id");
}
if (imgobj_id == null || imgobj_id.Equals(string.Empty)) {
try {
int intdepslipcount = 0;
if (!string.IsNullOrEmpty(Deposit_Slip_Count)) {
Int32.TryParse(Deposit_Slip_Count, out intdepslipcount);
}
DateTime dtuploaddate = DateTime.Now;
DateTime.TryParse(Upload_date, out dtuploaddate);
string struploaddate = string.Empty;
string format;
DateTime result;
CultureInfo provider = CultureInfo.InvariantCulture;
try {
format = "dd/mm/yyyy";
result = DateTime.ParseExact(dtuploaddate.ToShortDateString(), format, provider);
} catch {
format = "d/m/yyyy";
result = DateTime.ParseExact(dtuploaddate.ToShortDateString(), format, provider);
}
struploaddate = result.ToShortDateString();
IDfSysObject loOldObject = (IDfSysObject)loSession.getObjectByQualification("ctb_main_img where trans_id ='" + trans_id + "' and prod_name ='" + product_name + "' and prod_cat_name ='" + prod_cat_name + "' and eflow_batch_no ='" + eflow_batch_no + "' and batch_no='" + batch_no + "' and clot_no='" + clotno + "'");
if (loOldObject == null)
{
IDfSysObject loObject = (IDfSysObject)loSession.newObject("ctb_main_img");
loObject.setString("trans_id", trans_id);
loObject.setString("prod_name", product_name);
loObject.setString("prod_cat_name", prod_cat_name);
loObject.setString("eflow_batch_no", eflow_batch_no);
loObject.setString("batch_no", batch_no);
DateTime loDate = Convert.ToDateTime(struploaddate);
loObject.setString("upload_date", loDate.ToString());
loObject.setString("base_no", BaseNo);
loObject.setString("basetransaction_id", Base_Transaction_Id.Replace("'", "''").Replace("\n", " "));
loObject.setString("deposit_slip_count", intdepslipcount.ToString());
loObject.setString("clot_no", clotno);
loObject.setString("client_code", client_code.Replace("'", "''").Replace("\n", " "));
loObject.setString("client_name", client_name.Replace("'", "''").Replace("\n", " "));
loObject.setString("client_refno", client_refno.Replace("'", "''").Replace("\n", " "));
loObject.setString("full_batch_no", full_batch_no);
String loObjectName = "Main" + product_name + trans_id;
loObject.setString("object_name", loObjectName);
loObject.setContentType("tiff");
if (File.Exists(imagepath)) {
//Log
}
loObject.setFile(imagepath);
String loLinkPath = "/CIMS/TRANSACTION/" + product_name + "/" + batch_no + "/" + trans_id + "/MAIN/DOCUMENT";
loObject.link(loLinkPath);
loObject.save();
double d = loObject.getDouble("r_content_size");
while (imgobjid_coll.next()) {
//Log
}
flag = "Success in main image insertion";
}
} catch (Exception e) {
//Log
}
}
else {
flag = "Main Image Already Exists";
}
} catch (Exception e) {
//Log
} finally {
try {
if (img_objid_qry != null) {
System.Runtime.InteropServices.Marshal.ReleaseComObject(img_objid_qry);
img_objid_qry = null;
}
if (imgobjid_coll != null) {
System.Runtime.InteropServices.Marshal.ReleaseComObject(imgobjid_coll);
imgobjid_coll = null;
}
} catch (Exception e) {
//Log
}
}
return flag;
}
------------------------------------------------------------------------------------------------------