public static void Seed()
        {
            using var _ctx = new Context();
            _ctx.Database.EnsureDeleted();
            _ctx.Database.EnsureCreated();
            var comp1 = new Company("pingo ácido", 123456789);
            var reg1  = new Region("Covilhã");
            var est1  = new Establishment("rua das papoilas", "09h00", "20h00", "sundays and holidays", reg1.Id, comp1.Id);
            var reQ1  = new ReservedQueue(est1.Id);
            var stQ1  = new StoreQueue(12, est1.Id);

            var cat1 = new Category("Non-Alcoholic Beverages");
            var bra1 = new Brand("Luso");
            var eg1  = new EssentialGood("Água", false, "560-3187-922", 0.39, 0.5);
            var spb1 = new ShoppingBasket(est1.Id);


            _ctx.Companies.AddRange(comp1);
            _ctx.Regions.AddRange(reg1);
            _ctx.Establishments.AddRange(est1);
            _ctx.ReservedQueues.AddRange(reQ1);
            _ctx.StoreQueues.AddRange(stQ1);
            _ctx.ShoppingBaskets.AddRange(spb1);
            _ctx.SaveChanges();
        }
        public static void Seed()
        {
            using var _ctx = new Context();
            _ctx.Database.EnsureDeleted();
            _ctx.Database.EnsureCreated();

            var reg1  = new Region("Covilhã");
            var comp1 = new Company("pingo ácido", 123456789);
            var est1  = new Establishment("Avenida da liberdade, numero 1029, Lisboa", "09:00", "20:00", "Domingo", reg1.Id, comp1.Id);
            var cat1  = new Category("Non-Alcoholic Beverages");
            var bra1  = new Brand("Dona Edite");
            var prof1 = new Profile(123456789, "Paulo", "Macabres", 919191919, DateTime.UtcNow);
            var sb1   = new ShoppingBasket(prof1.Id);
            var mod1  = new ProductModel("Vinho Tinto da Barraca do Tejo", "506-1237-424", "oklmwelkmcwekmowmcklm", 3.99, 0.75, Measure.Kg, bra1.Id, cat1.Id);
            var stoQ1 = new StoreQueue(42, est1.Id);
            var resQ1 = new ReservedQueue(est1.Id, prof1.Id);
            var unit1 = new ProductUnit("lolada69420", false, mod1.Id, est1.Id, sb1.Id);


            _ctx.Regions.AddRange(reg1);
            _ctx.Companies.AddRange(comp1);
            _ctx.Establishments.AddRange(est1);
            _ctx.Categories.AddRange(cat1);
            _ctx.Brands.AddRange(bra1);
            _ctx.Profiles.AddRange(prof1);
            _ctx.ShoppingBaskets.AddRange(sb1);
            _ctx.ProductModels.AddRange(mod1);
            _ctx.StoreQueues.AddRange(stoQ1);
            _ctx.ReservedQueues.AddRange(resQ1);
            _ctx.ProductUnits.AddRange(unit1);


            _ctx.SaveChanges();
        }
Beispiel #3
0
 private void Start()
 {
     storageInterFace = GetComponent <StorageInterFace>();
     humansInRoom     = GetComponent <HumansInRoom>();
     storeQueue       = GetComponent <StoreQueue>();
     lastSellTime     = 0;
 }
 public static StoreQueueViewModel Parse(StoreQueue storeQueue)
 {
     return(new StoreQueueViewModel()
     {
         Id = storeQueue.Id,
         Quantity = storeQueue.Quantity
     });
 }
        public void TestCreateAndReadStoreQueuesAsync()
        {
            ContextSeeder.Seed();
            var ebo       = new EstablishmentBusinessObject();
            var sbo       = new StoreQueueBusinessObject();
            var est       = ebo.List().Result.First();
            var reg       = new StoreQueue(2, est.Id);
            var resCreate = sbo.CreateAsync(reg).Result;
            var resGet    = sbo.ReadAsync(reg.Id).Result;

            Assert.IsTrue(resCreate.Success && resGet.Success && resGet.Result != null);
        }
Beispiel #6
0
        protected override async Task ExecuteAsync(CancellationToken stoppingToken)
        {
            while (!stoppingToken.IsCancellationRequested)
            {
                var item = await StoreQueue.DequeueAsync(stoppingToken);

                var id = await IdentityGenerator.GenerateAsync();

                var evt = new Event
                {
                    Id            = id,
                    GlobalId      = id,
                    ApplicationId = Options.CurrentApplicationId,
                    Category      = item.Category,
                    Level         = item.Level,
                    EventId       = item.EventId,
                    EventType     = item.EventType,
                    Message       = item.Message,
                    Exception     = JsonConvert.SerializeObject(item.Exception, new JsonSerializerSettings {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                    }),
                    ProcessId = item.ProcessId,
                    TimeStamp = item.Timestamp
                };

                try
                {
                    await EventWriter.WriteAsync(evt, stoppingToken);

                    await Context.Clients.Group(Options.CurrentApplicationId.ToString()).ReceiveMessage(new EventViewModel
                    {
                        Id        = id,
                        Level     = item.Level,
                        Category  = item.Category,
                        Message   = item.Message,
                        AppId     = evt.ApplicationId,
                        EventId   = item.EventId,
                        EventType = item.EventType,
                        Timestamp = item.Timestamp
                    });
                }
                catch (Exception ex)
                {
                    // TODO 不可在日志组件内使用日志功能 会导致循环日志
                    File.WriteAllText(Path.Combine(Directory.GetCurrentDirectory(), $"{DateTime.Now.Ticks}.ex.log"),
                                      JsonConvert.SerializeObject(ex, new JsonSerializerSettings
                    {
                        ReferenceLoopHandling = ReferenceLoopHandling.Ignore
                    }));
                }
            }
        }
Beispiel #7
0
        public void Init()
        {
            if (MinimumPackageQuantity == default(int) ||
                MaximumPackageQuantity == default(int) ||
                ExpiretionThreshHoldInMilliseconds == default(int))
            {
                throw new Exception(StorageNotInitializedMessage);
            }

            tree        = new TreeWithSubTrees <WidthData>();
            _storeQueue = new StoreQueue();

            //SetJob();
        }
 public OperationResult Create(StoreQueue item)
 {
     try
     {
         _dao.Create(item);
         return(new OperationResult()
         {
             Success = true
         });
     }
     catch (Exception e)
     {
         return(new OperationResult()
         {
             Success = false, Exception = e
         });
     }
 }
        public async Task <OperationResult> CreateAsync(StoreQueue item)
        {
            try
            {
                await _dao.CreateAsync(item);

                return(new OperationResult()
                {
                    Success = true
                });
            }
            catch (Exception e)
            {
                return(new OperationResult()
                {
                    Success = false, Exception = e
                });
            }
        }
        public void TestCreateAndReadStoreQueueAsync()
        {
            ContextSeeder.Seed();
            var regBo = new RegionBusinessObject();
            var reg   = new Region("Algordos");

            regBo.Create(reg);
            var compBo = new CompanyBusinessObject();
            var comp   = new Company("", 1234567890);

            compBo.Create(comp);
            var estBo = new EstablishmentBusinessObject();
            var est   = new Establishment("anywhere", "sempre", "nunca", "8º dia da semana", reg.Id, comp.Id);

            estBo.Create(est);
            var bo         = new StoreQueueBusinessObject();
            var storeQueue = new StoreQueue(32, est.Id);
            var stoQCreate = bo.CreateAsync(storeQueue).Result;
            var stoQGet    = bo.ReadAsync(storeQueue.Id).Result;

            Assert.IsTrue(stoQCreate.Success && stoQGet.Success && stoQGet.Result != null);
        }
Beispiel #11
0
 public async Task DeleteAsync(StoreQueue storeQueue)
 {
     storeQueue.IsDeleted = true;
     await UpdateAsync(storeQueue);
 }
Beispiel #12
0
 public void Delete(StoreQueue storeQueue)
 {
     storeQueue.IsDeleted = true;
     Update(storeQueue);
 }
Beispiel #13
0
 public async Task UpdateAsync(StoreQueue storeQueue)
 {
     _context.Entry(storeQueue).State = EntityState.Modified;
     await _context.SaveChangesAsync();
 }
Beispiel #14
0
 public void Update(StoreQueue storeQueue)
 {
     _context.Entry(storeQueue).State = EntityState.Modified;
     _context.SaveChanges();
 }
Beispiel #15
0
        public async Task CreateAsync(StoreQueue storeQueue)
        {
            await _context.StoreQueues.AddAsync(storeQueue);

            await _context.SaveChangesAsync();
        }
Beispiel #16
0
 public void Create(StoreQueue storeQueue)
 {
     _context.StoreQueues.Add(storeQueue);
     _context.SaveChanges();
 }
Beispiel #17
0
 public bool CompareToModel(StoreQueue model)
 {
     return(EstablishmentId == model.EstablishmentId && Quantity == model.Quantity);
 }
Beispiel #18
0
 public StoreQueue ToModel(StoreQueue model)
 {
     model.EstablishmentId = EstablishmentId;
     model.Quantity        = Quantity;
     return(model);
 }
Beispiel #19
0
 public ExpirationJobRunner(StoreQueue queue) : base()
 {
     _queue = queue;
 }
Beispiel #20
0
 public void SetStore(StoreQueue _storeQueue)
 {
     storeQueue = _storeQueue;
     SetPosision(storeQueue.AddCustomerToLine(this));
 }