示例#1
0
        public static RecipeActionEN Convert(RecipeActionDTO dto)
        {
            RecipeActionEN newinstance = null;

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



                    newinstance.Id = dto.Id;
                    if (dto.Recipe_oid != -1)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IRecipeCAD recipeCAD = new MoSIoTGenNHibernate.CAD.MosIoT.RecipeCAD();

                        newinstance.Recipe = recipeCAD.ReadOIDDefault(dto.Recipe_oid);
                    }
                    if (dto.Operation_oid != -1)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IEntityOperationCAD entityOperationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityOperationCAD();

                        newinstance.Operation = entityOperationCAD.ReadOIDDefault(dto.Operation_oid);
                    }
                    newinstance.Name        = dto.Name;
                    newinstance.Description = dto.Description;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(newinstance);
        }
        public static IoTScenarioEN Convert(IoTScenarioDTO dto)
        {
            IoTScenarioEN newinstance = null;

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



                    newinstance.Id   = dto.Id;
                    newinstance.Name = dto.Name;

                    if (dto.Entity != null)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IEntityCAD entityCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityCAD();

                        newinstance.Entity = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.EntityEN>();
                        foreach (EntityDTO entry in dto.Entity)
                        {
                            newinstance.Entity.Add(EntityAssemblerDTO.Convert(entry));
                        }
                    }

                    if (dto.Recipes != null)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IRecipeCAD recipeCAD = new MoSIoTGenNHibernate.CAD.MosIoT.RecipeCAD();

                        newinstance.Recipes = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.RecipeEN>();
                        foreach (RecipeDTO entry in dto.Recipes)
                        {
                            newinstance.Recipes.Add(RecipeAssemblerDTO.Convert(entry));
                        }
                    }

                    if (dto.Association != null)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IAssociationCAD associationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.AssociationCAD();

                        newinstance.Association = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.AssociationEN>();
                        foreach (AssociationDTO entry in dto.Association)
                        {
                            newinstance.Association.Add(AssociationAssemblerDTO.Convert(entry));
                        }
                    }
                    newinstance.Description = dto.Description;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(newinstance);
        }
        public static RecipeTriggerEN Convert(RecipeTriggerDTO dto)
        {
            RecipeTriggerEN newinstance = null;

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



                    if (dto.Recipe_oid != -1)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IRecipeCAD recipeCAD = new MoSIoTGenNHibernate.CAD.MosIoT.RecipeCAD();

                        newinstance.Recipe = recipeCAD.ReadOIDDefault(dto.Recipe_oid);
                    }
                    newinstance.Id        = dto.Id;
                    newinstance.Operator_ = dto.Operator_;
                    newinstance.Value     = dto.Value;
                    if (dto.EntityAttributes_oid != null)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IEntityAttributesCAD entityAttributesCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityAttributesCAD();

                        newinstance.EntityAttributes = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.EntityAttributesEN>();
                        foreach (int entry in dto.EntityAttributes_oid)
                        {
                            newinstance.EntityAttributes.Add(entityAttributesCAD.ReadOIDDefault(entry));
                        }
                    }
                    if (dto.Event__oid != -1)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IEntityOperationCAD entityOperationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityOperationCAD();

                        newinstance.Event_ = entityOperationCAD.ReadOIDDefault(dto.Event__oid);
                    }
                    newinstance.Description = dto.Description;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(newinstance);
        }