public Storage LockStorage(Storage storage, Product product) { var cell = storage.Cell; if (Lock(cell)) { if (string.IsNullOrEmpty(storage.LockTag) && storage.ProductCode == product.ProductCode) { try { storage.LockTag = this.LockKey; StorageRepository.SaveChanges(); } catch (Exception) { if (storage != null) { StorageRepository.Detach(storage); } storage = null; } } else { storage = null; } } else { storage = null; } UnLock(cell); return(storage); }
public bool CreateNewTaskForEmptyPalletSupply(int positionID) { string palletCode = ""; var storageQuery = StorageRepository.GetQueryable() .Where(i => i.ProductCode == palletCode && i.Quantity - i.OutFrozenQuantity > 0) .OrderBy(i => i.StorageTime); var storage = storageQuery.FirstOrDefault(); var position = PositionRepository.GetQueryable() .Where(i => i.ID == positionID).FirstOrDefault(); var positionCell = CellPositionRepository.GetQueryable() .Where(i => i.StockInPositionID == positionID).FirstOrDefault(); if (storage != null && position != null && positionCell != null) { var cellPosition = CellPositionRepository.GetQueryable() .Where(cp => cp.CellCode == storage.CellCode).FirstOrDefault(); if (cellPosition != null) { var path = PathRepository.GetQueryable() .Where(p => p.OriginRegion == cellPosition.StockOutPosition.Region && p.TargetRegion == position.Region) .FirstOrDefault(); if (path != null) { var quantity = storage.Quantity - storage.OutFrozenQuantity; storage.OutFrozenQuantity += quantity; var newTask = new Task(); newTask.TaskType = "01"; newTask.TaskLevel = 0; newTask.PathID = path.ID; newTask.ProductCode = palletCode; newTask.ProductName = "空托盘"; newTask.OriginStorageCode = storage.CellCode; newTask.TargetStorageCode = positionCell.CellCode; newTask.OriginPositionID = cellPosition.StockOutPositionID; newTask.TargetPositionID = positionID; newTask.CurrentPositionID = cellPosition.StockOutPositionID; newTask.CurrentPositionState = "02"; newTask.State = "01"; newTask.TagState = "01";//拟不使用 newTask.Quantity = Convert.ToInt32(storage.Quantity); newTask.TaskQuantity = Convert.ToInt32(quantity); newTask.OperateQuantity = 0; //newTask.OrderID = inItem.BillNo; //newTask.OrderType = "01"; //newTask.AllotID = inItem.ID; newTask.DownloadState = "1"; TaskRepository.Add(newTask); TaskRepository.SaveChanges(); return(true); } } } return(false); }
public UnitOfWork(DataContext dataContext) { _dataContext = dataContext; CaseRepository = new CaseRepository(_dataContext); ChipsetRepository = new ChipsetRepository(_dataContext); CoreSeriesRepository = new CoreSeriesRepository(_dataContext); CoreSpeedRepository = new CoreSpeedRepository(_dataContext); CPURepository = new CPURepository(_dataContext); CPUCoolerRepository = new CPUCoolerRepository(_dataContext); EfficiencyRatingRepository = new EfficiencyRatingRepository(_dataContext); FormFactorRepository = new FormFactorRepository(_dataContext); InterfaceRepository = new InterfaceRepository(_dataContext); ManufacturerRepository = new ManufacturerRepository(_dataContext); MemorySpeedRepository = new MemorySpeedRepository(_dataContext); MemoryTypeRepository = new MemoryTypeRepository(_dataContext); ModuleRepository = new ModuleRepository(_dataContext); MotherboardRepository = new MotherboardRepository(_dataContext); NumbersRepository = new NumbersRepository(_dataContext); PowerSupplyRepository = new PowerSupplyRepository(_dataContext); ProtocolRepository = new ProtocolRepository(_dataContext); RAMRepository = new RAMRepository(_dataContext); SocketRepository = new SocketRepository(_dataContext); StorageRepository = new StorageRepository(_dataContext); StorageTypeRepository = new StorageTypeRepository(_dataContext); VideoCardRepository = new VideoCardRepository(_dataContext); WirelessAdapterRepository = new WirelessAdapterRepository(_dataContext); }
public async Task <IHttpActionResult> GetPhotoModel(string id) { var cache = RedisCache.Connection.GetDatabase(); var repo = new RedisRepository(cache); //Get a single item from the cache based on its ID var photo = await repo.GetPhotoByIDAsync(id); if (null == photo) { //Not in the cache. Retrieve from storage. string connectionString = SettingsHelper.LocalStorageConnectionString; string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; var storageRepo = new StorageRepository(connectionString); photo = await storageRepo.GetPhotoFromTableAsync(DAL.Azure.StorageConfig.PhotosBlobContainerName, owner, id); if (null == photo) { //Not found in cache or storage. } else { //Update the cache using the cache aside pattern. await repo.AddPhotoToUserCacheAsync(photo); } } if (null != photo) { return(Ok(photo)); } else { return(NotFound()); } }
public Storage LockNoEmpty(Cell cell, Product product) { Storage storage = null; if (Lock(cell)) { try { storage = cell.Storages.Where(s => s.ProductCode == product.ProductCode && s.Quantity - s.OutFrozenQuantity > 0) .FirstOrDefault(); if (storage != null) { storage.LockTag = this.LockKey; StorageRepository.SaveChanges(); } } catch (Exception) { if (storage != null) { StorageRepository.Detach(storage); } storage = null; } } UnLock(cell); return(storage); }
/// <summary> /// Constructor /// </summary> /// <param name="storage"></param> public TableRef(StorageController storage) { _storage = storage; _repository = storage.Repository; ItemMeta = _repository.GetMetadata <T>(); TableName = ItemMeta.Table; _channel += ItemMeta.Table; _notifications = new Dictionary <StorageEventType, Dictionary <StorageNotificationType, List <Action <ItemSnapshot> > > >(); var putEvents = new Dictionary <StorageNotificationType, List <Action <ItemSnapshot> > >(); putEvents.Add(StorageNotificationType.ON, new List <Action <ItemSnapshot> >()); putEvents.Add(StorageNotificationType.ONCE, new List <Action <ItemSnapshot> >()); putEvents.Add(StorageNotificationType.DELETE, new List <Action <ItemSnapshot> >()); _notifications.Add(StorageEventType.PUT, putEvents); var updateEvents = new Dictionary <StorageNotificationType, List <Action <ItemSnapshot> > > { { StorageNotificationType.ON, new List <Action <ItemSnapshot> >() }, { StorageNotificationType.ONCE, new List <Action <ItemSnapshot> >() }, { StorageNotificationType.DELETE, new List <Action <ItemSnapshot> >() } }; _notifications.Add(StorageEventType.UPDATE, new Dictionary <StorageNotificationType, List <Action <ItemSnapshot> > >(updateEvents)); var deleteEvents = new Dictionary <StorageNotificationType, List <Action <ItemSnapshot> > > { { StorageNotificationType.ON, new List <Action <ItemSnapshot> >() }, { StorageNotificationType.ONCE, new List <Action <ItemSnapshot> >() }, { StorageNotificationType.DELETE, new List <Action <ItemSnapshot> >() } }; _notifications.Add(StorageEventType.DELETE, new Dictionary <StorageNotificationType, List <Action <ItemSnapshot> > >(deleteEvents)); }
/// <summary> /// 根据参数查询要生成的盘点数据 --产品查询预览 /// </summary> /// <param name="page"></param> /// <param name="rows"></param> /// <param name="products">卷烟信息集合</param> /// <returns></returns> public object GetProductDetails(int page, int rows, string products) { IQueryable <Storage> storageQuery = StorageRepository.GetQueryable(); if (products != string.Empty && products != null) { products = products.Substring(0, products.Length - 1); var storages = storageQuery.Where(s => s.ProductCode != null && products.Contains(s.ProductCode) && s.Quantity > 0 && s.IsLock == "0") .OrderBy(s => s.StorageCode) .Select(s => s); int total = storages.Count(); storages = storages.Skip((page - 1) * rows).Take(rows); var temp = storages.ToArray().Select(s => new { s.StorageCode, s.Cell.CellCode, s.Cell.CellName, s.Product.ProductCode, s.Product.ProductName, s.Product.Unit.UnitCode, s.Product.Unit.UnitName, Quantity = s.Quantity / s.Product.Unit.Count, IsActive = s.IsActive == "1" ? "可用" : "不可用", StorageTime = s.StorageTime.ToString("yyyy-MM-dd"), UpdateTime = s.UpdateTime.ToString("yyyy-MM-dd") }); return(new { total, rows = temp.ToArray() }); } return(null); }
internal static async Task ReplicateBlobAsync(PhotoModel model, TextWriter log) { //The source connection string needs to be in AppSettings using the //storage account name. var sourceConnectionString = ConfigurationManager.AppSettings[model.StorageAccountName]; //The target connection string is the local region's storage account var targetConnectionString = SettingsHelper.LocalStorageConnectionString; //Copy from the upload container to the photos container, // potentially across storage accounts await log.WriteLineAsync("sourceConnectionString: " + sourceConnectionString); await log.WriteLineAsync("targetConnectionString: " + targetConnectionString); var storageRepo = new StorageRepository(sourceConnectionString); var container = await storageRepo.ReplicateBlobAsync( targetConnectionString, StorageConfig.UserUploadBlobContainerName, StorageConfig.PhotosBlobContainerName, model.ServerFileName, log); //Monitor the copy operation and wait for it to finish //before proceeding await storageRepo.MonitorCopy(container, model.ServerFileName, log); }
public async Task <IHttpActionResult> Get() { var cache = RedisCache.Connection.GetDatabase(); var repo = new RedisRepository(cache); string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; var items = await repo.GetPhotosForUserAsync(owner); //Do this so we can get the count List <IPhotoModel> typedItems = new List <IPhotoModel>(items); if (typedItems.Count == 0) { //Nothing in cache... head off to storage. var storageRepo = new StorageRepository(SettingsHelper.LocalStorageConnectionString); var photos = await storageRepo.GetPhotosFromTableAsync(DAL.Azure.StorageConfig.TableName, owner); foreach (var photo in photos) { //TODO: Find a MUCH better algorithm than // iterating every item and calling // Redis 3 times in a row for each // item. This is PAINFUL. await repo.AddPhotoToCachesAsync(photo); } items = photos; } return(Ok(items)); }
public void GetAllTest() { //Arrange using (var context = new AppDbContext(options)) { var storages = new List <Storage> { new Storage { Id = 1 } }; var repo = new StorageRepository(context); //Act foreach (var storage in storages) { context.Add(storage); } context.SaveChanges(); var expectedResult = repo.GetAll(); var actualResult = storages; //Assert Assert.AreEqual(expectedResult, actualResult); } }
public bool CheckIsNeedSyncMoveBill(string warehouseCode) { IQueryable <Storage> storageQuery = StorageRepository.GetQueryable(); var storages = storageQuery.Where(s => s.Cell.WarehouseCode == warehouseCode && s.Cell.IsActive == "1" && s.Quantity - s.OutFrozenQuantity > 0 && s.OutFrozenQuantity > 0); //1:主库区 1;2:件烟区 2; //3;条烟区 3;4:暂存区 4; //5:备货区 0;6:残烟区 0; //7:罚烟区 0;8:虚拟区 0; //9:其他区 0; //主库区未满盘件烟移到件烟区 string[] areaTypes = new string[] { "1" }; var ss = storages.Where(s => areaTypes.Any(a => a == s.Cell.Area.AreaType) && ((s.Quantity - s.OutFrozenQuantity) / s.Product.Unit.Count) > 1); if (ss.Count() > 0 && storageQuery.Where(s => s.Cell.Area.AreaType == "2").Count() > 0) { return(true); } ////主库区件烟库区条烟移到条烟区 //areaTypes = new string[] { "1", "2" }; //ss = storages.Where(s => areaTypes.Any(a => a == s.Cell.Area.AreaType) // && (s.Quantity - s.OutFrozenQuantity) % s.Product.Unit.Count > 0); //if (ss.Count() > 0 && storageQuery.Where(s => s.Cell.Area.AreaType == "3").Count() > 0) { return true; } return(false); }
public async Task Consume(ConsumeContext <IOrder> context) { var order = context.Message; if (order.StatusKey != EventConstants.EVENT_STATUS_KEY_STORAGE) { // 如果不是StorageService要处理的Event则忽略该消息 return; } var result = StorageRepository.CreateStorage(order).GetAwaiter().GetResult(); if (result) { IOrderEventEntity orderEventEntity = new OrderEventEntity { OrderID = order.ID, EventType = EventConstants.EVENT_TYPE_CREATE_ORDER, StatusKey = EventConstants.EVENT_STATUS_KEY_STORAGE, StatusValue = EventStatusEnum.HANDLED }; await EventBus.Publish(orderEventEntity); } }
/// <summary> /// Notify the backend that a new file was uploaded /// by sending a queue message. /// </summary> /// <param name="value">The name of the blob to be processed</param> /// <returns>Void</returns> public async Task Post(CompleteRequest item) { string owner = ClaimsPrincipal.Current.FindFirst(ClaimTypes.NameIdentifier).Value; //Get the owner name field string ownerName = ClaimsPrincipal.Current.FindFirst("name").Value; //Replace any commas with periods ownerName = ownerName.Replace(',', '.'); string message = string.Format( "{0},{1},{2},{3}, {4}, {5}, {6}", item.ID, item.ServerFileName, item.StorageAccountName, owner, ownerName, item.BlobURL, SettingsHelper.CurrentRegion); //Send a queue message to the local storage account //The local web job will pick it up and broadcast to //all storage accounts in appSettings prefixed with "Storage" var repo = new StorageRepository(SettingsHelper.LocalStorageConnectionString); await repo.SendBroadcastQueueMessageAsync(message); }
public void Remove() { if (SelectedServer == null) { return; } Log.Info($"Try remove server: {SelectedServer}"); var result = StorageRepository.GetServersList().Delete(SelectedServer.Id); Log.Info($"RemoveResult: {result}"); if (!result) { //TODO: Add string MessageBoxViewModel.ShowDialog("RemoveErrorContent", manager); } var ind = ServerIndex -= 1; //if (App.Instance.KeblerControl.SelectedServer.Id == SelectedServer.Id) //{ // App.Instance.KeblerControl.Disconnect(); //} _eventAggregator.PublishOnUIThreadAsync(new Messages.ServersUpdated()); SelectedServer = null; GetServers(); ServerIndex = ind; }
public void GetAll_ReturnStorageCollection() { // arrange var logger = Substitute.For <ILogger <StorageRepository> >(); var repository = new StorageRepository(logger); var storageCollection = new List <Storage>() { new Storage() { Id = "testId1", Materials = new List <Material>() { new Material() { Id = "materialId1", Name = "materialName1", Quantity = 12 } } } }; repository.AddCollection(storageCollection); // act var actual = repository.GetAll(); // assert Assert.IsNotNull(actual); Assert.IsInstanceOfType(actual, typeof(List <Storage>)); Assert.AreEqual(storageCollection.Count, actual.Count); }
public void AddCollection_CorrectPayload_AddItemCollectionToStorage() { // arrange var logger = Substitute.For <ILogger <StorageRepository> >(); var repository = new StorageRepository(logger); var storageCollection = new List <Storage>() { new Storage() { Id = "testId1", Materials = new List <Material>() { new Material() { Id = "materialId1", Name = "materialName1", Quantity = 12 } } } }; // act var actual = repository.AddCollection(storageCollection); // assert Assert.AreEqual(storageCollection.Count, actual); }
Task <TableMetadata> WaitForTable(StorageRepository store, string tableName, int timeout = 2500) { Terminal.Log("Waiting..."); return(Task.Run(() => { for (int i = 0; i < 300; i++) { var result2 = store.GetTable(tableName); result2.Wait(); Assert.IsFalse(result2.IsFaulted, "request failed"); var rdy = result2.Result.data.status == TableMetadata.Status.ACTIVE; if (rdy) { return result2.Result.data; } Task.Delay(timeout); Terminal.Log("."); } Assert.Fail("Table Timeout"); return null; })); }
/// <summary> /// 产品盘点显示卷烟信息,入库新增显示卷烟数据 /// </summary> /// <returns></returns> public object checkFindProduct(string QueryString, string value) { IQueryable <Product> ProductQuery = ProductRepository.GetQueryable(); IQueryable <Storage> StorageQuery = StorageRepository.GetQueryable(); string ProductName = ""; string ProductCode = ""; if (QueryString == "ProductCode") { ProductCode = value; } else { ProductName = value; } var storage = StorageQuery.Join(ProductQuery, s => s.ProductCode, p => p.ProductCode, (s, p) => new { p.ProductCode, p.ProductName, s.Quantity, s.Product, p.Unit, p.BuyPrice } ).GroupBy(s => new { s.ProductCode, s.ProductName, s.Unit, s.BuyPrice }) .Select(s => new { ProductCode = s.Key.ProductCode, ProductName = s.Key.ProductName, UnitCode = s.Key.Unit.UnitCode, UnitName = s.Key.Unit.UnitName, BuyPrice = s.Key.BuyPrice, Quantity = s.Sum(st => (st.Quantity / st.Product.Unit.Count)) }).Where(p => p.ProductCode.Contains(ProductCode) && p.ProductName.Contains(ProductName)); // var product = ProductQuery.OrderBy(p => p.ProductCode).Where(p => p.Storages.Any(s => s.ProductCode == p.ProductCode)); return(storage.ToArray()); }
public async Task <IHttpActionResult> Get() { var cache = RedisCache.Connection.GetDatabase(); var repo = new RedisRepository(cache); var items = await repo.GetAllPhotosAsync(); List <IPhotoModel> typedItems = new List <IPhotoModel>(items); if (typedItems.Count == 0) { //Pull from storage. This is a cross-partition query, // and will be slower than using Redis. var storageConnectionString = SettingsHelper.LocalStorageConnectionString; var storageRepo = new StorageRepository(storageConnectionString); typedItems = await storageRepo.GetLatestFromTableStorageAsync(); if (typedItems.Count > 0) { foreach (var item in typedItems) { //Add to cache as cache-aside pattern await repo.AddPhotoToAllUsersCacheAsync(item); } items = typedItems; } } return(Ok(items)); }
public bool uploadBusiStorage() { try { IQueryable <Storage> storageQuery = StorageRepository.GetQueryable(); var storage = storageQuery.GroupBy(s => s.ProductCode).Select(s => new { productCode = s.Max(t => t.ProductCode), warehouseCode = s.Max(t => t.Cell.WarehouseCode), quantity = s.Sum(t => t.Quantity) / (s.Max(t => t.Product.UnitList.Quantity02) * s.Max(t => t.Product.UnitList.Quantity03)) }); DataSet ds = this.GenerateEmptyTable(); DataRow inbrddr = ds.Tables["wms_busistorage"].NewRow(); foreach (var p in storage) { inbrddr["ORG_CODE"] = p.warehouseCode; inbrddr["BRAND_CODE"] = p.productCode; inbrddr["DIST_CTR_CODE"] = p.warehouseCode; inbrddr["QUANTITY"] = p.quantity; ds.Tables["wms_busistorage"].Rows.Add(inbrddr); } upload.QueryBusiStock(ds); return(true); } catch { return(false); } }
public object GetCellDetails(string type, string id) { try { IQueryable <Cell> cellQuery = CellRepository.GetQueryable(); IQueryable <Storage> storageQuery = StorageRepository.GetQueryable(); var storages = storageQuery; var cells = cellQuery.Where(s => s.MaxPalletQuantity == 0); if (type == "ware") { cells = cellQuery.Where(c => c.Shelf.Area.Warehouse.WarehouseCode == id && c.MaxPalletQuantity == 0); } else if (type == "area") { cells = cellQuery.Where(c => c.Shelf.Area.AreaCode == id && c.MaxPalletQuantity == 0); } else if (type == "shelf") { cells = cellQuery.Where(c => c.Shelf.ShelfCode == id && c.MaxPalletQuantity == 0); } else if (type == "cell") { cells = cellQuery.Where(c => c.CellCode == id && c.MaxPalletQuantity == 0); } var sCells = cells.Join(storages, c => c.CellCode, s => s.CellCode, (c, s) => new { cells = c, storages = s }).ToArray(); if (sCells.Count() > 0) { var Cell = sCells.Select(c => new { cellCode = c.cells.CellCode, cellName = c.cells.CellName, productCode = string.IsNullOrEmpty(c.storages.ProductCode) == true ? "" : c.storages.ProductCode, productName = c.storages.Product == null ? "" : c.storages.Product.ProductName, shelfCode = c.cells.ShelfCode, unitCode = c.storages.Product == null ? "" : c.storages.Product.Unit.UnitCode, unitName = c.storages.Product == null ? "" : c.storages.Product.Unit.UnitName, maxQuantity = c.cells.MaxQuantity, asdd1 = c.cells.CellCode.Substring(4, 2), //区 asdd2 = c.cells.CellCode.Substring(8, 2), //货架 asdd3 = c.cells.CellCode.Substring(14, 1), //层 asdd4 = c.cells.CellCode.Substring(11, 2), //列 Quantity = c.storages.Product == null ? 0 : c.storages.Quantity / c.storages.Product.Unit.Count, EmptyQuantity = c.storages.Product == null ? c.cells.MaxQuantity : c.cells.MaxQuantity - c.storages.Quantity / c.storages.Product.Unit.Count, IsActive = c.cells.IsActive == "1" ? "可用" : "不可用", UpdateTime = c.storages.UpdateTime.ToString("yyyy-MM-dd") }).OrderByDescending(c => c.asdd4).OrderByDescending(c => c.asdd3).OrderByDescending(c => c.asdd2).OrderByDescending(c => c.asdd1); return(Cell.ToArray()); } else { var s = "".ToArray(); return(s); } } catch (Exception ex) { throw ex; } }
internal static async Task CreateThumbnailAsync(StorageRepository repo, string fileName, TextWriter log) { using (var memStream = await repo.GetBlob(StorageConfig.PhotosBlobContainerName, fileName)) { MemoryStream thumbnail = null; try { thumbnail = PhotoEditor.ProcessImage(memStream); await repo.UploadBlobAsync(thumbnail, StorageConfig.ThumbnailsBlobContainerName, fileName); } catch (Exception oops) { await log.WriteAsync(oops.Message); throw oops; } finally { if (null != thumbnail) { thumbnail.Dispose(); } } } }
public ExternalLoadController( StorageNameRepository storageNameRepository, CriteriaRepository <Nomenclature> nomenclatureRepository, CriteriaRepository <Worker> workerRepository, CriteriaRepository <WorkerWorkplace> workerWorkplaceRepository, StorageRepository storageRepository, CriteriaRepository <Operation> operationRepository, CriteriaRepository <OperType> operTypeRepository, CriteriaRepository <WorkerCardHead> workerCardHeadRepository, CriteriaRepository <WorkerCardContent> workerCardContentRepository, CriteriaRepository <Organization> organizationRepository, CriteriaRepository <Motiv> motivRepository, RemainRepository remaindRepository ) { Check.Require(workerRepository != null, "workerRepository may not be null"); this.storageNameRepository = storageNameRepository; this.nomenclatureRepository = nomenclatureRepository; this.workerRepository = workerRepository; this.workerWorkplaceRepository = workerWorkplaceRepository; this.storageRepository = storageRepository; this.operationRepository = operationRepository; this.operTypeRepository = operTypeRepository; this.workerCardHeadRepository = workerCardHeadRepository; this.workerCardContentRepository = workerCardContentRepository; this.organizationRepository = organizationRepository; this.motivRepository = motivRepository; this.remaindRepository = remaindRepository; }
private void CreateDynamicCanvas() { Rectangle = new ObservableCollection <Rectangles>(); Rectangle = DinamiclyDrawingRepository.GetInstance().GetAllRectangles(); Storage = StorageRepository.GetInstance().GetAllStorage(); RoomsInfo = new ObservableCollection <PatientsRoomVieW>(PatientsRoomConverter.ConvertRoomToPatientsRoomView( Backend.App.Instance().RoomService.GetAllEntitiesByType(3).ToList())); WorkTime = new ObservableCollection <RoomWorkTime>(WorkTimeRoomConverter.ConvertRoomToRoomWorkTime( Backend.App.Instance().RoomService.GetAllEntitiesByType(4).ToList())); foreach (Rectangles r in Rectangle) { Rectangle rect = new Rectangle() { Fill = r.Paint, Height = r.Height, Width = r.Width, Name = r.Id }; TextBlock txtb = new TextBlock() { Width = r.WidthText, Height = r.HeightText, Text = r.Text, Background = r.Background }; canvas.Children.Add(txtb); foreach (PatientsRoomVieW room in RoomsInfo) { if (r.Id.Equals(room.IdOfRoom)) { rect.MouseDown += RoomInformation; } } foreach (StorageModel s in Storage) { if (r.Id.Equals(s.IdS)) { rect.MouseDown += StorageInfo; } } foreach (RoomWorkTime s in WorkTime) { if (r.Id.Equals(s.IdOfRoom)) { rect.MouseDown += WorkTimeInfo; } } Canvas.SetLeft(txtb, r.LeftText); Canvas.SetTop(txtb, r.TopText); Canvas.SetLeft(rect, r.Left); Canvas.SetTop(rect, r.Top); canvas.Children.Add(rect); } }
public System.Data.DataTable GetProductTimeOut(int page, int rows, string productCode, decimal assemblyTime) { System.Data.DataTable dt = new System.Data.DataTable(); IQueryable <Storage> StorageQuery = StorageRepository.GetQueryable(); IQueryable <ProductWarning> ProductWarningQuery = ProductWarningRepository.GetQueryable(); var ProductWarning = ProductWarningQuery.Where(p => p.ProductCode.Contains(productCode)); var storage = StorageQuery.Where(s => s.ProductCode.Contains(productCode)); var Storages = storage.Join(ProductWarning, s => s.ProductCode, p => p.ProductCode, (s, p) => new { storage = s, ProductWarning = p }).ToArray(); Storages = Storages.Where(s => !string.IsNullOrEmpty(s.ProductWarning.AssemblyTime.ToString())).ToArray(); if (Storages.Count() > 0) { if (productCode != "") { Storages = Storages.Where(s => s.storage.ProductCode == productCode).ToArray(); } if (assemblyTime != 360) { Storages = Storages.Where(s => s.ProductWarning.AssemblyTime >= assemblyTime).ToArray(); } else { Storages = Storages.Where(s => s.ProductWarning.AssemblyTime <= (DateTime.Now - s.storage.StorageTime).Days).ToArray(); } } var ProductTimeOut = Storages.AsEnumerable() .Select(s => new { ProductCode = s.storage.ProductCode, ProductName = s.storage.Product.ProductName, cellCode = s.storage.CellCode, cellName = s.storage.Cell.CellName, quantity = s.storage.Quantity / s.storage.Product.Unit.Count, storageTime = s.storage.StorageTime.ToString("yyyy-MM-dd hh:mm:ss"), days = (DateTime.Now - s.storage.StorageTime).Days }); dt.Columns.Add("商品代码", typeof(string)); dt.Columns.Add("商品名称", typeof(string)); dt.Columns.Add("货位编码", typeof(string)); dt.Columns.Add("货位名称", typeof(string)); dt.Columns.Add("数量(件)", typeof(string)); dt.Columns.Add("入库时间", typeof(string)); dt.Columns.Add("积压时间(天)", typeof(string)); foreach (var p in ProductTimeOut) { dt.Rows.Add ( p.ProductCode, p.ProductName, p.cellCode, p.cellName, p.quantity, p.storageTime, p.days ); } return(dt); }
public WebhookTests(ITestOutputHelper output, ApplicationBaseFixture app) { _output = output; _app = app; _access = _app.ServiceProvider.GetService <TenantAccess>(); _accountingApi = new AccountingApi(); _storageRepository = _app.ServiceProvider.GetService <StorageRepository>(); }
public void GetStorage() { IRepositoryContext uow = new EntityFrameworkRepositoryContext(); var repo = new StorageRepository(uow); var result = repo.GetAll(); Assert.IsTrue(result.Count() == 0); }
internal static async Task SaveToTableStorageAsync(PhotoModel p, TextWriter log) { var storageConnectionString = SettingsHelper.LocalStorageConnectionString; var repo = new StorageRepository(storageConnectionString); var result = await repo.SaveToTableStorageAsync(DAL.Azure.StorageConfig.TableName, p); await log.WriteLineAsync("Save to table HTTP result: " + result); }
public Storage LockPiece(Cell cell, Product product) { Storage storage = null; if (Lock(cell)) { try { if (cell.Storages.Count == 1) { storage = cell.Storages.Where(s => (s.ProductCode == product.ProductCode && (s.Cell.MaxQuantity * product.Unit.Count - s.Quantity - s.InFrozenQuantity + s.OutFrozenQuantity) > 0) || string.IsNullOrEmpty(s.ProductCode) || (s.Quantity == 0 && s.InFrozenQuantity == 0)) .FirstOrDefault(); if (storage != null) { if (string.IsNullOrEmpty(storage.LockTag)) { storage.LockTag = this.LockKey; } else { storage = null; } } } else if (cell.Storages.Count == 0) { storage = new Storage() { Cell = cell, StorageCode = Guid.NewGuid().ToString(), CellCode = cell.CellCode, IsLock = "0", LockTag = this.LockKey, IsActive = "0", StorageTime = DateTime.Now, UpdateTime = DateTime.Now }; cell.Storages.Add(storage); } StorageRepository.SaveChanges(); } catch (Exception) { if (storage != null) { StorageRepository.Detach(storage); } storage = null; } } UnLock(cell); return(storage); }
public bool Save(OutBillDetail outBillDetail, out string errorInfo) { bool result = false; errorInfo = string.Empty; var outbm = OutBillDetailRepository.GetQueryable().FirstOrDefault(i => i.BillNo == outBillDetail.BillNo && i.ProductCode == outBillDetail.ProductCode); var unit = UnitRepository.GetQueryable().FirstOrDefault(u => u.UnitCode == outBillDetail.UnitCode); var storage = StorageRepository.GetQueryable().Where(s => s.ProductCode == outBillDetail.ProductCode);// var storageQuantity = storage.Sum(s => (s.Quantity - s.OutFrozenQuantity)); if ((outbm != null && outbm.ID == outBillDetail.ID) || outbm == null) { if (outbm == null) { outbm = OutBillDetailRepository.GetQueryable().FirstOrDefault(i => i.BillNo == outBillDetail.BillNo && i.ID == outBillDetail.ID); } if (storageQuantity >= (outBillDetail.BillQuantity * unit.Count)) { outbm.BillNo = outBillDetail.BillNo; outbm.ProductCode = outBillDetail.ProductCode; outbm.UnitCode = outBillDetail.UnitCode; outbm.Price = outBillDetail.Price; outbm.BillQuantity = outBillDetail.BillQuantity * unit.Count; outbm.AllotQuantity = 0; outbm.RealQuantity = 0; outbm.Description = outBillDetail.Description; OutBillDetailRepository.SaveChanges(); result = true; } else { errorInfo = "当前库存小于您输入的数量!请从新输入!"; } } else if (outbm != null && outbm.ID != outBillDetail.ID) { string err = string.Empty; if (storageQuantity >= outbm.BillQuantity + (outBillDetail.BillQuantity * unit.Count)) { bool deltrue = this.Delete(outBillDetail.ID.ToString(), out err); outbm.BillNo = outBillDetail.BillNo; outbm.ProductCode = outBillDetail.ProductCode; outbm.UnitCode = outBillDetail.UnitCode; outbm.Price = outBillDetail.Price; outbm.BillQuantity = outbm.BillQuantity + (outBillDetail.BillQuantity * unit.Count); outbm.Description = outBillDetail.Description; OutBillDetailRepository.SaveChanges(); result = true; } else { errorInfo = "当前库存小于您输入的数量!请从新输入!"; } } return(result); }
protected void Awake() { Terminal.LogInput("RealtimeStorageTest"); //debug option Task.DisableMultiThread = SingleThreaded; Task.LogErrors = true; Repository = new StorageRepository(); LoadCommands(); }
public void GetStorage() { IRepositoryContext uow = new EntityFrameworkRepositoryContext(); var repo = new StorageRepository(uow); var result = repo.GetAll(); Assert.IsTrue(result.Count() == 0); }
Task<TableMetadata> WaitForTable(StorageRepository store, string tableName, int timeout = 2500) { Terminal.Log("Waiting..."); return Task.Run(() => { for (int i = 0;i < 300;i++) { var result2 = store.GetTable(tableName); result2.Wait(); Assert.IsFalse(result2.IsFaulted, "request failed"); var rdy = result2.Result.data.status == TableMetadata.Status.ACTIVE; if (rdy) { return result2.Result.data; } Task.Delay(timeout); Terminal.Log("."); } Assert.Fail("Table Timeout"); return null; }); }