/// <summary> /// Insere o dispositivo /// </summary> /// <param name="device"></param> public void insertDevice(HardwareModel device) { dog.Begin(); Graph g = null; OntoDevice deviceBD = new OntoDevice(device); deviceBD.InsertDevice(ref g); dog.SaveGraph(g); deviceBD.InsertDeviceBrand(ref g); dog.SaveGraph(g); deviceBD.InsertDeviceType(ref g); dog.SaveGraph(g); deviceBD.InsertDeviceModel(ref g); dog.SaveGraph(g); deviceBD.InsertDeviceTypeConnection(ref g); dog.SaveGraph(g); // faz o commit do elementos de hardware dog.Commit(); }
/// <summary> /// Insere no banco RDF o ID e o número do dispositivo /// </summary> /// <param name="UserID">ID do usuário utilizado para fazer o login do sistema</param> /// <param name="deviceToken">numero do dispositivo móvel</param> public void InsertUserDeviceTokenInDatabase(string Matricula, string deviceToken, string DeviceName) { Graph g = new Graph(); UserContextModel user = new UserContextModel(); //Pega a instancia do banco de dados RDF SingletonStarDog dog = SingletonStarDog.getDbInstance(); user.Matricula = Matricula; HardwareModel device = new HardwareModel(); device.model_name = DeviceName; //Nome do dispositivo device.Device_ID = deviceToken; //ID do dispositivo para enviar notificações OntoStudent obj = new OntoStudent(user, device); dog.GetDBConnection().Begin(); obj.insertStudent(ref g); dog.GetDBConnection().SaveGraph(g); OntoDevice OntoDev = new OntoDevice(device); OntoDev.InsertDevice(ref g); dog.GetDBConnection().SaveGraph(g); //obj.insertHasDevice(ref g); dog.GetDBConnection().SaveGraph(g); dog.GetDBConnection().Commit(); }
public void GetObjectbyContext(string contextFile) { RootObject deserializedProduct = null; try { deserializedProduct = JsonConvert.DeserializeObject<RootObject>(contextFile); } catch (IOException) { } #region Armazena o Contexto var g = new Graph(); var ctx = new UserContextModel(); var dog = SingletonStarDog.getDbInstance(); if (deserializedProduct != null && deserializedProduct.Profile != null) { ctx.StudentIdiom = deserializedProduct.Profile.Language; ctx.StudentPreference = deserializedProduct.Profile.PreferenceMedia; ctx.Matricula = deserializedProduct.Profile.Matricula; } var device = new HardwareModel(); if (deserializedProduct != null && deserializedProduct.Device.DeviceIMEI != null) { device.Device_ID = deserializedProduct.Device.DeviceIMEI.ToString(); } if (deserializedProduct != null) device.device_os_version = deserializedProduct.Device.SystemVersion; device.model_name = "Dev" + device.Device_ID; dog.GetDBConnection().Reasoning = VDS.RDF.Storage.StardogReasoningMode.SL; var Student = new OntoStudent(ctx, device); dog.GetDBConnection().Begin(); Student.insertStudent(ref g); dog.GetDBConnection().SaveGraph(g); Student.insertPreference(ref g, ctx.StudentPreference); dog.GetDBConnection().SaveGraph(g); device.MediaPreference = ctx.StudentPreference; Student.insertLearningStyle(ref g); dog.GetDBConnection().SaveGraph(g); Student.insertDeviceID(ref g); dog.GetDBConnection().SaveGraph(g); var dev = new OntoDevice(device); dev.InsertDevice(ref g); dog.GetDBConnection().SaveGraph(g); dev.insertDeviceMediaPreference(ref g); dog.GetDBConnection().SaveGraph(g); dev.InsertDeviceToken(ref g); dog.GetDBConnection().SaveGraph(g); dog.GetDBConnection().Commit(); #endregion #region LOCALIZAR OBJ String strSparql = @"PREFIX rdf: <http://www.w3.org/1999/02/22-rdf-syntax-ns#> PREFIX owl: <http://www.w3.org/2002/07/owl#> PREFIX xsd: <http://www.w3.org/2001/XMLSchema#> PREFIX rdfs: <http://www.w3.org/2000/01/rdf-schema#> PREFIX onto: <http://www.owl-ontologies.com/OntoAdapt2.owl#> SELECT ?obj ?p WHERE {:" + ctx.Matricula; strSparql += " onto:hasObjectChosenToStudent ?obj. " + "?obj :LO_Link ?p.}"; dog.GetDBConnection().Reasoning = StardogReasoningMode.SL; var resultsNoReasoning = dog.GetDBConnection().Query(strSparql) as SparqlResultSet; if (resultsNoReasoning != null) { List<SparqlResult> lista = resultsNoReasoning.ToList(); var toReturn = new List<string>(); var strBuilder = new StringBuilder(); foreach (SparqlResult rlt in lista) { //RemoveURLFromOntoloryResults( strBuilder.Append(rlt[1].ToString()); } #endregion #region EnviaMsg SendPushMessages(device.Device_ID, "Você tem um Objeto de Aprendizagem para fazer Donwload"); #endregion } }