예제 #1
0
        public void Execute(IServiceProvider serviceProvider)
        {
            ITracingService             tracer  = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
            IPluginExecutionContext     context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
            IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
            IOrganizationService        service = factory.CreateOrganizationService(context.UserId);

            QueryExpression      query              = context.InputParameterOrDefault <QueryExpression>("Query");
            var                  metadataHelper     = new MetadataHelper(service, query.EntityName);
            IOrganizationService externalCrmService = ExternalD365ServiceHelper.GetOrgWebProxyClient(service, metadataHelper.GetDatasourceId());

            var externalResults = externalCrmService.RetrieveMultiple(Mapper.MapQuery(metadataHelper, query));
            var results         = Mapper.MapExternalResults(metadataHelper, externalResults);

            context.OutputParameters["BusinessEntityCollection"] = results;
        }
예제 #2
0
        public void Execute(IServiceProvider serviceProvider)
        {
            ITracingService             tracer  = (ITracingService)serviceProvider.GetService(typeof(ITracingService));
            IPluginExecutionContext     context = (IPluginExecutionContext)serviceProvider.GetService(typeof(IPluginExecutionContext));
            IOrganizationServiceFactory factory = (IOrganizationServiceFactory)serviceProvider.GetService(typeof(IOrganizationServiceFactory));
            IOrganizationService        service = factory.CreateOrganizationService(context.UserId);

            EntityReference      target             = (EntityReference)context.InputParameters["Target"];
            ColumnSet            entityCols         = (ColumnSet)context.InputParameters["ColumnSet"];
            var                  metadataHelper     = new MetadataHelper(service, target.LogicalName);
            IOrganizationService externalCrmService = ExternalD365ServiceHelper.GetOrgWebProxyClient(service, metadataHelper.GetDatasourceId());

            if (entityCols != null)
            {
                entityCols = Mapper.MapColumnSet(metadataHelper, entityCols);
            }

            var externalResult = externalCrmService.Retrieve(metadataHelper.GetExternalEntityName(), target.Id, entityCols);
            var result         = Mapper.MapExternalResult(metadataHelper, externalResult);

            context.OutputParameters["BusinessEntity"] = result;
        }