CODE:
________________________________________________________________________________________________________
using System;
using System.Data;
using System.Configuration;
using System.Collections;
using System.Web;
using System.Web.Security;
using System.Web.UI;
//using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.Text.RegularExpressions;
/DFS Dll References/
using Emc.Documentum.FS.DataModel.Core.Query;
using Emc.Documentum.FS.DataModel.CI;
using Emc.Documentum.FS.DataModel.Core;
using Emc.Documentum.FS.DataModel.Core.Properties;
using Emc.Documentum.FS.DataModel.Core.Context;
using Emc.Documentum.FS.DataModel.Core.Content;
using Emc.Documentum.FS.DataModel.Core.Profiles;
using Emc.Documentum.FS.DataModel.Core.Acl;
using Emc.Documentum.FS.Runtime;
using Emc.Documentum.FS.Runtime.Context;
using Emc.Documentum.FS.Services.Core;
/============================/
using System.Collections.Generic;
using System.Collections.ObjectModel;
using System.IO;
public partial class Default : System.Web.UI.Page</p><p>{</p><p> #region "Add Section"</p><p> </p><p> string RepositoryName = ConfigurationManager.AppSettings["RepositoryName"].ToString();</p><p> string ModuleName = ConfigurationManager.AppSettings["ModuleName"].ToString();</p><p> string Address = ConfigurationManager.AppSettings["Address"].ToString();</p><p> string userName = ConfigurationManager.AppSettings["UserName"].ToString();</p><p> string password = ConfigurationManager.AppSettings["password"].ToString();</p><p> #endregion</p><p> </p><p> protected void PageLoad(object sender, EventArgs e)
{
Label1.Text = HttpContext.Current.Request.UserHostAddress.ToString();
string r_object_id = string.Empty;
string r_PolicyNo = string.Empty;
string queryString = string.Empty;
string PANCard = string.Empty;
string Signature = string.Empty;
string Photo = string.Empty;
string License = string.Empty;
string IDCard = string.Empty;
// http://10.126.142.25/DCTMView/Default.aspx?PANCard@r_advisor_code=21349215
//QualificationString = "rli_advisor_licensing where name like '21349215_PANCard%' order by r_creation_date asc enable(return_top 1)";
//http://10.126.142.25/DCTMView/Default.aspx?Signature@r_advisor_code=21349215
//QualificationString = "rli_advisor_licensing where name like '21349215_PANCard%' order by r_creation_date asc enable(return_top 1)";
//http://10.126.142.25/DCTMView/Default.aspx?Photo@r_advisor_code=21349215
//QualificationString = "rli_advisor_licensing where name like '21349215_Signature%' order by r_creation_date asc enable(return_top 1)";
//http://10.126.142.25/DCTMView/Default.aspx?License@r_advisor_code=21349215
//QualificationString = "rli_advisor_licensing where name like '21349215_License%' order by r_creation_date asc enable(return_top 1)";
//http://10.126.142.25/DCTMView/Default.aspx?IDCard@r_advisor_code=21349215
//QualificationString = "rli_advisor_licensing where name like '21349215_IDCard%' order by r_creation_date asc enable(return_top 1)";
try
{
if (bool.Parse(ConfigurationManager.AppSettings["DCTMFlag"].ToString()) == true)
{
divErrMsg.InnerText = ConfigurationManager.AppSettings["DCTMMsg"].ToString();
return;
}
if (Request.QueryString["ObjectId"] != null)
r_object_id = Request.QueryString["ObjectId"].ToString();
else if (Request.QueryString["PolicyNo"] != null)
r_PolicyNo = Request.QueryString["PolicyNo"].ToString();
else if (Request.QueryString["PANCard@r_advisor_code"] != null)
PANCard = Request.QueryString["PANCard@r_advisor_code"].ToString();
else if (Request.QueryString["Signature@r_advisor_code"] != null)
Signature = Request.QueryString["Signature@r_advisor_code"].ToString();
else if (Request.QueryString["Photo@r_advisor_code"] != null)
Photo = Request.QueryString["Photo@r_advisor_code"].ToString();
else if (Request.QueryString["License@r_advisor_code"] != null)
License = Request.QueryString["License@r_advisor_code"].ToString();
else if (Request.QueryString["IDCard@r_advisor_code"] != null)
IDCard = Request.QueryString["IDCard@r_advisor_code"].ToString();
else
throw new Exception("ObjectId is not present for Current transaction");
#region "Add Section(Create a repository identity to store repository credentials on the service context)"
ContextFactory contextFactory = ContextFactory.Instance;
IServiceContext ServiceContext = contextFactory.NewContext();
//IQueryService QueryService = contextFactory.NewContext();
RepositoryIdentity repoId = new RepositoryIdentity();
repoId.RepositoryName = RepositoryName;
repoId.UserName = userName;
repoId.Password = password;
ServiceContext.AddIdentity(repoId);
#endregion
//string DocURL = null;
#region "DEFINE object identity with r_object_id and CREATE object service"
ObjectIdentity objectIdentity = new ObjectIdentity(RepositoryName);
ServiceFactory serviceFactory = ServiceFactory.Instance;
IObjectService objectService = serviceFactory.GetRemoteService<IObjectService>(ServiceContext, ModuleName, Address);
string QualificationString = String.Empty;
if (r_object_id != string.Empty)
QualificationString = "dm_document where r_object_id = '" + r_object_id + "'";
else if (r_PolicyNo != string.Empty)
QualificationString = "rli_newbusiness where pf_contract_no ='" + r_PolicyNo + "' order by r_creation_date asc enable(return_top 1)";
else if (PANCard != string.Empty)
QualificationString = "rli_advisor_licensing where object_name like '" + PANCard + "_PANCard%' order by r_creation_date asc enable(return_top 1)";
else if (Signature != string.Empty)
QualificationString = "rli_advisor_licensing where object_name like '" + Signature + "_signature%' order by r_creation_date asc enable(return_top 1)";
else if (Photo != string.Empty)
QualificationString = "rli_advisor_licensing where object_name like '" + Photo + "_photo%' order by r_creation_date asc enable(return_top 1)";
else if (License != string.Empty)
QualificationString = "rli_advisor_licensing where object_name like '" + License + "_License%' order by r_creation_date asc enable(return_top 1)";
else if (IDCard != string.Empty)
QualificationString = "rli_advisor_licensing where object_name like '" + IDCard + "_IDCard%' order by r_creation_date asc enable(return_top 1)";
Qualification qualification = new Qualification(QualificationString);
ObjectIdentity targetObjectIdentity = new ObjectIdentity(qualification, RepositoryName);
ObjectIdentitySet objectIdentitySet = new ObjectIdentitySet(targetObjectIdentity);
#endregion
/====CONFIGURE properties to retrieve================/
OperationOptions operationOption = new OperationOptions();
#region "Add Section(CONFIGURE content transfer profile and mode)"
ContentProfile cProfile = operationOption.ContentProfile;
cProfile.FormatFilter = FormatFilter.ANY;
operationOption.ContentProfile = cProfile;
ContentTransferProfile tProfile = operationOption.ContentTransferProfile;
tProfile.TransferMode = ContentTransferMode.BASE64;
operationOption.ContentTransferProfile = tProfile;
#endregion
operationOption.SetProfile(cProfile);
///QueryResult
//string query = "select * from " + QualificationString + " ;";
//QueryExecution queexe = new QueryExecution();
//Query q = new qu
//DataTable dt = QueryService.Execute(query, queexe, operationOption);
/=========================================/
#region "RETRIEVE documents from Datapackages and get the file"
DataPackage dataPackage = new DataPackage();
//objectService.Validate(dataPackage);
dataPackage = objectService.Get(objectIdentitySet, operationOption);
List<DataObject> dataObjects = dataPackage.DataObjects;
int numberOfObjects = dataObjects.Count;
foreach (DataObject dObj in dataObjects)
{
try
{
PropertySet docProperties = dObj.Properties;
String objectId = dObj.Identity.GetValueAsString();
String docName = docProperties.Get("object_name").GetValueAsString();
int content = dObj.Contents.Count;
List<Content> contentList = dObj.Contents;
string strFormat = string.Empty;
string strFilName = string.Empty;
string StrDestPath = @"" + ConfigurationManager.AppSettings["DestFolder"].ToString();
//Response.Write(StrDestPath);
foreach (Content c in contentList)
{
strFormat = c.Format;
FileInfo f = c.GetAsFile();
strFilName = f.Name; // + "." + docName;
//if (r_PolicyNo != string.Empty || c.Format == "pdf")
if (r_PolicyNo != string.Empty || c.Format == "pdf" || c.Format == "html")
strFilName = strFilName + "." + c.Format;
// Response.Write(f.FullName);
//Response.Write("-"c.Format"--");
// Response.Write(f.Name + "." + docName);
strFilName = strFilName.Replace("/", "-");
//Response.Write(strFilName);
//Response.End();
f.CopyTo(StrDestPath + "" + strFilName);
string strpath = f.FullName;
f.Delete();
Response.Redirect(ConfigurationManager.AppSettings["URLPath"].ToString() + strFilName);
#region "Commented(Could be useful in any future changes)"
//Response.Write("<
br>path is...="+f.DirectoryName);
//Response.Write("<
br>(" + f.Length + ") " + f.DirectoryName +
// " format=" + c.Format);
#endregion
}
#region "Alternative Solution but doesn't Work"
//List<Content> contentList = dObj.Contents;
//UrlContent urlString = (UrlContent)dObj.Contents[0];
//DocURL = urlString.Url.ToString();
#endregion
}
catch (Exception ex)
{
//Response.Write(ex.ToString());
//Response.Write("hiiiiiiiiiii");
///ex.
// divErrMsg.InnerHtml = ex.Message;
divErrMsg.InnerHtml = ex.ToString();
}
}
#endregion
}
//catch (DfcOperationException exd)
//{
// Response.Write("HiiiTop");
//}
catch (Emc.Documentum.FS.Runtime.ServiceInvocationException ext)
{
//Response.Write(ext.);
//Response.Write("hello ameya :::: " + ext.ToString());
string erro1 = "System.ServiceModel.FaultException: Operation output generation failed: could not retrieve data";
if (ext.ToString().ToLower().Contains(erro1.ToString().ToLower()))
{
divErrMsg.InnerHtml = "Unable to find/retirve document..";
}
else
{
divErrMsg.InnerHtml = ext.ToString();
}
}
catch (Exception ex1)
{
//Response.Write(ex1.ToString());
divErrMsg.InnerHtml = ex1.ToString();
// Display the exception's data dictionary.
}
}
}
___________________________________________________________________________________________________________________________
<span style="text-decoration: underline;" mcestyle="text-decoration: underline;">Error:
<p id="divErrMsg" style="font-size: 20px; color: red; font-family: Verdana;" mcestyle="font-size: 20px; color: red; font-family: Verdana;">Emc.Documentum.FS.Runtime.ServiceInvocationException: Service method "Get" invocation failed. ---> System.ServiceModel.CommunicationException: The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. ---> System.ServiceModel.QuotaExceededException: The maximum message size quota for incoming messages (65536) has been exceeded. To increase the quota, use the MaxReceivedMessageSize property on the appropriate binding element. --- End of inner exception stack trace --- Server stack trace: at System.ServiceModel.Channels.MessageEncoder.BufferMessageStream(Stream stream, BufferManager bufferManager, Int32 maxBufferSize) at System.ServiceModel.Channels.MessageEncoder.ReadMessage(Stream stream, BufferManager bufferManager, Int32 maxBufferSize, String contentType) at System.ServiceModel.Channels.HttpInput.ReadChunkedBufferedMessage(Stream inputStream) at System.ServiceModel.Channels.HttpInput.ParseIncomingMessage(Exception& requestException) at System.ServiceModel.Channels.HttpChannelFactory.HttpRequestChannel.HttpChannelRequest.WaitForReply(TimeSpan timeout) at System.ServiceModel.Channels.RequestChannel.Request(Message message, TimeSpan timeout) at System.ServiceModel.Dispatcher.RequestChannelBinder.Request(Message message, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs, TimeSpan timeout) at System.ServiceModel.Channels.ServiceChannel.Call(String action, Boolean oneway, ProxyOperationRuntime operation, Object[] ins, Object[] outs) at System.ServiceModel.Channels.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation) at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message) Exception rethrown at : at System.Runtime.Remoting.Proxies.RealProxy.HandleReturnMessage(IMessage reqMsg, IMessage retMsg) at System.Runtime.Remoting.Proxies.RealProxy.PrivateInvoke(MessageData& msgData, Int32 type) at Emc.Documentum.FS.Services.Core.ObjectServicePort.get(getRequest request) at Emc.Documentum.FS.Services.Core.ObjectServicePortClient.Emc.Documentum.FS.Services.Core.ObjectServicePort.get(getRequest request) at Emc.Documentum.FS.Services.Core.ObjectServicePortClient.Get(ObjectIdentitySet forObjects, OperationOptions options) --- End of inner exception stack trace --- at Emc.Documentum.FS.Runtime.Context.Impl.ClientReflectionServiceInvoker.Invoke(Object proxy, MethodInfo method, Object[] args) at Emc.Documentum.FS.Runtime.Context.Impl.SoapClientInvocationHandler.Invoke(Object proxy, MethodInfo method, Object[] arguments) at Emc.Documentum.FS.Runtime.Context.Impl.UcfClientInvocationHandler.Invoke(Object proxy, MethodInfo method, Object[] args) at Emc.Documentum.FS.Runtime.Context.Impl.HttpSessionInvocationHandler.Invoke(Object proxy, MethodInfo method, Object[] args) at Emc.Documentum.FS.Runtime.Context.Impl.ContextThreadLocalInvocationHandler.Invoke(Object proxy, MethodInfo method, Object[] args) at Emc.Documentum.FS.Runtime.Context.Impl.ReturnedContentTransformationHandler.Invoke(Object proxy, MethodInfo method, Object[] args) at Emc.Documentum.FS.Runtime.Context.Impl.ServiceContextInvocationHandler.Invoke(Object proxy, MethodInfo method, Object[] args) at $Proxy0.Emc.Documentum.FS.Services.Core.IObjectService.Get(ObjectIdentitySet , OperationOptions ) at Default.PageLoad(Object sender, EventArgs e) in c:\DCTMV\Testweb1\Default.aspx.cs:line 166
<br></p>