Ejemplo n.º 1
0
        public void CreateUserSession(int testerId)
        {
            using (var manufacturingStoreRepository = dataContextFactory.CreateManufacturingStoreRepository())
            {
                // Start User Session with tester information
                userSession = new UserSession()
                {
                    ApplicationName = "Home Automation Tester",
                    TesterId        = testerId,
                    StartTime       = DateTime.Now
                };

                manufacturingStoreRepository.UserSessions.Add(userSession);
                manufacturingStoreRepository.SaveChanges();
            }
        }
Ejemplo n.º 2
0
        private bool VerifyEui(EmberEui64 eui)
        {
            bool result = false;

            using (var manufacturingStoreRepository = dataContextFactory.CreateManufacturingStoreRepository())
            {
                var euiString = eui.ToString();
                var dbEui     = manufacturingStoreRepository.EuiLists.AsNoTracking().FirstOrDefault(e => e.EUI == euiString);

                string dbEuiSKU = null;
                if (dbEui != null)
                {
                    dbEuiSKU = dbEui.TargetDevices.OrderByDescending(x => x.Id).FirstOrDefault()?.TestSession?.Product?.SKU;

                    if (dbEuiSKU == ValidProduct?.SKU)
                    {
                        result = true;
                    }
                    else
                    {
                        errorProducerService.AddMessage(new ErrorMessage(string.Format("SKU: {0} is invalid for the selected product", dbEuiSKU), ErrorType.Error));
                    }
                }
                else
                {
                    if (ValidProduct?.Board.ChipType.Name == EM250_CHIP)
                    {
                        // EM250 Chips do not have EUIs in DB since they are not coded in EBL
                        dbEui = new EuiList()
                        {
                            EUI = euiString,
                            ProductionSiteId = CurrentStationSite.ProductionSite.Id
                        };

                        manufacturingStoreRepository.EuiLists.Add(dbEui);
                        manufacturingStoreRepository.SaveChanges();

                        result = true;
                    }
                    else
                    {
                        errorProducerService.AddMessage(new ErrorMessage(string.Format("EUI: {0} could not be found in database", euiString), ErrorType.Error));
                    }
                }

                return(result);
            }
        }