public static UserAnonimousDTOA Convert(UserEN en, NHibernate.ISession session = null) { UserAnonimousDTOA dto = null; UserAnonimousRESTCAD userAnonimousRESTCAD = null; UserCEN userCEN = null; UserCP userCP = null; if (en != null) { dto = new UserAnonimousDTOA(); userAnonimousRESTCAD = new UserAnonimousRESTCAD(session); userCEN = new UserCEN(userAnonimousRESTCAD); userCP = new UserCP(session); // // Attributes dto.Id = en.Id; // // TravesalLink // // Service } return(dto); }
public HttpResponseMessage Login([FromBody] UserDTO dto) { // CAD, CEN, returnValue UserAnonimousRESTCAD userAnonimousRESTCAD = null; UserCEN userCEN = null; string token = null; try { SessionInitializeTransaction(); userAnonimousRESTCAD = new UserAnonimousRESTCAD(session); userCEN = new UserCEN(userAnonimousRESTCAD); // Operation token = userCEN.Login( dto.Id , dto.Pass ); SessionCommit(); } catch (Exception e) { SessionRollBack(); 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 200 - OK if (token != null) { return(this.Request.CreateResponse(HttpStatusCode.OK, token)); } else { return(this.Request.CreateResponse(HttpStatusCode.Unauthorized, "")); } }
public static UserDTOA Convert(UserEN en, NHibernate.ISession session = null) { UserDTOA dto = null; UserRESTCAD userRESTCAD = null; UserCEN userCEN = null; UserCP userCP = null; if (en != null) { dto = new UserDTOA(); userRESTCAD = new UserRESTCAD(session); userCEN = new UserCEN(userRESTCAD); userCP = new UserCP(session); // // Attributes dto.Id = en.Id; dto.BirthDate = en.BirthDate; dto.Surnames = en.Surnames; dto.Address = en.Address; dto.Phone = en.Phone; dto.Photo = en.Photo; dto.IsActive = en.IsActive; dto.Type = en.Type; dto.IsDiseased = en.IsDiseased; dto.Email = en.Email; // // TravesalLink // // Service } return(dto); }
public static UserDTOA Convert(UserEN en, NHibernate.ISession session = null) { UserDTOA dto = null; UserRESTCAD userRESTCAD = null; UserCEN userCEN = null; UserCP userCP = null; if (en != null) { dto = new UserDTOA(); userRESTCAD = new UserRESTCAD(session); userCEN = new UserCEN(userRESTCAD); userCP = new UserCP(session); // // Attributes dto.Id = en.Id; dto.Name = en.Name; dto.Surnames = en.Surnames; dto.IsActive = en.IsActive; // // TravesalLink // // Service } return(dto); }
public HttpResponseMessage ReadAll() { // CAD, CEN, EN, returnValue UserRESTCAD userRESTCAD = null; UserCEN userCEN = null; List <UserEN> userEN = null; List <UserDTOA> returnValue = null; try { SessionInitializeWithoutTransaction(); userRESTCAD = new UserRESTCAD(session); userCEN = new UserCEN(userRESTCAD); // Data // TODO: paginación userEN = userCEN.ReadAll(0, -1).ToList(); // Convert return if (userEN != null) { returnValue = new List <UserDTOA>(); foreach (UserEN entry in userEN) { returnValue.Add(UserAssembler.Convert(entry, 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 204 - Empty if (returnValue == null || returnValue.Count == 0) { return(this.Request.CreateResponse(HttpStatusCode.NoContent)); } // Return 200 - OK else { return(this.Request.CreateResponse(HttpStatusCode.OK, returnValue)); } }
public HttpResponseMessage New_([FromBody] UserDTO dto) { // CAD, CEN, returnValue, returnOID UserRESTCAD userRESTCAD = null; UserCEN userCEN = null; UserDTOA returnValue = null; int returnOID = -1; // HTTP response HttpResponseMessage response = null; string uri = null; try { SessionInitializeTransaction(); userRESTCAD = new UserRESTCAD(session); userCEN = new UserCEN(userRESTCAD); // Create returnOID = userCEN.New_( dto.Surnames //Atributo Primitivo: p_surnames , dto.IsActive //Atributo Primitivo: p_isActive , dto.IsDiseased //Atributo Primitivo: p_isDiseased , dto.Pass //Atributo Primitivo: p_pass , dto.Name //Atributo Primitivo: p_name , dto.Description //Atributo Primitivo: p_description , dto.Email //Atributo Primitivo: p_email ); SessionCommit(); // Convert return returnValue = UserAssembler.Convert(userRESTCAD.ReadOIDDefault(returnOID), session); } catch (Exception e) { SessionRollBack(); 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 201 - Created response = this.Request.CreateResponse(HttpStatusCode.Created, returnValue); // Location Header /* * Dictionary<string, object> routeValues = new Dictionary<string, object>(); * * // TODO: y rolPaths * routeValues.Add("id", returnOID); * * uri = Url.Link("GetOIDUser", routeValues); * response.Headers.Location = new Uri(uri); */ return(response); }
public HttpResponseMessage ReadOID(int idUser) { // CAD, CEN, EN, returnValue UserRESTCAD userRESTCAD = null; UserCEN userCEN = null; UserEN userEN = null; UserDTOA returnValue = null; try { SessionInitializeWithoutTransaction(); userRESTCAD = new UserRESTCAD(session); userCEN = new UserCEN(userRESTCAD); // Data userEN = userCEN.ReadOID(idUser); // Convert return if (userEN != null) { returnValue = UserAssembler.Convert(userEN, 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 void InitializeData() { /*PROTECTED REGION ID(initializeDataMethod) ENABLED START*/ try { // Insert the initilizations of entities using the CEN classes UserCEN userCEN = new UserCEN(); userCEN.New_("shahabsur", true, false, "1234", "shahab", "Shahab", "*****@*****.**"); int idUser = userCEN.New_("Lucas Grijander", true, true, "1234", "Chiquito", "Paciente Alzheimer", "*****@*****.**"); DeviceTemplateCEN deviceTCEN = new DeviceTemplateCEN(); int deviceT1 = deviceTCEN.New_("Smartring", DeviceTypeEnum.sensor, false); int deviceT2 = deviceTCEN.New_("Smartphone", DeviceTypeEnum.actuator, false); int deviceT3 = deviceTCEN.New_("Voice Assistance", DeviceTypeEnum.actuator, false); CommandCEN commandCEN = new CommandCEN(); commandCEN.New_(deviceT1, "Command 1", true, OperationTypeEnum.GetByID, "get device by id"); PropertyCEN propertyCEN = new PropertyCEN(); propertyCEN.New_(deviceT1, "property 1", true, true); TelemetryCEN telemetryCEN = new TelemetryCEN(); int idTelemetry = telemetryCEN.New_(deviceT1, 2, MoSIoTGenNHibernate.Enumerated.MosIoT.DataTypeEnum.Integer, TypeUnitEnum.steps, "Heart beats", TelemetryTypeEnum.event_); EventTelemetryCEN eventTelemetry = new EventTelemetryCEN(); int eventTel1 = eventTelemetry.New_(idTelemetry, "evento", MoSIoTGenNHibernate.Enumerated.MosIoT.SeverityEventEnum.info); PatientProfileCEN patientProfile = new PatientProfileCEN(); int idPatientProfile = patientProfile.New_(LanguageCodeEnum.es, "Espana", HazardValueEnum.olfactoryHazard, "patient with Alzheimer", "patient with a mild Alzheimer with a cognitive disability"); ConditionCEN conditionCEN = new ConditionCEN(); int idCondition = conditionCEN.New_(idPatientProfile, "Alzheimer", ClinicalStatusEnum.active, DiseaseEnum.Alzheimer, "Alzheimer"); DisabilityCEN disabilityCEN = new DisabilityCEN(); int idDisability = disabilityCEN.New_(idPatientProfile, "cognitive", DisabilityTypeEnum.cognitive, SeverityEnum.mild, "Cognitive Disability"); AccessModeCEN accessMode = new AccessModeCEN(); int idAccessMode = accessMode.New_(idPatientProfile, AccessModeValueEnum.textual, "Acceso al Smartphone", idDisability, "accessMode Smartphone"); AdaptationRequestCEN adaptRequest = new AdaptationRequestCEN(); adaptRequest.New_(AccessModeValueEnum.auditory, idAccessMode, LanguageCodeEnum.es, "adaptation auditive"); AdaptationTypeRequiredCEN adapTypeReq = new AdaptationTypeRequiredCEN(); adapTypeReq.New_(AdaptationTypeValueEnum.audioDescription, "Describe el contenido con voz", idAccessMode); AdaptationDetailRequiredCEN adaptationDetail = new AdaptationDetailRequiredCEN(); adaptationDetail.New_(AdaptationDetailValueEnum.record, idAccessMode, "Se graba el la voz generada"); CarePlanTemplateCEN carePlan = new CarePlanTemplateCEN(); int idCarePlanT = carePlan.New_(CareStatusEnum.active, CarePlanIntentEnum.proposal, "Plan de cuidados para persona con Alzheimer", DateTime.Now, 100, "cuidadosAlzheimer", "Se describen todos los objetivos y actividades necesarias para que se cuide a una persona que presenta Alzheimer"); carePlan.AddCondition(idCarePlanT, new List <int> { idCondition }); CareActivityCEN careActivity = new CareActivityCEN(); careActivity.New_(idCarePlanT, TypePeriodicityEnum.daily, "Realizar un paseo", 40, "parque", "", TypeActivityEnum.sportActivity, " ", "Paseo"); int idActivityMed = careActivity.New_(idCarePlanT, TypePeriodicityEnum.perHour, "Tomar Ceregumil", 0, "en casa", "", TypeActivityEnum.medication, "", "Tomar medicamento mente activa"); MedicationCEN medicationCEN = new MedicationCEN(); medicationCEN.New_(idActivityMed, 346864, "Ceregumil Original 500 ml", " ", "Tomar una cucharada 3 veces al dia", "cucharada", FormTypeEnum.powder, "346864"); GoalCEN goal = new GoalCEN(); int idGoal = goal.New_(idCarePlanT, PriorityTypeEnum.high, CareStatusEnum.active, idCondition, "Mejorar los indicadores cognitivos", CategoryGoalEnum.behavioral, " ", "Mejora cognitiva"); TargetCEN target = new TargetCEN(); int idTarget = target.New_(idGoal, "70", "Reducir las pulsaciones a 70", DateTime.Today.AddDays(60)); MeasureCEN measureCEN = new MeasureCEN(); int idMeasure = measureCEN.New_("Pulsaciones_minuto", "Pulsaciones por minuto", " "); target.AddMeasure(idTarget, idMeasure); measureCEN.AddTelemetries(idMeasure, new List <int> { idTelemetry }); // SCENARIO IoTScenarioCEN scenarioCEN = new IoTScenarioCEN(); int idScenarioIoT = scenarioCEN.New_("Escenario Paciente con Alzheimer", "Se reproducen los elementos de un enfermo de alzheimer con discapacidad cognitiva"); PatientCEN patientCEN = new PatientCEN(); patientCEN.New_("Juan Lucas", idScenarioIoT, "Es un paciente nuevo", idPatientProfile, idUser); PatientAccessCEN patientAccessCEN = new PatientAccessCEN(); patientAccessCEN.New_("PatientAccessSmartphone", idScenarioIoT, "patient Access Smartphone", idAccessMode); DeviceCEN deviceCEN = new DeviceCEN(); deviceCEN.New_("Iphone 12", idScenarioIoT, "Iphone 12 120 Gb", false, "1212", true, "1818181818181", "firm1", "Apple", deviceT2); CarePlanCEN carePlanCEN = new CarePlanCEN(); carePlanCEN.New_("Care Plan Alzheimer", idScenarioIoT, "El carePlan adecuado para el alzheimer", idCarePlanT); /*PROTECTED REGION END*/ } catch (Exception ex) { System.Console.WriteLine(ex.InnerException); throw ex; } }
public static void InitializeData () { /*PROTECTED REGION ID(initializeDataMethod) ENABLED START*/ try { // Insert the initilizations of entities using the CEN classes UserCEN userCen = new UserCEN(); IdiomaCEN idio = new IdiomaCEN(); idio.New_("Castellano"); idio.New_("Ingles"); idio.New_("Aleman"); idio.New_("Frances"); NoConectadoCEN nconCen = new NoConectadoCEN(); ConectadoCEN conec = new ConectadoCEN(); //idioma? conec.New_("John Jonero Jonancio", "JoJoJo", new DateTime(1991, 11, 13), "pass", "*****@*****.**", false, 1, http://m.memegen.com/1j7mtm.jpg); conec.New_("Tum Tumtum Tumtumtum", "Tumx6", new DateTime(1995, 10, 10), "tumaqueguay", "*****@*****.**", true, 1, http://m.memegen.com/sg0yim.jpg); conec.New_("Bruno Lee", "LeeBru", new DateTime(1986, 01, 02), "leeunlibru", "*****@*****.**", false, 1, https://s-media-cache-ak0.pinimg.com/236x/7a/10/88/7a1088b474181b312d12b4fb2565cf7d.jpg); conec.New_("Maria Muffin", "LovePalomas", new DateTime(1998, 05, 24), "jajaja", "*****@*****.**", true, 1, http://img.desmotivaciones.es/201107/MariaMuffin.jpg); conec.New_("Jair Powa", "DigoJairPaReirme", new DateTime(1988, 08, 30), "garagefruit", "*****@*****.**", true, 1, http://m.memegen.com/v47sxo.jpg); AdminCEN admi = new AdminCEN(); //idioma? admi.New_("Paco Gonzalez Garcia", "Paconator", new DateTime(1990, 08, 03), "123456", "*****@*****.**", true, 1, http://r30.imgfast.net/users/3017/12/50/30/avatars/640-22.jpg); admi.New_("Laura Gutierrez Fuentes", "Larra", new DateTime(1989, 10, 12), "password", "*****@*****.**", true, 1, http://vignette3.wikia.nocookie.net/hieloyfuego/images/d/d6/A_Lyseni_noblewoman_by_Magali_Villeneuve%C2%A9.jpg/revision/latest?cb=20150214193400); admi.New_("Luis Sanchez Aroca", "Luis S.A.", new DateTime(1992, 02, 22), "contraseña", "*****@*****.**", false, 1, https://s-media-cache-ak0.pinimg.com/236x/12/c4/6a/12c46a55fd7c5257f1eae1e1f49c49ac.jpg); RedactorCEN redCen = new RedactorCEN(); //idioma? redCen.New_("Juan Lujan Fernandez", "JuanLuFer", new DateTime(1981, 09, 13), "jajajajeje", "*****@*****.**", false, 1, https://kiwicdn.akamaized.net/6c10/ELxRqkM4UYyi4EQRxL2pER_150.jpg); redCen.New_("Fernanda Gomariz Sanchez", "GomaGoma", new DateTime(1985, 12, 12), "gomugomu", "*****@*****.**", true, 1, http://papels.es/gestion/imagenesges/zoom/goma-borrar-milan-430.png); redCen.New_("Vicente Blasco Ibanez", "MorFil", new DateTime(1970, 01, 28), "tadeloemon", "*****@*****.**", true, 1, http://vignette4.wikia.nocookie.net/mortadelo/images/f/f6/Se%C3%B1or_s%C3%BAper.jpg/revision/latest?cb=20110622161302&path-prefix=es); ArticuloCEN art = new ArticuloCEN (); //redacta? art.New_("Bla blablablablablablablablablablablabla blabla", new DateTime(2013,11,07), OscarsitosGenNHibernate.Enumerated.Oscarsitos.CategArticuloEnum.Rosa, "Paquito clavo un clavito", true, true, http://1.bp.blogspot.com/-CDKU6JbgfDs/UzqMzGs9W2I/AAAAAAAAAKc/SBoA2yBhkBg/s1600/pabl.png); art.New_("Blebleble bleblebleblebleblebleblebleble", new DateTime(2013,11,06), OscarsitosGenNHibernate.Enumerated.Oscarsitos.CategArticuloEnum.Estrenos, "Tom es el nuevo Bartman", true, true, http://img10.deviantart.net/e750/i/2008/170/e/0/i_am_bartman__by_leif_j.png); art.New_("Bla blablablablabla blobloblobloblo blablablablablablabla blabla", new DateTime(2013,11,10), OscarsitosGenNHibernate.Enumerated.Oscarsitos.CategArticuloEnum.Rumores, "Sara protagonizara Un viaje a tu casa", false, true, https://jetmarinspiraviajar.files.wordpress.com/2015/06/blog_balanza1.jpg); art.New_("Blublublu bliblibli blablablablablablablablablablablabla blabla", new DateTime(2013,11, 12), OscarsitosGenNHibernate.Enumerated.Oscarsitos.CategArticuloEnum.Curiosidades, "Gazapos en el rodaje de SuperShurperro", false, false, http://i47.tinypic.com/4g3jtt.jpg); PuntuancionConectadoCEN puntCen = new PuntuancionConectadoCEN(); //espuntuado puntua? puntCen.New_(0, 0, 0); puntCen.New_(0, 0, 0); puntCen.New_(0, 0, 0); puntCen.New_(0, 0, 0);n ComentarioCEN comen = new ComentarioCEN(); //escritor y articulo? comen.New_("Te odio Juan Hanks!", 256, 1,1); comen.New_("Yo aparqué ahí ayer", 3, 1,1); comen.New_("Ojalá rueden aqui y necesiten extras", 0, 1,1); comen.New_("Dos chicas sin blanca es una serie muy buena", -30, 1,1); /*UsuarioConectCEN usconCen = new UsuarioConectCEN(); //comentario? usconCen.New_("Jose Escalejo Muniz", "joes", new DateTime(1978,12,20), "jajajojojeje", "*****@*****.**");//attribute? usconCen.New_("Sara Gertrude Garcia", "saGer", new DateTime(1992,10,01), "esagerado", "*****@*****.**");//attribute? usconCen.New_("Perico Palotes", "Palote", new DateTime(1980,04,05), "perpalo", "*****@*****.**");//attribute? UsuarioNoConectCen usnoconCen = new usnoconCen ();*/ /*PROTECTED REGION END*/ } catch (Exception ex) { System.Console.WriteLine (ex.InnerException); throw ex; } }