Exemple #1
0
 private void OnZipChanged(object sender, EventArgs e)
 {
     //Validate consignee zip as deliverable (new shippers only)
     try {
         string zipCode = this.txtZip5.Text;
         if (this.mShipper.Number.Trim().Length == 0 && zipCode.Trim().Length == 5)
         {
             ServiceLocation location = FreightGateway.ReadPickupLocation(zipCode);
             if (location == null)
             {
                 this.txtCity.Text = this.txtState.Text = this.txtZip5.Text = "";
                 this.txtZip5.Focus();
                 MessageBox.Show(zipCode + " is currently not supported for pickup.", App.Product, MessageBoxButtons.OK, MessageBoxIcon.Warning);
             }
             else
             {
                 this.txtCity.Text  = location.City.Trim();
                 this.txtState.Text = location.State.Trim();
                 this.txtName.Focus();
             }
         }
     }
     catch (Exception ex) { App.ReportError(ex, true, LogLevel.Information); }
     finally { OnAddressChanged(null, EventArgs.Empty); }
 }
Exemple #2
0
 private void OnConsigneeZipChanged(object sender, EventArgs e)
 {
     //Event handler for change in consignee zip text
     this.Cursor = Cursors.WaitCursor;
     try {
         //Validate zip entry
         if (this.txtConsigneeZip.Text.Trim().Length == 5)
         {
             //Validate this is a servicable location
             string          zip      = this.txtConsigneeZip.Text;
             ServiceLocation location = FreightGateway.ReadServiceLocation(zip);
             if (location == null)
             {
                 this.txtConsigneeZip.Text = "";
                 this.txtConsigneeZip.Focus();
                 MessageBox.Show(zip + " is currently not supported for delivery.", App.Product, MessageBoxButtons.OK, MessageBoxIcon.Information);
             }
             else
             {
                 this.lblZone.Text = location.ZoneCode.Trim();
             }
             showQuote(null);
         }
     }
     catch (Exception ex) { App.ReportError(ex, false, LogLevel.Warning); }
     finally { OnValidateForm(null, EventArgs.Empty); this.Cursor = Cursors.Default; }
 }
Exemple #3
0
        public int CreateLTLConsignee(LTLConsignee consignee)
        {
            //Add a new LTL consignee
            int id = 0;

            try {
                //Apply simple business rules
                //Validate the consignee zip code is a delivery location by an Argix agent terminal
                ServiceLocation location = ReadServiceLocation(consignee.Zip);
                if (location == null)
                {
                    throw new ApplicationException(consignee.Zip + " is currently not supported for delivery.");
                }

                //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()) {
                    //
                    id = new LTLGateway().CreateLTLConsignee(consignee);

                    //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(id);
        }
Exemple #4
0
        public ServiceLocation ReadPickupLocation(string zipCode)
        {
            //
            ServiceLocation        location = null;
            LTLClientServiceClient client   = new LTLClientServiceClient();

            try {
                location = client.ReadPickupLocation(zipCode);
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <LTLFault> cfe) { client.Abort(); throw new ApplicationException(cfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(location);
        }
Exemple #5
0
        public ServiceLocation ReadPickupLocation(string zipCode)
        {
            ServiceLocation location = null;

            try {
                DataSet ds = new LTLGateway().ReadPickupLocation(zipCode);
                if (ds != null && ds.Tables["ServiceLocationTable"].Rows.Count > 0)
                {
                    location          = new ServiceLocation();
                    location.ZipCode  = ds.Tables["ServiceLocationTable"].Rows[0]["Zip"].ToString();
                    location.City     = ds.Tables["ServiceLocationTable"].Rows[0]["City"].ToString();
                    location.State    = ds.Tables["ServiceLocationTable"].Rows[0]["State"].ToString();
                    location.ZoneCode = ds.Tables["ServiceLocationTable"].Rows[0]["Zone"].ToString();
                }
            }
            catch (Exception ex) { throw new FaultException <LTLFault>(new LTLFault(ex.Message), "Service Error"); }
            return(location);
        }
Exemple #6
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);
        }