Exemplo n.º 1
0
        public object Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;
            DtoRecord record = new DtoRecord();

            if (response == null)
            {
                return record;
            }

            // operation specific fields
            PayloadStatus payloadStatus = (PayloadStatus)BinaryParser.ToByte(response.Data.Skip(offset).Take(1).ToArray());
            offset += 1;

            if (payloadStatus != PayloadStatus.NoRemainingRecords)
            {
                int contentLength = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                offset += 4;
                record.Content = response.Data.Skip(offset).Take(contentLength).ToArray();
                offset += contentLength;

                record.Version = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                offset += 4;

                record.Type = (ORecordType)BinaryParser.ToByte(response.Data.Skip(offset).Take(1).ToArray());
                offset += 1;
            }

            return record;
        }
Exemplo n.º 2
0
        public object Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;
            DtoDatabase database = new DtoDatabase();

            if (response == null)
            {
                return database;
            }

            // operation specific fields
            database.SessionID = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
            offset += 4;
            database.ClustersCount = BinaryParser.ToShort(response.Data.Skip(offset).Take(2).ToArray());
            offset += 2;

            if (database.ClustersCount > 0)
            {
                for (int i = 1; i <= database.ClustersCount; i++)
                {
                    OCluster cluster = new OCluster();

                    int clusterNameLength = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                    offset += 4;

                    cluster.Name = BinaryParser.ToString(response.Data.Skip(offset).Take(clusterNameLength).ToArray());
                    offset += clusterNameLength;

                    cluster.ID = BinaryParser.ToShort(response.Data.Skip(offset).Take(2).ToArray());
                    offset += 2;

                    int clusterTypeLength = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                    offset += 4;

                    string clusterName = BinaryParser.ToString(response.Data.Skip(offset).Take(clusterTypeLength).ToArray());
                    cluster.Type = (OClusterType)Enum.Parse(typeof(OClusterType), clusterName, true);
                    offset += clusterTypeLength;

                    cluster.DataSegmentID = BinaryParser.ToShort(response.Data.Skip(offset).Take(2).ToArray());
                    offset += 2;

                    database.Clusters.Add(cluster);
                }
            }

            int clusterConfigLength = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
            offset += 4;

            database.ClusterConfig = response.Data.Skip(offset).Take(clusterConfigLength).ToArray();
            offset += clusterConfigLength;

            return database;
        }
Exemplo n.º 3
0
        public object Response(Response response)
        {
            bool wasShutdownSuccessful = false;

            if (response == null)
            {
                return wasShutdownSuccessful;
            }

            if (response.Status == ResponseStatus.OK)
            {
                wasShutdownSuccessful = true;
            }

            return wasShutdownSuccessful;
        }
Exemplo n.º 4
0
        public object Response(Response response)
        {
            bool wasDatabaseClosed = false;

            if (response == null)
            {
                return wasDatabaseClosed;
            }

            if (response.Status == ResponseStatus.OK)
            {
                wasDatabaseClosed = true;
            }

            return wasDatabaseClosed;
        }
Exemplo n.º 5
0
        public object Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;
            long databaseRecordsCount = 0;

            if (response == null)
            {
                return databaseRecordsCount;
            }

            // operation specific fields
            databaseRecordsCount = BinaryParser.ToLong(response.Data.Skip(offset).Take(8).ToArray());
            offset += 8;

            return databaseRecordsCount;
        }
Exemplo n.º 6
0
        public object Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;
            byte deleteOnClientSide = 0;

            if (response == null)
            {
                return deleteOnClientSide;
            }

            // operation specific fields
            deleteOnClientSide = BinaryParser.ToByte(response.Data.Skip(offset).Take(1).ToArray());
            offset += 1;

            return deleteOnClientSide;
        }
Exemplo n.º 7
0
        public object Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;
            bool succeeded = false;

            if (response == null)
            {
                return succeeded;
            }

            // operation specific fields
            succeeded = BinaryParser.ToBoolean(response.Data.Skip(offset).Take(1).ToArray());
            offset += 1;

            return succeeded;
        }
Exemplo n.º 8
0
        public object Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;
            int sessionID = -1;

            if (response == null)
            {
                return sessionID;
            }

            // operation specific fields
            sessionID = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
            offset += 4;

            return sessionID;
        }
Exemplo n.º 9
0
        public object Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;
            short clusterID = 0;

            if (response == null)
            {
                return clusterID;
            }

            // operation specific fields
            clusterID = BinaryParser.ToShort(response.Data.Skip(offset).Take(2).ToArray());
            offset += 2;

            return clusterID;
        }
Exemplo n.º 10
0
        public object Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;

            bool deleteResult = false;

            if (response == null)
            {
                return deleteResult;
            }

            // operation specific fields
            deleteResult = BinaryParser.ToByte(response.Data.Skip(offset).Take(1).ToArray()) == 1 ? true : false;
            offset += 1;

            return deleteResult;
        }
Exemplo n.º 11
0
        public object Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;
            long[] dataRange = new long[2];

            if (response == null)
            {
                return dataRange;
            }

            // operation specific fields
            dataRange[0] = BinaryParser.ToLong(response.Data.Skip(offset).Take(8).ToArray());
            offset += 8;

            dataRange[1] = BinaryParser.ToLong(response.Data.Skip(offset).Take(8).ToArray());
            offset += 8;

            return dataRange;
        }
Exemplo n.º 12
0
        public object Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;
            DtoRecord record = new DtoRecord();
            record.ORID.ClusterID = ClusterID;

            if (response == null)
            {
                return record;
            }

            // operation specific fields
            record.ORID.ClusterPosition = BinaryParser.ToLong(response.Data.Skip(offset).Take(8).ToArray());
            offset += 8;

            record.Version = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
            offset += 4;

            return record;
        }
Exemplo n.º 13
0
        public object Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;
            bool databaseExist = false;

            if (response == null)
            {
                return databaseExist;
            }

            // operation specific fields
            byte existByte = BinaryParser.ToByte(response.Data.Skip(offset).Take(1).ToArray());
            offset += 1;

            if (existByte > 0)
            {
                databaseExist = true;
            }

            return databaseExist;
        }
Exemplo n.º 14
0
        public object Response(Response response)
        {
            // start from this position since standard fields (status, session ID) has been already parsed
            int offset = 5;
            DtoCommand command = new DtoCommand();

            if (response == null)
            {
                return command;
            }

            // operation specific fields
            command.PayloadStatus = (PayloadStatus)BinaryParser.ToByte(response.Data.Skip(offset).Take(1).ToArray());
            offset += 1;

            if (OperationMode == OperationMode.Asynchronous)
            {
                command.Content = new List<DtoRecord>();

                while (command.PayloadStatus != PayloadStatus.NoRemainingRecords)
                {
                    switch (command.PayloadStatus)
                    {
                        case PayloadStatus.ResultSet:
                            DtoRecord record = new DtoRecord();

                            int contentLength = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                            offset += 4;
                            record.Content = response.Data.Skip(offset).Take(contentLength).ToArray();
                            offset += contentLength;

                            record.Version = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                            offset += 4;

                            record.Type = (ORecordType)BinaryParser.ToByte(response.Data.Skip(offset).Take(1).ToArray());
                            offset += 1;

                            ((List<DtoRecord>)command.Content).Add(record);
                            break;
                        case PayloadStatus.PreFetched:
                            // TODO:
                            break;
                        default:
                            break;
                    }

                    command.PayloadStatus = (PayloadStatus)BinaryParser.ToByte(response.Data.Skip(offset).Take(1).ToArray());
                    offset += 1;
                }
            }
            else
            {
                DtoRecord record;
                int contentLength;

                switch (command.PayloadStatus)
                {
                    case PayloadStatus.NullResult:
                        command.Content = null;
                        break;
                    case PayloadStatus.SingleRecord:
                        record = new DtoRecord();

                        contentLength = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                        offset += 4;
                        record.Content = response.Data.Skip(offset).Take(contentLength).ToArray();
                        offset += contentLength;

                        record.Version = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                        offset += 4;

                        record.Type = (ORecordType)BinaryParser.ToByte(response.Data.Skip(offset).Take(1).ToArray());
                        offset += 1;

                        command.Content = record;
                        break;
                    case PayloadStatus.SerializedResult:
                        contentLength = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                        offset += 4;
                        command.Content = response.Data.Skip(offset).Take(contentLength).ToArray();
                        offset += contentLength;
                        break;
                    case PayloadStatus.RecordCollection:
                        command.Content = new List<DtoRecord>();
                        int recordsCount = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                        offset += 4;

                        for (int i = 0; i < recordsCount; i++)
                        {
                            record = new DtoRecord();

                            contentLength = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                            offset += 4;
                            record.Content = response.Data.Skip(offset).Take(contentLength).ToArray();
                            offset += contentLength;

                            record.Version = BinaryParser.ToInt(response.Data.Skip(offset).Take(4).ToArray());
                            offset += 4;

                            record.Type = (ORecordType)BinaryParser.ToByte(response.Data.Skip(offset).Take(1).ToArray());
                            offset += 1;

                            ((List<DtoRecord>)command.Content).Add(record);
                        }
                        break;
                    default:
                        break;
                }
            }

            return command;
        }
Exemplo n.º 15
0
        public object Response(Response response)
        {
            // there is no specific response fields processing for this operation

            return null;
        }