Esempio n. 1
0
        public void updateAllIdentifiedItemsToVirtualBox(int failedItemPK)
        {
            try
            {
                FailedItem            failedItem      = db.FailedItems.Find(failedItemPK);
                ClassifiedItem        classifiedItem  = db.ClassifiedItems.Find(failedItem.ClassifiedItemPK);
                PackedItem            packedItem      = db.PackedItems.Find(classifiedItem.PackedItemPK);
                List <IdentifiedItem> identifiedItems = (from iI in db.IdentifiedItems
                                                         where iI.PackedItemPK == packedItem.PackedItemPK
                                                         select iI).ToList();
                UnstoredBox virtualBox = (from uB in db.UnstoredBoxes
                                          where uB.BoxPK == (from b in db.Boxes
                                                             where b.BoxID == "InvisibleBox"
                                                             select b).FirstOrDefault().BoxPK
                                          select uB).FirstOrDefault();

                foreach (var item in identifiedItems)
                {
                    item.UnstoredBoxPK   = virtualBox.UnstoredBoxPK;
                    db.Entry(item).State = EntityState.Modified;
                }
                db.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
        public bool isNotStoredOrReturned(int classifiedItemPK)
        {
            ClassifiedItem classifiedItem = db.ClassifiedItems.Find(classifiedItemPK);

            if (classifiedItem.QualityState == 2)
            {
                PassedItem passedItem = (from pI in db.PassedItems
                                         where pI.ClassifiedItemPK == classifiedItemPK
                                         select pI).FirstOrDefault();
                if (passedItem.IsStored)
                {
                    return(false);
                }
            }
            else if (classifiedItem.QualityState == 3)
            {
                FailedItem failedItem = (from fI in db.FailedItems
                                         where fI.ClassifiedItemPK == classifiedItemPK
                                         select fI).FirstOrDefault();
                if (failedItem.IsReturned)
                {
                    return(false);
                }
            }
            return(true);
        }
        public void deleteItemByQualityState(int classifiedItemPK, int qualityState)
        {
            try
            {
                switch (qualityState)
                {
                case 2:
                    PassedItem passedItem = (from pI in db.PassedItems
                                             where pI.ClassifiedItemPK == classifiedItemPK
                                             select pI).FirstOrDefault();
                    db.PassedItems.Remove(passedItem);
                    break;

                case 3:
                    FailedItem failedItem = (from fI in db.FailedItems
                                             where fI.ClassifiedItemPK == classifiedItemPK
                                             select fI).FirstOrDefault();
                    db.FailedItems.Remove(failedItem);
                    break;

                default:
                    break;
                }
                db.SaveChanges();
            }
            catch (Exception e)
            {
                throw e;
            }
        }
Esempio n. 4
0
 public void updateFailedItemIsReturned(int failedItemPK)
 {
     try
     {
         FailedItem failedItem = db.FailedItems.Find(failedItemPK);
         failedItem.IsReturned      = true;
         db.Entry(failedItem).State = EntityState.Modified;
         db.SaveChanges();
     }
     catch (Exception e)
     {
         throw e;
     }
 }
Esempio n. 5
0
        private string LogFailedItem(List <FailedItem> failedItems, string errorMessage)
        {
            if (IsNullOrEmpty(errorMessage))
            {
                return(errorMessage);
            }

            var productId = GetProductFromMaterialErrorMessage(errorMessage);

            if (productId == Empty)
            {
                Log(
                    $"{ErrorMessages.ERRORS_CONTAINED_IN_RESPONSE} - Unable to get product from error return object");
            }

            Log($"{ErrorMessages.ERRORS_CONTAINED_IN_RESPONSE} for product {productId}");

            var failedItem = new FailedItem {
                ErrorMessage = errorMessage, ProductId = productId
            };

            failedItems.Add(failedItem);
            return(productId);
        }
 internal void AddFailedItem(FailedItem item)
 {
     myFailedItems.Add(item);
 }
 public Client_FailedItem(Accessory accessory, Pack pack, ClassifyingSession classifyingSession, FailedItem failedItem, double sumIdentifiedQuantity)
 {
     FailedItemPK         = failedItem.FailedItemPK;
     ExecutedDate         = classifyingSession.ExecutedDate;
     AccessoryID          = accessory.AccessoryID;
     AccessoryDescription = accessory.AccessoryDescription;
     Art    = accessory.Art;
     Color  = accessory.Color;
     Item   = accessory.Item;
     PackID = pack.PackID;
     SumIdentifiedQuantity = sumIdentifiedQuantity;
 }
Esempio n. 8
0
        public List <Client_Session_Activity_Angular> GetSessions(int sessionNum)
        {
            List <Client_Session_Activity_Angular> result = new List <Client_Session_Activity_Angular>();

            switch (sessionNum)
            {
            case 1:
                List <IdentifyingSession> identifyingSessions = (from ss in db.IdentifyingSessions
                                                                 select ss).ToList();
                foreach (var ss in identifyingSessions)
                {
                    SystemUser systemUser = db.SystemUsers.Find(ss.UserID);
                    // query pack
                    IdentifiedItem identifiedItem = (from iI in db.IdentifiedItems
                                                     where iI.IdentifyingSessionPK == ss.IdentifyingSessionPK
                                                     select iI).FirstOrDefault();
                    PackedItem packedItem = db.PackedItems.Find(identifiedItem.PackedItemPK);
                    Pack       pack       = db.Packs.Find(packedItem.PackPK);
                    string     content    = "Ghi nhận " + "cụm phụ liệu thuộc Phiếu nhập mã số " + pack.PackID;
                    result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content));
                }
                break;

            case 2:
                List <CountingSession> countingSessions = (from ss in db.CountingSessions
                                                           select ss).ToList();
                foreach (var ss in countingSessions)
                {
                    SystemUser systemUser = db.SystemUsers.Find(ss.UserID);
                    // query pack
                    IdentifiedItem identifiedItem = db.IdentifiedItems.Find(ss.IdentifiedItemPK);
                    PackedItem     packedItem     = db.PackedItems.Find(identifiedItem.PackedItemPK);
                    Pack           pack           = db.Packs.Find(packedItem.PackPK);
                    string         content        = "Kiểm số lượng " + "cụm phụ liệu thuộc Phiếu nhập mã số " + pack.PackID;
                    result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content));
                }
                break;

            case 3:
                List <CheckingSession> checkingSessions = (from ss in db.CheckingSessions
                                                           select ss).ToList();
                foreach (var ss in checkingSessions)
                {
                    SystemUser     systemUser     = db.SystemUsers.Find(ss.UserID);
                    IdentifiedItem identifiedItem = db.IdentifiedItems.Find(ss.IdentifiedItemPK);
                    PackedItem     packedItem     = db.PackedItems.Find(identifiedItem.PackedItemPK);
                    Pack           pack           = db.Packs.Find(packedItem.PackPK);
                    string         content        = "Kiểm chất lượng " + "cụm phụ liệu thuộc Phiếu nhập mã số " + pack.PackID;
                    result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content));
                }
                break;

            case 4:
                List <ClassifyingSession> classifyingSessions = (from ss in db.ClassifyingSessions
                                                                 select ss).ToList();
                foreach (var ss in classifyingSessions)
                {
                    SystemUser     systemUser     = db.SystemUsers.Find(ss.UserID);
                    ClassifiedItem classifiedItem = db.ClassifiedItems.Find(ss.ClassifiedItemPK);
                    PackedItem     packedItem     = db.PackedItems.Find(classifiedItem.PackedItemPK);
                    Pack           pack           = db.Packs.Find(packedItem.PackPK);
                    string         content        = "Đánh giá " + "phụ liệu thuộc Phiếu nhập mã số " + pack.PackID;
                    result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content));
                }
                break;

            case 5:
                List <ArrangingSession> arrangingSessions = (from ss in db.ArrangingSessions
                                                             select ss).ToList();
                foreach (var ss in arrangingSessions)
                {
                    SystemUser  systemUser = db.SystemUsers.Find(ss.UserID);
                    UnstoredBox uBox1      = db.UnstoredBoxes.Find(ss.StartBoxPK);
                    Box         box1       = db.Boxes.Find(uBox1.BoxPK);
                    UnstoredBox uBox2      = db.UnstoredBoxes.Find(ss.DestinationBoxPK);
                    Box         box2       = db.Boxes.Find(uBox2.BoxPK);
                    string      content    = "Sắp xếp " + "cụm phụ liệu từ thùng mã số " + box1.BoxID.Substring(0, box1.BoxID.Length - 3) + "sang thùng mã số " + box2.BoxID.Substring(0, box2.BoxID.Length - 3);
                    result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content));
                }
                break;

            case 6:
                List <ReturningSession> returningSessions = (from ss in db.ReturningSessions
                                                             select ss).ToList();
                foreach (var ss in returningSessions)
                {
                    SystemUser     systemUser     = db.SystemUsers.Find(ss.UserID);
                    FailedItem     failedItem     = db.FailedItems.Find(ss.FailedItemPK);
                    ClassifiedItem classifiedItem = db.ClassifiedItems.Find(failedItem.ClassifiedItemPK);
                    PackedItem     packedItem     = db.PackedItems.Find(classifiedItem.PackedItemPK);
                    Pack           pack           = db.Packs.Find(packedItem.PackPK);
                    string         content        = "Trả hàng lỗi " + "thuộc Phiếu nhập mã số " + pack.PackID;
                    result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content));
                }
                break;

            case 7:
                List <StoringSession> storingSessions = (from ss in db.StoringSessions
                                                         select ss).ToList();
                foreach (var ss in storingSessions)
                {
                    SystemUser systemUser = db.SystemUsers.Find(ss.UserID);
                    Box        box        = db.Boxes.Find(ss.BoxPK);
                    string     content    = "Lưu kho " + "thùng mã số " + box.BoxID.Substring(0, box.BoxID.Length - 3);
                    result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content));
                }
                break;

            case 8:
                List <MovingSession> movingSessions = (from ss in db.MovingSessions
                                                       select ss).ToList();
                foreach (var ss in movingSessions)
                {
                    SystemUser systemUser = db.SystemUsers.Find(ss.UserID);
                    StoredBox  sBox       = db.StoredBoxes.Find(ss.StoredBoxPK);
                    Box        box        = db.Boxes.Find(sBox.BoxPK);
                    Shelf      shelf1     = db.Shelves.Find(ss.StartShelfPK);
                    Shelf      shelf2     = db.Shelves.Find(ss.DestinationShelfPK);
                    string     content    = "Di chuyển thùng " + "mã số " + box.BoxID.Substring(0, box.BoxID.Length - 3)
                                            + "từ kệ " + shelf1.ShelfID + "sang kệ " + shelf2.ShelfID;
                    result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content));
                }
                break;

            case 9:
                List <TransferringSession> tranferringSessions = (from ss in db.TransferringSessions
                                                                  select ss).ToList();
                foreach (var ss in tranferringSessions)
                {
                    SystemUser systemUser = db.SystemUsers.Find(ss.UserID);
                    StoredBox  sBox1      = db.StoredBoxes.Find(ss.StartBoxPK);
                    Box        box1       = db.Boxes.Find(sBox1.BoxPK);

                    StoredBox sBox2 = db.StoredBoxes.Find(ss.StartBoxPK);
                    Box       box2  = db.Boxes.Find(sBox2.BoxPK);

                    string content = "Chuyển phụ liệu " + "tồn kho từ thùng mã số " + box1.BoxID.Substring(0, box1.BoxID.Length - 3)
                                     + "sang thùng mã số " + box2.BoxID.Substring(0, box2.BoxID.Length - 3);
                    result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content));
                }
                break;

            case 10:
                List <IssuingSession> issuingSessions = (from ss in db.IssuingSessions
                                                         select ss).ToList();
                foreach (var ss in issuingSessions)
                {
                    SystemUser systemUser = db.SystemUsers.Find(ss.UserID);
                    Request    request    = db.Requests.Find(ss.RequestPK);
                    string     content    = "Xuất kho " + "phụ liệu cho Yêu cầu nhận mã số " + request.RequestID;
                    result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content));
                }
                break;

            case 11:
                List <ReceivingSession> restoringSessions = (from ss in db.ReceivingSessions
                                                             select ss).ToList();
                foreach (var ss in restoringSessions)
                {
                    SystemUser  systemUser  = db.SystemUsers.Find(ss.UserID);
                    Restoration restoration = db.Restorations.Find(ss.RestorationPK);
                    string      content     = "Nhận tồn " + "phụ liệu thuộc Phiếu trả mã số " + restoration.RestorationID;
                    result.Add(new Client_Session_Activity_Angular(ss.ExecutedDate, systemUser.Name + " (" + ss.UserID + ")", content));
                }
                break;

            default:
                break;
            }

            return(result);
        }
Esempio n. 9
0
 public Client_FailedItemDetail(Accessory accessory, Pack pack, ClassifyingSession classifyingSession, IdentifiedItem identifiedItem, FailedItem failedItem, SystemUser systemUser, PackedItem packedItem, double sample, double defectLimit, double sumIdentifiedQuantity, double sumCountedQuantity, double sumCheckedQuantity, double sumUnqualifiedQuantity, HashSet<string> boxIDs)
 {
     FailedItemPK = failedItem.FailedItemPK;
     ExecutedDate = classifyingSession.ExecutedDate;
     Comment = classifyingSession.Comment;
     UserID = systemUser.UserID;
     Name = systemUser.Name;
     AccessoryID = accessory.AccessoryID;
     AccessoryDescription = accessory.AccessoryDescription;
     Art = accessory.Art;
     Color = accessory.Color;
     Item = accessory.Item;
     PackID = pack.PackID;
     PackedQuantity = packedItem.PackedQuantity;
     Sample = sample;
     DefectLimit = defectLimit;
     SumIdentifiedQuantity = sumIdentifiedQuantity;
     SumCountedQuantity = sumCountedQuantity;
     SumCheckedQuantity = sumCheckedQuantity;
     SumUnqualifiedQuantity = sumUnqualifiedQuantity;
     BoxIDs = boxIDs;
 }
Esempio n. 10
0
        public SimulateOrderResponse SimulateOrder(SimulateOrderRequest simulateOrderRequest)
        {
            var endPoint = _soapStoreFrontWebService.ToString();
            var request  = simulateOrderRequest.ToWmSimulateOrderRequest();
            var backup   = new BackupLogEntry(request, nameof(SimulateOrder));

            LogRequest(request, nameof(SimulateOrder));
            var wmSimulateOrderResponse = _soapStoreFrontWebService.SimulateOrderWebServiceAsync(request).Result;
            var orderResponseError      = "We were not able to obtain response items for all requested products.  Please see list of failed inventory items.";

            backup.AddResponse(wmSimulateOrderResponse);
            _repository.InsertOne(backup);
            LogResponse(wmSimulateOrderResponse);
            var failedItems = new List <FailedItem>();

            while (ContainsSAPError(wmSimulateOrderResponse))
            {
                var    errorMessage = wmSimulateOrderResponse.ErrorResponse.ErrorResponse1.Body[0].Error;
                string productId    = LogFailedItem(failedItems, errorMessage);

                //if we have an error condition but no failed products, we have an order order level issue, we can return
                if (productId == Empty)
                {
                    failedItems.Clear();
                    var failedItem = new FailedItem {
                        ErrorMessage = errorMessage, ProductId = "Order Level Exception, not applicable"
                    };
                    failedItems.Add(failedItem);
                    var orderLevelFailureResponse = new SimulateOrderResponse
                    {
                        FailedItems  = failedItems,
                        ErrorMessage = "We were not able to obtain response items for all requested products.Please see list of failed inventory items."
                    };
                    return(orderLevelFailureResponse);
                }

                var newItemsList = request.OrderRequest.OrderRequest.Body[0].OrderRequestDetail.Where(val => val.ProductID != productId).ToArray();
                request.OrderRequest.OrderRequest.Body[0].OrderRequestDetail = newItemsList;

                //We had an error condition for a single product .. we need to collect that error and return
                if (newItemsList.Length == 0)
                {
                    var orderLevelFailureResponse = new SimulateOrderResponse
                    {
                        FailedItems  = failedItems,
                        ErrorMessage = orderResponseError
                    };
                    return(orderLevelFailureResponse);
                }
                var backup2 = new BackupLogEntry(request, "Addtional SimulateOrder (to handle failed products");
                LogRequest(request, "Additional SimulateOrder (to handle failed products");
                wmSimulateOrderResponse = _soapStoreFrontWebService.SimulateOrderWebServiceAsync(request).Result;
                backup2.AddResponse(wmSimulateOrderResponse);
                _repository.InsertOne(backup2);
                LogResponse(wmSimulateOrderResponse);
            }

            var simulateOrderResponse = wmSimulateOrderResponse.ToSimulateOrderResponse();

            if (failedItems.Count == 0)
            {
                return(simulateOrderResponse);
            }
            simulateOrderResponse.FailedItems  = failedItems;
            simulateOrderResponse.ErrorMessage = orderResponseError;
            return(simulateOrderResponse);
        }