Jonathan Ouellette 580e90f6a2 initial add
2022-09-27 14:10:30 -07:00

168 lines
5.8 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
//using DFClib.DfException;
//using DFCLib.DfId;
//using DFCLib.IDfId;
//using DFCLib.IDfList;
//using DFCLib.IDfLoginInfo;
//using DFCLib.IDfClient;
//using DFCLib.IDfDocument;
//using DFCLib.IDfSession;
//using DFCLib.IDfSessionManager;
//using DFCLib.DfClientX;
//using DFCLib.IDfClientX;
//using DFCLib.IDfFile;
//using DFCLib.IDfImportNode;
//using DFCLib.IDfImportOperation;
namespace Fab2ApprovalSystem.Misc
{
public class Documentum
{
//public static void Process(string m_fileName)
//{
// String username = "rkotian1";
// String password = "";
// String repoName = "globaldocudms";
// String filename = m_fileName; // for example {"C:\\devprog\\ECN12345.zip"};
// String destFldrId = "0c00359980061536";
// try
// {
// DFCLib.IDfSessionManager sessMgr = createSessionManager();
// addIdentity(sessMgr, username, password, repoName);
// importFiles(sessMgr, repoName, filename, destFldrId);
// }
// catch (Exception ex)
// {
// //string s = ex.InnerException.ToString();
// }
//}
///**
// * Imports a single file in the repository
// *
// */
//private static void importFiles(DFCLib.IDfSessionManager sessMgr, String repoName, String filename, String destFldrId)
//{
// DFCLib.IDfSession sess = null;
// try
// {
// DFCLib.IDfClientX clientX = new DFCLib.DfClientX();
// DFCLib.IDfImportOperation impOper = clientX.getImportOperation();
// //DFCLib.IDfId destId = new DfId(destFldrId);
// DFCLib.IDfId destId = clientX.getId(destFldrId);
// //This will import all files to a single destination.
// //To import each file to a different destination
// //set call this method on the import node.
// //impOper.setDestinationFolderId(destId);
// DFCLib.IDfFile localFile = clientX.getFile(filename);
// DFCLib.IDfImportNode impNode = (DFCLib.IDfImportNode)impOper.add(localFile);
// //You can set different destination ids here for each import node
// //This way files get imported to different destinations.
// impNode.setDestinationFolderId(destId);
// //set custom object type. If not called dm_document is used.
// impNode.setDocbaseObjectType("dp_text");
// int randomName = ((int)(new Random().Next(int.MinValue, int.MaxValue) * 100));
// //set custom object name.
// impNode.setNewObjectName(localFile.getName() + "" + randomName.ToString());
// //The import operation determines the file format.
// //It is also possible to explicitly set the format.
// //impNode.setFormat("");
// sess = sessMgr.getSession(repoName);
// impOper.setSession(sess);
// if (impOper.execute())
// {
// Console.WriteLine("Import Operation Succeeded");
// DFCLib.IDfList newObjLst = impOper.getNewObjects();
// for (int i = 0; i < newObjLst.getCount(); i++)
// {
// DFCLib.IDfDocument newObj = (DFCLib.IDfDocument)newObjLst.get(i);
// //you can set any custom/standard attr values on the document now
// //newObj.setString("my_attr","someValue");
// //newObj.save();
// Console.WriteLine("Created Object: " + newObj.getObjectId());
// }
// }
// else
// {
// Console.WriteLine("Import Operation Failed");
// DFCLib.IDfList errList = impOper.getErrors();
// for (int i = 0; i < errList.getCount(); i++)
// {
// DFCLib.IDfOperationError err = (DFCLib.IDfOperationError)errList.get(i);
// Console.WriteLine(err.getMessage());
// }
// }
// }
// finally
// {
// if (sess != null)
// {
// sessMgr.release(sess);
// }
// }
//}
///**
// * Creates a new session manager instance. The session manager does not have
// * any identities associated with it.
// * @return a new session manager object.
//*/
//private static DFCLib.IDfSessionManager createSessionManager()
//{
// DFCLib.IDfClientX clientX = new DFCLib.DfClientX();
// DFCLib.IDfClient localClient = clientX.getLocalClient();
// DFCLib.IDfSessionManager sessMgr = localClient.newSessionManager();
// return sessMgr;
//}
///**
// * Adds a new identity to the session manager.
// *
// */
//private static void addIdentity(DFCLib.IDfSessionManager sm, String username,
// String password, String repoName)
//{
// DFCLib.IDfClientX clientX = new DFCLib.DfClientX();
// DFCLib.IDfLoginInfo li = clientX.getLoginInfo();
// li.setUser(username);
// li.setPassword(password);
// // check if session manager already has an identity.
// // if yes, remove it.
// if (sm.hasIdentity(repoName))
// {
// sm.clearIdentity(repoName);
// }
// sm.setIdentity(repoName, li);
//}
}
}