// Modify default (Update all attributes of the class) public void ModifyDefault(IMCommandEN iMCommand) { try { SessionInitializeTransaction(); IMCommandEN iMCommandEN = (IMCommandEN)session.Load(typeof(IMCommandEN), iMCommand.Id); session.Update(iMCommandEN); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in IMCommandCAD.", ex); } finally { SessionClose(); } }
public IMCommandEN ReadOIDDefault(int id ) { IMCommandEN iMCommandEN = null; try { SessionInitializeTransaction(); iMCommandEN = (IMCommandEN)session.Get(typeof(IMCommandEN), id); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in IMCommandCAD.", ex); } finally { SessionClose(); } return(iMCommandEN); }
public IMCommandEN ReadOID(int id ) { IMCommandEN iMCommandEN = null; iMCommandEN = _IIMCommandCAD.ReadOID(id); return(iMCommandEN); }
public void Modify(int p_IMCommand_OID, string p_name, MoSIoTGenNHibernate.Enumerated.MosIoT.DataTypeEnum p_type, MoSIoTGenNHibernate.Enumerated.MosIoT.ServiceTypeEnum p_serviceType, string p_description) { IMCommandEN iMCommandEN = null; //Initialized IMCommandEN iMCommandEN = new IMCommandEN(); iMCommandEN.Id = p_IMCommand_OID; iMCommandEN.Name = p_name; iMCommandEN.Type = p_type; iMCommandEN.ServiceType = p_serviceType; iMCommandEN.Description = p_description; //Call to IMCommandCAD _IIMCommandCAD.Modify(iMCommandEN); }
public static IMCommandDTOA Convert(EntityOperationEN en, NHibernate.ISession session = null) { IMCommandDTOA dto = null; IMCommandRESTCAD iMCommandRESTCAD = null; IMCommandCEN iMCommandCEN = null; IMCommandCP iMCommandCP = null; if (en != null) { dto = new IMCommandDTOA(); iMCommandRESTCAD = new IMCommandRESTCAD(session); iMCommandCEN = new IMCommandCEN(iMCommandRESTCAD); iMCommandCP = new IMCommandCP(session); IMCommandEN enHijo = iMCommandRESTCAD.ReadOIDDefault(en.Id); // // Attributes dto.Id = en.Id; dto.Name = en.Name; dto.Description = en.Description; // // TravesalLink /* Rol: IMCommand o--> Command */ dto.ValueCommand = CommandAssembler.Convert((CommandEN)enHijo.Command, session); // // Service } return(dto); }
public int New_(IMCommandEN iMCommand) { try { SessionInitializeTransaction(); if (iMCommand.Entity != null) { // Argumento OID y no colección. iMCommand.Entity = (MoSIoTGenNHibernate.EN.MosIoT.EntityEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.EntityEN), iMCommand.Entity.Id); iMCommand.Entity.Operations .Add(iMCommand); } if (iMCommand.Command != null) { // Argumento OID y no colección. iMCommand.Command = (MoSIoTGenNHibernate.EN.MosIoT.CommandEN)session.Load(typeof(MoSIoTGenNHibernate.EN.MosIoT.CommandEN), iMCommand.Command.Id); } session.Save(iMCommand); SessionCommit(); } catch (Exception ex) { SessionRollBack(); if (ex is MoSIoTGenNHibernate.Exceptions.ModelException) { throw ex; } throw new MoSIoTGenNHibernate.Exceptions.DataLayerException("Error in IMCommandCAD.", ex); } finally { SessionClose(); } return(iMCommand.Id); }
public int New_(string p_name, MoSIoTGenNHibernate.Enumerated.MosIoT.DataTypeEnum p_type, MoSIoTGenNHibernate.Enumerated.MosIoT.ServiceTypeEnum p_serviceType, string p_description, int p_entity, int p_command) { IMCommandEN iMCommandEN = null; int oid; //Initialized IMCommandEN iMCommandEN = new IMCommandEN(); iMCommandEN.Name = p_name; iMCommandEN.Type = p_type; iMCommandEN.ServiceType = p_serviceType; iMCommandEN.Description = p_description; if (p_entity != -1) { // El argumento p_entity -> Property entity es oid = false // Lista de oids id iMCommandEN.Entity = new MoSIoTGenNHibernate.EN.MosIoT.EntityEN(); iMCommandEN.Entity.Id = p_entity; } if (p_command != -1) { // El argumento p_command -> Property command es oid = false // Lista de oids id iMCommandEN.Command = new MoSIoTGenNHibernate.EN.MosIoT.CommandEN(); iMCommandEN.Command.Id = p_command; } //Call to IMCommandCAD oid = _IIMCommandCAD.New_(iMCommandEN); return(oid); }
public HttpResponseMessage ReadOID(int idIMCommand) { // CAD, CEN, EN, returnValue IMCommandRESTCAD iMCommandRESTCAD = null; IMCommandCEN iMCommandCEN = null; IMCommandEN iMCommandEN = null; IMCommandDTOA returnValue = null; try { SessionInitializeWithoutTransaction(); iMCommandRESTCAD = new IMCommandRESTCAD(session); iMCommandCEN = new IMCommandCEN(iMCommandRESTCAD); // Data iMCommandEN = iMCommandCEN.ReadOID(idIMCommand); // Convert return if (iMCommandEN != null) { returnValue = IMCommandAssembler.Convert(iMCommandEN, 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)); } }
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); }