// Modify default (Update all attributes of the class) public void ModifyDefault(IMCommunicationEN iMCommunication) { try { SessionInitializeTransaction(); IMCommunicationEN iMCommunicationEN = (IMCommunicationEN)session.Load(typeof(IMCommunicationEN), iMCommunication.Id); session.Update(iMCommunicationEN); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in IMCommunicationCAD.", ex); } finally { SessionClose(); } }
public int New_(string p_name, int p_scenario, string p_description, int p_comunication) { IMCommunicationEN iMCommunicationEN = null; int oid; //Initialized IMCommunicationEN iMCommunicationEN = new IMCommunicationEN(); iMCommunicationEN.Name = p_name; if (p_scenario != -1) { // El argumento p_scenario -> Property scenario es oid = false // Lista de oids id iMCommunicationEN.Scenario = new MoSIoTGenNHibernate.EN.MosIoT.IoTScenarioEN(); iMCommunicationEN.Scenario.Id = p_scenario; } iMCommunicationEN.Description = p_description; if (p_comunication != -1) { // El argumento p_comunication -> Property comunication es oid = false // Lista de oids id iMCommunicationEN.Comunication = new MoSIoTGenNHibernate.EN.MosIoT.ComunicationEN(); iMCommunicationEN.Comunication.Id = p_comunication; } //Call to IMCommunicationCAD oid = _IIMCommunicationCAD.New_(iMCommunicationEN); return(oid); }
public IMCommunicationEN ReadOIDDefault(int id ) { IMCommunicationEN iMCommunicationEN = null; try { SessionInitializeTransaction(); iMCommunicationEN = (IMCommunicationEN)session.Get(typeof(IMCommunicationEN), id); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in IMCommunicationCAD.", ex); } finally { SessionClose(); } return(iMCommunicationEN); }
public IMCommunicationEN ReadOID(int id ) { IMCommunicationEN iMCommunicationEN = null; iMCommunicationEN = _IIMCommunicationCAD.ReadOID(id); return(iMCommunicationEN); }
public void Modify(int p_IMCommunication_OID, string p_name, string p_description) { IMCommunicationEN iMCommunicationEN = null; //Initialized IMCommunicationEN iMCommunicationEN = new IMCommunicationEN(); iMCommunicationEN.Id = p_IMCommunication_OID; iMCommunicationEN.Name = p_name; iMCommunicationEN.Description = p_description; //Call to IMCommunicationCAD _IIMCommunicationCAD.Modify(iMCommunicationEN); }
public static IMCommunicationDTOA Convert(EntityEN en, NHibernate.ISession session = null) { IMCommunicationDTOA dto = null; IMCommunicationRESTCAD iMCommunicationRESTCAD = null; IMCommunicationCEN iMCommunicationCEN = null; IMCommunicationCP iMCommunicationCP = null; if (en != null) { dto = new IMCommunicationDTOA(); iMCommunicationRESTCAD = new IMCommunicationRESTCAD(session); iMCommunicationCEN = new IMCommunicationCEN(iMCommunicationRESTCAD); iMCommunicationCP = new IMCommunicationCP(session); IMCommunicationEN enHijo = iMCommunicationRESTCAD.ReadOIDDefault(en.Id); // // Attributes dto.Id = en.Id; dto.Name = en.Name; dto.Description = en.Description; // // TravesalLink /* Rol: IMCommunication o--> Comunication */ dto.ValueCommunication = ComunicationAssembler.Convert((ComunicationEN)enHijo.Comunication, session); // // Service } return(dto); }
public int New_(IMCommunicationEN iMCommunication) { try { SessionInitializeTransaction(); if (iMCommunication.Scenario != null) { // Argumento OID y no colección. iMCommunication.Scenario = (MoSIoTGenNHibernate.EN.MosIoT.IoTScenarioEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.IoTScenarioEN), iMCommunication.Scenario.Id); iMCommunication.Scenario.Entity .Add(iMCommunication); } if (iMCommunication.Comunication != null) { // Argumento OID y no colección. iMCommunication.Comunication = (MoSIoTGenNHibernate.EN.MosIoT.ComunicationEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.ComunicationEN), iMCommunication.Comunication.Id); } session.Save(iMCommunication); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in IMCommunicationCAD.", ex); } finally { SessionClose(); } return(iMCommunication.Id); }
public static IMCommunicationEN Convert(IMCommunicationDTO dto) { IMCommunicationEN newinstance = null; try { if (dto != null) { newinstance = new IMCommunicationEN(); if (dto.Comunication_oid != -1) { MoSIoTGenNHibernate.CAD.MosIoT.IComunicationCAD comunicationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.ComunicationCAD(); newinstance.Comunication = comunicationCAD.ReadOIDDefault(dto.Comunication_oid); } newinstance.Id = dto.Id; newinstance.Name = dto.Name; if (dto.OriginAssociation_oid != null) { MoSIoTGenNHibernate.CAD.MosIoT.IAssociationCAD associationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.AssociationCAD(); newinstance.OriginAssociation = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.AssociationEN>(); foreach (int entry in dto.OriginAssociation_oid) { newinstance.OriginAssociation.Add(associationCAD.ReadOIDDefault(entry)); } } if (dto.TargetAssociation_oid != null) { MoSIoTGenNHibernate.CAD.MosIoT.IAssociationCAD associationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.AssociationCAD(); newinstance.TargetAssociation = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.AssociationEN>(); foreach (int entry in dto.TargetAssociation_oid) { newinstance.TargetAssociation.Add(associationCAD.ReadOIDDefault(entry)); } } if (dto.Scenario_oid != -1) { MoSIoTGenNHibernate.CAD.MosIoT.IIoTScenarioCAD ioTScenarioCAD = new MoSIoTGenNHibernate.CAD.MosIoT.IoTScenarioCAD(); newinstance.Scenario = ioTScenarioCAD.ReadOIDDefault(dto.Scenario_oid); } newinstance.Description = dto.Description; if (dto.Operations != null) { MoSIoTGenNHibernate.CAD.MosIoT.IEntityOperationCAD entityOperationCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityOperationCAD(); newinstance.Operations = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.EntityOperationEN>(); foreach (EntityOperationDTO entry in dto.Operations) { newinstance.Operations.Add(EntityOperationAssemblerDTO.Convert(entry)); } } if (dto.Attributes != null) { MoSIoTGenNHibernate.CAD.MosIoT.IEntityAttributesCAD entityAttributesCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityAttributesCAD(); newinstance.Attributes = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.EntityAttributesEN>(); foreach (EntityAttributesDTO entry in dto.Attributes) { newinstance.Attributes.Add(EntityAttributesAssemblerDTO.Convert(entry)); } } if (dto.States != null) { MoSIoTGenNHibernate.CAD.MosIoT.IEntityStateCAD entityStateCAD = new MoSIoTGenNHibernate.CAD.MosIoT.EntityStateCAD(); newinstance.States = new System.Collections.Generic.List <MoSIoTGenNHibernate.EN.MosIoT.EntityStateEN>(); foreach (EntityStateDTO entry in dto.States) { newinstance.States.Add(EntityStateAssemblerDTO.Convert(entry)); } } } } catch (Exception ex) { throw ex; } return(newinstance); }
public HttpResponseMessage ReadOID(int idIMCommunication) { // CAD, CEN, EN, returnValue IMCommunicationRESTCAD iMCommunicationRESTCAD = null; IMCommunicationCEN iMCommunicationCEN = null; IMCommunicationEN iMCommunicationEN = null; IMCommunicationDTOA returnValue = null; try { SessionInitializeWithoutTransaction(); iMCommunicationRESTCAD = new IMCommunicationRESTCAD(session); iMCommunicationCEN = new IMCommunicationCEN(iMCommunicationRESTCAD); // Data iMCommunicationEN = iMCommunicationCEN.ReadOID(idIMCommunication); // Convert return if (iMCommunicationEN != null) { returnValue = IMCommunicationAssembler.Convert(iMCommunicationEN, session); } } catch (Exception e) { if (e.GetType() == typeof(HttpResponseException)) { throw e; } else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) && e.Message.Equals("El token es incorrecto")) { throw new HttpResponseException(HttpStatusCode.Forbidden); } else if (e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.ModelException) || e.GetType() == typeof(MoSIoTGenNHibernate.Exceptions.DataLayerException)) { throw new HttpResponseException(HttpStatusCode.BadRequest); } else { throw new HttpResponseException(HttpStatusCode.InternalServerError); } } finally { SessionClose(); } // Return 404 - Not found if (returnValue == null) { return(this.Request.CreateResponse(HttpStatusCode.NotFound)); } // Return 200 - OK else { return(this.Request.CreateResponse(HttpStatusCode.OK, returnValue)); } }