Beispiel #1
0
        public string RetrieveMultiple(QueryBase query, long duration, bool cached, CacheItemTelemetry telemetry)
        {
            if (query == null)
            {
                return(GetActivityId());
            }

            var queryInfo        = string.Empty;
            var fetchExpression  = query as FetchExpression;
            var queryExpression  = query as QueryExpression;
            var queryByAttribute = query as QueryByAttribute;

            if (fetchExpression != null && fetchExpression.Query != null)
            {
                queryInfo = fetchExpression.Query;
            }

            if (queryExpression != null)
            {
                queryInfo = queryExpression.EntityName;
            }

            if (queryByAttribute != null)
            {
                queryInfo = queryByAttribute.EntityName;
            }

            WriteEventRetrieveMultiple(
                queryInfo,
                duration,
                cached,
                this.PortalUrl,
                this.PortalVersion,
                this.ProductionOrTrial,
                this.SessionId,
                this.ElapsedTime(),
                telemetry?.IsAllColumns ?? false,
                telemetry?.Caller.MemberName,
                telemetry?.Caller.SourceFilePath,
                telemetry?.Caller.SourceLineNumber ?? 0);

            return(GetActivityId());
        }
Beispiel #2
0
        public string Retrieve(string entityLogicalName, Guid entityId, ColumnSet columnSet, long duration, bool cached, CacheItemTelemetry telemetry)
        {
            var columns = string.Empty;

            if (columnSet != null && columnSet.Columns != null && columnSet.Columns.Count > 0)
            {
                columns = string.Join(";", columnSet.Columns.ToArray());
            }

            WriteEventRetrieve(
                entityLogicalName,
                entityId.ToString(),
                columns,
                duration,
                cached,
                this.PortalUrl,
                this.PortalVersion,
                this.ProductionOrTrial,
                this.SessionId,
                this.ElapsedTime(),
                telemetry?.IsAllColumns ?? false,
                telemetry?.Caller.MemberName,
                telemetry?.Caller.SourceFilePath,
                telemetry?.Caller.SourceLineNumber ?? 0);

            return(GetActivityId());
        }
Beispiel #3
0
        public string OrganizationRequest(OrganizationRequest request, long duration, bool cached, CacheItemTelemetry telemetry = null)
        {
            if (request == null)
            {
                return(GetActivityId());
            }

            var cachedRequest = request as CachedOrganizationRequest;

            if (cachedRequest != null)
            {
                return(this.OrganizationRequest(cachedRequest.Request, duration, cached, cachedRequest.Telemetry));
            }

            var retrieveMultiple = request as RetrieveMultipleRequest;

            if (retrieveMultiple != null)
            {
                return(RetrieveMultiple(retrieveMultiple.Query, duration, cached, telemetry));
            }

            var fetchMultiple = request as FetchMultipleRequest;

            if (fetchMultiple != null)
            {
                return(RetrieveMultiple(fetchMultiple.Query, duration, cached, telemetry));
            }

            var retrieveSingle = request as RetrieveSingleRequest;

            if (retrieveSingle != null)
            {
                return(RetrieveMultiple(retrieveSingle.Query, duration, cached, telemetry));
            }

            var retrieve = request as RetrieveRequest;

            if (retrieve != null && retrieve.Target != null)
            {
                return(Retrieve(retrieve.Target.LogicalName, retrieve.Target.Id, retrieve.ColumnSet, duration, cached, telemetry));
            }

            var create = request as CreateRequest;

            if (create != null && create.Target != null)
            {
                return(Create(new Entity(create.Target.LogicalName)
                {
                    Id = create.Target.Id
                }, duration));
            }

            var update = request as UpdateRequest;

            if (update != null && update.Target != null)
            {
                return(Update(new Entity(update.Target.LogicalName)
                {
                    Id = update.Target.Id
                }, duration));
            }

            var delete = request as DeleteRequest;

            if (delete != null && delete.Target != null)
            {
                return(Delete(delete.Target.LogicalName, delete.Target.Id, duration));
            }

            var associate = request as AssociateRequest;

            if (associate != null && associate.Target != null)
            {
                return(Associate(associate.Target.LogicalName, associate.Target.Id, associate.Relationship, associate.RelatedEntities, duration));
            }

            var disassociate = request as DisassociateRequest;

            if (disassociate != null && disassociate.Target != null)
            {
                return(Disassociate(disassociate.Target.LogicalName, disassociate.Target.Id, disassociate.Relationship, disassociate.RelatedEntities, duration));
            }

            WriteEventOrganizationRequest(
                request.RequestName,
                request.RequestId.HasValue ? request.RequestId.Value.ToString() : null,
                duration,
                cached,
                this.PortalUrl,
                this.PortalVersion,
                this.ProductionOrTrial,
                this.SessionId,
                this.ElapsedTime(),
                telemetry?.Caller.MemberName,
                telemetry?.Caller.SourceFilePath,
                telemetry?.Caller.SourceLineNumber ?? 0);

            return(GetActivityId());
        }