Exemplo n.º 1
0
        private void btnCadUser_Click(object sender, EventArgs e)
        {
            Graph g = new Graph();
            UserContextModel ctx = new UserContextModel();
            SingletonStarDog dog = SingletonStarDog.getDbInstance();

            //ctx.userID = txtAlunoID.Text;
            //ctx.ComunidadeMoodle = txtAlunoComunidade.Text;
            HardwareModel device = new HardwareModel();
            //device.Device_ID = txtDeviceID.Text;
            //ctx.DeviceList.Add(device);

            OntoStudent obj = new OntoStudent(ctx, device);
            dog.GetDBConnection().Begin();
            obj.insertStudent(ref g);
            dog.GetDBConnection().SaveGraph(g);
               // obj.insertHasDevice(ref g);
            dog.GetDBConnection().SaveGraph(g);
            obj.insertComunidadeMoodle(ref g);
            dog.GetDBConnection().SaveGraph(g);
            dog.GetDBConnection().Commit();

            Ontology.Ontology.ListAllDevices(txtComunidades.Text);

            Ontology.Ontology onto2 = new Ontology.Ontology();
            onto2.ListAllUserDevice();
        }
Exemplo n.º 2
0
        /// <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();
        }
Exemplo n.º 3
0
        public void insertUser()
        {
            HardwareModel device = new HardwareModel();
            device.Device_ID = "b297de0164546e4a5b5d0c7d876b14dc15cca8f849c96da9a50472a35384b533";
            device.model_name = "iPhone_4S";
            device.Brand_Name = "Apple";
            device.Device_type = "smartphone";

            UserContextModel user = new UserContextModel();
            user.Matricula = "0895837";

            dog.Begin();
            Graph g = null;
            OntoStudent student = new OntoStudent(user, device);

            student.insertStudent(ref g); dog.SaveGraph(g);
            //student.insertLearningStyle(ref g, "LearningStyle_Active"); dog.SaveGraph(g);
            //student.insertLearningStyle(ref g, "LearningStyle_Intuitive"); dog.SaveGraph(g);

            dog.Commit();
        }
Exemplo n.º 4
0
        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

            }
        }