Example #1
0
        public IHttpActionResult Get()
        {
            InstrumentService instrumentService = CreateInstrumentService();
            var instrument = instrumentService.GetInstrument();

            return(Ok(instrument));
        }
Example #2
0
        public IHttpActionResult GetByExpLvl(int id)
        {
            InstrumentService instrumentService = CreateInstrumentService();
            var instruments = instrumentService.GetInstrumentByExpLvl(id);

            return(Ok(instruments));
        }
Example #3
0
        public void _01_ETF50Tests()
        {
            var htmlService       = new HtmlService();
            var instrumentService = new InstrumentService(htmlService);
            var etf50Insts        = instrumentService.GetInstruments(SinaInstrumentCategory.Index.Index_Sh_50).Take(10);

            // Category
            var categService = new CategorizationService(htmlService);
            var categorizes  = new HashSet <string>();

            foreach (var inst in etf50Insts)
            {
                var cates = categService.GetCateogories(inst.SymbolShort);
                foreach (var cate in cates)
                {
                    categorizes.Add(cate);
                }
                inst.AsDynamic().Categories = cates;
            }

            // Equity structure
            var structureService = new EquityStructureService(htmlService);

            foreach (var inst in etf50Insts)
            {
                var structure = structureService.GetEquityStructure(inst.SymbolShort);
                inst.AsDynamic().EquityStructure = structure;
            }

            var str = JsonUtil.Serialize(etf50Insts);
        }
        public NewCalibrationDialogViewModel(IEventAggregator eventAggregator,
                                             InstrumentService instrumentService,
                                             IDataService <LInstContext> lInstData) : base()
        {
            _lInstData         = lInstData;
            _instrumentService = instrumentService;
            LabList            = _lInstData.RunQuery(new OrganizationsQuery()
            {
                Role = OrganizationsQuery.OrganizationRoles.CalibrationLab
            })
                                 .ToList();
            _eventAggregator  = eventAggregator;
            _validationErrors = new Dictionary <string, ICollection <string> >();
            CalibrationDate   = DateTime.Now.Date;

            CancelCommand = new DelegateCommand <Window>(
                parentDialog =>
            {
                parentDialog.DialogResult = false;
            });

            ConfirmCommand = new DelegateCommand <Window>(
                parentDialog =>
            {
                ReportInstance                     = new CalibrationReport();
                ReportInstance.Date                = CalibrationDate;
                ReportInstance.Year                = DateTime.Now.Year - 2000;
                ReportInstance.Number              = _instrumentService.GetNextCalibrationNumber(ReportInstance.Year);
                ReportInstance.InstrumentID        = _instrumentInstance.ID;
                ReportInstance.LaboratoryID        = _selectedLab.ID;
                ReportInstance.Notes               = "";
                ReportInstance.CalibrationResultID = 1;

                if (IsNotExternalLab)
                {
                    ReportInstance.TechID = SelectedTech.ID;
                }

                foreach (InstrumentProperty iProperty in _lInstData.RunQuery(new InstrumentPropertiesQuery(ReportInstance.InstrumentID)
                {
                    ExcludeNonCalibrationProperties = true
                }))
                {
                    ReportInstance.CalibrationReportProperties.Add(new CalibrationReportProperty()
                    {
                        Name             = iProperty.Name,
                        TargetValue      = iProperty.TargetValue,
                        UpperLimit       = iProperty.UpperLimit,
                        LowerLimit       = iProperty.LowerLimit,
                        ParentPropertyID = iProperty.ID,
                        UM = iProperty.UM
                    });
                }

                _lInstData.Execute(new InsertEntityCommand <LInstContext>(ReportInstance));

                parentDialog.DialogResult = true;
            },
                parentDialog => !HasErrors);
        }
Example #5
0
        private InstrumentService CreateInstrumentService()
        {
            var instrumentId      = Guid.Parse(User.Identity.GetUserId());
            var instrumentService = new InstrumentService(instrumentId);

            return(instrumentService);
        }
Example #6
0
        private async Task <MainWindowViewModel> InitializeAsync()
        {
            return(await Task.Run(async() =>
            {
                Trace.AutoFlush = true;

                var sysname = System.Environment.MachineName;
                if (sysname == "JAKE-PC")
                {
                    ConfigurationManager.AppSettings.Set("BatchTestSystem", "BTS1");
                }
                else if (sysname == "DESKTOP-GQQ0M3J")
                {
                    ConfigurationManager.AppSettings.Set("BatchTestSystem", "BTS2");
                }
                Debug.WriteLine("sysname: " + sysname);
                await InstrumentService.CreateCoordinatorAsync();
                await OriginService.CreateControllerAsync();
                await DataProcessingService.CreateLEDCalculatorAsync();
                if (Debugger.IsAttached)
                {
                    Properties.Settings.Default.Reset();
                }
                var dBConnectionManager = new DBConnectionManager();
                ctx = new DeviceBatchContext();
                Task[] initTasks = new Task[2];
                initTasks[0] = LoadDirectoryTreeView();
                initTasks[1] = UpdateIPAddress();
                await Task.WhenAll(initTasks);
                Trace.TraceInformation("Initialized MainWindowViewModel");
                return this;
            }).ConfigureAwait(false));
        }
Example #7
0
        public IHttpActionResult GetByInstrumentType(int id)
        {
            InstrumentService instrumentServices = CreateInstrumentService();
            var instruments = instrumentServices.GetInstrumentByInstrumentType(id);

            return(Ok(instruments));
        }
Example #8
0
        public IHttpActionResult GetByInstrumentTypeAndExpLvl(int Expid, int TypeId)
        {
            InstrumentService instrumentService = CreateInstrumentService();
            var instruments = instrumentService.GetInstrumentByInstrumentTypeAndExpLvl(Expid, TypeId);

            return(Ok(instruments));
        }
Example #9
0
        public void _01_InstrumentServiceTest_GetInstruments()
        {
            var html        = new HtmlService();
            var service     = new InstrumentService(html);
            var instruments = service.GetInstruments();

            Assert.IsTrue(instruments.Length > 2000);
        }
Example #10
0
 public TradeController(TradeService tradeService, UserManager <IdentityUser> userManager,
                        InstrumentService instrumentService, InstrumentMarketDataService instrumentMarketDataService)
 {
     _tradeService          = tradeService;
     _userManager           = userManager;
     _instrumentService     = instrumentService;
     _instrumentDataService = instrumentMarketDataService;
 }
        public InstrumentServiceTests()
        {
            _eventManagerSource.Setup(s => s.Create())
            .Returns(_eventManager.Object)
            .Verifiable();

            _sut = new InstrumentService(
                _instrumentRepository.Object,
                _eventManagerSource.Object);
        }
Example #12
0
        public InstrumentMainViewModel(IDataService <LabDbEntities> labDbData,
                                       IEventAggregator eventAggregator,
                                       InstrumentService instrumentService) : base()
        {
            _eventAggregator   = eventAggregator;
            _labDbData         = labDbData;
            _instrumentService = instrumentService;

            DeleteInstrumentCommand = new DelegateCommand(
                () =>
            {
                _selectedInstrument.Delete();
                SelectedInstrument = null;
            },
                () => IsInstrumentAdmin && _selectedInstrument != null);

            NewInstrumentCommand = new DelegateCommand(
                () =>
            {
                _instrumentService.CreateInstrument();
            },
                () => IsInstrumentAdmin);

            OpenInstrumentCommand = new DelegateCommand(
                () =>
            {
                NavigationToken token = new NavigationToken(InstrumentViewNames.InstrumentEditView,
                                                            SelectedInstrument);
                _eventAggregator.GetEvent <NavigationRequested>().Publish(token);
            },
                () => SelectedInstrument != null);

            OpenPendingCommand = new DelegateCommand(
                () =>
            {
                NavigationToken token = new NavigationToken(InstrumentViewNames.InstrumentEditView,
                                                            SelectedPending);
                _eventAggregator.GetEvent <NavigationRequested>().Publish(token);
            });

            _eventAggregator.GetEvent <CalibrationIssued>().Subscribe(
                calRep =>
            {
                RaisePropertyChanged("PendingCalibrationsList");
                RaisePropertyChanged("CalibrationsList");
            });

            _eventAggregator.GetEvent <InstrumentListUpdateRequested>().Subscribe(
                () =>
            {
                RaisePropertyChanged("InstrumentList");
                RaisePropertyChanged("PendingCalibrationsList");
            });
        }
Example #13
0
        public void Create_InvalidIdSupplied_ArgumentExceptionThrown()
        {
            var id                       = Guid.Empty;
            var manufacturer             = "Druck";
            var modelNo                  = "DPI601IS";
            var range                    = "Not Specified";
            var description              = "Digital Pressure Indicator";
            var allocatedCalibrationTime = 20;

            _instrumentService = InstrumentServiceFactory.Create(MockRepository.GenerateStub <IInstrumentRepository>());
            CreateInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime);
        }
Example #14
0
        public void SearchModelNoByKeywordFilterByManufacturer_ModelNoContains_1Result()
        {
            _instrumentService = InstrumentServiceFactory.CreateForSearch(_instrumentRepository);
            _instrumentService.Create(Guid.NewGuid(), "Bird", "DPI601IS", "None", "Digital Pressure Indicator", 0);
            _instrumentService.Create(Guid.NewGuid(), "Druck", "DPI601IS", "None", "Digital Pressure Indicator", 0);
            _instrumentService.Create(Guid.NewGuid(), "Fluke", "DruckDPI601", "None", "Digital Pressure Indicator", 0);

            var instruments = _instrumentService.SearchModelNoByKeywordFilterByManufacturer("dpi601", "Druck").ToList();

            Assert.AreEqual(1, instruments.Count);
            _instrumentRepository.DeleteAll();
        }
Example #15
0
        public void SearchByKeyword_ManufacturerContains_2Results()
        {
            _instrumentService = InstrumentServiceFactory.CreateForSearch(_instrumentRepository);
            _instrumentService.Create(Guid.NewGuid(), "Druck", "DPI601IS", "None", "Digital Pressure Indicator", 0);
            _instrumentService.Create(Guid.NewGuid(), "Druck", "DPI701IS", "None", "Digital Pressure Indicator", 0);
            _instrumentService.Create(Guid.NewGuid(), "Fluke", "FLK100", "None", "Digital Pressure Indicator", 0);

            var instruments = _instrumentService.SearchByKeyword("Dru");

            Assert.AreEqual(2, instruments.ToList().Count);
            _instrumentRepository.DeleteAll();
        }
Example #16
0
        public void SearchByKeyword_ModelNoExactMatchCaseInsensitive_2Results()
        {
            _instrumentService = InstrumentServiceFactory.CreateForSearch(_instrumentRepository);
            _instrumentService.Create(Guid.NewGuid(), "Druck", "DPI601IS", "None", "Digital Pressure Indicator", 0);
            _instrumentService.Create(Guid.NewGuid(), "Druck", "DPI701IS", "None", "Digital Pressure Indicator", 0);
            _instrumentService.Create(Guid.NewGuid(), "Fluke", "FLK100", "None", "Digital Pressure Indicator", 0);

            var instruments = _instrumentService.SearchByKeyword("dpi601IS");

            Assert.AreEqual(1, instruments.ToList().Count);
            _instrumentRepository.DeleteAll();
        }
Example #17
0
        public void Create_ManufacturerNotSupplied_DomainValidationExceptionThrown()
        {
            var id                       = Guid.NewGuid();
            var manufacturer             = String.Empty;
            var modelNo                  = "DPI601IS";
            var range                    = "Not Specified";
            var description              = "Digital Pressure Indicator";
            var allocatedCalibrationTime = 20;

            _instrumentService = InstrumentServiceFactory.Create(MockRepository.GenerateStub <IInstrumentRepository>());
            CreateInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.ManufacturerRequired));
        }
Example #18
0
        public void Create_AllocatedCalibrationTimeGreaterThan1000_DomainValidationExceptionThrown()
        {
            var id                       = Guid.NewGuid();
            var manufacturer             = "Druck";
            var modelNo                  = "DPI601IS";
            var range                    = "Not Specified";
            var description              = "Digital Pressure Indicator";
            var allocatedCalibrationTime = 1001;

            _instrumentService = InstrumentServiceFactory.Create(MockRepository.GenerateStub <IInstrumentRepository>());
            CreateInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InvalidAllocatedCalibrationTime));
        }
Example #19
0
        public void Create_ModelNoGreaterThan50Characters_DomainValidationExceptionThrown()
        {
            var id                       = Guid.NewGuid();
            var manufacturer             = "Druck";
            var modelNo                  = new string('A', 51);
            var range                    = "Not Specified";
            var description              = "Digital Pressure Indicator";
            var allocatedCalibrationTime = 20;

            _instrumentService = InstrumentServiceFactory.Create(MockRepository.GenerateStub <IInstrumentRepository>());
            CreateInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.ModelNoTooLong));
        }
Example #20
0
        public void InstrumentServiceTestGetAllInstrumentsSuccess()
        {
            // Arrange
            var expectedSize = 30;
            var instrumentObjects = Builder<party_instrumenttype>.CreateListOfSize(30).Build();
            _instrumentRepository.Setup(i => i.GetAll()).Returns(instrumentObjects);
            var instrumentService = new InstrumentService(_instrumentRepository.Object);

            // Act
            var instruments = instrumentService.GetAllInstruments();

            // Assert
            Assert.AreEqual(expectedSize, instruments.Count());
        }
Example #21
0
        public void Edit_InvalidInstrumentId_ArgumentExceptionThrown()
        {
            var id                       = Guid.NewGuid();
            var manufacturer             = "Fluke";
            var modelNo                  = "21";
            var range                    = "Range";
            var description              = "Digital Multimeter";
            var allocatedCalibrationTime = 20;

            var instrumentRepositoryStub = MockRepository.GenerateStub <IInstrumentRepository>();

            instrumentRepositoryStub.Stub(x => x.GetById(id)).Return(null);
            _instrumentService = InstrumentServiceFactory.Create(instrumentRepositoryStub);
            EditInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime);
        }
Example #22
0
 public void GetInstruments_UserHasInsufficientSecurityClearance_DomainValidationExceptionThrown()
 {
     try
     {
         var id = Guid.NewGuid();
         var instrumentRepositoryMock = MockRepository.GenerateMock <IInstrumentRepository>();
         _instrumentService = InstrumentServiceFactory.Create(
             MockRepository.GenerateMock <IInstrumentRepository>(), TestUserContext.Create("*****@*****.**", "Test User", "Operations Manager", UserRole.Public));
         _instrumentService.GetInstruments();
     }
     catch (DomainValidationException dex)
     {
         _domainValidationException = dex;
     }
     Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InsufficientSecurityClearance));
 }
Example #23
0
        public void Edit_AllocatedCalibrationTimeGreaterThan1000_DomainValidationExceptionThrown()
        {
            var id                       = Guid.NewGuid();
            var manufacturer             = "Fluke";
            var modelNo                  = "DPI601IS";
            var range                    = "range";
            var description              = "Digital Pressure Indicator";
            var allocatedCalibrationTime = 1001;

            var instrumentRepositoryStub = MockRepository.GenerateStub <IInstrumentRepository>();

            instrumentRepositoryStub.Stub(x => x.GetById(id)).Return(GetInstrumentForEdit(id));
            _instrumentService = InstrumentServiceFactory.Create(instrumentRepositoryStub);
            EditInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.InvalidAllocatedCalibrationTime));
        }
Example #24
0
        public void Edit_DescriptionGreaterThan50Characters_DomainValidationExceptionThrown()
        {
            var id                       = Guid.NewGuid();
            var manufacturer             = "Fluke";
            var modelNo                  = "DPI601IS";
            var range                    = "range";
            var description              = new string('a', 51);
            var allocatedCalibrationTime = 20;

            var instrumentRepositoryStub = MockRepository.GenerateStub <IInstrumentRepository>();

            instrumentRepositoryStub.Stub(x => x.GetById(id)).Return(GetInstrumentForEdit(id));
            _instrumentService = InstrumentServiceFactory.Create(instrumentRepositoryStub);
            EditInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.DescriptionTooLong));
        }
Example #25
0
        public void Edit_ModelNoRequired_DomainValidationExceptionThrown()
        {
            var id                       = Guid.NewGuid();
            var manufacturer             = "Fluke";
            var modelNo                  = String.Empty;
            var range                    = "Range";
            var description              = "Digital Multimeter";
            var allocatedCalibrationTime = 20;

            var instrumentRepositoryStub = MockRepository.GenerateStub <IInstrumentRepository>();

            instrumentRepositoryStub.Stub(x => x.GetById(id)).Return(GetInstrumentForEdit(id));
            _instrumentService = InstrumentServiceFactory.Create(instrumentRepositoryStub);
            EditInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime);
            Assert.IsTrue(_domainValidationException.ResultContainsMessage(Messages.ModelNoRequired));
        }
Example #26
0
 public JobItemController(
     UserManagementService userManagementService,
     JobItemService jobItemService,
     ListItemService listItemService,
     InstrumentService instrumentService,
     ConsignmentService consignmentService,
     QuoteItemService quoteItemService,
     OrderItemService orderItemService,
     DeliveryItemService deliveryItemService,
     CertificateService certificateService)
 {
     _jobItemService        = jobItemService;
     _listItemService       = listItemService;
     _instrumentService     = instrumentService;
     _consignmentService    = consignmentService;
     _quoteItemService      = quoteItemService;
     _orderItemService      = orderItemService;
     _deliveryItemService   = deliveryItemService;
     _certificateService    = certificateService;
     _userManagementService = userManagementService;
 }
        public static void CreateContext(Guid testStandardId, Guid jobItemId)
        {
            var dispatcher     = MockRepository.GenerateMock <IQueueDispatcher <IMessage> >();
            var userRepository = new UserAccountRepository();
            var user           = userRepository.GetByEmail("*****@*****.**", false);
            var userContext    = new TestUserContext(user);

            var companyDetailsRepository = new CompanyDetailsRepository();
            var quoteRepository          = new QuoteRepository();
            var quoteItemRepository      = new QuoteItemRepository();
            var customerRepository       = new CustomerRepository();
            var jobRepository            = new JobRepository();
            var jobItemRepository        = new JobItemRepository();
            var listItemRepository       = new ListItemRepository();
            var entityIdProvider         = new DirectEntityIdProvider();
            var instrumentRepository     = new InstrumentRepository();

            var instrumentId      = Guid.NewGuid();
            var instrumentService = new InstrumentService(userContext, instrumentRepository, dispatcher);

            instrumentService.Create(instrumentId, "Druck", "DPI601IS", "None", "Description", 15);

            var customerId      = Guid.NewGuid();
            var customerService = new CustomerService(userContext, customerRepository, dispatcher);

            customerService.Create(customerId, "Gael Ltd", String.Empty, new Address(), new ContactInfo(), "Gael Ltd", new Address(), new ContactInfo(), "Gael Ltd", new Address(), new ContactInfo());

            var listItemService = new ListItemService(userContext, listItemRepository, dispatcher);
            var jobService      = new JobService(userContext, null, jobRepository, listItemRepository, customerRepository, entityIdProvider, dispatcher);
            var jobItemService  = new JobItemService(userContext, jobRepository, jobItemRepository, listItemService, instrumentService, dispatcher);

            var jobId = Guid.NewGuid();

            jobService.CreateJob(jobId, "Some instructions", "PO1000", "AD1000", listItemService.GetAllByCategory(ListItemCategoryType.JobType).First().Id, customerId, "some notes", "job contact");
            jobItemService.CreateJobItem(
                jobId, jobItemId, instrumentId, "12345", String.Empty,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemInitialStatus).First().Id,
                listItemService.GetAllByCategory(ListItemCategoryType.JobItemCategory).First().Id,
                12, "instructions", String.Empty, false, String.Empty, String.Empty);
        }
Example #28
0
        public void Edit_ValidInstrumentDetails_InstrumentCreated()
        {
            var id                       = Guid.NewGuid();
            var manufacturer             = "Fluke";
            var modelNo                  = "21";
            var range                    = "Range";
            var description              = "Digital Multimeter";
            var allocatedCalibrationTime = 20;

            var instrumentRepositoryMock = MockRepository.GenerateMock <IInstrumentRepository>();

            instrumentRepositoryMock.Expect(x => x.Update(null)).IgnoreArguments();
            instrumentRepositoryMock.Stub(x => x.GetById(id)).Return(GetInstrumentForEdit(id));
            _instrumentService = InstrumentServiceFactory.Create(instrumentRepositoryMock);
            EditInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime);
            instrumentRepositoryMock.VerifyAllExpectations();
            Assert.AreEqual(manufacturer, _savedInstrument.Manufacturer);
            Assert.AreEqual(modelNo, _savedInstrument.ModelNo);
            Assert.AreEqual(range, _savedInstrument.Range);
            Assert.AreEqual(description, _savedInstrument.Description);
            Assert.AreEqual(allocatedCalibrationTime, _savedInstrument.AllocatedCalibrationTime);
        }
Example #29
0
        public void Create_ValidInstrumentDetails_InstrumentCreated()
        {
            var id                       = Guid.NewGuid();
            var manufacturer             = "Druck";
            var modelNo                  = "DPI601IS";
            var range                    = "Not Specified";
            var description              = "Digital Pressure Indicator";
            var allocatedCalibrationTime = 20;

            var instrumentRepositoryMock = MockRepository.GenerateMock <IInstrumentRepository>();

            instrumentRepositoryMock.Expect(x => x.Create(null)).IgnoreArguments();
            _instrumentService = InstrumentServiceFactory.Create(instrumentRepositoryMock);
            CreateInstrument(id, manufacturer, modelNo, range, description, allocatedCalibrationTime);
            instrumentRepositoryMock.VerifyAllExpectations();
            Assert.AreEqual(id, _savedInstrument.Id);
            Assert.AreEqual(manufacturer, _savedInstrument.Manufacturer);
            Assert.AreEqual(modelNo, _savedInstrument.ModelNo);
            Assert.AreEqual(range, _savedInstrument.Range);
            Assert.AreEqual(description, _savedInstrument.Description);
            Assert.AreEqual(allocatedCalibrationTime, _savedInstrument.AllocatedCalibrationTime);
        }
Example #30
0
 public void Setup()
 {
     _instrumentService         = InstrumentServiceFactory.Create();
     _domainValidationException = null;
 }