Пример #1
0
        public object ExitScan(List <int> FulOrderIdList, int PalletId)
        {
            try
            {
                List <FulOrder> FulOrderList = new List <FulOrder>();

                FulOrderList = (from fo in context.FulOrder
                                where FulOrderIdList.Contains(fo.FulOrderId) && fo.PalletId == PalletId
                                select fo).ToList();
                if (FulOrderList.Count == 0)
                {
                    return new { status = false, message = _iconfiguration["NO_FO_ON_PALLET"] }
                }
                ;
                /* Considerting all the FO are in Palletized status and updateing all at a time */
                FulOrderStatus FulOrderStatusObj = (from fos in context.FulOrderStatus
                                                    where fos.Name.ToUpper() == _iconfiguration["EXITSCAN"]
                                                    select fos).FirstOrDefault();
                Pallet PalletObj = (from p in context.Pallet
                                    where p.PalletId == PalletId
                                    select p).FirstOrDefault();
                if (PalletObj == null)
                {
                    return new { status = false, message = _iconfiguration["PALLETID_NOTFOUND"] }
                }
                ;
                PalletStatus palletStatusObj = (from ps in context.PalletStatus
                                                where ps.Name.ToUpper() == _iconfiguration["CLOSED"]
                                                select ps).FirstOrDefault();
                foreach (FulOrder FulOrderObj in FulOrderList)
                {
                    FulOrderObj.FulOrderStatusId = FulOrderStatusObj.FulOrderStatusId;
                }
                PalletObj.PalletStatusId = palletStatusObj.PalletStatusId;
                context.Pallet.Update(PalletObj);
                context.FulOrder.UpdateRange(FulOrderList);
                context.SaveChanges();
                return(new { status = true, message = _iconfiguration["EXISSCAN_SUCCESS"] });
            }
            catch (Exception Ex)
            {
                LogServiceObj.LogException(Ex);
                MailServiceObj.SendMail(Ex.Message ?? "", (Ex.InnerException != null) ? Ex.InnerException.Message : "", Ex.StackTrace ?? "");
                return(new { status = false, message = _iconfiguration["ERROR_EXITSCAN"] });
            }
        }
Пример #2
0
        public object CreatePackage(int fulOrderId)
        {
            try
            {
                UpdateTrackingDTO response    = new UpdateTrackingDTO();
                FulOrder          FulOrderObj = (from fo in context.FulOrder
                                                 join fos in context.FulOrderStatus on fo.FulOrderStatusId equals fos.FulOrderStatusId
                                                 where fo.FulOrderId == fulOrderId &&
                                                 fos.Name.ToUpper() == _iconfiguration["LABELCREATED"]
                                                 select fo).FirstOrDefault();
                if (FulOrderObj == null)
                {
                    return new
                           {
                               status  = false,
                               message = _iconfiguration["FULORDER_NOT_LABELED"]
                           }
                }
                ;
                FulOrderStatus FulOrderStatus = (from fos in context.FulOrderStatus
                                                 where fos.Name.ToUpper() == _iconfiguration["PACKAGED"]
                                                 select fos).FirstOrDefault();

                Product productObj = (from fi in context.FulItem
                                      join p in context.Product on fi.ProductId equals p.ProductId
                                      where fi.FulOrderId == fulOrderId
                                      select p).FirstOrDefault();
                ProductSKU productSKU = (from p in context.Product
                                         join ps in context.ProductSKU on p.ProductId equals ps.ProductId
                                         join pt in context.ProductSKUType on ps.SKUTypeId equals pt.ProductSKUTypeId
                                         where p.ProductId == productObj.ProductId && pt.Name.ToUpper() == _iconfiguration["SKU"]
                                         select ps).FirstOrDefault();
                Shipment shipmentObj = (from s in context.Shipment
                                        where s.FulOrderId == fulOrderId
                                        select s).FirstOrDefault();

                FulOrderObj.FulOrderStatusId = FulOrderStatus.FulOrderStatusId;
                context.FulOrder.Update(FulOrderObj);
                context.SaveChanges();

                if (productObj != null && productSKU != null && shipmentObj != null)
                {
                    response.fulOrderId = fulOrderId;

                    response.fulOrderStatus = FulOrderStatus.Name;
                    response.productName    = productObj.Name;
                    response.sku            = productSKU.SKU;
                    response.trackingNumber = shipmentObj.TrackingNumber.ToString();
                }
                else if (productObj == null)
                {
                    return(new { status = false, message = _iconfiguration["PRODUCTNOTFOUND"] });
                }
                else if (productSKU == null)
                {
                    return(new { status = false, message = _iconfiguration["PRODUCTSKUNOTFOUND"] });
                }
                else if (shipmentObj == null)
                {
                    return(new { status = false, message = _iconfiguration["SHIPMENTNOTFOUND"] });
                }
                return(new { status = true, message = string.Format(_iconfiguration["PACKAGE_SUCCESS"], fulOrderId.ToString()), data = response });
            }
            catch (Exception Ex)
            {
                LogServiceObj.LogException(Ex);
                MailServiceObj.SendMail(Ex.Message ?? "", (Ex.InnerException != null) ? Ex.InnerException.Message : "", Ex.StackTrace ?? "");
                return(new { status = false, message = _iconfiguration["ERROR_PACKAGE"] });
            }
        }
Пример #3
0
        public Object PalletizeFulOrder(string trackingNumber, int palletId)
        {
            try
            {
                Guid TrackingNumber;
                if (!Guid.TryParse(trackingNumber, out TrackingNumber))
                {
                    return(new { status = false, message = _iconfiguration["INVALID_TRACKINGFORMAT"] });
                }
                /*get FulOrder information based on given tracking number and palletId*/
                Shipment shipmentObj = new Shipment();
                shipmentObj = (from s in context.Shipment
                               where s.TrackingNumber == TrackingNumber
                               select s).FirstOrDefault();
                if (shipmentObj == null)
                {
                    return(new { status = false, message = _iconfiguration["TRACKINGNO_NOTFOUND"] });
                }

                Pallet PalletObj = (from p in context.Pallet
                                    where p.PalletId == palletId
                                    select p).FirstOrDefault();
                if (PalletObj == null)
                {
                    return new { status = false, message = _iconfiguration["PALLETID_NOTFOUND"] }
                }
                ;

                int?CarrierServiceTypeId = (from cs in context.CarrierService
                                            where cs.CarrierServiceId == shipmentObj.CarrierServiceId && cs.CarrierId == shipmentObj.CarrierId
                                            select cs.CarrierServiceTypeId).FirstOrDefault();

                if (PalletObj.CarrierId != shipmentObj.CarrierId || PalletObj.CarrierServiceTypeId != CarrierServiceTypeId)
                {
                    return new { status = false, message = _iconfiguration["PALLET_SHIPMENT_CARRIER_NOT_MATCH"] }
                }
                ;

                if (shipmentObj.CarrierId == PalletObj.CarrierId && CarrierServiceTypeId != null && CarrierServiceTypeId == PalletObj.CarrierServiceTypeId)
                {
                    FulOrder FulOrderObj = new FulOrder();

                    FulOrderObj = (from fo in context.FulOrder
                                   join fos in context.FulOrderStatus on fo.FulOrderStatusId equals fos.FulOrderStatusId
                                   where fo.FulOrderId == shipmentObj.FulOrderId && fos.Name == _iconfiguration["PACKAGED"]
                                   select fo).FirstOrDefault();

                    if (FulOrderObj == null)
                    {
                        return new { status = false, message = _iconfiguration["FULORDER_NOT_IN_PACKAGE"] }
                    }
                    ;

                    FulOrderStatus FulOrderStatusObj = (from fos in context.FulOrderStatus
                                                        where fos.Name.ToUpper() == _iconfiguration["PALLETIZED"]
                                                        select fos).FirstOrDefault();
                    FulOrderObj.FulOrderStatusId = FulOrderStatusObj.FulOrderStatusId;
                    FulOrderObj.PalletId         = palletId;
                    context.FulOrder.Update(FulOrderObj);
                    context.SaveChanges();

                    Product ProductObj = new Product();
                    ProductObj = (from fi in context.FulItem
                                  join p in context.Product on fi.ProductId equals p.ProductId
                                  select p).FirstOrDefault();
                    ProductSKU productSKUObj = (from ps in context.ProductSKU
                                                where ps.ProductId == ProductObj.ProductId
                                                select ps).FirstOrDefault();

                    UpdateTrackingDTO response = new UpdateTrackingDTO();
                    response.fulOrderId     = FulOrderObj.FulOrderId;
                    response.fulOrderStatus = FulOrderStatusObj.Name;
                    response.productName    = ProductObj.Name;
                    response.sku            = productSKUObj.SKU;
                    response.trackingNumber = shipmentObj.TrackingNumber.ToString();
                    return(new { status = true, data = response, message = string.Format(_iconfiguration["PALLETIZED_SUCCESS"], FulOrderObj.FulOrderId.ToString()) });
                }
                return(new { status = false, message = _iconfiguration["ERROR_NOFULORDERPACKAGEFOUND"] });
            }
            catch (Exception Ex)
            {
                LogServiceObj.LogException(Ex);
                MailServiceObj.SendMail(Ex.Message ?? "", (Ex.InnerException != null) ? Ex.InnerException.Message : "", Ex.StackTrace ?? "");
                return(new
                {
                    status = false,
                    message = _iconfiguration["ERROR_CREATEPALLET"]
                });
            }
        }
Пример #4
0
        public object GenerateLabel(string UPC)
        {
            try
            {
                Product ProductObj = (from p in context.Product
                                      join ps in context.ProductSKU on p.ProductId equals ps.ProductId
                                      join pt in context.ProductSKUType on ps.SKUTypeId equals pt.ProductSKUTypeId
                                      where pt.Name.ToUpper() == _iconfiguration["SKU"] &&
                                      p.UPC == UPC
                                      select p).FirstOrDefault();
                Guid?RandomTrackingNumberStr = Guid.Empty;

                if (ProductObj != null)
                {
                    bool   GenerateShipment = false;
                    string ProductSKU       = (from psku in context.ProductSKU
                                               join pskutype in context.ProductSKUType on psku.SKUTypeId equals pskutype.ProductSKUTypeId
                                               where psku.ProductId == ProductObj.ProductId && pskutype.Name.ToUpper() == _iconfiguration["SKU"]
                                               select psku.SKU).FirstOrDefault();
                    FulOrder fulOrderObj = (from fi in context.FulItem
                                            join fo in context.FulOrder on fi.FulOrderId equals fo.FulOrderId
                                            join fs in context.FulOrderStatus on fo.FulOrderStatusId equals fs.FulOrderStatusId
                                            where fs.Name.ToUpper() == _iconfiguration["LABELCREATED"] &&
                                            (fo.OnHold_FLG ?? false) == false &&
                                            fi.ProductId == ProductObj.ProductId
                                            select fo).OrderBy(fo => fo.OrderId).FirstOrDefault();

                    if (fulOrderObj != null)
                    {
                        GenerateShipment        = true;
                        RandomTrackingNumberStr = (from s in context.Shipment where s.FulOrderId == fulOrderObj.FulOrderId select s.TrackingNumber).FirstOrDefault();
                    }
                    else
                    {
                        fulOrderObj = (from fi in context.FulItem
                                       join fo in context.FulOrder on fi.FulOrderId equals fo.FulOrderId
                                       join fs in context.FulOrderStatus on fo.FulOrderStatusId equals fs.FulOrderStatusId
                                       where fs.Name.ToUpper() == _iconfiguration["PICKING"] &&
                                       (fo.OnHold_FLG ?? false) == false &&
                                       (fo.Error_FLG ?? false) == false &&
                                       fi.ProductId == ProductObj.ProductId
                                       select fo).OrderBy(fo => fo.OrderId).FirstOrDefault();
                    }
                    if (fulOrderObj == null)
                    {
                        return new { status = false, message = _iconfiguration["UPC_PICKED_NOTFOUND"] }
                    }
                    ;

                    FulOrderStatus fulOrderStatusObj = (from fs in context.FulOrderStatus where fs.Name.ToUpper() == _iconfiguration["LABELCREATED"] select fs).FirstOrDefault();
                    Box            BoxObj            = (from b in context.Box
                                                        where b.BoxId == ProductObj.BoxId
                                                        select b).FirstOrDefault();
                    if (!GenerateShipment && fulOrderObj != null && ProductObj != null)
                    {
                        fulOrderObj.FulOrderStatusId = fulOrderStatusObj.FulOrderStatusId;

                        RandomTrackingNumberStr = Guid.NewGuid();
                        /* Insertion of Shipment record */
                        Shipment ShipmentObj = new Shipment();
                        ShipmentObj.CarrierId        = fulOrderObj.AssignedCarrierId ?? 0;
                        ShipmentObj.CarrierServiceId = fulOrderObj.AssignedCarrierServiceId ?? 0;
                        ShipmentObj.FulOrderId       = fulOrderObj.FulOrderId;
                        ShipmentObj.Height           = (BoxObj != null) ? BoxObj.Height : 0;
                        ShipmentObj.Length           = (BoxObj != null) ? BoxObj.Length : 0;
                        ShipmentObj.StatusUpdatedDT  = DateTime.Now;
                        ShipmentObj.Width            = (BoxObj != null) ? BoxObj.Width : 0;
                        ShipmentObj.Weight           = ProductObj.Weight;
                        ShipmentObj.TrackingNumber   = RandomTrackingNumberStr;
                        ShipmentObj.ShippingLabel    = null;
                        ShipmentObj.ShipmentStatusId = (from ss in context.ShipmentStatus
                                                        where ss.Name.ToUpper() == _iconfiguration["ACTIVE"]
                                                        select ss.ShipmentStatusId).FirstOrDefault();
                        context.Shipment.Add(ShipmentObj);
                        context.FulOrder.Update(fulOrderObj);
                        context.SaveChanges();
                    }
                    UpdateTrackingDTO TrackingDTOObj = new UpdateTrackingDTO();
                    TrackingDTOObj.fulOrderId     = fulOrderObj.FulOrderId;
                    TrackingDTOObj.productName    = ProductObj.Name;
                    TrackingDTOObj.fulOrderStatus = fulOrderStatusObj.Name;
                    TrackingDTOObj.sku            = ProductSKU;
                    TrackingDTOObj.trackingNumber = (RandomTrackingNumberStr != null) ? RandomTrackingNumberStr.ToString() : "";
                    return(new { status = true, data = TrackingDTOObj });
                }
                else
                {
                    return(new { status = false, message = _iconfiguration["UPC_NOT_FOUND"] });
                }
            }
            catch (Exception Ex)
            {
                LogServiceObj.LogException(Ex);
                MailServiceObj.SendMail(Ex.Message ?? "", (Ex.InnerException != null) ? Ex.InnerException.Message : "", Ex.StackTrace ?? "");
                return(new { status = false, message = _iconfiguration["UNHANDLEDEXCEPTION"] });
            }
        }