Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

Plugin Update downloading current entity Reports cause time our error

$
0
0

Hi ,

I am troubleshooting with this issue from a week. i tried to post the issue through other sites i dint get any response.. please respond to my issue,

My task is to download the report and save to local file.

initially i created plugin on workorder entty for Update step. I have Report which  need to download and save the report by Form ID. In my report Prompt parameter is Entity ID. when am rendering the report though current Entity ID it gives time out exception.  if i hard code different form id through parameter value its rendering report bytes when i refer dynamical form id its giving channel time out exception.

I tried to trace report parameters value..its referring to right values but its throwing timeout exception..any one know the reason to time out  for current form id.. i tried to set the time out for 5 minuts..after 5 minutes its thworing the error by saying increase sendtimeout value.. :(

My error,

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: The request channel timed out while waiting for a reply after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.The HTTP request to 'http://xxxx/ReportServer/ReportExecution2005.asmx' has exceeded the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout.
Server stack trace: 
   at System.ServiceModel.Channels.RequestChannel.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.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)<KeyValuePairOfstringanyType><d2p1:key>OperationStatus</d2p1:key><d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">0</d2p1:value></KeyValuePairOfstringanyType></ErrorDetails><Message>The request channel timed out while waiting for a reply after 00:01:00. Increase the timeout value passed to the call to Request or increase the SendTimeout value on the Binding. The time allotted to this operation may have been a portion of a longer timeout.The HTTP request to 'http://xxxx/ReportServer/ReportExecution2005.asmx' has exceeded the allotted timeout of 00:01:00. The time allotted to this operation may have been a portion of a longer timeout.
Server stack trace: 
   at System.ServiceModel.Channels.RequestChannel.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.ServiceChannelProxy.InvokeService(IMethodCallMessage methodCall, ProxyOperationRuntime operation)
   at System.ServiceModel.Channels.ServiceChannelProxy.Invoke(IMessage message)


Since its giving timeout exception for cureent form id i started working with diffrent approach.

I created another plugin on CustomEntity On Create  download the report by reading workorder id from custom entity new field. 

My first plugin Work order Update creating new record through custom entity. when am calling through first plugin i could see its creating new record through custom enity , form loads for a while and throwing error 'Need to start a transaction before commit'. when workorderform realods newly created record deleted from custom entity. why..?

Error,

Unhandled Exception: System.ServiceModel.FaultException`1[[Microsoft.Xrm.Sdk.OrganizationServiceFault, Microsoft.Xrm.Sdk, Version=5.0.0.0, Culture=neutral, PublicKeyToken=31bf3856ad364e35]]: Need to start a transaction before commitDetail: <OrganizationServiceFault xmlns:i="http://www.w3.org/2001/XMLSchema-instance" xmlns="http://schemas.microsoft.com/xrm/2011/Contracts"><ErrorCode>-2147220911</ErrorCode><ErrorDetails xmlns:d2p1="http://schemas.datacontract.org/2004/07/System.Collections.Generic"><KeyValuePairOfstringanyType><d2p1:key>CallStack</d2p1:key><d2p1:value xmlns:d4p1="http://www.w3.org/2001/XMLSchema" i:type="d4p1:string">   at Microsoft.Crm.Extensibility.VersionedPluginProxyStepBase.Execute(PipelineExecutionContext context)
   at Microsoft.Crm.Extensibility.Pipeline.Execute(PipelineExecutionContext context)
   at Microsoft.Crm.Extensibility.MessageProcessor.Execute(PipelineExecutionContext context)
   at Microsoft.Crm.Extensibility.InternalMessageDispatcher.Execute(PipelineExecutionContext context)
   at Microsoft.Crm.Extensibility.ExternalMessageDispatcher.ExecuteInternal(IInProcessOrganizationServiceFactory serviceFactory, IPlatformMessageDispatcherFactory dispatcherFactory, String messageName, String requestName, Int32 primaryObjectTypeCode, Int32 secondaryObjectTypeCode, ParameterCollection fields, CorrelationToken correlationToken, CallerOriginToken originToken, UserAuth userAuth, Guid callerId, Guid transactionContextId, Int32 invocationSource, Nullable`1 requestId, Version endpointVersion)
   at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.ExecuteRequest(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType)
   at Microsoft.Crm.Extensibility.OrganizationSdkServiceInternal.Execute(OrganizationRequest request, CorrelationToken correlationToken, CallerOriginToken callerOriginToken, WebServiceType serviceType)</d2p1:value></KeyValuePairOfstringanyType></ErrorDetails><Message>Need to start a transaction before commit</Message><Timestamp>2013-07-23T21:12:33.0259135Z</Timestamp><InnerFault i:nil="true" /><TraceText i:nil="true" /></OrganizationServiceFault>

My code for 1st plug in,

 public void Execute(IServiceProvider serviceProvider)
        {
            IPluginExecutionContext context = (IPluginExecutionContext)
            serviceProvider.GetService(typeof(IPluginExecutionContext));
            Entity entity;
            ITracingService TracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
            // Check if the input parameters property bag contains a target
            // of the create operation and that target is of type Entity.
            if (context.InputParameters.Contains("Target") &&
            context.InputParameters["Target"] is Entity)
            {
                // Obtain the target business entity from the input parameters.
                entity = (Entity)context.InputParameters["Target"];
                // Verify that the entity represents a contact.
                if (entity.LogicalName != "new_workorder") { return; }
            }
            else
            {
                return;
            }
            try
            {
                TracingService.Trace("loading service factory");
                IOrganizationServiceFactory serviceFactory =
                    (IOrganizationServiceFactory)serviceProvider.GetService(
                typeof(IOrganizationServiceFactory));
                IOrganizationService service =
                serviceFactory.CreateOrganizationService(context.UserId);
                var id = entity.Id;
                var crmContext = new XrmServiceContext(service);               
                var contact1 = crmContext.New_WorkOrderSet.Where(w => w.New_WorkOrderId == id).First();
                new_esignature esign = new new_esignature();//custom entity
                if (!string.IsNullOrEmpty(contact1.new_inpersonsigninglinks) && !string.IsNullOrEmpty(contact1.new_EmailSigningLinks))
                {
                    TracingService.Trace("Creating new record  new_esignature");
                    esign.new_WorkOrderID = id.ToString();
                    crmContext.Create(esign);
                }
            }

second plugin,

  public void Execute(IServiceProvider serviceProvider)
        {
            IPluginExecutionContext context = (IPluginExecutionContext)
            serviceProvider.GetService(typeof(IPluginExecutionContext));
            Entity entity;
            ITracingService TracingService = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
            // Check if the input parameters property bag contains a target
            // of the create operation and that target is of type Entity.
            if (context.InputParameters.Contains("Target") &&
            context.InputParameters["Target"] is Entity)
            {
                // Obtain the target business entity from the input parameters.
                entity = (Entity)context.InputParameters["Target"];
                // Verify that the entity represents a work order.
               // if (entity.LogicalName != "new_workorder") { return; }
                //new
                if (entity.LogicalName != "new_esignature") { return; }
            }
            else
            {
                return;
            }
            try
            {
                TracingService.Trace("loading service factory");
                IOrganizationServiceFactory serviceFactory =
                    (IOrganizationServiceFactory)serviceProvider.GetService(
                typeof(IOrganizationServiceFactory));
                TracingService.Trace("generating organization service from factory");
                IOrganizationService service =
                serviceFactory.CreateOrganizationService(context.UserId);
 var crmContext = new XrmServiceContext(service);        
                var contact1 = crmContext.new_esignatureSet.Where(w => w.new_esignatureId == esignid).First();
                string workorderid = contact1.new_WorkOrderID;
CreateReportPDF(sFilepath, workorderid.ToString(), id, ref TracingService);

Can anyone suggest me best approach??


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>