Exemplo n.º 1
0
// Modify default (Update all attributes of the class)

        public void ModifyDefault(IMTargetEN iMTarget)
        {
            try
            {
                SessionInitializeTransaction();
                IMTargetEN iMTargetEN = (IMTargetEN)session.Load(typeof(IMTargetEN), iMTarget.Id);

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

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


            finally
            {
                SessionClose();
            }
        }
Exemplo n.º 2
0
        public IMTargetEN ReadOIDDefault(int id
                                         )
        {
            IMTargetEN iMTargetEN = null;

            try
            {
                SessionInitializeTransaction();
                iMTargetEN = (IMTargetEN)session.Get(typeof(IMTargetEN), id);
                SessionCommit();
            }

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


            finally
            {
                SessionClose();
            }

            return(iMTargetEN);
        }
Exemplo n.º 3
0
        public IMTargetEN ReadOID(int id
                                  )
        {
            IMTargetEN iMTargetEN = null;

            iMTargetEN = _IIMTargetCAD.ReadOID(id);
            return(iMTargetEN);
        }
Exemplo n.º 4
0
        public void Modify(int p_IMTarget_OID, string p_name, MoSIoTGenNHibernate.Enumerated.MosIoT.DataTypeEnum p_type, bool p_isOID, bool p_isWritable, string p_description, string p_value)
        {
            IMTargetEN iMTargetEN = null;

            //Initialized IMTargetEN
            iMTargetEN             = new IMTargetEN();
            iMTargetEN.Id          = p_IMTarget_OID;
            iMTargetEN.Name        = p_name;
            iMTargetEN.Type        = p_type;
            iMTargetEN.IsOID       = p_isOID;
            iMTargetEN.IsWritable  = p_isWritable;
            iMTargetEN.Description = p_description;
            iMTargetEN.Value       = p_value;
            //Call to IMTargetCAD

            _IIMTargetCAD.Modify(iMTargetEN);
        }
Exemplo n.º 5
0
        public void Modify(IMTargetEN iMTarget)
        {
            try
            {
                SessionInitializeTransaction();
                IMTargetEN iMTargetEN = (IMTargetEN)session.Load(typeof(IMTargetEN), iMTarget.Id);

                iMTargetEN.Name = iMTarget.Name;


                iMTargetEN.Type = iMTarget.Type;


                iMTargetEN.IsOID = iMTarget.IsOID;


                iMTargetEN.IsWritable = iMTarget.IsWritable;


                iMTargetEN.Description = iMTarget.Description;


                iMTargetEN.Value = iMTarget.Value;

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

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


            finally
            {
                SessionClose();
            }
        }
Exemplo n.º 6
0
        public int New_(string p_name, MoSIoTGenNHibernate.Enumerated.MosIoT.DataTypeEnum p_type, bool p_isOID, bool p_isWritable, string p_description, int p_entity, string p_value, int p_target)
        {
            IMTargetEN iMTargetEN = null;
            int        oid;

            //Initialized IMTargetEN
            iMTargetEN      = new IMTargetEN();
            iMTargetEN.Name = p_name;

            iMTargetEN.Type = p_type;

            iMTargetEN.IsOID = p_isOID;

            iMTargetEN.IsWritable = p_isWritable;

            iMTargetEN.Description = p_description;


            if (p_entity != -1)
            {
                // El argumento p_entity -> Property entity es oid = false
                // Lista de oids id
                iMTargetEN.Entity    = new MoSIoTGenNHibernate.EN.MosIoT.EntityEN();
                iMTargetEN.Entity.Id = p_entity;
            }

            iMTargetEN.Value = p_value;


            if (p_target != -1)
            {
                // El argumento p_target -> Property target es oid = false
                // Lista de oids id
                iMTargetEN.Target    = new MoSIoTGenNHibernate.EN.MosIoT.TargetEN();
                iMTargetEN.Target.Id = p_target;
            }

            //Call to IMTargetCAD

            oid = _IIMTargetCAD.New_(iMTargetEN);
            return(oid);
        }
Exemplo n.º 7
0
        public int New_(IMTargetEN iMTarget)
        {
            try
            {
                SessionInitializeTransaction();
                if (iMTarget.Entity != null)
                {
                    // Argumento OID y no colección.
                    iMTarget.Entity = (MoSIoTGenNHibernate.EN.MosIoT.EntityEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.EntityEN), iMTarget.Entity.Id);

                    iMTarget.Entity.Attributes
                    .Add(iMTarget);
                }
                if (iMTarget.Target != null)
                {
                    // Argumento OID y no colección.
                    iMTarget.Target = (MoSIoTGenNHibernate.EN.MosIoT.TargetEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.TargetEN), iMTarget.Target.Id);
                }

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

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


            finally
            {
                SessionClose();
            }

            return(iMTarget.Id);
        }
Exemplo n.º 8
0
        public static IMTargetEN Convert(IMTargetDTO dto)
        {
            IMTargetEN newinstance = null;

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



                    if (dto.Target_oid != -1)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.ITargetCAD targetCAD = new MoSIoTGenNHibernate.CAD.MosIoT.TargetCAD();

                        newinstance.Target = targetCAD.ReadOIDDefault(dto.Target_oid);
                    }
                    newinstance.Id    = dto.Id;
                    newinstance.Name  = dto.Name;
                    newinstance.Type  = dto.Type;
                    newinstance.IsOID = dto.IsOID;
                    if (dto.TargetAssociation_oid != null)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IAssociationCAD associationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.AssociationCAD();

                        newinstance.TargetAssociation = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.AssociationEN>();
                        foreach (int entry in dto.TargetAssociation_oid)
                        {
                            newinstance.TargetAssociation.Add(associationCAD.ReadOIDDefault(entry));
                        }
                    }
                    if (dto.OriginAsociation_oid != null)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IAssociationCAD associationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.AssociationCAD();

                        newinstance.OriginAsociation = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.AssociationEN>();
                        foreach (int entry in dto.OriginAsociation_oid)
                        {
                            newinstance.OriginAsociation.Add(associationCAD.ReadOIDDefault(entry));
                        }
                    }
                    newinstance.AssociationType = dto.AssociationType;
                    newinstance.IsWritable      = dto.IsWritable;
                    newinstance.Description     = dto.Description;
                    if (dto.Entity_oid != -1)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IEntityCAD entityCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityCAD();

                        newinstance.Entity = entityCAD.ReadOIDDefault(dto.Entity_oid);
                    }
                    if (dto.Trigger_oid != null)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IRecipeTriggerCAD recipeTriggerCAD = new MoSIoTGenNHibernate.CAD.MosIoT.RecipeTriggerCAD();

                        newinstance.Trigger = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.RecipeTriggerEN>();
                        foreach (int entry in dto.Trigger_oid)
                        {
                            newinstance.Trigger.Add(recipeTriggerCAD.ReadOIDDefault(entry));
                        }
                    }
                    if (dto.Register_oid != null)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IRegisterCAD registerCAD = new MoSIoTGenNHibernate.CAD.MosIoT.RegisterCAD();

                        newinstance.Register = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.RegisterEN>();
                        foreach (int entry in dto.Register_oid)
                        {
                            newinstance.Register.Add(registerCAD.ReadOIDDefault(entry));
                        }
                    }
                    newinstance.Value = dto.Value;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(newinstance);
        }