Vous êtes sur la page 1sur 5

1. First you need to create the Library Object.

2. Get the Session Manager.


3. Set the SessionManager to the Library Object.
4. Login to IS Library.
5. Create the LogonID Manager object using IDMWEBUTLib.CoIDMWebLogonIDManager
6. Add the Library.LogonID to the LogonIDManager.
7. View the Document using Docview.aspx.
8. Make sure you are using correct DocContent.dll. This gets installed if you install either
IDMWebServices or OpenClient.
Here is the code snippet in C# I am using:
public bool Logon(string userName, string password, string domainName, ref string errMsg)
{
IDMObjects.Neighborhood fnNeighborhood = null;
IDMObjects.Library fnLibrary = null;
bool isLoginOk = false;
try
{
// IDM COM objects declarations
fnNeighborhood = new IDMObjects.Neighborhood();
fnLibrary = null;
fnNeighborhood.UserConfiguration = IDMObjects.idmUsers.idmUsersAll;
// Check if the Library exists with this Domain Name
foreach (IDMObjects.Library fnLib in fnNeighborhood.Libraries)
{
int pos = fnLib.Name.IndexOf(domainName);
if ((fnLib.Name.IndexOf(domainName) > 0 || fnLib.Name == domainName) &&
fnLib.SystemType == IDMObjects.idmSysTypeOptions.idmSysTypeIS)
{
fnLibrary = fnLib;
break;
}
}
if (fnLibrary == null)
{
errMsg = "IDM Library is not defined for the Domain " + domainName;
return isLoginOk;
}
isLoginOk = fnLibrary.GetState(IDMObjects.idmLibraryState.idmLibraryLoggedOn);
if (isLoginOk == true)
{
fnLibrary.Logoff();
}
IDMObjects.SessionManager idmSessionManager = (IDMObjects.SessionManager)
HttpContext.Current.Application["SessionManager"];
fnLibrary.SessionManager = idmSessionManager;
isLoginOk = fnLibrary.Logon(userName, password, "",
IDMObjects.idmLibraryLogon.idmLogonOptNoUI);
if (isLoginOk == true)
{

object logonId = fnLibrary.LogonId;


HttpContext.Current.Session.Add("LogonId", logonId.ToString());
HttpContext.Current.Session.Add("Library", fnLibrary.Name);
HttpContext.Current.Session.Add("UserName", userName);
HttpContext.Current.Session.Add("Password", password);
// Create the Logon ID Manager Collection
IDMWEBUTLib.CoIDMWebLogonIDManager idmLogonIdMgr = new
IDMWEBUTLib.CoIDMWebLogonIDManagerClass();
//
string lidCookie = idmLogonIdMgr.InitLIDCollection().ToString();
HttpContext.Current.Session.Add("LogonIDManager", idmLogonIdMgr);
HttpContext.Current.Session.Add("LogonIDManagerCookie", lidCookie);
idmLogonIdMgr.AddLogonID(logonId, fnLibrary.Name);
System.Web.HttpCookie idmContentCookie = new
System.Web.HttpCookie("LogonIDManagerCookie", lidCookie);
HttpContext.Current.Response.Cookies.Add(idmContentCookie);
}
return isLoginOk;
}
catch(Exception exception)
{
errMsg = exception.Message;
return isLoginOk;
}
finally
{
if (fnNeighborhood != null) Marshal.ReleaseComObject(fnNeighborhood);
if (fnLibrary != null) Marshal.ReleaseComObject(fnLibrary);
}
}
public void Logout()
{
try
{
IDMWEBUTLib.CoIDMWebLogonIDManager logonIDMgr =
(IDMWEBUTLib.CoIDMWebLogonIDManager)
HttpContext.Current.Session["LogonIDManager"];
string logonId = HttpContext.Current.Session["LogonId"].ToString();
logonIDMgr.RemoveLogonID(logonId);
Marshal.ReleaseComObject(logonIDMgr);
}
catch(Exception exception)
{
string errMsg = exception.Message;
}
}

This is the code in DocView.aspx


using System;
using System.Collections;

using
using
using
using
using
using
using
using

System.ComponentModel;
System.Data;
System.Drawing;
System.Web;
System.Web.SessionState;
System.Web.UI;
System.Web.UI.WebControls;
System.Web.UI.HtmlControls;

namespace WmsIDM
{
/// <summary>
/// Summary description for DocView.
/// </summary>
public class DocView : System.Web.UI.Page
{
private void Page_Load(object sender, System.EventArgs e)
{
try
{
// Parse Query string get the values
string libraryName = Request.QueryString["Library"];
int idmDocId = Convert.ToInt32(Request.QueryString["DocId"]);
short pageNum = Convert.ToInt16(Request.QueryString["Page"]);
if (pageNum <= 0) pageNum = 1;
string qryStr = Request.QueryString.ToString();
string
string
string
string

userName = (string) Request.QueryString["UserName"];


password = Request.QueryString["Password"];
idmWebServiceURL = Request.QueryString["IDMWebServiceURL"];
logonId = Request.QueryString["LogonId"];

// Create a new Library object and set the Logon Id.


// Setting the Logon Id to the Library object will inherit the library properties user has initially
logged on
IDMObjects.Library idmLibrary = new IDMObjects.Library();
idmLibrary.LogonId = logonId;
object genericIDMDoc =
idmLibrary.GetObject(IDMObjects.idmObjectType.idmObjTypeDocument, idmDocId, null, null,
null);
IDMObjects.IFnDocumentDual idmDocument = (IDMObjects.IFnDocumentDual)
genericIDMDoc;
IDMObjects.Document idmDoc = (IDMObjects.Document) idmDocument;
int pageCount = idmDocument.PageCount;
string idmDocFormat = "";
string idmDocLocation = "";
string aspSessionId = Request.QueryString["ASPSessionId"];;
aspSessionId = "ASPSESSIONID=" + aspSessionId + '\u000A';
string sessionCookie = "SESSIONCOOKIE=FileNET-Panagon-Web-Services=" +
Request.QueryString["SessionCookie"] + '\u000A';
try
{
IDMObjects.Properties idmDocProperties = idmDocument.Properties;

if (idmDocProperties != null)
{
idmDocFormat = idmDocProperties["F_DOCFORMAT"].Value.ToString() ;
idmDocLocation = idmDocProperties["F_DOCLOCATION"].Value.ToString();
}
}
catch(Exception propertyException)
{
string errMsg = propertyException.Message;
}
string fnWebNavigateVer = "FNWEBNAVIGATE=1.0" + '\u000A';
string applicationURL = "APPLICATIONURL=" + idmWebServiceURL + "/" + '\u000A';
string navigatorURL = "NAVIGATORURL=" + idmWebServiceURL + "/DocView.aspx" +
'\u000A';
string propertiesURL = "PROPERTIESURL=" + idmWebServiceURL +
"/AnnotationContent.aspx" + '\u000A';
string securityURL = "SECURITYURL=" + idmWebServiceURL + "/AnnoSecInfo.aspx" +
'\u000A';
libraryName = "LIBRARYNAME=" + libraryName + '\u000A';
string systemType = "SYSTEMTYPE=1" + '\u000A';
string docIdStr = "DOCUMENTID=" + idmDocId.ToString() + '\u000A';
string pageStr = "STARTPAGE=" + pageNum.ToString() + '\u000A';
string pageCountStr = "PAGECOUNT=" + pageCount.ToString() + '\u000A';
string docCanAnnotate = "false";
string logonIdStr = "LOGONID=" + logonId + '\u000A';
if (idmDocument.GetState(IDMObjects.idmDocState.idmDocCanAnnotate)) docCanAnnotate =
"true";
docCanAnnotate = "DOCSTATECANANNOTATE=" + docCanAnnotate + '\u000A';
// Get the Content URL. Not Sure of what to set????????????????????????
string contentQueryStr = "LogonId=" + logonId + "&DocId=" + idmDocId.ToString() +
"&Page=" + pageNum.ToString();
string contentURL = "CONTENTURL=" + idmWebServiceURL + "/DocContent.dll" + '\u000A';
Response.Expires = -1;
Response.ContentType = "application/x-FileNETNavigate";
Response.AppendHeader("Content-disposition", "filename=" + "DocView.fni" + ";");
Response.Write(fnWebNavigateVer);
Response.Write(applicationURL);
Response.Write(navigatorURL);
Response.Write(contentURL);
Response.Write(propertiesURL);
Response.Write(securityURL);
Response.Write(libraryName);
Response.Write(systemType);
Response.Write(docIdStr);
Response.Write(pageStr);
Response.Write(pageCountStr);
Response.Write(docCanAnnotate);
Response.Write(logonIdStr);
Response.Write(aspSessionId);
Response.Write(sessionCookie);
if (idmDocument !=

null)System.Runtime.InteropServices.Marshal.ReleaseComObject(idmDocument);
if (idmDoc != null)System.Runtime.InteropServices.Marshal.ReleaseComObject(idmDoc);
if (idmLibrary !=
null)System.Runtime.InteropServices.Marshal.ReleaseComObject(idmLibrary);
}
catch(Exception exception)
{
string errMsg = exception.Message;
Response.AddHeader("cache-control", "no-cache");
Response.AddHeader("Pragma", "no-cache");
Response.Status = "200 OK";
Response.ContentType = "text/HTML";
Response.Write(errMsg);
Response.End();
}
}
#region Web Form Designer generated code
override protected void OnInit(EventArgs e)
{
//
// CODEGEN: This call is required by the ASP.NET Web Form Designer.
//
InitializeComponent();
base.OnInit(e);
}
/// <summary>
/// Required method for Designer support - do not modify
/// the contents of this method with the code editor.
/// </summary>
private void InitializeComponent()
{
this.Load += new System.EventHandler(this.Page_Load);
}
#endregion
}
}

Vous aimerez peut-être aussi