コード例 #1
0
        /// <summary>
        /// Places the passed box on the passed pallet.
        /// </summary>
        /// <param name="palletId">The pallet to place the box on. If null, a new pallet id is created.</param>
        /// <param name="ucc128Id">The box to place on the pallet.</param>
        /// <param name="isVasUi"> </param>
        /// <returns>The pallet on which the box was placed. Useful when a new pallet id is created.</returns>
        /// <remarks>
        /// Decrements the cached qualifying box count by 1 for the criteria of the passed box
        /// </remarks>
        public string PutBoxOnPallet(string palletId, string ucc128Id, bool isVasUi)
        {
            if (string.IsNullOrWhiteSpace(ucc128Id))
            {
                throw new ArgumentNullException("ucc128Id");
            }
            if (string.IsNullOrWhiteSpace(palletId))
            {
                palletId = _repos.GetTemporaryPalletId();
            }
            _repos.PutBoxOnPallet(ucc128Id, palletId, palletId.StartsWith("T"), isVasUi);

            // Sharad 6 Jul 2012. The pallet boxes cache is now stale. Requery it
            _palletBoxes = _repos.GetBoxes(palletId, null);
            var box = _palletBoxes.FirstOrDefault();

            if (box == null)
            {
                // Should not happen
                return(palletId);
            }
            int oldCount;

            if (isVasUi)
            {
                if (CachedQualifyingBoxesForVas.TryGetValue(box.CustomerId, out oldCount) && oldCount > 0)
                {
                    // Now there is one less qualifying box for VAS
                    CachedQualifyingBoxesForVas[box.CustomerId] = oldCount - 1;
                }
            }
            else
            {
                var criteria = GetSortCriteria(box.CustomerId, false);
                var qual     = new QualificationCriteria
                {
                    BucketId     = criteria.HasFlag(SortCriteria.AllowBucketMixing) ? null : box.BucketId,
                    CustomerDcId = criteria.HasFlag(SortCriteria.AllowCustomerDcMixing) ? null : box.CustomerDcId,
                    CustomerId   = box.CustomerId,
                    PoId         = criteria.HasFlag(SortCriteria.AllowPoMixing) ? null : box.PoId
                };
                if (CachedQualifyingBoxes.TryGetValue(qual, out oldCount) && oldCount > 0)//MBisht (6 July 2012): If the count is already 0 then no need to further decrementing the count as it will become negative.
                {
                    // Now there is one less qualifying box for STP
                    CachedQualifyingBoxes[qual] = oldCount - 1;
                }
            }
            return(palletId);
        }
コード例 #2
0
        /// <summary>
        /// Returns the number of under process unpalletized boxes for the passed criteria
        /// </summary>
        /// <param name="customerId"></param>
        /// <param name="poId"></param>
        /// <param name="customerDcId"></param>
        /// <param name="bucketId"></param>
        /// <returns></returns>
        /// <remarks>
        /// This count is cached per criteria for performance reasons.
        /// </remarks>
        public int GetQualifyingBoxCount(string customerId, string poId, string customerDcId, int?bucketId)
        {
            int count;
            var qual = new QualificationCriteria
            {
                CustomerId   = customerId,
                PoId         = poId,
                CustomerDcId = customerDcId,
                BucketId     = bucketId
            };
            var b = CachedQualifyingBoxes.TryGetValue(qual, out count);

            if (b)
            {
                return(count);
            }
            count = _repos.GetQualifyingBoxCount(customerId, poId, customerDcId, bucketId, false, false);
            CachedQualifyingBoxes.TryAdd(qual, count);
            return(count);
        }