Ejemplo n.º 1
0
        public void Create_IsSaved()
        {
            try
            {
                // Run the test against one instance of the context
                using (var context = new DatabaseContext(options))
                {
                    IWarehouseRepository service = new WarehouseRepository(context, NullLogger <WarehouseRepository> .Instance);
                    Warehouse            wh      = new Warehouse()
                    {
                        Code = "123456789", Description = "yo dawg", ProcessingDelayMins = 1
                    };
                    service.Create(wh);
                }

                // Use a separate instance of the context to verify correct data was saved to database
                using (var context = new DatabaseContext(options))
                {
                    Assert.Equal(1, context.Hops.Count());
                    Assert.Equal("123456789", context.Hops.Single().Code);
                    Assert.Equal("yo dawg", context.Hops.Single().Description);
                }
            }
            finally { }
        }
Ejemplo n.º 2
0
        public void Create_ThrowsDuplicateHopExpection()
        {
            try
            {
                using (var context = new DatabaseContext(options))
                {
                    IWarehouseRepository service = new WarehouseRepository(context, NullLogger <WarehouseRepository> .Instance);
                    Warehouse            wh      = new Warehouse()
                    {
                        Code = "123456789", Description = "yo dawg", ProcessingDelayMins = 1
                    };
                    service.Create(wh);
                }

                using (var context = new DatabaseContext(options))
                {
                    IWarehouseRepository service = new WarehouseRepository(context, NullLogger <WarehouseRepository> .Instance);
                    Warehouse            wh      = new Warehouse()
                    {
                        Code = "123456789", Description = "yo dawg", ProcessingDelayMins = 1
                    };
                    Assert.Throws <DuplicateHopExpection>(() => service.Create(wh));
                }
            }
            finally { }
        }
Ejemplo n.º 3
0
        public void GetByCode_ReturnsHop()
        {
            try
            {
                // Run the test against one instance of the context
                using (var context = new DatabaseContext(options))
                {
                    Warehouse wh = new Warehouse()
                    {
                        Code = "123456789", Description = "yo dawg", ProcessingDelayMins = 1
                    };
                    context.Hops.Add(wh);
                    context.SaveChanges();
                }

                // Use a separate instance of the context to verify correct data was saved to database
                using (var context = new DatabaseContext(options))
                {
                    IWarehouseRepository service = new WarehouseRepository(context, NullLogger <WarehouseRepository> .Instance);
                    Warehouse            wh      = service.GetByCode("123456789");
                    Assert.Equal("123456789", wh.Code);
                    Assert.Equal("yo dawg", wh.Description);
                }
            }
            finally { }
        }
Ejemplo n.º 4
0
 public DataManager()
 {
     cont                       = new ModelContainer();
     branchRepository           = new BranchRepository(cont);
     categoryRepository         = new CategoryRepository(cont);
     checkDishRepository        = new CheckDishRepository(cont);
     checkMerchandiseRepository = new CheckMerchandiseRepository(cont);
     clientRepository           = new ClientRepository(cont);
     companyOwnerRepository     = new CompanyOwnerRepository(cont);
     companyRepository          = new CompanyRepository(cont);
     contactPersonRepository    = new ContactPersonRepository(cont);
     dishRepository             = new DishRepository(cont);
     documentRepository         = new DocumentRepository(cont);
     ejectionRepository         = new EjectionRepository(cont);
     employeeRepository         = new EmployeeRepository(cont);
     encashmentRepository       = new EncashmentRepository(cont);
     landlordRepository         = new LandlordRepository(cont);
     orderRepository            = new OrderRepository(cont);
     personRepository           = new PersonRepository(cont);
     positionRepository         = new PositionRepository(cont);
     prepackRepository          = new PrepackRepository(cont);
     productRepository          = new ProductRepository(cont);
     purchaseRepository         = new PurchaseRepository(cont);
     recipeDishIngrRepository   = new RecipeDishIngrRepository(cont);
     recipeDishPrepRepository   = new RecipeDishPrepRepository(cont);
     recipePrepIngrRepository   = new RecipePrepIngrRepository(cont);
     recipePrepPrepRepository   = new RecipePrepPrepRepository(cont);
     roomRepository             = new RoomRepository(cont);
     shiftRepository            = new ShiftRepository(cont);
     tableRepository            = new TableRepository(cont);
     warehouseRepository        = new WarehouseRepository(cont);
 }
Ejemplo n.º 5
0
 private void Search()
 {
     _projectDataContext  = new ProjectDataContext();
     _warehouseRepository = new WarehouseRepository(_projectDataContext);
     dgvDuLieu.DataSource = _warehouseRepository.GetAll().OrderBy(_ => _.WarehouseName);
     Control();
 }
Ejemplo n.º 6
0
        /// <summary>
        /// 获取生成的仓库编码
        /// </summary>
        /// <returns></returns>
        public object GetWareCode()
        {
            string warehouseCode             = "";
            IQueryable <Warehouse> wareQuery = WarehouseRepository.GetQueryable();
            var wareCode = wareQuery.Max(w => w.WarehouseCode);

            if (wareCode == string.Empty || wareCode == null)
            {
                warehouseCode = "01";
            }
            else
            {
                int i = Convert.ToInt32(wareCode);
                i++;
                string newcode = i.ToString();
                if (newcode.Length <= 2)
                {
                    for (int j = 0; j < 2 - i.ToString().Length; j++)
                    {
                        newcode = "0" + newcode;
                    }
                    warehouseCode = newcode;
                }
            }
            return(warehouseCode);
        }
Ejemplo n.º 7
0
        public new bool Add(Cell cell)
        {
            var cellAdd   = new Cell();
            var warehouse = WarehouseRepository.GetQueryable().FirstOrDefault(w => w.WarehouseCode == cell.WarehouseCode);
            var area      = AreaRepository.GetQueryable().FirstOrDefault(a => a.AreaCode == cell.AreaCode);
            var shelf     = ShelfRepository.GetQueryable().FirstOrDefault(s => s.ShelfCode == cell.ShelfCode);
            var product   = ProductRepository.GetQueryable().FirstOrDefault(p => p.ProductCode == cell.DefaultProductCode);

            cellAdd.CellCode    = cell.CellCode;
            cellAdd.CellName    = cell.CellName;
            cellAdd.ShortName   = cell.ShortName;
            cellAdd.CellType    = cell.CellType;
            cellAdd.Layer       = cell.Layer;
            cellAdd.Col         = cell.Col;
            cellAdd.ImgX        = cell.ImgX;
            cellAdd.ImgY        = cell.ImgY;
            cellAdd.Rfid        = cell.Rfid;
            cellAdd.Warehouse   = warehouse;
            cellAdd.Area        = area;
            cellAdd.Shelf       = shelf;
            cellAdd.Product     = product;
            cellAdd.MaxQuantity = cell.MaxQuantity;
            cellAdd.IsSingle    = cell.IsSingle;
            cellAdd.Description = cell.Description;
            cellAdd.IsActive    = cell.IsActive;
            cellAdd.UpdateTime  = DateTime.Now;

            CellRepository.Add(cellAdd);
            CellRepository.SaveChanges();
            return(true);
        }
Ejemplo n.º 8
0
        /// <summary>
        /// 根据参数Code查询仓库信息
        /// </summary>
        /// <param name="wareCode">仓库Code</param>
        /// <returns></returns>
        public object FindWarehouse(string wareCode)
        {
            IQueryable <Warehouse> wareQuery = WarehouseRepository.GetQueryable();
            var warehouse = wareQuery.Where(w => w.WarehouseCode == wareCode).AsEnumerable().Select(w => new { w.WarehouseCode, w.WarehouseName, w.WarehouseType, w.ShortName, w.Description, IsActive = w.IsActive == "1" ? "可用" : "不可用", UpdateTime = w.UpdateTime.ToString("yyyy-MM-dd hh:mm:ss") });

            return(warehouse.First(w => w.WarehouseCode == wareCode));
        }
        public void RemoveWarehouse_GivenAnInstance_RemovesTheRecord()
        {
            // assert
            List <Warehouse> data = new List <Warehouse>();

            data.Add(new Warehouse()
            {
                ID = 10
            });
            Warehouse existingRecord = new Warehouse()
            {
                ID = 10
            };
            Mock <DbSet <Warehouse> > mockSet     = EntityMockFactory.CreateSet(data.AsQueryable());
            Mock <LocationDb>         mockContext = new Mock <LocationDb>();

            mockContext.Setup(c => c.Warehouses).Returns(mockSet.Object);
            WarehouseRepository sut = new WarehouseRepository(mockContext.Object, null);

            // act
            sut.RemoveWarehouse(existingRecord);

            // assert
            mockSet.Verify(s => s.Attach(It.Is <Warehouse>(a => a.ID == 10)), Times.Once());
            mockSet.Verify(s => s.Remove(It.Is <Warehouse>(a => a.ID == 10)), Times.Once());
            mockContext.Verify(c => c.SaveChanges(), Times.Once());
        }
Ejemplo n.º 10
0
        public object GetWareArea()
        {
            var            warehouses = WarehouseRepository.GetQueryable().AsEnumerable();
            HashSet <Tree> wareSet    = new HashSet <Tree>();

            foreach (var warehouse in warehouses)//仓库
            {
                Tree wareTree = new Tree();
                wareTree.id         = warehouse.WarehouseCode;
                wareTree.text       = "仓库:" + warehouse.WarehouseName;
                wareTree.state      = "open";
                wareTree.attributes = "ware";

                var areas = AreaRepository.GetQueryable().Where(a => a.Warehouse.WarehouseCode == warehouse.WarehouseCode)
                            .OrderBy(a => a.AreaCode).Select(a => a);
                HashSet <Tree> areaSet = new HashSet <Tree>();
                foreach (var area in areas)//库区
                {
                    Tree areaTree = new Tree();
                    areaTree.id         = area.AreaCode;
                    areaTree.text       = "库区:" + area.AreaName;
                    areaTree.state      = "open";
                    areaTree.attributes = "area";
                    areaSet.Add(areaTree);
                }
                wareTree.children = areaSet.ToArray();
                wareSet.Add(wareTree);
            }
            return(wareSet.ToArray());
        }
Ejemplo n.º 11
0
        public bool RemoveMatrailofTreatment(int clinecID, int matrailID = 0, int treatmentID = 0)
        {
            bool check;

            MaterialRepository materialRepository = new MaterialRepository();
            int quantity = materialRepository.getQuanityOfMatrailTreatment(matrailID, treatmentID);
            int storgeID = 0;

            StorgeRepository  storgeRepository = new StorgeRepository();
            IEnumerable <int> storgeList       = storgeRepository.getClinecStorgesList(clinecID);

            if (storgeList.Count() > 0)
            {
                storgeID = storgeList.First();

                Warehouse warehouse = new Warehouse()
                {
                    ItemID = matrailID, StorageID = storgeID
                };
                WarehouseRepository warehouseRepository = new WarehouseRepository();
                Warehouse           Getwarehouse        = warehouseRepository.Getwarehouse(warehouse);

                Getwarehouse.Available += quantity;
                warehouseRepository.UpdateWarehouse(Getwarehouse);
            }
            check = materialRepository.removeTreatmentMatrail(matrailID, treatmentID);

            return(check);
        }
Ejemplo n.º 12
0
        public static SelectList GetSelectList_Warehouse(object sValue, string NullOrNameEmpty)
        {
            var selectListItems = new List <SelectListItem>();
            WarehouseRepository warehouseRepository = new WarehouseRepository(new Domain.Sale.ErpSaleDbContext());

            if (NullOrNameEmpty != null)
            {
                SelectListItem itemEmpty = new SelectListItem();
                itemEmpty.Text  = NullOrNameEmpty;
                itemEmpty.Value = null;
                selectListItems.Add(itemEmpty);
            }
            try
            {
                var q = warehouseRepository.GetAllWarehouse().OrderBy(item => item.Id);
                foreach (var i in q)
                {
                    SelectListItem item = new SelectListItem();
                    item.Text  = i.Name;
                    item.Value = i.Id.ToString();
                    selectListItems.Add(item);
                }
            }
            catch { }

            var selectList = new SelectList(selectListItems, "Value", "Text", sValue);

            return(selectList);
        }
Ejemplo n.º 13
0
        public static SelectList GetSelectList_Warehouse(object sValue, int?BranchId, string NullOrNameEmpty, bool IsSale = true)
        {
            var selectListItems = new List <SelectListItem>();
            WarehouseRepository warehouseRepository = new WarehouseRepository(new Domain.Sale.ErpSaleDbContext());

            if (NullOrNameEmpty != null)
            {
                SelectListItem itemEmpty = new SelectListItem();
                itemEmpty.Text  = NullOrNameEmpty;
                itemEmpty.Value = null;
                selectListItems.Add(itemEmpty);
            }
            try
            {
                var q = warehouseRepository.GetAllWarehouse().Where(x => x.IsSale == IsSale).OrderBy(item => item.Id).AsEnumerable();
                if (BranchId != null)
                {
                    q = q.Where(x => x.BranchId == BranchId);
                }
                foreach (var i in q)
                {
                    SelectListItem item = new SelectListItem();
                    item.Text  = i.Name;
                    item.Value = i.Id.ToString();
                    selectListItems.Add(item);
                }
            }
            catch { }

            var selectList = new SelectList(selectListItems, "Value", "Text", sValue);

            return(selectList);
        }
Ejemplo n.º 14
0
        public List <TransportToWarehouse> GetTransportToWarehouse()
        {
            List <TransportToWarehouse> lstTimeZone = new List <TransportToWarehouse>();

            lstTimeZone = new WarehouseRepository().GetTransportToWarehouse();

            return(lstTimeZone);
        }
Ejemplo n.º 15
0
 private void FillDiscrepancies()
 {
     if (DocumentUoW.Root.Warehouse != null && DocumentUoW.Root.Warehouse.Id > 0)
     {
         var warehouseRepository = new WarehouseRepository();
         nomenclaturesWithDiscrepancies = warehouseRepository.GetDiscrepancyNomenclatures(UoW, DocumentUoW.Root.Warehouse.Id);
     }
 }
Ejemplo n.º 16
0
 public void Cleanup()
 {
     _mainContext           = null;
     _productRepository     = null;
     _warehouseRepository   = null;
     _productComandsHandler = null;
     _productService        = null;
 }
Ejemplo n.º 17
0
 public void Initialize()
 {
     _mainContext           = new MainContext();
     _productRepository     = new ProductRepository(_mainContext);
     _warehouseRepository   = new WarehouseRepository(_mainContext);
     _productComandsHandler = new ProductComandsHandler(_productRepository, _warehouseRepository);
     _productService        = new ProductService(_productRepository, _warehouseRepository, _productComandsHandler);
 }
Ejemplo n.º 18
0
        public FrayteWarehouse GetWarehouseDetail(int warehouseId)
        {
            FrayteWarehouse warehouseDetail = new FrayteWarehouse();

            warehouseDetail = new WarehouseRepository().GetWarehouseDetail(warehouseId);

            return(warehouseDetail);
        }
Ejemplo n.º 19
0
        public List <FrayteWarehouse> GetAllWarehouseList()
        {
            List <FrayteWarehouse> lstFraytehouse = new List <FrayteWarehouse>();

            lstFraytehouse = new WarehouseRepository().GetAllWarehouseList();

            return(lstFraytehouse);
        }
Ejemplo n.º 20
0
        public FrayteResult DeleteWarehouse(int warehouseId)
        {
            FrayteResult result = new FrayteResult();

            result = new WarehouseRepository().DeleteWarehouse(warehouseId);

            return(result);
        }
Ejemplo n.º 21
0
        public List <ShipmentWarehouse> GetWarehouseList()
        {
            List <ShipmentWarehouse> lstTimeZone = new List <ShipmentWarehouse>();

            lstTimeZone = new WarehouseRepository().GetWarehouseList();

            return(lstTimeZone);
        }
Ejemplo n.º 22
0
 private void FillDiscrepancies()
 {
     if (Entity.Warehouse != null && Entity.Warehouse.Id > 0)
     {
         var warehouseRepository = new WarehouseRepository();
         nomenclaturesWithDiscrepancies = warehouseRepository.GetDiscrepancyNomenclatures(UoW, Entity.Warehouse.Id);
     }
 }
Ejemplo n.º 23
0
        public NomenclatureStockFilterViewModel(IEntityAutocompleteSelectorFactory warehouseSelectorFactory)
        {
            WarehouseSelectorFactory = warehouseSelectorFactory ?? throw new ArgumentNullException(nameof(warehouseSelectorFactory));
            UserHasOnlyAccessToWarehouseAndComplaints =
                ServicesConfig.CommonServices.CurrentPermissionService.ValidatePresetPermission("user_have_access_only_to_warehouse_and_complaints") &&
                !ServicesConfig.CommonServices.UserService.GetCurrentUser(UoW).IsAdmin;

            AvailableWarehouses = new WarehouseRepository().GetActiveWarehouse(UoW);
        }
Ejemplo n.º 24
0
        public JsonResult GetWarehouse(string name)
        {
            WarehouseRepository warehouseRepository = new WarehouseRepository(_connectionString);
            var warehouse = warehouseRepository.Save(name);

            return(Json(
                       new { warehouse = warehouse, total = 1, success = true },
                       JsonRequestBehavior.AllowGet));
        }
 public ManageWarehouseProductCheckController(WarehouseRepository warehouseRepository
                                              , WarehouseProductCheckRepository warehouseProductCheckRepository
                                              , UsersAccessRepository usersAccessRepository
                                              , ProductRepostitory productRepostitory) : base(usersAccessRepository)
 {
     _warehouseRepository             = warehouseRepository;
     _warehouseProductCheckRepository = warehouseProductCheckRepository;
     _productRepostitory = productRepostitory;
 }
Ejemplo n.º 26
0
 /// <summary>
 /// 根据仓库类型获取仓库列表
 /// </summary>
 /// <param name="warehouseType">仓库类型</param>
 /// <returns>仓库列表</returns>
 public List<Warehouse> GetWarehousesByType(WarehouseType warehouseType)
 {
     using (IUnitOfWork unitwork = MSSqlHelper.DataContext())
     {
         IWarehouseRepository warehouseRep = new WarehouseRepository(unitwork);
         List<Warehouse> warehouses = warehouseRep.GetWarehouseByType(warehouseType);
         return warehouses;
     }
 }
Ejemplo n.º 27
0
        public ActionResult Index()
        {
            string playerName = "Chavp";
            WarehouseRepository warehouseRepository = new WarehouseRepository(_connectionString);
            var warehouse = warehouseRepository.Save(playerName);

            ViewBag.PlayerName = playerName;

            return(View(warehouse));
        }
Ejemplo n.º 28
0
 public StoragesController(
     StoragesRepository repository,
     ProductRepository productRepository,
     WarehouseRepository warehouseRepository
     ) : base(repository)
 {
     _repository          = repository;
     _productRepository   = productRepository;
     _warehouseRepository = warehouseRepository;
 }
Ejemplo n.º 29
0
        public void StartSync()
        {
            try
            {
                LoggerUtility.InitializeLogger();
                int      BranchID      = 45;
                DateTime syncStartTime = DateTime.Now.AddMinutes(-15);
                //LoggerUtility.Logger.Info($"Warehouse sync started at {syncStartTime.ToLongTimeString()}");
                //Console.Clear();
                Console.WriteLine($"Warehouse sync started at {syncStartTime.ToLongTimeString()}");
                WarehouseRepository warehouseRepository = new WarehouseRepository();
                CloudRepository     cloudRepository     = new CloudRepository();
                DataTable           dtEntity            = cloudRepository.GetEntityData(BranchID, "ToCloud");
                foreach (DataRow entityRow in dtEntity.Rows)
                {
                    string entityName = entityRow["ENTITYNAME"].ToString();
                    //LoggerUtility.Logger.Info($"{entityName} up sync started");
                    //Console.WriteLine($"{entityName} up sync started");
                    DataTable dtEntityWiseData = warehouseRepository.GetEntityWiseData(entityName, entityRow["SYNCDATE"]);
                    //LoggerUtility.Logger.Info($"Found {dtEntityWiseData.Rows.Count} records to up sync in entity : {entityName} ");
                    Console.WriteLine($"Found {dtEntityWiseData.Rows.Count} records to up sync in entity : {entityName} ");
                    cloudRepository.SaveData(entityName, dtEntityWiseData);
                    cloudRepository.UpdateEntitySyncStatus(entityRow["ENTITYSYNCSTATUSID"], syncStartTime);
                    //LoggerUtility.Logger.Info($"{entityName} up sync completed");
                    //Console.WriteLine($"{entityName} up sync completed");
                }

                // start down sync from cloud
                dtEntity = cloudRepository.GetEntityData(BranchID, "FromCloud");
                foreach (DataRow entityRow in dtEntity.Rows)
                {
                    string entityName = entityRow["ENTITYNAME"].ToString();
                    //LoggerUtility.Logger.Info($"{entityName} down sync started");
                    //Console.WriteLine($"{entityName} down sync started");
                    DataTable dtEntityWiseData = cloudRepository.GetEntityWiseData(entityName, entityRow["SYNCDATE"]);
                    //LoggerUtility.Logger.Info($"Found {dtEntityWiseData.Rows.Count} records to down sync in entity : {entityName} ");
                    Console.WriteLine($"Found {dtEntityWiseData.Rows.Count} records to down sync in entity : {entityName} ");
                    warehouseRepository.SaveData(entityName, dtEntityWiseData);
                    cloudRepository.UpdateEntitySyncStatus(entityRow["ENTITYSYNCSTATUSID"], syncStartTime);
                    //LoggerUtility.Logger.Info($"{entityName} down sync completed");
                    //Console.WriteLine($"{entityName} down sync completed");
                }

                //LoggerUtility.Logger.Info($"Warehouse sync completed");
                Console.WriteLine($"Warehouse sync completed");
            }
            catch (Exception ex)
            {
                Console.WriteLine(ex.Message);
                Console.WriteLine(ex.StackTrace);
                Console.ReadLine();
            }
            Thread.Sleep(5 * 60 * 1000);
            StartSync();
        }
        /// <summary>
        /// Calculate new line item quantity from inventory/in-store inventory
        /// </summary>
        /// <param name="lineItem">line item</param>
        /// <param name="changeQtyReason">messages explain to clients why item's quantity is changed</param>
        /// <param name="shipment">shipment</param>
        /// <returns>new line item quantity</returns>
        protected decimal GetNewLineItemQty(LineItem lineItem, List <string> changeQtyReason, Shipment shipment)
        {
            var newLineItemQty = shipment != null?Shipment.GetLineItemQuantity(shipment, lineItem.LineItemId) : lineItem.Quantity;

            if (newLineItemQty < lineItem.MinQuantity)
            {
                newLineItemQty = lineItem.MinQuantity;
                changeQtyReason.Add("by Min Quantity setting");
            }
            else if (newLineItemQty > lineItem.MaxQuantity)
            {
                newLineItemQty = lineItem.MaxQuantity;
                changeQtyReason.Add("by Max Quantity setting");
            }

            var entryRow = GetEntryRowForLineItem(lineItem);

            if (!InventoryTrackingEnabled(entryRow))
            {
                return(newLineItemQty);
            }

            var warehouseCode = shipment != null && !string.IsNullOrEmpty(shipment.WarehouseCode) ? shipment.WarehouseCode : lineItem.WarehouseCode;

            if (shipment == null && string.IsNullOrEmpty(warehouseCode))
            {
                var w = WarehouseRepository.List().FirstOrDefault(x => x.IsFulfillmentCenter && x.IsActive);
                warehouseCode = w.Code;
            }

            IWarehouse warehouse = WarehouseRepository.Get(warehouseCode);

            if (warehouse == null || !warehouse.IsActive)
            {
                changeQtyReason.Add("by inactive warehouse");
                return(0);
            }

            var inventoryRecord = InventoryService.Get(lineItem.Code, warehouseCode);

            if (inventoryRecord == null)
            {
                changeQtyReason.Add("by inactive warehouse");
                return(0);
            }

            // In case inventory status is Disable, always using newLineItemQty.
            if (!inventoryRecord.IsTracked)
            {
                return(newLineItemQty);
            }

            return(GetNewLineItemQtyFromInventory(inventoryRecord, changeQtyReason, lineItem, newLineItemQty));
        }
 public WarehouseService(WarehouseRepository warehouseRepo, EmployeeItemRepository employeeItemRepo)
 {
     _warehouseRepo = warehouseRepo;
     _employeeItemRepo = employeeItemRepo;
 }