//
        // The following methods are derived from Safir.Dob.EntityHandlerInjection.
        //
        public void OnCreateRequest(
            Safir.Dob.EntityRequestProxy entityRequestProxy,
            Safir.Dob.ResponseSender responseSender)
        {
            bool bOk = false;

            Safir.Dob.Typesystem.InstanceId instanceId;
            Safir.Dob.Typesystem.EntityId   entityId =
                new Safir.Dob.Typesystem.EntityId();

            // Cast to known type, the vehicle entity.
            Capabilities.Vehicles.Vehicle vehicle =
                (Capabilities.Vehicles.Vehicle)entityRequestProxy.Request;

            // Identification is a mandatory member.
            if (!vehicle.Identification.IsNull())
            {
                // Generate instance number from unique value.
                instanceId =
                    new Safir.Dob.Typesystem.InstanceId(vehicle.Identification.Val);

                // Check if entity with given value already exist.
                entityId.TypeId     = Capabilities.Vehicles.Vehicle.ClassTypeId;
                entityId.InstanceId = instanceId;

                if (!m_connection.IsCreated(entityId))
                {
                    // Store object in the Dob.
                    m_connection.SetAll(
                        vehicle, instanceId, new Safir.Dob.Typesystem.HandlerId());
                    bOk = true;
                    m_iNumberOfCreatedVehicles++;
                }
            }

            if (bOk)
            {
                // Inform requestor about the instance.
                Safir.Dob.EntityIdResponse entIdResponse =
                    new Safir.Dob.EntityIdResponse();
                entIdResponse.Assigned.Val = entityId;
                responseSender.Send(entIdResponse);

                // Send notification message when the number of created vehicles
                // has reached the limit.
                if (m_iNumberOfCreatedVehicles == Capabilities.Vehicles.VehicleParameters.VehicleLimit)
                {
                    MessageSender.Instance.SendMaxNofVehicleMsg();
                }
            }
            else
            {
                Safir.Dob.ErrorResponse errorResponse =
                    new Safir.Dob.ErrorResponse();
                errorResponse.Code.Val = Safir.Dob.ResponseGeneralErrorCodes.SafirReqErr;
                responseSender.Send(errorResponse);
            }
        }
 public void OnDeleteRequest(
     Safir.Dob.EntityRequestProxy entityRequestProxy,
     Safir.Dob.ResponseSender responseSender)
 {
     if (m_connection.IsCreated(entityRequestProxy.EntityId))
     {
         m_connection.Delete(
             entityRequestProxy.EntityId,
             new Safir.Dob.Typesystem.HandlerId());
         m_iNumberOfCreatedVehicles--;
     }
     responseSender.Send(new Safir.Dob.SuccessResponse());
 }
        public void OnUpdateRequest(
            Safir.Dob.EntityRequestProxy entityRequestProxy,
            Safir.Dob.ResponseSender responseSender)
        {
            bool bOk = false;

            // Cast to known type, the vehicle entity.
            Capabilities.Vehicles.Vehicle receivedVehicle =
                (Capabilities.Vehicles.Vehicle)entityRequestProxy.Request;

            if (m_connection.IsCreated(entityRequestProxy.EntityId))
            {
                // Don't allow the identification to be updated.
                if (!receivedVehicle.Identification.IsChanged())
                {
                    // Update the stored vehicle with the received one.
                    m_connection.SetChanges(
                        receivedVehicle,
                        entityRequestProxy.InstanceId,
                        new Safir.Dob.Typesystem.HandlerId());
                    bOk = true;
                }
            }

            if (bOk)
            {
                responseSender.Send(new Safir.Dob.SuccessResponse());
            }
            else
            {
                Safir.Dob.ErrorResponse errorResponse =
                    new Safir.Dob.ErrorResponse();
                errorResponse.Code.Val = Safir.Dob.ResponseGeneralErrorCodes.SafirReqErr;
                responseSender.Send(errorResponse);
            }
        }
Esempio n. 4
0
File: Player.cs Progetto: bjowes/cwg
 public void OnDeleteRequest(Safir.Dob.EntityRequestProxy entityRequestProxy, Safir.Dob.ResponseSender responseSender)
 {
     responseSender.Send(Safir.Dob.ErrorResponse.CreateErrorResponse(Safir.Dob.ResponseGeneralErrorCodes.SafirNoPermission, ""));
 }
Esempio n. 5
0
 void Safir.Dob.EntityRequestBase.OnUpdateRequest(Safir.Dob.EntityRequestProxy entityRequestProxy, Safir.Dob.ResponseSender responseSender)
 {
     responseSender.Send(new Safir.Dob.ErrorResponse());
 }