示例#1
0
// Modify default (Update all attributes of the class)

        public void ModifyDefault(IMGoalEN iMGoal)
        {
            try
            {
                SessionInitializeTransaction();
                IMGoalEN iMGoalEN = (IMGoalEN)session.Load(typeof(IMGoalEN), iMGoal.Id);

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

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


            finally
            {
                SessionClose();
            }
        }
示例#2
0
        public IMGoalEN ReadOIDDefault(int id
                                       )
        {
            IMGoalEN iMGoalEN = null;

            try
            {
                SessionInitializeTransaction();
                iMGoalEN = (IMGoalEN)session.Get(typeof(IMGoalEN), id);
                SessionCommit();
            }

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


            finally
            {
                SessionClose();
            }

            return(iMGoalEN);
        }
示例#3
0
        public IMGoalEN ReadOID(int id
                                )
        {
            IMGoalEN iMGoalEN = null;

            iMGoalEN = _IIMGoalCAD.ReadOID(id);
            return(iMGoalEN);
        }
示例#4
0
        public void Modify(int p_IMGoal_OID, string p_name, MoSIoTGenNHibernate.Enumerated.MosIoT.DataTypeEnum p_type, bool p_isOID, bool p_isWritable, string p_description, string p_value)
        {
            IMGoalEN iMGoalEN = null;

            //Initialized IMGoalEN
            iMGoalEN             = new IMGoalEN();
            iMGoalEN.Id          = p_IMGoal_OID;
            iMGoalEN.Name        = p_name;
            iMGoalEN.Type        = p_type;
            iMGoalEN.IsOID       = p_isOID;
            iMGoalEN.IsWritable  = p_isWritable;
            iMGoalEN.Description = p_description;
            iMGoalEN.Value       = p_value;
            //Call to IMGoalCAD

            _IIMGoalCAD.Modify(iMGoalEN);
        }
示例#5
0
        public void Modify(IMGoalEN iMGoal)
        {
            try
            {
                SessionInitializeTransaction();
                IMGoalEN iMGoalEN = (IMGoalEN)session.Load(typeof(IMGoalEN), iMGoal.Id);

                iMGoalEN.Name = iMGoal.Name;


                iMGoalEN.Type = iMGoal.Type;


                iMGoalEN.IsOID = iMGoal.IsOID;


                iMGoalEN.IsWritable = iMGoal.IsWritable;


                iMGoalEN.Description = iMGoal.Description;


                iMGoalEN.Value = iMGoal.Value;

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

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


            finally
            {
                SessionClose();
            }
        }
示例#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_goal)
        {
            IMGoalEN iMGoalEN = null;
            int      oid;

            //Initialized IMGoalEN
            iMGoalEN      = new IMGoalEN();
            iMGoalEN.Name = p_name;

            iMGoalEN.Type = p_type;

            iMGoalEN.IsOID = p_isOID;

            iMGoalEN.IsWritable = p_isWritable;

            iMGoalEN.Description = p_description;


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

            iMGoalEN.Value = p_value;


            if (p_goal != -1)
            {
                // El argumento p_goal -> Property goal es oid = false
                // Lista de oids id
                iMGoalEN.Goal    = new MoSIoTGenNHibernate.EN.MosIoT.GoalEN();
                iMGoalEN.Goal.Id = p_goal;
            }

            //Call to IMGoalCAD

            oid = _IIMGoalCAD.New_(iMGoalEN);
            return(oid);
        }
示例#7
0
        public int New_(IMGoalEN iMGoal)
        {
            try
            {
                SessionInitializeTransaction();
                if (iMGoal.Entity != null)
                {
                    // Argumento OID y no colección.
                    iMGoal.Entity = (MoSIoTGenNHibernate.EN.MosIoT.EntityEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.EntityEN), iMGoal.Entity.Id);

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

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

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


            finally
            {
                SessionClose();
            }

            return(iMGoal.Id);
        }
        public static IMGoalEN Convert(IMGoalDTO dto)
        {
            IMGoalEN newinstance = null;

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



                    if (dto.Goal_oid != -1)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IGoalCAD goalCAD = new MoSIoTGenNHibernate.CAD.MosIoT.GoalCAD();

                        newinstance.Goal = goalCAD.ReadOIDDefault(dto.Goal_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);
        }