public static DeviceTemplateEN Convert(DeviceTemplateDTO dto) { DeviceTemplateEN newinstance = null; try { if (dto != null) { newinstance = new DeviceTemplateEN(); newinstance.Id = dto.Id; newinstance.Name = dto.Name; if (dto.Property != null) { MoSIoTGenNHibernate.CAD.MosIoT.IPropertyCAD propertyCAD = new MoSIoTGenNHibernate.CAD.MosIoT.PropertyCAD(); newinstance.Property = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.PropertyEN>(); foreach (PropertyDTO entry in dto.Property) { newinstance.Property.Add(PropertyAssemblerDTO.Convert(entry)); } } if (dto.Command != null) { MoSIoTGenNHibernate.CAD.MosIoT.ICommandCAD commandCAD = new MoSIoTGenNHibernate.CAD.MosIoT.CommandCAD(); newinstance.Command = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.CommandEN>(); foreach (CommandDTO entry in dto.Command) { newinstance.Command.Add(CommandAssemblerDTO.Convert(entry)); } } if (dto.Telemetry != null) { MoSIoTGenNHibernate.CAD.MosIoT.ITelemetryCAD telemetryCAD = new MoSIoTGenNHibernate.CAD.MosIoT.TelemetryCAD(); newinstance.Telemetry = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.TelemetryEN>(); foreach (TelemetryDTO entry in dto.Telemetry) { newinstance.Telemetry.Add(TelemetryAssemblerDTO.Convert(entry)); } } newinstance.Type = dto.Type; newinstance.IsEdge = dto.IsEdge; } } catch (Exception ex) { throw ex; } return(newinstance); }
public static EventTelemetryEN Convert(EventTelemetryDTO dto) { EventTelemetryEN newinstance = null; try { if (dto != null) { newinstance = new EventTelemetryEN(); newinstance.Severity = dto.Severity; if (dto.EventCommand_oid != -1) { MoSIoTGenNHibernate.CAD.MosIoT.ICommandCAD commandCAD = new MoSIoTGenNHibernate.CAD.MosIoT.CommandCAD(); newinstance.EventCommand = commandCAD.ReadOIDDefault(dto.EventCommand_oid); } if (dto.Notification_oid != -1) { MoSIoTGenNHibernate.CAD.MosIoT.IComunicationCAD comunicationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.ComunicationCAD(); newinstance.Notification = comunicationCAD.ReadOIDDefault(dto.Notification_oid); } if (dto.Telemetry_oid != -1) { MoSIoTGenNHibernate.CAD.MosIoT.ITelemetryCAD telemetryCAD = new MoSIoTGenNHibernate.CAD.MosIoT.TelemetryCAD(); newinstance.Telemetry = telemetryCAD.ReadOIDDefault(dto.Telemetry_oid); } newinstance.Id = dto.Id; newinstance.Name = dto.Name; } } catch (Exception ex) { throw ex; } return(newinstance); }
public static IMCommandEN Convert(IMCommandDTO dto) { IMCommandEN newinstance = null; try { if (dto != null) { newinstance = new IMCommandEN(); if (dto.Command_oid != -1) { MoSIoTGenNHibernate.CAD.MosIoT.ICommandCAD commandCAD = new MoSIoTGenNHibernate.CAD.MosIoT.CommandCAD(); newinstance.Command = commandCAD.ReadOIDDefault(dto.Command_oid); } 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); }