コード例 #1
0
        public Request CreatePayloadRequest(int sessionId, byte[] token)
        {
            CommandPayloadQuery payload = new CommandPayloadQuery();

            payload.Text         = _sqlString;
            payload.NonTextLimit = -1;
            payload.FetchPlan    = _fetchPlan;

            Request request = new Request(OperationMode.Synchronous, sessionId);

            //base.Request(request);

            request.AddDataItem((byte)OperationType.COMMAND);
            request.AddDataItem(request.SessionId);

            if (DriverConstants.ProtocolVersion > 26 && _metaData.UseTokenBasedSession)
            {
                request.AddDataItem(token);
            }

            // operation specific fields
            request.AddDataItem((byte)request.OperationMode);

            // idempotent command (e.g. select)
            var queryPayload = payload;

            if (queryPayload != null)
            {
                // Write command payload length
                request.AddDataItem(queryPayload.PayLoadLength);
                request.AddDataItem(queryPayload.ClassName);
                //(text:string)(non-text-limit:int)[(fetch-plan:string)](serialized-params:bytes[])
                request.AddDataItem(queryPayload.Text);
                request.AddDataItem(queryPayload.NonTextLimit);
                request.AddDataItem(queryPayload.FetchPlan);

                if (queryPayload.SerializedParams == null || queryPayload.SerializedParams.Length == 0)
                {
                    request.AddDataItem((int)0);
                }
                else
                {
                    request.AddDataItem(queryPayload.SerializedParams);
                }
                return(request);
            }
            // @todo Fix this to a better domain exception.
            throw new Exception("Need to fix this");
        }
コード例 #2
0
        public Request CreatePayloadRequest(int sessionId, byte[] token)
        {
            //DictionaryOrientDBEntity paramsEntity = new DictionaryOrientDBEntity();
            //paramsEntity.SetField("params", _parameters as Dictionary<string, object>);

            CommandPayloadQuery payload = new CommandPayloadQuery();

            payload.Text         = _sqlString;
            payload.NonTextLimit = -1;
            payload.FetchPlan    = _fetchPlan;
            var paramsDictionary = new Dictionary <string, object>();

            for (var i = 0; i < _parameters.Length; i++)
            {
                paramsDictionary.Add(i.ToString(), _parameters[i]);
            }
            var pe = new ParametersEntity()
            {
                parameters = paramsDictionary
            };

            pe.OClassName            = string.Empty;
            payload.SerializedParams = _serializer.Serialize(pe);

            Request request = new Request(OperationMode.Synchronous, sessionId);

            //base.Request(request);

            request.AddDataItem((byte)OperationType.COMMAND);
            request.AddDataItem(request.SessionId);

            if (DriverConstants.ProtocolVersion > 26 && _metaData.UseTokenBasedSession)
            {
                request.AddDataItem(token);
            }

            // operation specific fields
            request.AddDataItem((byte)request.OperationMode);

            // idempotent command (e.g. select)
            var queryPayload = payload;

            if (queryPayload != null)
            {
                // Write command payload length
                request.AddDataItem(queryPayload.PayLoadLength);
                request.AddDataItem(queryPayload.ClassName);
                //(text:string)(non-text-limit:int)[(fetch-plan:string)](serialized-params:bytes[])
                request.AddDataItem(queryPayload.Text);
                request.AddDataItem(queryPayload.NonTextLimit);
                request.AddDataItem(queryPayload.FetchPlan);

                if (queryPayload.SerializedParams == null || queryPayload.SerializedParams.Length == 0)
                {
                    request.AddDataItem((int)0);
                }
                else
                {
                    request.AddDataItem(queryPayload.SerializedParams);
                }
                return(request);
            }
            // @todo Fix this to a better domain exception.
            throw new Exception("Need to fix this");
        }