public static IMPropertyDTOA Convert(EntityAttributesEN en, NHibernate.ISession session = null)
        {
            IMPropertyDTOA    dto = null;
            IMPropertyRESTCAD iMPropertyRESTCAD = null;
            IMPropertyCEN     iMPropertyCEN     = null;
            IMPropertyCP      iMPropertyCP      = null;

            if (en != null)
            {
                dto = new IMPropertyDTOA();
                iMPropertyRESTCAD = new IMPropertyRESTCAD(session);
                iMPropertyCEN     = new IMPropertyCEN(iMPropertyRESTCAD);
                iMPropertyCP      = new IMPropertyCP(session);


                IMPropertyEN enHijo = iMPropertyRESTCAD.ReadOIDDefault(en.Id);



                //
                // Attributes

                dto.Id = en.Id;

                dto.Name = en.Name;


                dto.Type = en.Type;


                dto.Value = en.Value;


                //
                // TravesalLink

                /* Rol: IMProperty o--> Property */
                dto.ValueProperty = PropertyAssembler.Convert((PropertyEN)enHijo.Property, session);


                //
                // Service
            }

            return(dto);
        }
Example #2
0
        public static DeviceTemplateDTOA Convert(DeviceTemplateEN en, NHibernate.ISession session = null)
        {
            DeviceTemplateDTOA    dto = null;
            DeviceTemplateRESTCAD deviceTemplateRESTCAD = null;
            DeviceTemplateCEN     deviceTemplateCEN     = null;
            DeviceTemplateCP      deviceTemplateCP      = null;

            if (en != null)
            {
                dto = new DeviceTemplateDTOA();
                deviceTemplateRESTCAD = new DeviceTemplateRESTCAD(session);
                deviceTemplateCEN     = new DeviceTemplateCEN(deviceTemplateRESTCAD);
                deviceTemplateCP      = new DeviceTemplateCP(session);



                //
                // Attributes

                dto.Id = en.Id;

                dto.Name = en.Name;


                dto.Type = en.Type;


                dto.IsEdge = en.IsEdge;


                //
                // TravesalLink

                /* Rol: DeviceTemplate o--> Command */
                dto.Commands = null;
                List <CommandEN> Commands = deviceTemplateRESTCAD.Commands(en.Id).ToList();
                if (Commands != null)
                {
                    dto.Commands = new List <CommandDTOA>();
                    foreach (CommandEN entry in Commands)
                    {
                        dto.Commands.Add(CommandAssembler.Convert(entry, session));
                    }
                }

                /* Rol: DeviceTemplate o--> Property */
                dto.Properties = null;
                List <PropertyEN> Properties = deviceTemplateRESTCAD.Properties(en.Id).ToList();
                if (Properties != null)
                {
                    dto.Properties = new List <PropertyDTOA>();
                    foreach (PropertyEN entry in Properties)
                    {
                        dto.Properties.Add(PropertyAssembler.Convert(entry, session));
                    }
                }

                /* Rol: DeviceTemplate o--> Telemetry */
                dto.Telemetries = null;
                List <TelemetryEN> Telemetries = deviceTemplateRESTCAD.Telemetries(en.Id).ToList();
                if (Telemetries != null)
                {
                    dto.Telemetries = new List <TelemetryDTOA>();
                    foreach (TelemetryEN entry in Telemetries)
                    {
                        dto.Telemetries.Add(TelemetryAssembler.Convert(entry, session));
                    }
                }


                //
                // Service
            }

            return(dto);
        }