Пример #1
0
        public static ComunicationEN Convert(ComunicationDTO dto)
        {
            ComunicationEN newinstance = null;

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



                    newinstance.Severity = dto.Severity;
                    newinstance.Message  = dto.Message;
                    newinstance.SendDate = dto.SendDate;
                    newinstance.Id       = dto.Id;
                    if (dto.EventTelemetry_oid != null)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IEventTelemetryCAD eventTelemetryCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EventTelemetryCAD();

                        newinstance.EventTelemetry = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.EventTelemetryEN>();
                        foreach (int entry in dto.EventTelemetry_oid)
                        {
                            newinstance.EventTelemetry.Add(eventTelemetryCAD.ReadOIDDefault(entry));
                        }
                    }
                    if (dto.CareActivity_oid != -1)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.ICareActivityCAD careActivityCAD = new MoSIoTGenNHibernate.CAD.MosIoT.CareActivityCAD();

                        newinstance.CareActivity = careActivityCAD.ReadOIDDefault(dto.CareActivity_oid);
                    }
                    if (dto.CarePlanTemplate_oid != -1)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.ICarePlanTemplateCAD carePlanTemplateCAD = new MoSIoTGenNHibernate.CAD.MosIoT.CarePlanTemplateCAD();

                        newinstance.CarePlanTemplate = carePlanTemplateCAD.ReadOIDDefault(dto.CarePlanTemplate_oid);
                    }
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(newinstance);
        }
Пример #2
0
        public static CommandEN Convert(CommandDTO dto)
        {
            CommandEN newinstance = null;

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



                    if (dto.DeviceTemplate_oid != -1)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IDeviceTemplateCAD deviceTemplateCAD = new MoSIoTGenNHibernate.CAD.MosIoT.DeviceTemplateCAD();

                        newinstance.DeviceTemplate = deviceTemplateCAD.ReadOIDDefault(dto.DeviceTemplate_oid);
                    }
                    newinstance.Id            = dto.Id;
                    newinstance.Name          = dto.Name;
                    newinstance.IsSynchronous = dto.IsSynchronous;
                    if (dto.Telemetries_oid != null)
                    {
                        MoSIoTGenNHibernate.CAD.MosIoT.IEventTelemetryCAD eventTelemetryCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EventTelemetryCAD();

                        newinstance.Telemetries = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.EventTelemetryEN>();
                        foreach (int entry in dto.Telemetries_oid)
                        {
                            newinstance.Telemetries.Add(eventTelemetryCAD.ReadOIDDefault(entry));
                        }
                    }
                    newinstance.Type        = dto.Type;
                    newinstance.Description = dto.Description;
                }
            }
            catch (Exception ex)
            {
                throw ex;
            }
            return(newinstance);
        }