예제 #1
0
        public bool UpdateLTLPallet(LTLPallet pallet)
        {
            //Update an existing LTL pallet
            bool updated = false;

            try {
                updated = new DataService().ExecuteNonQuery(SQL_CONNID, USP_PALLET_UPDATE,
                                                            new object[] {
                    pallet.ID, pallet.Weight
                });
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(updated);
        }
예제 #2
0
        public int CreateLTLPallet(LTLPallet pallet)
        {
            //Create a new LTL pallet
            int id = 0;

            try {
                object o = new DataService().ExecuteNonQueryWithReturn(SQL_CONNID, USP_PALLET_CREATE,
                                                                       new object[] {
                    0, pallet.ShipmentID, pallet.Weight, pallet.InsuranceValue
                });
                id = (int)o;
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(id);
        }
예제 #3
0
        public int CreateLTLShipment(LTLShipment shipment)
        {
            //Add a new LTL shipment
            int shipmentID = 0;

            try {
                //Apply simple business rules

                //Create the TransactionScope to execute the commands, guaranteeing that both commands can commit or roll back as a single unit of work
                using (TransactionScope scope = new TransactionScope()) {
                    //Create the shipment
                    LTLGateway gateway = new LTLGateway();
                    shipmentID  = gateway.CreateLTLShipment(shipment);
                    shipment.ID = shipmentID;

                    //Create the pallets
                    LTLPallet pallet = new LTLPallet();
                    pallet.ShipmentID = shipmentID;
                    if (shipment.Pallet1Weight > 0)
                    {
                        pallet.Weight = shipment.Pallet1Weight; pallet.InsuranceValue = shipment.Pallet1InsuranceValue; gateway.CreateLTLPallet(pallet);
                    }
                    if (shipment.Pallet2Weight > 0)
                    {
                        pallet.Weight = shipment.Pallet2Weight; pallet.InsuranceValue = shipment.Pallet2InsuranceValue; gateway.CreateLTLPallet(pallet);
                    }
                    if (shipment.Pallet3Weight > 0)
                    {
                        pallet.Weight = shipment.Pallet3Weight; pallet.InsuranceValue = shipment.Pallet3InsuranceValue; gateway.CreateLTLPallet(pallet);
                    }
                    if (shipment.Pallet4Weight > 0)
                    {
                        pallet.Weight = shipment.Pallet4Weight; pallet.InsuranceValue = shipment.Pallet4InsuranceValue; gateway.CreateLTLPallet(pallet);
                    }
                    if (shipment.Pallet5Weight > 0)
                    {
                        pallet.Weight = shipment.Pallet5Weight; pallet.InsuranceValue = shipment.Pallet5InsuranceValue; gateway.CreateLTLPallet(pallet);
                    }

                    //Schedule pickup request
                    LTLClient    client    = ReadLTLClient(shipment.ClientID);
                    LTLShipper   shipper   = ReadLTLShipper(shipment.ShipperID);
                    LTLConsignee consignee = ReadLTLConsignee(shipment.ConsigneeID);
                    //bool useBizTalk = bool.Parse(WebConfigurationManager.AppSettings["UseBizTalk"].ToString());
                    //if (useBizTalk) {
                    //    Argix.BizTalk.LTLShipment _shipment = new BizTalk.LTLShipment();
                    //    _shipment.ID = shipmentID;
                    //    _shipment.Created = shipment.Created;
                    //    _shipment.ShipDate = shipment.ShipDate;
                    //    _shipment.ShipmentNumber = shipment.ShipmentNumber;
                    //    _shipment.ClientID = shipment.ClientID;
                    //    _shipment.ClientNumber = client.Number;
                    //    _shipment.ClientName = client.Name;
                    //    _shipment.ShipperNumber = "";
                    //    _shipment.ShipperName = shipper.Name;
                    //    _shipment.ShipperAddress = shipper.AddressLine1 + "\n" + shipper.City + ", " + shipper.State + " " + shipper.Zip;
                    //    _shipment.ShipperContactName = shipper.ContactName;
                    //    _shipment.ShipperContactPhone = shipper.ContactPhone;
                    //    _shipment.ShipperWindowStartTime = shipper.WindowStartTime;
                    //    _shipment.ShipperWindowEndTime = shipper.WindowEndTime;
                    //    _shipment.ConsigneeID = shipment.ConsigneeID;
                    //    _shipment.Pallets = shipment.Pallets;
                    //    _shipment.Weight = int.Parse(shipment.Weight.ToString());
                    //    _shipment.PalletRate = shipment.PalletRate;
                    //    _shipment.FuelSurcharge = shipment.FuelSurcharge;
                    //    _shipment.AccessorialCharge = shipment.AccessorialCharge;
                    //    _shipment.InsuranceCharge = shipment.InsuranceCharge;
                    //    _shipment.TollCharge = shipment.TollCharge;
                    //    _shipment.TotalCharge = shipment.TotalCharge;
                    //    _shipment.LastUpdated = shipment.LastUpdated;
                    //    _shipment.UserID = shipment.UserID;
                    //    new Argix.BizTalk.BizTalkGateway().ScheduleLTLPickup(_shipment);
                    //}
                    //else {
                    //Direct to Pickup Log
                    PickupRequest request = new PickupRequest();
                    request.RequestID      = 0;
                    request.ScheduleDate   = shipment.ShipDate;
                    request.CallerName     = "Online";
                    request.ClientNumber   = client.Number;
                    request.Client         = client.Name;
                    request.ShipperNumber  = "";
                    request.Shipper        = shipper.Name;
                    request.ShipperAddress = shipper.AddressLine1 + "\n" + shipper.City + ", " + shipper.State + " " + shipper.Zip;
                    request.ShipperPhone   = shipper.ContactPhone;
                    request.WindowOpen     = shipper.WindowStartTime.CompareTo(DateTime.MinValue) > 0 ? int.Parse(shipper.WindowStartTime.ToString("HHmm")) : 0;
                    request.WindowClose    = shipper.WindowEndTime.CompareTo(DateTime.MinValue) > 0 ? int.Parse(shipper.WindowEndTime.ToString("HHmm")) : 0;
                    request.Amount         = shipment.Pallets;
                    request.AmountType     = "Pallets";
                    request.FreightType    = "Tsort";
                    request.OrderType      = "B";
                    request.Weight         = int.Parse(shipment.Weight.ToString());
                    request.Comments       = "";
                    request.IsTemplate     = false;
                    request.Created        = DateTime.Now;
                    request.CreateUserID   = "PSP";
                    request.TerminalNumber = "";
                    request.Terminal       = "";
                    request.LastUpdated    = shipment.LastUpdated;
                    request.UserID         = shipment.UserID;
                    int pickupID = new DispatchGateway().InsertPickupRequest3(request);

                    //Update shipment with PickupID
                    shipment.PickupID = pickupID;
                    new LTLGateway().DispatchLTLShipment(shipment);
                    //}

                    //Send email notification to customer
                    ServiceLocation location = ReadPickupLocation(shipper.Zip);
                    LTLClient       salesRep = null;
                    if (client.SalesRepClientID > 0)
                    {
                        salesRep = ReadLTLClient(client.SalesRepClientID);
                    }
                    new NotifyService().NotifyShipmentCreated(client, shipper, consignee, shipment, shipmentID, salesRep);

                    //Commits the transaction; if an exception is thrown, Complete is not called and the transaction is rolled back
                    scope.Complete();
                }
            }
            catch (Exception ex) { throw new FaultException <LTLFault>(new LTLFault(ex.Message), "Service Error"); }
            return(shipmentID);
        }