예제 #1
0
        public int New_(string p_name, MoSIoTGenNHibernate.Enumerated.MosIoT.DataTypeEnum p_type, MoSIoTGenNHibernate.Enumerated.MosIoT.ServiceTypeEnum p_serviceType, string p_description, int p_entity)
        {
            NotifyEN notifyEN = null;
            int      oid;

            //Initialized NotifyEN
            notifyEN      = new NotifyEN();
            notifyEN.Name = p_name;

            notifyEN.Type = p_type;

            notifyEN.ServiceType = p_serviceType;

            notifyEN.Description = p_description;


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

            //Call to NotifyCAD

            oid = _INotifyCAD.New_(notifyEN);
            return(oid);
        }
예제 #2
0
// Modify default (Update all attributes of the class)

        public void ModifyDefault(NotifyEN notify)
        {
            try
            {
                SessionInitializeTransaction();
                NotifyEN notifyEN = (NotifyEN)session.Load(typeof(NotifyEN), notify.Id);

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

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


            finally
            {
                SessionClose();
            }
        }
예제 #3
0
        public NotifyEN ReadOIDDefault(int id
                                       )
        {
            NotifyEN notifyEN = null;

            try
            {
                SessionInitializeTransaction();
                notifyEN = (NotifyEN)session.Get(typeof(NotifyEN), id);
                SessionCommit();
            }

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


            finally
            {
                SessionClose();
            }

            return(notifyEN);
        }
예제 #4
0
        public int New_(NotifyEN notify)
        {
            try
            {
                SessionInitializeTransaction();
                if (notify.Entity != null)
                {
                    // Argumento OID y no colección.
                    notify.Entity = (MoSIoTGenNHibernate.EN.MosIoT.EntityEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.EntityEN), notify.Entity.Id);

                    notify.Entity.Operations
                    .Add(notify);
                }

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

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


            finally
            {
                SessionClose();
            }

            return(notify.Id);
        }
예제 #5
0
        public NotifyEN ReadOID(int id
                                )
        {
            NotifyEN notifyEN = null;

            notifyEN = _INotifyCAD.ReadOID(id);
            return(notifyEN);
        }
예제 #6
0
        public void Modify(int p_Notify_OID, string p_name, MoSIoTGenNHibernate.Enumerated.MosIoT.DataTypeEnum p_type, MoSIoTGenNHibernate.Enumerated.MosIoT.ServiceTypeEnum p_serviceType, string p_description)
        {
            NotifyEN notifyEN = null;

            //Initialized NotifyEN
            notifyEN             = new NotifyEN();
            notifyEN.Id          = p_Notify_OID;
            notifyEN.Name        = p_name;
            notifyEN.Type        = p_type;
            notifyEN.ServiceType = p_serviceType;
            notifyEN.Description = p_description;
            //Call to NotifyCAD

            _INotifyCAD.Modify(notifyEN);
        }
        public static NotifyEN Convert(NotifyDTO dto)
        {
            NotifyEN newinstance = null;

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



                    if (dto.Users_oid != null)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IUserCAD userCAD = new MoSIoTGenNHibernate.CAD.MosIoT.UserCAD();

                        newinstance.Users = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.UserEN>();
                        foreach (int entry in dto.Users_oid)
                        {
                            newinstance.Users.Add(userCAD.ReadOIDDefault(entry));
                        }
                    }
                    newinstance.Id          = dto.Id;
                    newinstance.Name        = dto.Name;
                    newinstance.Type        = dto.Type;
                    newinstance.ServiceType = dto.ServiceType;
                    newinstance.Description = dto.Description;

                    if (dto.EntityArgument != null)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IEntityArgumentCAD entityArgumentCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityArgumentCAD();

                        newinstance.EntityArgument = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.EntityArgumentEN>();
                        foreach (EntityArgumentDTO entry in dto.EntityArgument)
                        {
                            newinstance.EntityArgument.Add(EntityArgumentAssemblerDTO.Convert(entry));
                        }
                    }
                    if (dto.Entity_oid != -1)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IEntityCAD entityCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityCAD();

                        newinstance.Entity = entityCAD.ReadOIDDefault(dto.Entity_oid);
                    }
                    if (dto.RuleAction_oid != null)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IRecipeActionCAD recipeActionCAD = new MoSIoTGenNHibernate.CAD.MosIoT.RecipeActionCAD();

                        newinstance.RuleAction = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.RecipeActionEN>();
                        foreach (int entry in dto.RuleAction_oid)
                        {
                            newinstance.RuleAction.Add(recipeActionCAD.ReadOIDDefault(entry));
                        }
                    }
                    if (dto.OriginState_oid != -1)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IEntityStateCAD entityStateCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityStateCAD();

                        newinstance.OriginState = entityStateCAD.ReadOIDDefault(dto.OriginState_oid);
                    }
                    if (dto.TargetState_oid != -1)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IEntityStateCAD entityStateCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityStateCAD();

                        newinstance.TargetState = entityStateCAD.ReadOIDDefault(dto.TargetState_oid);
                    }
                    if (dto.Triggers_oid != null)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IRecipeTriggerCAD recipeTriggerCAD = new MoSIoTGenNHibernate.CAD.MosIoT.RecipeTriggerCAD();

                        newinstance.Triggers = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.RecipeTriggerEN>();
                        foreach (int entry in dto.Triggers_oid)
                        {
                            newinstance.Triggers.Add(recipeTriggerCAD.ReadOIDDefault(entry));
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(newinstance);
        }