public void LockBatch(IUnitOfWork db, long batchId, DateTime?when) { _log.Info("Lock batch, batchId=" + batchId); var orderIds = db.OrderBatches.GetOrderIdsForBatch( batchId, OrderStatusEnumEx.AllUnshippedWithShipped); var shippingList = db.OrderShippingInfos .GetOrderInfoWithItems(_weightService, orderIds.ToList(), SortMode.ByLocation, unmaskReferenceStyle: false, includeSourceItems: false) .ToList(); shippingList = SortHelper.Sort(shippingList, SortMode.ByShippingMethodThenLocation).ToList(); for (int i = 0; i < shippingList.Count; i++) { var mapping = new OrderToBatch() { BatchId = batchId, ShippingInfoId = shippingList[i].Id, SortIndex1 = ShippingUtils.GetShippingMethodIndex(shippingList[i].ShippingMethodId), SortIndex2 = LocationHelper.GetLocationIndex(shippingList[i].SortIsle, shippingList[i].SortSection, shippingList[i].SortShelf), SortIndex3 = SortHelper.GetStringIndex(shippingList[i].SortStyleString), SortIndex4 = (decimal)SizeHelper.GetSizeIndex(shippingList[i].SortSize), SortIndex5 = SortHelper.GetStringIndex(shippingList[i].SortColor), //SortIndex6 = SortHelper.GetStringIndex(shippingList[i].FirstItemName), CreateDate = when, }; db.OrderToBatches.Add(mapping); } db.Commit(); db.OrderBatches.LockBatch(batchId, when); }