Example #1
0
public static StateDeviceEN Convert (StateDeviceDTO dto)
{
        StateDeviceEN newinstance = null;

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



                        newinstance.Id = dto.Id;
                        newinstance.Name = dto.Name;
                        newinstance.Value = dto.Value;
                        if (dto.StateTelemetry_oid != -1) {
                                MoSIoTGenNHibernate.CAD.MosIoT.IStateTelemetryCAD stateTelemetryCAD = new MoSIoTGenNHibernate.CAD.MosIoT.StateTelemetryCAD ();

                                newinstance.StateTelemetry = stateTelemetryCAD.ReadOIDDefault (dto.StateTelemetry_oid);
                        }
                }
        }
        catch (Exception ex)
        {
                throw ex;
        }
        return newinstance;
}
        public static RangeStateTelemetryEN Convert(RangeStateTelemetryDTO dto)
        {
            RangeStateTelemetryEN newinstance = null;

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



                    if (dto.StateTelemetry_oid != null)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IStateTelemetryCAD stateTelemetryCAD = new MoSIoTGenNHibernate.CAD.MosIoT.StateTelemetryCAD();

                        newinstance.StateTelemetry = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.StateTelemetryEN>();
                        foreach (int entry in dto.StateTelemetry_oid)
                        {
                            newinstance.StateTelemetry.Add(stateTelemetryCAD.ReadOIDDefault(entry));
                        }
                    }
                    newinstance.Id    = dto.Id;
                    newinstance.Name  = dto.Name;
                    newinstance.Value = dto.Value;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(newinstance);
        }