Beispiel #1
0
        protected virtual void HandlerHardwareButtonOk_Click(object sender, EventArgs e)
        {
            string errMsg = ReadView();

            if (!string.IsNullOrWhiteSpace(errMsg))
            {
                HardwareCardSubHeader.Text = errMsg;
                HardwareCardSubHeader.SetTextColor(Android.Graphics.Color.Red);
                Toast.MakeText(this, errMsg, ToastLength.Short).Show();
                return;
            }

            lock (DatabaseContext.DbLocker)
            {
                using (DatabaseContext db = new DatabaseContext(gs.DatabasePathBase))
                {
                    HardwareModel hardware = new HardwareModel()
                    {
                        AlarmSubscriber = HardwareAlarmSubscribing.Checked,
                        CommandsAllowed = HardwareCommandsAllowed.Checked,
                        Name            = HardwareName.Text.Trim(),
                        Address         = HardwareAddress.Text.Trim(),
                        Password        = HardwarePassword.Text.Trim()
                    };
                    db.Hardwares.Add(hardware);
                    db.SaveChanges();
                }
            }
            StartActivity(typeof(HardwaresListActivity));
        }
Beispiel #2
0
        public static void saveSettings(HardwareModel hardwareModel, SettingsModel settingsModel, ColorModel colorModel)
        {
            //hardware model settings
            Properties.Settings.Default.dp1Speed = hardwareModel.dataPoints[0].speed;
            Properties.Settings.Default.dp1Temp  = hardwareModel.dataPoints[0].temperature;

            Properties.Settings.Default.dp2Speed = hardwareModel.dataPoints[1].speed;
            Properties.Settings.Default.dp2Temp  = hardwareModel.dataPoints[1].temperature;

            Properties.Settings.Default.dp3Speed = hardwareModel.dataPoints[2].speed;
            Properties.Settings.Default.dp3Temp  = hardwareModel.dataPoints[2].temperature;

            Properties.Settings.Default.dp4Speed = hardwareModel.dataPoints[3].speed;
            Properties.Settings.Default.dp4Temp  = hardwareModel.dataPoints[3].temperature;

            Properties.Settings.Default.dp5Speed = hardwareModel.dataPoints[4].speed;
            Properties.Settings.Default.dp5Temp  = hardwareModel.dataPoints[4].temperature;

            Properties.Settings.Default.quietModeOn   = hardwareModel.quietModeEnabled;
            Properties.Settings.Default.quitModeSpeed = hardwareModel.quietModeSpeed;

            //color model settings
            //TODO: default mode
            Properties.Settings.Default.staticStartColor = colorModel.color;

            //settings model settings
            Properties.Settings.Default.autoStartOn    = settingsModel.startOnBoot;
            Properties.Settings.Default.autoReconnect  = settingsModel.autoReconnect;
            Properties.Settings.Default.startMinimized = settingsModel.startMinimized;

            Properties.Settings.Default.Save();
        }
Beispiel #3
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();
        }
        public override void OnBindViewHolder(RecyclerView.ViewHolder holder, int position)
        {
            Log.Debug(TAG, $"OnBindViewHolder - position:{position}");

            HardwareListItemViewHolder hardwareViewHolder = holder as HardwareListItemViewHolder;

            lock (DatabaseContext.DbLocker)
            {
                using (DatabaseContext db = new DatabaseContext(gs.DatabasePathBase))
                {
                    HardwareModel hardware = db.Hardwares.Skip(position).FirstOrDefault();
                    hardwareViewHolder.ObjectId = hardware.Id;
                    //
                    hardwareViewHolder.Name.Text    = hardware.Name;
                    hardwareViewHolder.Address.Text = hardware.Address;
                    if (!hardware.AlarmSubscriber)
                    {
                        hardwareViewHolder.AlarmSubscriber.Text = mContext.GetText(Resource.String.mute_marker_title);
                        hardwareViewHolder.AlarmSubscriber.SetTextColor(Color.LightGray);
                    }
                    if (!hardware.CommandsAllowed)
                    {
                        hardwareViewHolder.CommandsAllowed.Text = mContext.GetText(Resource.String.deaf_marker_title);
                        hardwareViewHolder.CommandsAllowed.SetTextColor(Color.LightGray);
                    }
                }
            }
        }
        public void retrieveState(OleDbConnection connection)
        {
            HardwareModel hardwareModel = HardwareModel.getInstance(connection);

            components = hardwareModel.listComponents();
            computers  = hardwareModel.listComputers();
        }
        private void Controllers_ItemSelected(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            int hardware_id = ParentActivity.Hardwares.Keys.ElementAt(e.Position);

            if (Command != null && Command.Execution != hardware_id)
            {
                CommandText.Text = Command.ExecutionParametr;
                Controllers.SetSelection(ParentActivity.Hardwares.Keys.ToList().IndexOf(Command.Execution));
                return;
            }
            Command = null;

            ParentActivity.command_executer_id = hardware_id;
            HardwareModel hw = null;

            if (ParentActivity.command_executer_id > 0)
            {
                lock (DatabaseContext.DbLocker)
                {
                    using (DatabaseContext db = new DatabaseContext(gs.DatabasePathBase))
                    {
                        hw = db.Hardwares.Find(ParentActivity.command_executer_id);
                    }
                }
            }
            if (hw == null)
            {
                Log.Error(TAG, $"{ParentActivity.GetString(Resource.String.err_selected_device_was_not_found_title)} - ControllerCommand_SpinnerItemSelected({ParentActivity.command_executer_id}) - Position:{e.Position}");
            }
            else
            {
                Log.Debug(TAG, $"ControllerCommand_SpinnerItemSelected(hw:{hw}) - Position:{e.Position}");
            }
        }
        private void ButtonDeleteHardware_Click(object sender, EventArgs e)
        {
            Log.Debug(TAG, "ButtonDeleteHardware_Click");

            HardwareCardHeader.Text = GetText(Resource.String.delete_hardware_card_title);

            HardwareCardSubHeader.Text = GetText(Resource.String.delete_hardware_card_sub_title);
            HardwareCardSubHeader.SetTextColor(Color.IndianRed);

            HardwareName.Enabled     = false;
            HardwareAddress.Enabled  = false;
            HardwarePassword.Enabled = false;

            HardwareAlarmSubscribing.Enabled = false;
            HardwareCommandsAllowed.Enabled  = false;

            HardwareCardButtonOk.Enabled = false;
            HardwareCardButtonOk.Text    = GetText(Resource.String.ok_mute_button_with_remove_hardware);

            buttonDeleteHardware.Enabled = false;
            buttonDeleteHardware.SetTextColor(Color.Gray);
            buttonDeleteHardware.Click -= ButtonDeleteHardware_Click;

            SystemSettingsHardware.Enabled = false;
            SystemSettingsHardware.SetTextColor(Color.Gray);
            SystemSettingsHardware.Click -= SystemSettingsHardware_Click;

            AppCompatTextView appCompatTextView = new AppCompatTextView(this)
            {
                Text = GetText(Resource.String.footer_text_with_remove_hardware), TextSize = 15
            };

            appCompatTextView.SetTextColor(Color.Red);
            appCompatTextView.SetWidth(3);
            HardwareFooterLayout.AddView(appCompatTextView);

            AppCompatButton ButtonConfirmDeleteHardware = new AppCompatButton(this)
            {
                Text = GetText(Resource.String.button_confirm_remove)
            };

            ButtonConfirmDeleteHardware.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            ButtonConfirmDeleteHardware.SetTextColor(Color.DarkRed);
            ButtonConfirmDeleteHardware.Click += new EventHandler((sender, eventArg) =>
            {
                lock (DatabaseContext.DbLocker)
                {
                    using (DatabaseContext db = new DatabaseContext(gs.DatabasePathBase))
                    {
                        HardwareModel hardware = db.Hardwares.Find(hardwareId);
                        db.Hardwares.Remove(hardware);
                        db.SaveChanges();

                        StartActivity(typeof(HardwaresListActivity));
                    }
                }
            });
            HardwareFooterLayout.AddView(ButtonConfirmDeleteHardware);
        }
Beispiel #8
0
 public ColorController(ColorModel model, HardwareModel hwModel, TinyMessengerHub messageHub, MainForm gui)
 {
     this._colorModel = model;
     this._hwModel    = hwModel;
     this._messageHub = messageHub;
     this._gui        = gui;
     this.isDisposed  = false;
 }
Beispiel #9
0
        public void init(ColorModel colorModel, HardwareModel hardwareModel, TinyMessengerHub messageHub)
        {
            this.colorModel    = colorModel;
            this.hardwareModel = hardwareModel;
            this.messageHub    = messageHub;

            messageHub.Subscribe <ColorModelMessage>((m) => colorModelUpdated(m.Content));
            messageHub.Subscribe <HardwareModelMessage>((m) => { this.Invoke(new MethodInvoker(hardwareModelUpdated)); });
            messageHub.Subscribe <SettingsModelMessage>((m) => { this.Invoke(new MethodInvoker(settingsModelUpdated)); });
        }
Beispiel #10
0
        public TemperarureColorMode(ColorModel model, HardwareModel hwModel)
        {
            this.model   = model;
            this.hwModel = hwModel;

            coolColor = model.coldTempColor;
            hotColor  = model.hotTempColor;

            coolThreshold = model.coldTemp;
            hotThreshold  = model.hotTemp;
        }
        public HardwareController(HardwareModel _hardwareModel, TinyMessenger.TinyMessengerHub _messageHub, MainForm gui)
        {
            this._hardwareModel = _hardwareModel;
            this._messageHub    = _messageHub;
            this._gui           = gui;

            _isRunning = false;

            if (_hardwareModel.dataPoints == null)
            {
                List <LinearDataPoint> dataPoints = new List <LinearDataPoint>();
                dataPoints.Add(new LinearDataPoint(0, 0));
                dataPoints.Add(new LinearDataPoint(40, 0));
                dataPoints.Add(new LinearDataPoint(50, 35));
                dataPoints.Add(new LinearDataPoint(70, 70));
                dataPoints.Add(new LinearDataPoint(100, 100));
                _hardwareModel.dataPoints = dataPoints;
            }
            _linearDataInterpolator = new LinearFunctionInterpolator(_hardwareModel.dataPoints);


            _computer.CPUEnabled = true;
            //computer.FanControllerEnabled = true;
            _computer.GPUEnabled = true;
            //computer.HDDEnabled = true;
            //computer.MainboardEnabled = true;
            //computer.RAMEnabled = true;

            _computer.Open();
            _provider = new WmiProvider(_computer);

            foreach (IHardware hw in _computer.Hardware)
            {
                Console.WriteLine(hw.Name);
                if (hw.HardwareType == HardwareType.CPU)
                {
                    foreach (ISensor sensor in hw.Sensors)
                    {
                        if (sensor.SensorType == SensorType.Temperature && !sensor.Name.ToLower().Equals("cpu package"))
                        {
                            _sensors.Add(sensor);
                        }
                    }
                }
            }
            _hardwareModel.sensors = _sensors;

            _thread = new System.Threading.Thread(run);
            _thread.IsBackground = true;
            _thread.Name         = "Hardware monitor thread";
            _thread.Start();
        }
        public void ControllerSelect(object sender, AdapterView.ItemSelectedEventArgs e)
        {
            int hardware_id = ParentActivity.Hardwares.Keys.ElementAt(e.Position);

            if (Command != null)
            {
                PortModel port = null;
                lock (DatabaseContext.DbLocker)
                {
                    using (DatabaseContext db = new DatabaseContext(gs.DatabasePathBase))
                    {
                        port = db.Ports.FirstOrDefault(x => x.Id == Command.Execution);
                    }
                }
                if (port.HardwareId != hardware_id)
                {
                    Controllers.SetSelection(ParentActivity.Hardwares.Keys.ToList().IndexOf(port.HardwareId));
                    return;
                }
            }

            PortsList = new Dictionary <int, string>();

            HardwareModel hw = null;

            if (hardware_id > 0)
            {
                lock (DatabaseContext.DbLocker)
                {
                    using (DatabaseContext db = new DatabaseContext(gs.DatabasePathBase))
                    {
                        hw = db.Hardwares.Include(x => x.Ports).FirstOrDefault(x => x.Id == hardware_id);
                    }
                }
            }
            if (hw == null)
            {
                Log.Error(TAG, $"{ParentActivity.GetString(Resource.String.err_selected_device_was_not_found_title)}; ControllerSelect(); hardware_id:{hardware_id}; Position:{e.Position};");
                return;
            }
            else
            {
                Log.Debug(TAG, $"ControllerSelect(); for command; hw:{hw}; Position:{e.Position};");
            }
            hw.Ports.ForEach(portHardware => { PortsList.Add(portHardware.Id, portHardware.ToString()); });
            //
            ArrayAdapter <string> adapterPorts = new ArrayAdapter <string>(ParentActivity, Android.Resource.Layout.SimpleSpinnerItem, PortsList.Values.ToList());

            adapterPorts.SetDropDownViewResource(Android.Resource.Layout.SimpleSpinnerDropDownItem);
            Ports.Adapter = adapterPorts;
        }
Beispiel #13
0
        public async Task <IActionResult> Index()
        {
            var _boards = await _context.Boards
                          .AsNoTracking().ToListAsync();

            var _components = await _context.Components
                              .AsNoTracking().ToListAsync();

            //IEnumerable<HardwareModel> hardware
            HardwareModel hardware = new HardwareModel {
                boards = _boards, components = _components
            };

            return(View(hardware));
        }
Beispiel #14
0
        public async Task <HardwareModel> GetHardwareModel()
        {
            List <Module> modules = new List <Module>();

            if (hardwareService != null)
            {
                modules = await hardwareService.GetModules();

                logger.LogDebug($"HardwareRestController.GetHardwareModel: {modules.Count} modules found");
            }

            HardwareModel model = new HardwareModel();

            model.Modules = modules;

            return(model);
        }
Beispiel #15
0
        // GET: System/Hardware
        public async Task <IActionResult> Index()
        {
            return(await Task.Run(async() =>
            {
                List <Module> modules = new List <Module>();
                if (this.hardwareService != null)
                {
                    modules = await this.hardwareService.GetModules();
                    logger.LogDebug($"HardwareController.Index: {modules.Count} modules found");
                }

                HardwareModel model = new HardwareModel();
                model.Modules = modules;

                return View(model);
            }));
        }
        private static HardwareModel GenerateHardwareModel(Hardware pHardware)
        {
            HardwareModel model = new HardwareModel
            {
                CameraRange       = pHardware.Camera.Range,
                CameraGenotype    = pHardware.CameraGenotype,
                CameraChromosome  = MathematicalOperations.ConvertIntToBinaryString(pHardware.CameraGenotype),
                EngineCapacity    = pHardware.Engine.MaxTerrainDifficulty,
                EngineGenotype    = pHardware.EngineGenotype,
                EngineChromosome  = MathematicalOperations.ConvertIntToBinaryString(pHardware.EngineGenotype),
                BatteryEnergy     = pHardware.Battery.Energy,
                BatteryGenotype   = pHardware.BatteryGenotype,
                BatteryChromosome = MathematicalOperations.ConvertIntToBinaryString(pHardware.BatteryGenotype)
            };

            return(model);
        }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            Log.Debug(TAG, "OnCreate");

            base.OnCreate(savedInstanceState);
            int id = Intent.Extras.GetInt(nameof(HardwareModel.Id), 0);

            hardwareCardSubHeader = FindViewById <TextView>(Resource.Id.hardware_system_settings_card_sub_header);
            lock (DatabaseContext.DbLocker)
            {
                using (DatabaseContext db = new DatabaseContext(gs.DatabasePathBase))
                {
                    hardware = db.Hardwares.Include(x => x.Ports).FirstOrDefault(x => x.Id == id);
                }
            }
            hardwareCardSubHeader.Text   = hardware.Name;
            HardwareSystemSettingsLayout = FindViewById <LinearLayout>(Resource.Id.hardware_system_settings_layout);

            GetHttp($"http://{hardware.Address}/{hardware.Password}/");
        }
Beispiel #18
0
        private HardwareModel LoadHardware()
        {
            var        hm       = new HardwareModel();
            HttpClient client   = WebApiServiceLogic.CreateClient(ServiceType.OnPremiseWebApi);
            var        response = client.GetAsync("api/asset/GetAll").Result;

            if (response.IsSuccessStatusCode)
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                if (!String.IsNullOrEmpty(jsonData))
                {
                    hm.Assets = JsonConvert.DeserializeObject <List <TeamAsset> >(jsonData);
                }
            }
            else
            {
                var jsonData = response.Content.ReadAsStringAsync().Result;
                var obj      = JsonConvert.DeserializeObject <ResponseFailure>(jsonData);
                ModelState.AddModelError("", response.ReasonPhrase + " - " + obj.Message);
            }
            return(hm);
        }
Beispiel #19
0
        public static HardwareModel readHardwareModelSettings(TinyMessengerHub messageHub)
        {
            HardwareModel   hwModel = new HardwareModel(messageHub);
            LinearDataPoint ldp1    = new LinearDataPoint(Properties.Settings.Default.dp1Temp, Properties.Settings.Default.dp1Speed);
            LinearDataPoint ldp2    = new LinearDataPoint(Properties.Settings.Default.dp2Temp, Properties.Settings.Default.dp2Speed);
            LinearDataPoint ldp3    = new LinearDataPoint(Properties.Settings.Default.dp3Temp, Properties.Settings.Default.dp3Speed);
            LinearDataPoint ldp4    = new LinearDataPoint(Properties.Settings.Default.dp4Temp, Properties.Settings.Default.dp4Speed);
            LinearDataPoint ldp5    = new LinearDataPoint(Properties.Settings.Default.dp5Temp, Properties.Settings.Default.dp5Speed);

            List <LinearDataPoint> dps = new List <LinearDataPoint>();

            dps.Add(ldp1);
            dps.Add(ldp2);
            dps.Add(ldp3);
            dps.Add(ldp4);
            dps.Add(ldp5);

            hwModel.dataPoints       = dps;
            hwModel.quietModeEnabled = Properties.Settings.Default.quietModeOn;
            hwModel.quietModeSpeed   = Properties.Settings.Default.quitModeSpeed;
            return(hwModel);
        }
Beispiel #20
0
        public ApplicationController(MainForm gui)
        {
            _messageHub = new TinyMessengerHub();

            _settingsModel = SettingsUtils.readSettingsModelSettings(_messageHub);
            _hardwareModel = SettingsUtils.readHardwareModelSettings(_messageHub);
            _colorModel    = SettingsUtils.readColorModelSettings(_messageHub);

            _colorController       = new ColorController(_colorModel, _hardwareModel, _messageHub, gui);
            _temperatureController = new HardwareController(_hardwareModel, _messageHub, gui);

            _comm = new Communicator(_colorModel, _hardwareModel, _settingsModel);

            _gui = gui;
            _gui.appController   = this;
            _gui.colorController = _colorController;
            _gui.settingsModel   = _settingsModel;
            _gui.init(_colorModel, _hardwareModel, _messageHub);

            checkWindowState();
            //TODO: this is not working at the moment, start up the application with windows by making a sheduled task!
            //checkAutoStartStatus();
        }
        public void saveState(OleDbConnection connection)
        {
            HardwareModel hardwareModel = HardwareModel.getInstance(connection);

            foreach (Component component in components)
            {
                //HardwareUtil.log(Loglevel.general, hardwareModel.componentExists(component).ToString());
                if (!hardwareModel.componentExists(component))
                {
                    hardwareModel.insertComponent(component);
                }
                else
                {
                    hardwareModel.editComponent(component);
                }
            }
            foreach (Computer computer in computers)
            {
                //HardwareUtil.log(Loglevel.general, hardwareModel.computerExists(computer).ToString());
                if (!hardwareModel.computerExists(computer))
                {
                    hardwareModel.insertComputer(computer);
                }
                else
                {
                    hardwareModel.editComputer(computer);
                }
            }
            foreach (int componentId in componentsToDelete)
            {
                hardwareModel.deleteComponent(componentId);
            }
            foreach (int computerId in computersToDelete)
            {
                hardwareModel.deleteComputer(computerId);
            }
        }
        protected override string ReadView(int command_id)
        {
            string errMsg = string.Empty;

            switch (SelectedTypeCommand)
            {
            case TypesCommands.Port:
                if (command_executer_id < 1)
                {
                    errMsg = $"{GetString(Resource.String.error_controller_port_is_not_selected_title)}: [{command_executer_id}]";
                    break;
                }
                PortModel selected_port = null;
                lock (DatabaseContext.DbLocker)
                {
                    using (DatabaseContext db = new DatabaseContext(gs.DatabasePathBase))
                    {
                        selected_port = db.Ports.FirstOrDefault(x => x.Id == command_executer_id);
                    }
                }
                if (selected_port == null)
                {
                    errMsg += $"{GetString(Resource.String.error_controller_port_was_not_found_in_the_database_title)}: [{command_executer_id}]";
                }

                break;

            case TypesCommands.Controller:
                if (command_executer_id < 1)
                {
                    errMsg = $"{GetString(Resource.String.error_no_controller_selected_title)}: [{command_executer_id}]";
                    break;
                }
                if (string.IsNullOrWhiteSpace(command_executer_parameter?.ToString()))
                {
                    errMsg = GetString(Resource.String.error_not_specified_the_command_controller_title);
                    break;
                }
                HardwareModel hw = null;
                lock (DatabaseContext.DbLocker)
                {
                    using (DatabaseContext db = new DatabaseContext(gs.DatabasePathBase))
                    {
                        hw = db.Hardwares.FirstOrDefault(x => x.Id == command_executer_id);
                    }
                }
                if (hw == null)
                {
                    errMsg += $"{GetString(Resource.String.err_selected_device_was_not_found_title)}: [{command_executer_id}]";
                }
                break;

            case TypesCommands.Exit:
                if (command_executer_id < 1)
                {
                    // выход из сценария
                    break;
                }
                CommandModel command = null;
                lock (DatabaseContext.DbLocker)
                {
                    using (DatabaseContext db = new DatabaseContext(gs.DatabasePathBase))
                    {
                        command = db.Commands.FirstOrDefault(x => x.Id == command_executer_id);
                    }
                }
                if (command == null)
                {
                    errMsg += $"{GetString(Resource.String.error_not_specified_the_command_controller_title)}: [{command_executer_id}]";
                }
                break;
            }
            return(errMsg.Trim());
        }
        public HttpResponseMessage Savehardware(HardwareModel t)
        {
            aAutomaticTakeTime s = new aAutomaticTakeTime();

            return(ut.ReturnResponse(s.SaveHardware(t)));
        }
Beispiel #24
0
        /// <summary>
        /// 
        /// </summary>
        /// <param name="strComunidade"></param>
        /// <param name="LearningObject"></param>
        /// <returns></returns>
        public static HardwareModel GetUserDeviceWithComunidade(String strComunidade, String User)
        {
            HardwareModel modelToReturn = new HardwareModel();
            StardogConnector dog = new StardogConnector("http://*****:*****@"PREFIX onto: <http://www.owl-ontologies.com/OntoAdapt2.owl#> ");
            strb.Append(@"SELECT ?Dev  { ");
            strb.AppendFormat("onto:{0} onto:ComunidadeMoodle  \"{1}\". ", User, strComunidade);
            strb.AppendFormat("onto:{0} onto:hasDevice ?Dev. ", User);
            //strb.Append("?Dev onto:DeviceID ?DevID");
            strb.Append("}");

            SparqlResultSet resultsNoReasoning = dog.Query(strb.ToString()) as SparqlResultSet;

            List<SparqlResult> lista = resultsNoReasoning.ToList();

            List<String> toReturn = new List<string>();

            foreach (SparqlResult rlt in lista)
            {
                modelToReturn.Device_ID = RemoveURLFromOntoloryResults(rlt[0].ToString());
            }
            return modelToReturn;
        }
        protected CommandModel ReadFormToObject(CommandModel my_command)
        {
            Log.Debug(TAG, "ReadFormToObject");
            Regex FloatSeparator = new Regex(@"[.,]");

            my_command.TypeCommand          = SelectedTypeCommand;
            my_command.Hidden               = HiddenCommandCheckBox.Checked;
            my_command.PauseBeforeExecution = double.Parse($"0{FloatSeparator.Replace(PauseSecondsBeforeStarting.Text, CultureInfo.CurrentCulture.NumberFormat.NumberDecimalSeparator)}");
            my_command.Execution            = command_executer_id;
            my_command.ExecutionParametr    = command_executer_parameter?.ToString();

            if (RequiredCondition.Checked)
            {
                string PortExecutionConditionAllowingState;
                my_command.PortExecutionConditionId = Ports.Keys.ElementAt(PortCondition.SelectedItemPosition);

                PortExecutionConditionAllowingState = Resources.GetStringArray(Resource.Array.required_condition_port_states_array)[StateCondition.SelectedItemPosition];
                if (PortExecutionConditionAllowingState == GetString(Resource.String.abc_capital_on))
                {
                    my_command.PortExecutionConditionAllowingState = true;
                }
                else if (PortExecutionConditionAllowingState == GetString(Resource.String.abc_capital_off))
                {
                    my_command.PortExecutionConditionAllowingState = false;
                }
                else
                {
                    my_command.PortExecutionConditionAllowingState = null;
                }
            }
            else
            {
                my_command.PortExecutionConditionId            = null;
                my_command.PortExecutionCondition              = null;
                my_command.PortExecutionConditionAllowingState = null;
            }

            switch (SelectedTypeCommand)
            {
            case TypesCommands.Port:
                bool?  setter_state_port      = command_executer_parameter as bool?;
                string setter_name_state_port = string.Empty;

                if (setter_state_port == true)
                {
                    setter_name_state_port = GetString(Resource.String.abc_capital_on);
                }
                else if (setter_state_port == false)
                {
                    setter_name_state_port = GetString(Resource.String.abc_capital_off);
                }
                else
                {
                    setter_name_state_port = GetString(Resource.String.abc_capital_switch);
                }

                lock (DatabaseContext.DbLocker)
                {
                    using (DatabaseContext db = new DatabaseContext(gs.DatabasePathBase))
                    {
                        PortModel port = db.Ports.Include(x => x.Hardware).FirstOrDefault(x => x.Id == command_executer_id);
                        my_command.Name = $"{port.Hardware} ●> {port} ●> {setter_name_state_port}";
                    }
                }
                break;

            case TypesCommands.Controller:
                lock (DatabaseContext.DbLocker)
                {
                    using (DatabaseContext db = new DatabaseContext(gs.DatabasePathBase))
                    {
                        HardwareModel hw = db.Hardwares.FirstOrDefault(x => x.Id == command_executer_id);
                        my_command.Name = $"{hw} ●> {command_executer_parameter}";
                    }
                }
                break;

            case TypesCommands.Exit:
                if (command_executer_id > 0)
                {
                    lock (DatabaseContext.DbLocker)
                    {
                        using (DatabaseContext db = new DatabaseContext(gs.DatabasePathBase))
                        {
                            CommandModel cmd = db.Commands.Include(x => x.Script).FirstOrDefault(x => x.Id == command_executer_id);
                            my_command.Name = $"{cmd.Script} ●> {cmd}";
                        }
                    }
                }
                else
                {
                    my_command.Name = GetString(Resource.String.exit_title);
                }
                break;
            }

            return(my_command);
        }
Beispiel #26
0
 /// <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();
 }
Beispiel #27
0
        public void InsertContext(RootObjectJSON Context)
        {
            hardware = new HardwareModel();
            hardware.battery_Level = Context.Device.BatteryLevel;
            hardware.battery_State = Context.Device.BatteryState;
            hardware.model_name = Context.Device.Model.Replace(" ","_");
            hardware.Brand_Name = "Apple"; //chumbado;
            hardware.Device_type = "smartphone"; //chumbado
            hardware.type_Connection = Context.Network.TypeConnection;

            insertDevice(hardware);
        }
Beispiel #28
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();
        }
Beispiel #29
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();
        }
Beispiel #30
0
        //GUARDA EL HARDWARE QUE TIENEN LOS USUARIOS, REVISA SI HAY NUEVOS Y LOS QUE YA NO, LOS MARCA COMO DESINSTALADOS
        public object SaveHardware(HardwareModel model)
        {
            Response rp = new Response();

            try
            {
                cp = tvh.getprincipal(Convert.ToString(model.token));
                if (cp != null)
                {
                    string empresa = cp.Claims.Where(c => c.Type == ClaimTypes.GroupSid).Select(c => c.Value).FirstOrDefault();

                    List <InstalledHardwareViewModel> livm = new List <InstalledHardwareViewModel>();

                    foreach (var i in model.InstalledHardwareViewModel)
                    {
                        InstalledHardwareViewModel ivm = new InstalledHardwareViewModel();
                        i.IdCompany = empresa.ToString();
                        Copier.CopyPropertiesTo(i, ivm);
                        livm.Add(ivm);
                    }
                    ;
                    if (livm.Count() > 0)
                    {
                        List <InstalledHardwareViewModel> installed = opc.GetHardware(empresa, livm[0].Pc);

                        foreach (var i in installed)
                        {
                            //paso 1, validar las que ya estan en base de datos, para agregar las que no
                            InstalledHardwareViewModel ipvm = livm.Where(l => l.Hardware == i.Hardware && l.Type == i.Type).SingleOrDefault();
                            //si no esta en la lista que viene del monitor, es porque se desinstalo
                            if (ipvm == null)
                            {
                                opc.UpdateHardware(i);
                            }
                            else
                            {
                                //si si esta, entonces la quito de la lista que viene del monitor para quedarme solo con las que no estan en BD que son las nuevas
                                livm.Remove(ipvm);
                            }
                        }

                        //si qedo algo lo agrego
                        if (livm.Count() > 0)
                        {
                            opc.AddHardware(livm);
                        }
                    }
                    rp.response_code = GenericErrors.SaveOk.ToString();
                }
                else
                {
                    //token invalido
                    rp = autil.ReturnMesagge(ref rp, (int)GenericErrors.InvalidToken, string.Empty, null, HttpStatusCode.OK);
                    return(rp);
                }

                return(rp);
            }
            catch (Exception ex)
            {
                //error general
                rp = autil.ReturnMesagge(ref rp, (int)GenericErrors.GeneralError, ex.Message + " " + ex.InnerException, null, HttpStatusCode.InternalServerError);
                return(rp);
            }
            return(rp);
        }
Beispiel #31
0
 //Dificulty dificuldade;
 public OntoStudent(UserContextModel _student, HardwareModel _device)
 {
     student = _student;
     device = _device;
 }
Beispiel #32
0
 public OntoDevice(HardwareModel _Device)
 {
     Device = _Device;
 }
Beispiel #33
0
        public void FireObjects()
        {
            #region  Seleciona todos os usuários do sistema
            String strSPARQL = @"SELECT ?Student ?DevID  {
                                ?Student rdf:type :Student.
                                ?Student :hasDevice ?Dev.
                                ?Dev :DeviceID ?DevID}";

            var dog = SingletonStarDog.getDbInstance();
            dog.GetDBConnection().Reasoning = StardogReasoningMode.SL;
            var resultsNoReasoning = dog.GetDBConnection().Query(strSPARQL) as SparqlResultSet;

            if (resultsNoReasoning != null)
            {
                var lista = resultsNoReasoning.ToList();

                var toReturn = new List<string>();
                StringBuilder strBuilder = new StringBuilder();
                List<UserContextModel> userList = new List<UserContextModel>();
                foreach (SparqlResult rlt in lista)
                {
                    UserContextModel user = new UserContextModel();
                    user.Matricula = rlt[0].ToString().Substring(rlt[0].ToString().IndexOf("#") + 1);
                    HardwareModel model = new HardwareModel();
                    model.Device_ID = rlt[1].ToString().Substring(rlt[1].ToString().IndexOf("#") + 1);
                    user.DeviceList = new List<HardwareModel>();
                    user.DeviceList.Add(model);
                    userList.Add(user);
                }
            #endregion

                foreach (UserContextModel user in userList)
                {
                    //selecionar o objeto e enviar push
                    String strSparqlobj = @"
                                    SELECT ?Title ?Link
                                    WHERE {:" + user.Matricula;
                    strSparqlobj += @" :hasObjectChosenToStudent  ?obj.
                    ?obj :LO_Link ?Link.
                    ?obj :LO_Title ?Title.}";

                    dog.GetDBConnection().Reasoning = StardogReasoningMode.SL;
                    var resultsNoReasoningOBJ =
                        dog.GetDBConnection().Query(strSparqlobj) as SparqlResultSet;

                    if (resultsNoReasoningOBJ != null)
                    {
                        var listaOBJ = resultsNoReasoningOBJ.ToList();

                        foreach (SparqlResult rlt in listaOBJ)
                        {
                            //RemoveURLFromOntoloryResults(
                            string obj = rlt[0].ToString().Substring(rlt[0].ToString().IndexOf("#") + 1);
                            //string link = rlt[1].ToString().Substring(rlt[1].ToString().IndexOf("#") + 1);

                            #region EnviaMsg
                            var msg = String.Format("O objeto : {0} está disponível para download.", obj);
                            SendPushMessages(user.DeviceList[0].Device_ID, msg);
                            #endregion
                        }
                    }
                }
            }
        }
Beispiel #34
0
        public ActionResult HardwareContainer()
        {
            HardwareModel model = LoadHardware();

            return(View(model));
        }
Beispiel #35
0
 public Communicator(ColorModel colorModel, HardwareModel hardwareModel, SettingsModel settingsModel)
 {
     this._colorModel    = colorModel;
     this._hardwareModel = hardwareModel;
     this._settingsModel = settingsModel;
 }
        protected override void OnCreate(Bundle savedInstanceState)
        {
            Log.Debug(TAG, "OnCreate");

            base.OnCreate(savedInstanceState);
            hardwareId = Intent.Extras.GetInt(nameof(HardwareModel.Id), 0);
            if (hardwareId < 1)
            {
                string err_title = GetText(Resource.String.err_title_2);
                HardwareName.Text    = err_title;
                HardwareName.Enabled = false;

                HardwareAddress.Text    = err_title;
                HardwareAddress.Enabled = false;

                HardwarePassword.Text    = err_title;
                HardwarePassword.Enabled = false;

                HardwareAlarmSubscribing.Enabled = false;
                HardwareCommandsAllowed.Enabled  = false;

                HardwareCardSubHeader.Text    = err_title;
                HardwareCardSubHeader.Enabled = false;

                HardwareCardButtonOk.Enabled = false;
                return;
            }

            lock (DatabaseContext.DbLocker)
            {
                using (DatabaseContext db = new DatabaseContext(gs.DatabasePathBase))
                {
                    hardware              = db.Hardwares.FirstOrDefault(x => x.Id == hardwareId);
                    hardwareId            = hardware?.Id ?? 0;
                    HardwareName.Text     = hardware?.Name;
                    HardwareAddress.Text  = hardware?.Address;
                    HardwarePassword.Text = hardware?.Password;

                    HardwareAlarmSubscribing.Checked = hardware.AlarmSubscriber;
                    HardwareCommandsAllowed.Checked  = hardware.CommandsAllowed;
                }
            }

            HardwareCardHeader.Text    = GetText(Resource.String.edit_hardware_title);
            HardwareCardSubHeader.Text = GetText(Resource.String.edit_hardware_sub_title);

            buttonDeleteHardware = new AppCompatButton(this)
            {
                Text = GetText(Resource.String.delete_title)
            };
            buttonDeleteHardware.SetTextColor(Color.DarkRed);
            buttonDeleteHardware.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            HardwareFooterLayout.AddView(buttonDeleteHardware);

            SystemSettingsHardware = new AppCompatButton(this)
            {
                Text = GetText(Resource.String.system_settings_title)
            };
            SystemSettingsHardware.LayoutParameters = new LinearLayout.LayoutParams(ViewGroup.LayoutParams.MatchParent, ViewGroup.LayoutParams.WrapContent);
            HardwareTopLayout.AddView(SystemSettingsHardware);
        }
Beispiel #37
0
        private HardwareModel SendHardware()
        {
            List <InstalledHardwareViewModel> InstalledHardwareViewModel = new List <InstalledHardwareViewModel>();
            InstalledHardwareViewModel        ih = new InstalledHardwareViewModel();

            //video card
            ManagementObjectSearcher myVideoObject = new ManagementObjectSearcher("select * from Win32_VideoController");

            foreach (ManagementObject obj in myVideoObject.Get())
            {
                ih          = new InstalledHardwareViewModel();
                ih.Hardware = obj["Name"].ToString();
                ih.Type     = HardwareType.VideoCard.ToString();
                ih.Pc       = Environment.MachineName;
                ih.User     = Environment.UserName;
                InstalledHardwareViewModel.Add(ih);

                break;
            }
            //procesor
            ManagementObjectSearcher myProcessorObject = new ManagementObjectSearcher("select * from Win32_Processor");

            foreach (ManagementObject obj in myProcessorObject.Get())
            {
                ih          = new InstalledHardwareViewModel();
                ih.Hardware = obj["Name"].ToString();
                ih.Type     = HardwareType.Procesor.ToString();
                ih.Pc       = Environment.MachineName;
                ih.User     = Environment.UserName;
                InstalledHardwareViewModel.Add(ih);
                break;
            }

            //SO
            ManagementObjectSearcher myOperativeSystemObject = new ManagementObjectSearcher("select * from Win32_OperatingSystem");

            foreach (ManagementObject obj in myOperativeSystemObject.Get())
            {
                ih          = new InstalledHardwareViewModel();
                ih.Hardware = obj["Caption"].ToString();
                ih.Type     = HardwareType.OperativeSystem.ToString();
                ih.Pc       = Environment.MachineName;
                ih.User     = Environment.UserName;
                InstalledHardwareViewModel.Add(ih);
                break;
            }

            //sound card
            ManagementObjectSearcher myAudioObject = new ManagementObjectSearcher("select * from Win32_SoundDevice");

            foreach (ManagementObject obj in myAudioObject.Get())
            {
                ih          = new InstalledHardwareViewModel();
                ih.Hardware = obj["Name"].ToString();
                ih.Type     = HardwareType.SoundCard.ToString();
                ih.Pc       = Environment.MachineName;
                ih.User     = Environment.UserName;
                InstalledHardwareViewModel.Add(ih);
                break;
            }
            //hard drive (just primary)
            DriveInfo[] allDrives = DriveInfo.GetDrives();

            foreach (DriveInfo d in allDrives)
            {
                ih          = new InstalledHardwareViewModel();
                ih.Hardware = "Name: " + d.Name + " Size: " + SizeSuffix(d.TotalSize);
                ih.Type     = HardwareType.HardDrive.ToString();
                ih.Pc       = Environment.MachineName;
                ih.User     = Environment.UserName;
                InstalledHardwareViewModel.Add(ih);
            }

            //memory
            ObjectQuery wql = new ObjectQuery("SELECT * FROM Win32_OperatingSystem");
            ManagementObjectSearcher   searcher = new ManagementObjectSearcher(wql);
            ManagementObjectCollection results  = searcher.Get();

            foreach (ManagementObject result in results)
            {
                ih          = new InstalledHardwareViewModel();
                ih.Hardware = SizeSuffix(Int64.Parse(result["TotalVisibleMemorySize"].ToString()) * 1024);
                ih.Type     = HardwareType.TotalMemory.ToString();
                ih.Pc       = Environment.MachineName;
                ih.User     = Environment.UserName;
                InstalledHardwareViewModel.Add(ih);
                break;
            }

            HardwareModel hm = new HardwareModel();

            hm.token = token;
            hm.InstalledHardwareViewModel = InstalledHardwareViewModel;

            return(hm);
        }
Beispiel #38
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

            }
        }