/// <summary>
 /// Fully populates the warehouse code
 /// </summary>
 /// <param name="nonWorkingDay">The warehousecode.</param>
 /// <param name="dataReader">The data reader.</param>
 /// <param name="fullyPopulate">if set to <c>true</c> [fullyPopulate].</param>
 private static void FullyPopulate(NonWorkingDay nonWorkingDay, IDataReader dataReader, bool fullyPopulate)
 {
     if (fullyPopulate && nonWorkingDay != null)
     {
         Warehouse warehouse = WarehouseController.GetWarehouse(nonWorkingDay.WarehouseId);
         nonWorkingDay.WarehouseCode = warehouse.Code;
     }
 }
Ejemplo n.º 2
0
 public static void CustomFill(Route item, IDataReader dataReader, bool fullyPopulate)
 {
     if (item != null)
     {
         if (fullyPopulate)
         {
             item.Warehouse = WarehouseController.GetWarehouse((int)dataReader["WarehouseId"], fullyPopulate);
         }
     }
 }
Ejemplo n.º 3
0
        /// <summary>
        /// Gets the print jobs.
        /// </summary>
        /// <param name="warehouseId">The warehouse to get a list of print jobs for.</param>
        /// <param name="sortExpression">The sort expression.</param>
        /// <returns></returns>
        public static List <PrintJob> GetPrintJobs(int warehouseId, string sortExpression)
        {
            List <PrintJob> printJobs = new List <PrintJob>();
            Warehouse       warehouse =
                WarehouseController.GetWarehouse(warehouseId, false);

            if (warehouse != null)
            {
                printJobs = GetPrintJobs(warehouse.PrinterName, sortExpression);
            }
            return(printJobs);
        }
Ejemplo n.º 4
0
 /// <summary>
 /// Fully populates the Trunker day
 /// </summary>
 /// <param name="trunkerDay">The trunker day.</param>
 /// <param name="dataReader">The data reader.</param>
 /// <param name="fullyPopulate">if set to <c>true</c> [fullyPopulate].</param>
 private static void FullyPopulate(TrunkerDay trunkerDay, IDataReader dataReader, bool fullyPopulate)
 {
     if (fullyPopulate && trunkerDay != null)
     {
         if (allWarehouses != null && allWarehouses.Count > 0)
         {
             trunkerDay.SourceWarehouse      = allWarehouses.Find(delegate(Warehouse obj) { return(obj.Id == trunkerDay.SourceWarehouseId); });
             trunkerDay.DestinationWarehouse = allWarehouses.Find(delegate(Warehouse obj) { return(obj.Id == trunkerDay.DestinationWarehouseId); });
         }
         else
         {
             trunkerDay.SourceWarehouse      = WarehouseController.GetWarehouse(trunkerDay.SourceWarehouseId);
             trunkerDay.DestinationWarehouse = WarehouseController.GetWarehouse(trunkerDay.DestinationWarehouseId);
         }
     }
 }
Ejemplo n.º 5
0
        /// <summary>
        /// Gets the trunker days.
        /// </summary>
        /// <param name="fullyPopulate">if set to <c>true</c> [fullyPopulate].</param>
        /// <returns></returns>
        public static List <TrunkerDay> GetTrunkerDays(bool fullyPopulate)
        {
            List <TrunkerDay> trunkerDays = new List <TrunkerDay>();

            try
            {
                allWarehouses = WarehouseController.GetWarehouses();
                trunkerDays   = CBO <TrunkerDay> .FillCollection(DataAccessProvider.Instance().GetTrunkerDays(), FullyPopulate, fullyPopulate);

                allWarehouses = null;
            }
            catch (Exception ex)
            {
                if (ExceptionPolicy.HandleException(ex, "Business Logic"))
                {
                    throw;
                }
            }
            return(trunkerDays);
        }
Ejemplo n.º 6
0
        /// <summary>
        /// Saves the shipmentDrop.
        /// </summary>
        /// <param name="shipmentDrop">The shipmentDrop.</param>
        /// <param name="depotCode">The depot code.</param>
        /// <returns></returns>
        public static Int32 SaveDrop(ShipmentDrop shipmentDrop, string depotCode)
        {
            if (shipmentDrop.TripId == Null.NullInteger)
            {
                //get warehouse id which will be used to find the trip id
                int       warehouseId;
                Warehouse relatedWarehouse = WarehouseController.GetWarehouse(depotCode);
                if (relatedWarehouse == null)
                {
                    throw new Exception(
                              string.Format("When importing ShipmentDrop data the related warehouse could not be found. The Warehouse number was '{0}'.",
                                            depotCode));
                }
                warehouseId = relatedWarehouse.Id;
                shipmentDrop.OriginalDepotId = warehouseId;

                //get and set the related trip id
                Trip relatedTrip = TripController.GetTripByWarehouseDateAndNumber(shipmentDrop.TripNumber, shipmentDrop.DeliveryDate, warehouseId);
                if (relatedTrip == null)
                {
                    //the trip file hasn't bee recieved yet so add a record to relate to for now
                    relatedTrip             = new Trip();
                    relatedTrip.TripNumber  = shipmentDrop.TripNumber;
                    relatedTrip.StartDate   = shipmentDrop.DeliveryDate;
                    relatedTrip.WarehouseId = warehouseId;
                    relatedTrip.Id          = TripController.SaveTrip(relatedTrip);
                }
                if (relatedTrip.Id == -1)
                {
                    throw new Exception(
                              string.Format("When importing ShipmentDrop data a related trip could not be created with details, Trip Number: '{0}', Search Date: '{1}', and WarehouseId: '{2}'.",
                                            shipmentDrop.TripNumber, shipmentDrop.DeliveryDate.ToShortDateString(), warehouseId));
                }
                shipmentDrop.TripId = relatedTrip.Id;
            }

            if (shipmentDrop.ShipmentId == Null.NullInteger && shipmentDrop.CallType != ShipmentDrop.CallTypeEnum.Depot)
            {
                //get shipment id
                TDCShipment tdcShipment = TDCShipmentController.GetShipment(shipmentDrop.OpcoCode, shipmentDrop.ShipmentNumber, shipmentDrop.DespatchNumber);
                if (tdcShipment == null)
                {
                    throw new Exception(
                              string.Format("When importing ShipmentDrop data the related shipment could not be found. The Opco Code was '{0}', the Shipment Number was '{1}', and the Despatch Number was '{2}'.",
                                            shipmentDrop.OpcoCode, shipmentDrop.ShipmentNumber, shipmentDrop.DespatchNumber));
                }
                else if (tdcShipment.Status == Shipment.StatusEnum.Routed)
                {
                    //TODO: Log that this shipment has already been routed, etc
                }

                //update the related shipments estimated date with the time now that optrak has calculated it for us
                string[] arriveTime = shipmentDrop.ArriveTime.Split(':');
                tdcShipment.EstimatedDeliveryDate.AddHours(Convert.ToDouble(arriveTime[0]));
                tdcShipment.EstimatedDeliveryDate.AddMinutes(Convert.ToDouble(arriveTime[1]));
                TDCShipmentController.SaveShipment(tdcShipment);

                shipmentDrop.ShipmentId = tdcShipment.Id;
            }


            try
            {
                if (shipmentDrop.IsValid)
                {
                    //check to see if we've had this data before or we have recieved a TRIPPART file that needed us to
                    //add a record to maintain referential integrity
                    ShipmentDrop existingShipmentDrop = GetDrop(shipmentDrop.ShipmentId, shipmentDrop.TripId, shipmentDrop.OrderSequence, shipmentDrop.DropSequence);
                    if (existingShipmentDrop != null)
                    {
                        //just overwite with this new data
                        //log?
                        shipmentDrop.Id       = existingShipmentDrop.Id;
                        shipmentDrop.CheckSum = existingShipmentDrop.CheckSum;
                    }
                    // Save entity
                    shipmentDrop.Id = DataAccessProvider.Instance().SaveDrop(shipmentDrop);

                    if (shipmentDrop.Id == -1)
                    {
                        throw new Exception(
                                  string.Format("A Drop could not be saved. The Opco Code was '{0}', the Shipment Number was '{1}', and the Despatch Number was '{2}'.",
                                                shipmentDrop.OpcoCode, shipmentDrop.ShipmentNumber, shipmentDrop.DespatchNumber));
                    }
                }
                else
                {
                    // Entity is not valid
                    throw new InValidBusinessObjectException(shipmentDrop);
                }
            }
            catch (Exception ex)
            {
                if (ExceptionPolicy.HandleException(ex, "Business Logic"))
                {
                    throw;
                }
            }

            return(shipmentDrop.Id);
        }
Ejemplo n.º 7
0
        public static Int32 SaveDropLine(ShipmentDropLine line)
        {
            TDCShipmentLine tdcShipmentLine;

            //if (line.ShipmentLineId == Null.NullInteger)
            //{
            //    //get shipment id

            tdcShipmentLine = TDCShipmentLineController.GetLine(line.LineCode, line.OpcoCode, line.ShipmentNumber, line.DespatchNumber);
            if (tdcShipmentLine == null)
            {
                throw new Exception(
                          string.Format("When importing Drop Line data the related Shipment Line could not be found. The line code was '{3}', Opco Code was '{0}', the Shipment Number was '{1}', and the Despatch Number was '{2}'.",
                                        line.OpcoCode, line.ShipmentNumber, line.DespatchNumber, line.LineCode));
            }

            //if (line.ShipmentLineId == Null.NullInteger)
            //{
            //    throw new Exception(
            //        string.Format("When importing Drop Line data the related Shipment Line could not be found. The Opco Code was '{0}', the Shipment Number was '{1}', and the Despatch Number was '{2}' and the Line Code was '{3}'.",
            //                      line.OpcoCode, line.ShipmentNumber, line.DespatchNumber, line.LineCode));
            //}
            line.ShipmentLineId = tdcShipmentLine.Id;


            if (!line.Split)
            {
            }
            else
            {
                //optrak split this line
                //  tdcShipment.SplitShipment()
            }

            //}

            if (line.DropId == Null.NullInteger)
            {
                //get warehouse id which will be used to find the trip id
                int       warehouseId;
                Warehouse relatedWarehouse = WarehouseController.GetWarehouse(line.Depot);
                if (relatedWarehouse == null)
                {
                    throw new Exception(
                              string.Format("When importing Drop Line data the related warehouse could not be found. The Warehouse number was '{0}'.",
                                            line.Depot));
                }
                warehouseId = relatedWarehouse.Id;

                //get the related trip id
                Trip relatedTrip = TripController.GetTripByWarehouseDateAndNumber(line.TripNumber, line.DeliveryDate, warehouseId);
                if (relatedTrip == null)
                {
                    //the trip file hasn't bee recieved yet so add a record to relate to for now
                    relatedTrip             = new Trip();
                    relatedTrip.TripNumber  = line.TripNumber;
                    relatedTrip.StartDate   = line.DeliveryDate;
                    relatedTrip.WarehouseId = warehouseId;
                    relatedTrip.Id          = TripController.SaveTrip(relatedTrip);
                }
                if (relatedTrip.Id == -1)
                {
                    throw new Exception(
                              string.Format("When importing ShipmentDrop data a related trip could not be created with details, Trip Number: '{0}', Search Date: '{1}', and WarehouseId: '{2}'.",
                                            line.TripNumber, line.DeliveryDate.ToShortDateString(), warehouseId));
                }


                //get drop id this line relates to
                ShipmentDrop relatedShipmentDrop = GetDrop(tdcShipmentLine.ShipmentId, relatedTrip.Id, line.OrderSequence, line.DropSequence);
                if (relatedShipmentDrop == null)
                {
                    //a related shipment drop could not be found
                    //this could be because that file has not been proced yet so create
                    //a blank one to relate to
                    relatedShipmentDrop            = new ShipmentDrop();
                    relatedShipmentDrop.ShipmentId = tdcShipmentLine.ShipmentId;
                    relatedShipmentDrop.TripId     = relatedTrip.Id;
                    // relatedShipmentDrop.OrderSequence = line.OrderSequence;
                    relatedShipmentDrop.DropSequence = line.DropSequence;
                    relatedShipmentDrop.Id           = SaveDrop(relatedShipmentDrop, line.Depot);
                }
                if (relatedShipmentDrop.Id == -1)
                {
                    throw new Exception(
                              string.Format("When importing Drop Line data a related Drop could not be created with details, Shipment Id: '{0}', Trip Id: '{1}', and Order OrderSequence: '{2}' and Drop OrderSequence '{3}'.",
                                            tdcShipmentLine.ShipmentId, relatedTrip.Id, line.OrderSequence, line.DropSequence));
                }

                line.DropId = relatedShipmentDrop.Id;
            }

            try
            {
                if (line.IsValid)
                {
                    // Save entity
                    //check to see if we've had this data before or we have recieved a TRIPPART file that needed us to
                    //add a record to maintain referential integrity
                    ShipmentDropLine existingShipmentDropLine = null;// DropController.GetDropLine(line.ShipmentLineId);
                    if (existingShipmentDropLine != null)
                    {
                        //just overwite with this new data
                        //log?
                        line.Id       = existingShipmentDropLine.Id;
                        line.CheckSum = existingShipmentDropLine.CheckSum;
                    }
                    line.OriginalShipmentLineId = line.ShipmentLineId;
                    line.Id = DataAccessProvider.Instance().SaveDropLine(line);
                }
                else
                {
                    // Entity is not valid
                    throw new InValidBusinessObjectException(line);
                }
            }
            catch (Exception ex)
            {
                if (ExceptionPolicy.HandleException(ex, "Business Logic"))
                {
                    throw;
                }
            }

            // Done
            return(line.Id);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Customs the fill.
 /// </summary>
 /// <param name="item">The item.</param>
 /// <param name="dataReader">The data reader.</param>
 /// <param name="fullyPopulate">if set to <c>true</c> [fully populate].</param>
 public static void CustomFill(Trip item, IDataReader dataReader, bool fullyPopulate)
 {
     item.Warehouse = WarehouseController.GetWarehouse(item.WarehouseId, fullyPopulate);
 }