Exemplo n.º 1
0
        public void validate_default()
        {
            InstructionViewModel viewModel = new InstructionViewModel();
            var result = viewModel.Validate(null);

            Assert.True(0 < result.Count());
        }
Exemplo n.º 2
0
        public MainWindow()
        {
            this.InitializeComponent();

            // Insert code required on object creation below this point.
            instruction_view_model = (InstructionViewModel)this.FindResource("instruction_view_model");
        }
Exemplo n.º 3
0
        public async Task <ActionResult> AddInstruction(int?id)
        {
            if (!id.HasValue)
            {
                return(RedirectToAction("Index", "QualityControl"));
            }


            Expression <Func <Instruction, bool> > expr = (i => i.QualityControlId == id);
            var instructions = await _unitOfWork.InstructionRepository.GetAsync(expr);

            var control = await _unitOfWork.QualityControlRepository.FindByIdAsync(id);

            if (control == null)
            {
                return(HttpNotFound());
            }
            var vm = new InstructionViewModel
            {
                QualityControlId = id.Value,
                Instructions     = instructions,
                CanSave          = control.Status ==
                                   QualityControlStatus.Closed ? false : true
            };

            return(View(vm));
        }
Exemplo n.º 4
0
        public async Task <ActionResult> AddInstruction(InstructionViewModel vm)
        {
            if (!ModelState.IsValid)
            {
                ModelState.AddModelError("", "Data is invalid");
                return(View(vm));
            }
            var control = await _unitOfWork.QualityControlRepository.FindByIdAsync(vm.QualityControlId);

            if (control == null)
            {
                return(HttpNotFound());
            }

            try
            {
                var user = await GetUserAsync();

                var instruction = _factory.Create(vm, user);
                control.AddInstruction(instruction, user);
                await _unitOfWork.SaveChangesAsync();

                vm.Name         = vm.Description =
                    vm.Comments = "";
            }
            catch (Exception ex)
            {
                await LogExceptionAsync(ex);

                return(new HttpStatusCodeResult(HttpStatusCode.BadRequest, ex.Message));
            }

            vm.Instructions = control.Instructions;
            return(View(vm));
        }
Exemplo n.º 5
0
        public ActionResult New()
        {
            var instructionViewModel = new InstructionViewModel();

            instructionViewModel.ProductDtos = productService.GetAll();

            return(View("InstructionForm", instructionViewModel));
        }
Exemplo n.º 6
0
        public void Flash(IEnumerable <string> firmware, bool newFirmware)
        {
            Simulation.Error = "Error stopping audio player";
            if (this.Loaded)
            {
                Reset();
            }

            Simulation.Error = "Error decoding hex file";
            var decoder = new HexDecoder();
            int minAddr, maxAddr;

            decoder.Decode(firmware, out minAddr, out maxAddr);
            this.MinAddr = minAddr;
            this.MaxAddr = maxAddr;

            // add the disassembled instructions
            Simulation.Error  = "Error dissassembling hex file";
            this.Disassembly  = new List <InstructionViewModel>();
            this.Instructions = new Dictionary <int, InstructionViewModel>();
            int hide = 0;

            for (int i = 0; i < AtmelContext.Flash.Length; i++)
            {
                var vm = new InstructionViewModel(this, i);
                if (hide > 0)
                {
                    vm.Hidden = true;
                    hide--;
                }
                else
                {
                    hide += vm.Size - 1;
                }
                this.Disassembly.Add(vm);
                this.Instructions[i] = vm;
            }

            Simulation.Error = "Error initializing breakpoints";
            if ((this.Breakpoints == null) || newFirmware)
            {
                this.Breakpoints = new Boolean[this.Disassembly.Count()];
            }
            else
            {
                Array.Resize(ref this.Breakpoints, this.Disassembly.Count());
                for (int i = 0; i < this.Disassembly.Count(); i++)
                {
                    this.Disassembly[i].Breakpoint = this.Breakpoints[i];
                }
            }

            this.Loaded      = (this.MinAddr >= 0) && (this.MaxAddr < 2 * AtmelContext.Flash.Length) && (this.MaxAddr > this.MinAddr);
            Simulation.Error = "Error performing initial flash update";
            Update();
        }
Exemplo n.º 7
0
 public static InstructionEntity ToBll(this InstructionViewModel model)
 {
     return(new InstructionEntity()
     {
         Id = model.Id,
         Name = model.Name,
         Description = model.Description,
         IsSupported = model.IsSupported
     });
 }
Exemplo n.º 8
0
 public Instruction Create(InstructionViewModel model, User user)
 {
     return(new Instruction(user)
     {
         QualityControlId = model.QualityControlId,
         Name = model.Name,
         Description = model.Description,
         Comments = model.Comments,
         Status = InstructionStatus.Pending
     });
 }
Exemplo n.º 9
0
 public ActionResult Update(InstructionViewModel model)
 {
     try
     {
         _service.Update(model.ToBll());
     }
     catch (ServiceException ex)
     {
         return(Json(new { answer = ex.Message, success = false }));
     }
     return(Json(new { answer = "Instruction updated successfully.", success = true }));
 }
Exemplo n.º 10
0
        public FilterWindow()
        {
            InitializeComponent();

            /* Restore any existing filter state */
            low_instruction_enabled.IsChecked = (bool)Application.Current.Resources["filter_instruction_low_enabled"];
            if ((bool)low_instruction_enabled.IsChecked)
            {
                uint filter_low;
                UInt32.TryParse(Application.Current.Resources["filter_instruction_low"].ToString(), out filter_low);
                low_instruction.Text = filter_low.ToString("X");
            }
            high_instruction_enabled.IsChecked = (bool)Application.Current.Resources["filter_instruction_high_enabled"];
            if ((bool)high_instruction_enabled.IsChecked)
            {
                uint filter_high;
                UInt32.TryParse(Application.Current.Resources["filter_instruction_high"].ToString(), out filter_high);
                high_instruction.Text = filter_high.ToString("X");
            }
            low_depth_enabled.IsChecked = (bool)Application.Current.Resources["filter_depth_low_enabled"];
            if ((bool)low_depth_enabled.IsChecked)
            {
                low_depth.Text = (Application.Current.Resources["filter_depth_low"]).ToString();
            }
            high_depth_enabled.IsChecked = (bool)Application.Current.Resources["filter_depth_high_enabled"];
            if ((bool)high_depth_enabled.IsChecked)
            {
                high_depth.Text = (Application.Current.Resources["filter_depth_high"]).ToString();
            }
            library_name_enabled.IsChecked = (bool)Application.Current.Resources["filter_libraries_included_enabled"];
            if (library_name_enabled.IsChecked.HasValue && (bool)library_name_enabled.IsChecked)
            {
                InstructionViewModel ivm = (InstructionViewModel)this.FindResource("instruction_view_model");
                library_name.SelectedItems.Clear();
                foreach (string i in ivm.Library_names)
                {
                    library_name.SelectedItems.Add(i);
                }
            }
            thread_id_enabled.IsChecked = (bool)Application.Current.Resources["filter_threads_included_enabled"];
            if ((bool)thread_id_enabled.IsChecked)
            {
                InstructionViewModel ivm = (InstructionViewModel)this.FindResource("instruction_view_model");
                thread_id.SelectedItems.Clear();
                foreach (uint i in ivm.Thread_ids)
                {
                    thread_id.SelectedItems.Add(i);
                }
            }
            system_call_enabled.IsChecked = (bool)Application.Current.Resources["filter_system_calls_enabled"];
        }
Exemplo n.º 11
0
        public void validate_Steps()
        {
            var steps = new List <StepViewModel>()
            {
                new StepViewModel()
            };
            InstructionViewModel viewModel = new InstructionViewModel()
            {
                Steps = steps
            };
            var result = viewModel.Validate(null);

            Assert.True(0 < result.Count());
        }
Exemplo n.º 12
0
        public void Mapping_With_AutoMapper_Profiles()
        {
            var configuration = new MapperConfiguration(cfg =>
            {
                cfg.AddProfile <InstructionProfile>();
            });
            var mapper = configuration.CreateMapper();

            InstructionViewModel vm = new InstructionViewModel {
                Id = 1
            };
            InstructionModel model = mapper.Map <InstructionModel>(vm);

            Assert.Equal(vm.Id, model.Id);
        }
Exemplo n.º 13
0
        public JsonResult Delete([FromBody] InstructionViewModel vm)
        {
            try
            {
                var instruction = Mapper.Map <Instruction>(vm);

                _instructionsRepository.Delete(instruction);

                Response.StatusCode = (int)HttpStatusCode.OK;
                return(Json(true));
            }
            catch (Exception ex)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json(new { Message = $"An error occurred - {ex.Message}" }));
            }
        }
Exemplo n.º 14
0
 protected override void InitializeMockData()
 {
     control = new QualityControl
     {
         Id           = 1,
         Name         = "Dimensional Control",
         Description  = "Control dimensions DIM312 in CMM3",
         Instructions = new List <Instruction>(),
         Status       = QualityControlStatus.Open
     };
     viewModel = new InstructionViewModel
     {
         QualityControlId = 1,
         Name             = "CMM",
         Description      = "Control dimension DI312",
         Comments         = "N/A"
     };
 }
Exemplo n.º 15
0
        public void Should_Success_Instantiate()
        {
            var steps = new List <StepViewModel>()
            {
                new StepViewModel()
            };
            InstructionViewModel viewModel = new InstructionViewModel()
            {
                UId   = "UId",
                Code  = "Code",
                Name  = "Name",
                Steps = steps
            };

            Assert.Equal("UId", viewModel.UId);
            Assert.Equal("Code", viewModel.Code);
            Assert.Equal("Name", viewModel.Name);
            Assert.Equal(steps, viewModel.Steps);
        }
Exemplo n.º 16
0
        public ActionResult Save(InstructionViewModel instructionViewModel)
        {
            var instructionDto = Mapper.Map <InstructionDto>(instructionViewModel);

            if (!ModelState.IsValid)
            {
                instructionViewModel = new InstructionViewModel();

                return(View("InstructionForm", instructionViewModel));
            }
            if (instructionDto.Id == 0)
            {
                instructionService.Add(instructionDto);
            }
            else
            {
                instructionService.Edit(instructionDto);
            }
            return(RedirectToAction("Index", "Instructions"));
        }
Exemplo n.º 17
0
        private void apply_filters(object sender, RoutedEventArgs e)
        {
            LibraryViewModel     global_library_list     = (LibraryViewModel)this.FindResource("library_view_model");
            InstructionViewModel global_instruction_list = (InstructionViewModel)this.FindResource("instruction_view_model");

            FilterWindow filter = new FilterWindow();

            foreach (Library l in global_library_list.Model)
            {
                filter.library_name.Items.Add(l.Library_name);
            }

            foreach (Instruction i in global_instruction_list.Model)
            {
                if (!filter.thread_id.Items.Contains(i.Thread_id))
                {
                    filter.thread_id.Items.Add(i.Thread_id);
                }
            }

            filter.Show();
            filter.Closed += filter_Closed;
        }
Exemplo n.º 18
0
        public JsonResult Put([FromBody] InstructionViewModel vm)
        {
            try
            {
                if (ModelState.IsValid)
                {
                    var instruction = Mapper.Map <Instruction>(vm);

                    _instructionsRepository.Update(instruction);

                    var instructionViewModel = Mapper.Map <InstructionViewModel>(instruction);
                    Response.StatusCode = (int)HttpStatusCode.OK;
                    return(Json(instructionViewModel));
                }

                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json(new { Message = $"Invalid model state", Errors = GetModelStateErrors() }));
            }
            catch (Exception ex)
            {
                Response.StatusCode = (int)HttpStatusCode.BadRequest;
                return(Json(new { Message = $"An error occurred - {ex.Message}" }));
            }
        }
Exemplo n.º 19
0
        private void apply_filter_button(object sender, RoutedEventArgs e)
        {
            InstructionViewModel ivm = (InstructionViewModel)this.FindResource("instruction_view_model");

            UInt32 filter_instruction_low = new UInt32();

            filter_instruction_low = 0x40000000;

            Application.Current.Resources["filter_instruction_low"] = filter_instruction_low;
            filter_instruction_low = (UInt32)this.FindResource("filter_instruction_low");

            Application.Current.Resources["filter_instruction_low_enabled"]    = low_instruction_enabled.IsChecked;
            Application.Current.Resources["filter_instruction_high_enabled"]   = high_instruction_enabled.IsChecked;
            Application.Current.Resources["filter_depth_low_enabled"]          = low_depth_enabled.IsChecked;
            Application.Current.Resources["filter_depth_high_enabled"]         = high_depth_enabled.IsChecked;
            Application.Current.Resources["filter_libraries_included_enabled"] = library_name_enabled.IsChecked;
            Application.Current.Resources["filter_threads_included_enabled"]   = thread_id_enabled.IsChecked;
            Application.Current.Resources["filter_system_calls_enabled"]       = system_call_enabled.IsChecked;

            UInt32 result_uint;

            if ((bool)low_instruction_enabled.IsChecked)
            {
                if (UInt32.TryParse(low_instruction.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out result_uint))
                {
                    Application.Current.Resources["filter_instruction_low"] = result_uint;
                }
                else
                {
                    MessageBox.Show("Couldn't parse low disk instruction cutoff! Hex, no leading 0x");
                    return;
                }
            }

            if ((bool)high_instruction_enabled.IsChecked)
            {
                if (UInt32.TryParse(high_instruction.Text, NumberStyles.HexNumber, CultureInfo.InvariantCulture, out result_uint))
                {
                    Application.Current.Resources["filter_instruction_high"] = result_uint;
                }
                else
                {
                    MessageBox.Show("Couldn't parse high disk instruction cutoff! Hex, no leading 0x");
                    return;
                }
            }

            Int32 result_int;

            if ((bool)low_depth_enabled.IsChecked)
            {
                if (Int32.TryParse(low_depth.Text, out result_int))
                {
                    Application.Current.Resources["filter_depth_low"] = result_int;
                }
                else
                {
                    MessageBox.Show("Couldn't parse low filter depth! Decimal format only. ");
                    return;
                }
            }

            if ((bool)high_depth_enabled.IsChecked)
            {
                if (Int32.TryParse(high_depth.Text, out result_int))
                {
                    Application.Current.Resources["filter_depth_high"] = result_int;
                }
                else
                {
                    MessageBox.Show("Couldn't parse high filter depth! Decimal format only. ");
                    return;
                }
            }

            if ((bool)library_name_enabled.IsChecked)
            {
                ivm.Library_names.Clear();
                foreach (string s in library_name.SelectedItems)
                {
                    ivm.Library_names.Add(s);
                }
            }

            if ((bool)thread_id_enabled.IsChecked)
            {
                ivm.Thread_ids.Clear();
                foreach (uint i in thread_id.SelectedItems)
                {
                    ivm.Thread_ids.Add(i);
                }
            }

            this.Close();
        }
Exemplo n.º 20
0
 public InstructionPage()
 {
     InitializeComponent();
     ViewModel = new InstructionViewModel(VideoView);
 }
Exemplo n.º 21
0
 public static void SetCurrentInstruction(UIElement element, InstructionViewModel value)
 {
     element.SetValue(CurrentInstructionProperty, value);
 }