public void Dispose(bool disposing) { using (var rep = new BatchRepository()) { rep.Dispose(); } }
public void TestARBatchStoredProc() { var repo = new BatchRepository(); var batches = repo.GetARBatchesByBatchID("ARCR-0050090").Result; Assert.IsNotNull(batches.Count > 1); }
public void Insert(BatchView batchView, String userId) { using (var rep = new BatchRepository()) { rep.Insert(ConvertBatch(batchView, userId)); } }
[InlineData(50000, 100, 10)] //5만개의 데이터 인입에 소요시간은 10초이내여야한다. public void Test1(int daatSize, int batchSize, int cutoff) { var bulkItems_reseverd = new List <MessageReseved>(); for (int i = 0; i < daatSize; i++) { var addData = new MessageReseved() { Seq = i.ToString(), no = i, Message = "TestMessage" + i, updateTime = DateTime.Now }; bulkItems_reseverd.Add(addData); } Within(TimeSpan.FromSeconds(cutoff), () => { EntityFrameworkManager.ContextFactory = context => new BatchRepository(appSettings); using (var context = new BatchRepository(appSettings)) { context.BulkInsertAsync(bulkItems_reseverd, options => { options.BatchSize = batchSize; }).Wait(); } }); }
public void Delete(BatchView batchView) { using (var rep = new BatchRepository()) { //rep.Delete(ConvertBatch(batchView)); } }
public void Update(BatchView batchView, string userId) { using (var rep = new BatchRepository()) { var user = _db.Users.ToList().Find(x => x.Id == userId); Batch batch = rep.GetById(batchView.BatchTypeid); if (batch != null) { //batch.Batchid = batchView.Batchid; batch.BatchTypeid = batchView.BatchTypeid; batch.UserId = batchView.UserId; // batch.Name = user.UserProfile.FirstName; batch.BatchCode = _TypeBl.GetBatchTypeById(batchView.BatchTypeid).BatchTypeDesc.Substring(0, 2) + DateTime.Now; batch.Agerange = batchView.Agerange; batch.NumOfAnimals = batchView.NumOfAnimals; batch.Wiegth = batchView.Wiegth; batch.Totalcost = batchView.Totalcost; } // rep.Update(batch); rep.Update(ConvertBatch(batchView, userId)); } }
public UnitOfWork(FELFELContext context) { _context = context; Batches = new BatchRepository(_context); Products = new ProductRepository(_context); StockChanges = new BatchStockChangeRepository(_context); }
public override async Task Setup() { await base.Setup(); BatchRepository = new BatchRepository(DbConnectionFactory); Sut = new CommandRepository(DbConnectionFactory); }
public void TestGetAPBatches() { var repo = new BatchRepository(); var batches = repo.GetAPBatchesAsync("").Result; Assert.IsNotNull(batches.Count > 1); }
public HttpResponseMessage AddBatch(AddBatchDto addBatch) { var repository = new BatchRepository(); var result = repository.Create(addBatch.RecipeId, addBatch.Cooker); return((result) ? Request.CreateResponse(HttpStatusCode.Created) : Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Could not create recipe. Please try again.")); }
public void Initialize() { var builder = new ConfigurationBuilder().SetBasePath(Directory.GetCurrentDirectory()).AddJsonFile("appsettings.json"); _configuration = builder.Build(); _options = new DbContextOptionsBuilder <StockContext>().UseSqlite (_configuration.GetConnectionString("DefaultConnection")).Options; objRepo = new BatchRepository(_databaseContext); }
public HttpResponseMessage AddBatch(BatchDto batch) { var repository = new BatchRepository(); var result = repository.Create(batch.RecipeId, batch.Cooker); if (result) { return(Request.CreateResponse(HttpStatusCode.Created)); } return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Batch could not be created, try again.")); }
public HttpResponseMessage AddBatch(AddBatchDto addBatch) { var repository = new BatchRepository(); var result = repository.Create(addBatch.RecipeId, addBatch.Cooker); if (result) { return(Request.CreateResponse(HttpStatusCode.Created)); } return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Sorry about your luck, shmuck")); }
public HttpResponseMessage AddBatch(AddBatchDto addBatch) { var batchRepository = new BatchRepository(); var createBatch = batchRepository.Create(addBatch.RecipeId, addBatch.Cooker); if (createBatch) { return(Request.CreateResponse(HttpStatusCode.Created)); } return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Sorry we could not create a batch at this time, please try again later.")); }
public HttpResponseMessage AddBatch(AddBatchDto addBatch) { var repository = new BatchRepository(); var result = repository.Create(addBatch.RecipeId, addBatch.Cooker); if (result) { return(Request.CreateResponse(HttpStatusCode.Created)); } ; return(Request.CreateErrorResponse(HttpStatusCode.InternalServerError, "Could not create batch")); }
public async Task It_Should_Return_Command_Does_Not_Exist_When_CommandName_Is_Incorrect() { // Arrange var fullyPopulatedBatch = Batches.FullyPopulated; fullyPopulatedBatch.Id = "123"; await BatchRepository.Create(fullyPopulatedBatch); var step = fullyPopulatedBatch.Steps[0]; // Act var doesExist = await Sut.DoesCommandExist(fullyPopulatedBatch.Id, step.Name, "CommandName_1"); // Assert doesExist.Should().BeFalse(); }
public async Task It_Should_Return_Command_Option_Exist() { // Arrange var fullyPopulatedBatch = Batches.FullyPopulated; fullyPopulatedBatch.Id = "123"; await BatchRepository.Create(fullyPopulatedBatch); var step = fullyPopulatedBatch.Steps[0]; var command = step.Commands[0]; // Act var doesExist = await Sut.DoesCommandOptionExist(fullyPopulatedBatch.Id, step.Name, command.Name, command.Options[0].Name); // Assert doesExist.Should().BeTrue(); }
public async Task It_Should_Return_Command_Variable_Does_Not_Exist_When_StepName_Is_Incorrect() { // Arrange var fullyPopulatedBatch = Batches.FullyPopulated; fullyPopulatedBatch.Id = "123"; await BatchRepository.Create(fullyPopulatedBatch); var step = fullyPopulatedBatch.Steps[0]; var command = step.Commands[0]; // Act var doesExist = await Sut.DoesCommandVariableExist(fullyPopulatedBatch.Id, "StepName_1", command.Name, command.Variables[0].Name); // Assert doesExist.Should().BeFalse(); }
public IEnumerable <StorageSiteOverview> GetSitesOverview() { List <StorageSiteOverview> overview = new List <StorageSiteOverview>(); var sites = LocationsRepository.GetAllStorageSites(); foreach (var site in sites) { overview.Add(new StorageSiteOverview() { Site = site, Temperature = EnvironmentalDataRepository.GetLatestValue(site, EnvironmentalFactor.Temperature).Value, Humidity = EnvironmentalDataRepository.GetLatestValue(site, EnvironmentalFactor.Humidity).Value, TotalMaterial = BatchRepository.GetMaterialBatches(null, site.Id).Sum(b => b.Quantity) }); } return(overview); }
public UnitOfWork(FypDbContext db) { _context = db; Campus = new CampusRepository(_context); Department = new DepartmentRepository(_context); Batch = new BatchRepository(_context); Section = new SectionRepository(_context); Student = new StudentRepository(_context); File = new FileRepository(_context); Teacher = new TeacherRepository(_context); EnrollDep = new EnrollDepartmentRepository(_context); EnrollBatch = new EnrollBatchRepository(_context); EnrollSection = new EnrollSectionRepository(_context); Course = new CourseRepository(_context); CourseToDep = new CourseToDepRepository(_context); StudentRegistration = new StudentRegistrationRepository(_context); subjectallocate = new SubjectAllocatRepository(_context); }
public BatchView GetBatchById(int id) { using (var rep = new BatchRepository()) { // var user = _db.Users.ToList().Find(x => x.Id == userid); return(rep.GetAll().Select(x => new BatchView { Batchid = x.Batchid, Agerange = x.Agerange, UserId = x.UserId, Name = x.Name, BatchCode = x.BatchCode, BatchTypeid = x.BatchTypeid, BatchTypeViews = x.BatchTypeViews, NumOfAnimals = x.NumOfAnimals, Totalcost = x.Totalcost, Wiegth = x.Wiegth }).First(b => b.Batchid == id)); } }
public LookUpService() { _custClassRepo = new CustClassRepository(context); _paymentTermsRepo = new PaymentTermsRepository(context); _statementCycleRepository = new StatementCycleRepository(context); _shipMethodRepository = new ShipMethodRepository(context); _businessFormRepository = new BusinessFormRepository(context); _salesSourceRepository = new SalesSourceRepository(context); _branchRepository = new BranchRepository(context); _salesTerritoryRepository = new SalesTerritoryRepository(context); _territoryRepository = new TerritoryRepository(context); _countryRepository = new CountryRepository(context); _customerRepository = new CustomerRepository(context); _userRepository = new UserRepository(context); _groupRepository = new GroupRepository(context); _creditCardTypeRepository = new CreditCardTypeRepository(context); _stateRepository = new StateRepository(context); _taxSubjClassRepository = new TaxSubjClassRepository(context); _taxScheduleRepository = new TaxScheduleRepository(context); _batchRepository = new BatchRepository(); }
public List <BatchView> GetAllBatches() { using (var rep = new BatchRepository()) { var bat = new List <BatchView>(); foreach (var x in rep.GetAll()) { bat.Add(new BatchView { Batchid = x.Batchid, Agerange = x.Agerange, UserId = x.UserId, Name = x.Name, BatchTypeid = x.BatchTypeid, NumOfAnimals = x.NumOfAnimals, BatchCode = x.BatchCode, Wiegth = x.Wiegth, Totalcost = x.Totalcost } ); } return(bat); } }
public BatchWriterActor() { ReceiveAsync <object>(async message => { if (message is Batch batchMessage) { Context.IncrementMessagesReceived(); var bulkItems_reseverd = new List <MessageReseved>(); var bulkItems_completed = new List <MessageCompleted>(); foreach (var item in batchMessage.Obj) { if (item is DelayMsg delayMsg) { if (delayMsg.State == DelayMsgState.Reserved) { bulkItems_reseverd.Add(new MessageReseved() { Seq = delayMsg.Seq, Message = delayMsg.Message, updateTime = DateTime.Now }); } else if (delayMsg.State == DelayMsgState.Completed) { bulkItems_completed.Add(new MessageCompleted() { Seq = delayMsg.Seq, Message = delayMsg.Message, updateTime = DateTime.Now }); } } } string BatchType = ""; if (bulkItems_reseverd.Count > 0 && IsWriteDB) { BatchType = "reserved"; EntityFrameworkManager.ContextFactory = context => new BatchRepository(Startup.AppSettings); using (var context = new BatchRepository(Startup.AppSettings)) { await context.BulkInsertAsync(bulkItems_reseverd, options => { options.BatchSize = BatchSize; }); Context.IncrementCounter("akka.custom.received1", bulkItems_reseverd.Count); } } if (bulkItems_completed.Count > 0 && IsWriteDB) { BatchType = "completed"; EntityFrameworkManager.ContextFactory = context => new BatchRepository(Startup.AppSettings); using (var context = new BatchRepository(Startup.AppSettings)) { await context.BulkInsertAsync(bulkItems_completed, options => { options.BatchSize = BatchSize; }); Context.IncrementCounter("akka.custom.received1", bulkItems_completed.Count); } } logger.Info($"========= Bulk Type:{BatchType} Count:{batchMessage.Obj.Count.ToString()}"); } }); }
public void TestTransactionRepository() { // Create prerequisite entities Plastic plastic = PlasticsRepository.CreatePlastic("PP", "Polypropylene"); Material material = MaterialsRepository.CreateMaterial("m", "m", "m", plastic); StorageSite site = LocationsRepository.CreateStorageSite("site"); StorageArea area = LocationsRepository.CreateStorageArea(site, "area"); StorageLocation location = new StorageLocation() { StorageSiteId = site.Id, StorageAreaId = area.Id, StorageSiteName = site.Name, StorageAreaName = area.Name }; MaterialBatch batch = BatchRepository.CreateMaterialBatch(material, DateTime.Today.AddDays(3), location, 42, 42, new Dictionary <Guid, string>(), false); (string password, byte[] salt) = new PasswordHashingService(new LoggerFactory()).HashAndSaltPassword("test"); User user = UserRepository.CreateUser("alex", "Alex", password, salt, Role.Administrator); // Create transactions Repository.LogTransaction(new Transaction() { Id = Guid.NewGuid(), MaterialBatchId = batch.Id, Quantity = -3, Timestamp = DateTime.Today.AddDays(-3), UserId = user.Id }); Repository.LogTransaction(new Transaction() { Id = Guid.NewGuid(), MaterialBatchId = batch.Id, Quantity = -2, Timestamp = DateTime.Today.AddDays(-2), UserId = user.Id }); Guid lastId = Guid.NewGuid(); Repository.LogTransaction(new Transaction() { Id = lastId, MaterialBatchId = batch.Id, Quantity = -1, Timestamp = DateTime.Today.AddDays(-1), UserId = user.Id }); // Check with getAll IEnumerable <Transaction> transactions = Repository.GetTransactionsForBatch(batch.Id); Assert.Equal(3, transactions.Count()); Assert.Single(transactions, t => t.Quantity == -3); Assert.Single(transactions, t => t.Quantity == -2); Assert.Single(transactions, t => t.Quantity == -1); // Check get last Transaction transaction = Repository.GetLastTransactionForBatch(batch.Id); Assert.Equal(batch.Id, transaction.MaterialBatchId); Assert.Equal(lastId, transaction.Id); Assert.Equal(-1, transaction.Quantity); // Test transaction update transaction.Quantity = 200; Repository.UpdateTransaction(transaction); transaction = Repository.GetLastTransactionForBatch(batch.Id); Assert.Equal(lastId, transaction.Id); Assert.Equal(200, transaction.Quantity); }