Exemplo n.º 1
0
        public StateDeviceEN ReadOIDDefault(int id
                                            )
        {
            StateDeviceEN stateDeviceEN = null;

            try
            {
                SessionInitializeTransaction();
                stateDeviceEN = (StateDeviceEN)session.Get(typeof(StateDeviceEN), id);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is MoSIoTGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in StateDeviceCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(stateDeviceEN);
        }
Exemplo n.º 2
0
public static StateDeviceEN Convert (StateDeviceDTO dto)
{
        StateDeviceEN newinstance = null;

        try
        {
                if (dto != null) {
                        newinstance = new StateDeviceEN ();



                        newinstance.Id = dto.Id;
                        newinstance.Name = dto.Name;
                        newinstance.Value = dto.Value;
                        if (dto.StateTelemetry_oid != -1) {
                                MoSIoTGenNHibernate.CAD.MosIoT.IStateTelemetryCAD stateTelemetryCAD = new MoSIoTGenNHibernate.CAD.MosIoT.StateTelemetryCAD ();

                                newinstance.StateTelemetry = stateTelemetryCAD.ReadOIDDefault (dto.StateTelemetry_oid);
                        }
                }
        }
        catch (Exception ex)
        {
                throw ex;
        }
        return newinstance;
}
Exemplo n.º 3
0
// Modify default (Update all attributes of the class)

        public void ModifyDefault(StateDeviceEN stateDevice)
        {
            try
            {
                SessionInitializeTransaction();
                StateDeviceEN stateDeviceEN = (StateDeviceEN)session.Load(typeof(StateDeviceEN), stateDevice.Id);

                stateDeviceEN.Name = stateDevice.Name;


                stateDeviceEN.Value = stateDevice.Value;


                session.Update(stateDeviceEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is MoSIoTGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in StateDeviceCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Exemplo n.º 4
0
        public void Destroy(int id
                            )
        {
            try
            {
                SessionInitializeTransaction();
                StateDeviceEN stateDeviceEN = (StateDeviceEN)session.Load(typeof(StateDeviceEN), id);
                session.Delete(stateDeviceEN);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is MoSIoTGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in StateDeviceCAD.", ex);
            }


            finally
            {
                SessionClose();
            }
        }
Exemplo n.º 5
0
        public int New_(StateDeviceEN stateDevice)
        {
            try
            {
                SessionInitializeTransaction();
                if (stateDevice.StateTelemetry != null)
                {
                    // Argumento OID y no colección.
                    stateDevice.StateTelemetry = (MoSIoTGenNHibernate.EN.MosIoT.StateTelemetryEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.StateTelemetryEN), stateDevice.StateTelemetry.Id);

                    stateDevice.StateTelemetry.RangeStates
                    .Add(stateDevice);
                }

                session.Save(stateDevice);
                SessionCommit();
            }

            catch (Exception ex) {
                SessionRollBack();
                if (ex is MoSIoTGenNHibernate.Exceptions.ModelException)
                {
                    throw ex;
                }
                throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in StateDeviceCAD.", ex);
            }


            finally
            {
                SessionClose();
            }

            return(stateDevice.Id);
        }
        public int New_(string p_name, string p_value, int p_stateTelemetry)
        {
            StateDeviceEN stateDeviceEN = null;
            int           oid;

            //Initialized StateDeviceEN
            stateDeviceEN      = new StateDeviceEN();
            stateDeviceEN.Name = p_name;

            stateDeviceEN.Value = p_value;


            if (p_stateTelemetry != -1)
            {
                // El argumento p_stateTelemetry -> Property stateTelemetry es oid = false
                // Lista de oids id
                stateDeviceEN.StateTelemetry    = new MoSIoTGenNHibernate.EN.MosIoT.StateTelemetryEN();
                stateDeviceEN.StateTelemetry.Id = p_stateTelemetry;
            }

            //Call to StateDeviceCAD

            oid = _IStateDeviceCAD.New_(stateDeviceEN);
            return(oid);
        }
        public StateDeviceEN ReadOID(int id
                                     )
        {
            StateDeviceEN stateDeviceEN = null;

            stateDeviceEN = _IStateDeviceCAD.ReadOID(id);
            return(stateDeviceEN);
        }
        public void Modify(int p_StateDevice_OID, string p_name, string p_value)
        {
            StateDeviceEN stateDeviceEN = null;

            //Initialized StateDeviceEN
            stateDeviceEN       = new StateDeviceEN();
            stateDeviceEN.Id    = p_StateDevice_OID;
            stateDeviceEN.Name  = p_name;
            stateDeviceEN.Value = p_value;
            //Call to StateDeviceCAD

            _IStateDeviceCAD.Modify(stateDeviceEN);
        }
        public static StateDeviceDTOA Convert(StateDeviceEN en, NHibernate.ISession session = null)
        {
            StateDeviceDTOA    dto = null;
            StateDeviceRESTCAD stateDeviceRESTCAD = null;
            StateDeviceCEN     stateDeviceCEN     = null;
            StateDeviceCP      stateDeviceCP      = null;

            if (en != null)
            {
                dto = new StateDeviceDTOA();
                stateDeviceRESTCAD = new StateDeviceRESTCAD(session);
                stateDeviceCEN     = new StateDeviceCEN(stateDeviceRESTCAD);
                stateDeviceCP      = new StateDeviceCP(session);



                //
                // Attributes

                dto.Id = en.Id;

                dto.Name = en.Name;


                dto.Value = en.Value;


                //
                // TravesalLink


                //
                // Service
            }

            return(dto);
        }