Esempio n. 1
0
        private void ReadRequest(RequestExecutionContext context)
        {
            Serializer.MergeWithLengthPrefix(context.RequestMessage.Stream, context.Request, PrefixStyle.Base128);

            if (context.Request.PrepareOnly)
            {
                // prevent any ambiguities
                context.Request.ReturnDataset = false;
            }

            if (context.Request.HaveParameters)
            {
                context.ParsedRequest.HaveParametersDataInput = true;
                Serializer.MergeWithLengthPrefix(context.RequestMessage.Stream, context.RequestParameters, PrefixStyle.Base128);
                ReadParametersDataInput(context);
            }

            if (context.Request.HaveRequestBulk)
            {
                context.ParsedRequest.IsBulk = true;
                Serializer.MergeWithLengthPrefix(context.RequestMessage.Stream, context.RequestBulk, PrefixStyle.Base128);

                // after this point in stream, bulk input data will be read by instance of InputDataStreamEnumerator
                // e.g. we're not yet done reading the request stream here
            }

            if (m_tracer.IsInfoEnabled)
            {
                var cmdText = context.Request.CommandText;
                if (string.IsNullOrEmpty(cmdText) && context.Request.HaveRequestBulk)
                {
                    cmdText = string.Format("Bulk {0} with {2} items on {1}", context.RequestBulk.DbStatementType, context.RequestBulk.EntityName, context.RequestBulk.InputItemsCount);
                }

                m_tracer.Info("Received command: " + cmdText);
            }

            // bring up cache record
            var cacheKey  = ParsedRequestCache.GetRequestHash(context.Request, context.RequestBulk, context.RequestParameters);
            var cacheInfo = m_parsedRequestCache.AddOrGetExisting(cacheKey, context.Request.HaveParameters);

            context.AttachCachedInfo(cacheInfo);

            // populate cache record
            if (!cacheInfo.HaveRequestHeaders)
            {
                lock (cacheInfo)
                {
                    cacheInfo.CheckIsError();
                    if (!cacheInfo.HaveRequestHeaders)
                    {
                        cacheInfo.ReadRequestHeaders(context.Request, context.RequestParameters, context.RequestBulk, context.ParsedRequest);
                    }
                }
            }
        }