Example #1
0
 //LTL services
 public void DispatchShipment(LTLShipment shipment)
 {
     //Dispatch an existing LTL shipment (i.e. record pickupID
     try {
         new LTLGateway().DispatchLTLShipment(shipment);
     }
     catch (Exception ex) { throw new FaultException <LTLFault>(new LTLFault(ex.Message), "Service Error"); }
 }
Example #2
0
 public void ArriveShipment(LTLShipment shipment)
 {
     //Arrive an existing LTL shipment (i.e. record arrival datetime)
     try {
         new LTLGateway().ArriveLTLShipment(shipment);
     }
     catch (Exception ex) { throw new FaultException <LTLFault>(new LTLFault(ex.Message), "Service Error"); }
 }
Example #3
0
        public bool DispatchLTLShipment(LTLShipment shipment)
        {
            //Dispatch an existing LTL shipment
            bool updated = false;

            try {
                updated = new DataService().ExecuteNonQuery(SQL_CONNID, USP_SHIPMENT_DISPATCH,
                                                            new object[] { shipment.ID, shipment.PickupID });
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(updated);
        }
Example #4
0
        public bool ArriveLTLShipment(LTLShipment shipment)
        {
            //Update an existing LTL shipment
            bool updated = false;

            try {
                updated = new DataService().ExecuteNonQuery(SQL_CONNID, USP_SHIPMENT_ARRIVE,
                                                            new object[] { shipment.ID, shipment.PickupDate });
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(updated);
        }
Example #5
0
        public LTLShipment ReadLTLShipment(int shipmentID)
        {
            LTLShipment shipment = null;

            try {
                DataSet ds = new LTLGateway().ReadLTLShipment(shipmentID);
                if (ds != null && ds.Tables["LTLShipmentTable"] != null && ds.Tables["LTLShipmentTable"].Rows.Count > 0)
                {
                    DataRow _shipment = ds.Tables["LTLShipmentTable"].Rows[0];
                    shipment                        = new LTLShipment();
                    shipment.ID                     = int.Parse(_shipment["ID"].ToString());
                    shipment.ShipmentNumber         = _shipment["ShipmentNumber"].ToString();
                    shipment.Created                = DateTime.Parse(_shipment["Created"].ToString());
                    shipment.ShipDate               = DateTime.Parse(_shipment["ShipDate"].ToString());
                    shipment.ClientID               = int.Parse(_shipment["ClientID"].ToString());
                    shipment.ShipperID              = int.Parse(_shipment["ShipperID"].ToString());
                    shipment.ConsigneeID            = int.Parse(_shipment["ConsigneeID"].ToString());
                    shipment.Pallet1Weight          = int.Parse(_shipment["Pallet1Weight"].ToString());
                    shipment.Pallet1Class           = _shipment["Pallet1Class"].ToString();
                    shipment.Pallet1InsuranceValue  = decimal.Parse(_shipment["Pallet1InsuranceValue"].ToString());
                    shipment.Pallet2Weight          = int.Parse(_shipment["Pallet2Weight"].ToString());
                    shipment.Pallet2Class           = _shipment["Pallet2Class"].ToString();
                    shipment.Pallet2InsuranceValue  = decimal.Parse(_shipment["Pallet2InsuranceValue"].ToString());
                    shipment.Pallet3Weight          = int.Parse(_shipment["Pallet3Weight"].ToString());
                    shipment.Pallet3Class           = _shipment["Pallet3Class"].ToString();
                    shipment.Pallet3InsuranceValue  = decimal.Parse(_shipment["Pallet3InsuranceValue"].ToString());
                    shipment.Pallet4Weight          = int.Parse(_shipment["Pallet4Weight"].ToString());
                    shipment.Pallet4Class           = _shipment["Pallet4Class"].ToString();
                    shipment.Pallet4InsuranceValue  = decimal.Parse(_shipment["Pallet4InsuranceValue"].ToString());
                    shipment.Pallet5Weight          = int.Parse(_shipment["Pallet5Weight"].ToString());
                    shipment.Pallet5Class           = _shipment["Pallet5Class"].ToString();
                    shipment.Pallet5InsuranceValue  = decimal.Parse(_shipment["Pallet5InsuranceValue"].ToString());
                    shipment.InsidePickup           = !_shipment.IsNull("InsidePickup") ? bool.Parse(_shipment["InsidePickup"].ToString()) : false;
                    shipment.LiftGateOrigin         = !_shipment.IsNull("LiftGateOrigin") ? bool.Parse(_shipment["LiftGateOrigin"].ToString()) : false;
                    shipment.AppointmentOrigin      = !_shipment.IsNull("AppointmentOrigin") ? DateTime.Parse(_shipment["AppointmentOrigin"].ToString()) : DateTime.MinValue;
                    shipment.InsideDelivery         = !_shipment.IsNull("InsideDelivery") ? bool.Parse(_shipment["InsideDelivery"].ToString()) : false;
                    shipment.LiftGateDestination    = !_shipment.IsNull("LiftGateDestination") ? bool.Parse(_shipment["LiftGateDestination"].ToString()) : false;
                    shipment.AppointmentDestination = !_shipment.IsNull("AppointmentDestination") ? DateTime.Parse(_shipment["AppointmentDestination"].ToString()) : DateTime.MinValue;
                    shipment.Pallets                = int.Parse(_shipment["Pallets"].ToString());
                    shipment.Weight                 = int.Parse(_shipment["Weight"].ToString());
                    shipment.PalletRate             = decimal.Parse(_shipment["PalletRate"].ToString());
                    shipment.FuelSurcharge          = decimal.Parse(_shipment["FuelSurcharge"].ToString());
                    shipment.AccessorialCharge      = decimal.Parse(_shipment["AccessorialCharge"].ToString());
                    shipment.InsuranceCharge        = decimal.Parse(_shipment["InsuranceCharge"].ToString());
                    shipment.TollCharge             = decimal.Parse(_shipment["TollCharge"].ToString());
                    shipment.TotalCharge            = decimal.Parse(_shipment["TotalCharge"].ToString());
                    shipment.LastUpdated            = DateTime.Parse(_shipment["LastUpdated"].ToString());
                    shipment.UserID                 = _shipment["UserID"].ToString();
                }
            }
            catch (Exception ex) { throw new FaultException <LTLFault>(new LTLFault(ex.Message), "Service Error"); }
            return(shipment);
        }
Example #6
0
        public int CreateLTLShipment(LTLShipment shipment)
        {
            //Create a new LTL shipment
            int id = 0;
            LTLClientServiceClient client = new LTLClientServiceClient();

            try {
                id = client.CreateLTLShipment(shipment);
            }
            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(id);
        }
Example #7
0
        public bool UpdateLTLShipment(LTLShipment shipment)
        {
            //Update an existing LTL shipment
            bool updated = false;

            try {
                updated = new DataService().ExecuteNonQuery(SQL_CONNID, USP_SHIPMENT_UPDATE,
                                                            new object[] {
                    0, shipment.ShipDate,
                    shipment.Pallets, shipment.Weight, shipment.PalletRate, shipment.FuelSurcharge, shipment.AccessorialCharge, shipment.InsuranceCharge, shipment.TollCharge, shipment.TotalCharge,
                    shipment.InsidePickup, shipment.LiftGateOrigin,
                    (shipment.AppointmentOrigin != DateTime.MinValue ? shipment.AppointmentOrigin : null as object),
                    shipment.InsideDelivery, shipment.LiftGateDestination,
                    (shipment.AppointmentDestination != DateTime.MinValue ? shipment.AppointmentDestination : null as object),
                    shipment.LastUpdated, shipment.UserID
                });
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(updated);
        }
Example #8
0
        public int CreateLTLShipment(LTLShipment shipment)
        {
            //Create a new Book Log shipment
            int id = 0;

            try {
                object o = new DataService().ExecuteNonQueryWithReturn(SQL_CONNID, USP_SHIPMENT_CREATE,
                                                                       new object[] {
                    0, shipment.Created, shipment.ClientID, shipment.ShipDate, shipment.ShipperID, shipment.ConsigneeID,
                    shipment.Pallets, shipment.Weight, shipment.PalletRate, shipment.FuelSurcharge, shipment.AccessorialCharge, shipment.InsuranceCharge, shipment.TollCharge, shipment.TotalCharge,
                    shipment.InsidePickup, shipment.LiftGateOrigin,
                    (shipment.AppointmentOrigin != DateTime.MinValue ? shipment.AppointmentOrigin : null as object),
                    shipment.InsideDelivery, shipment.LiftGateDestination,
                    (shipment.AppointmentDestination != DateTime.MinValue ? shipment.AppointmentDestination : null as object),
                    shipment.LastUpdated, shipment.UserID
                });
                id = (int)o;
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(id);
        }
Example #9
0
        public bool UpdateLTLShipment(LTLShipment shipment)
        {
            //Update an existing LTL shipment
            bool updated = false;

            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()) {
                    //
                    updated = new LTLGateway().UpdateLTLShipment(shipment);

                    //Update the pallets
                    throw new ApplicationException("TODO: Update shipment pallets.");

                    //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(updated);
        }
Example #10
0
    protected void OnShipmentCommand(object sender, CommandEventArgs e)
    {
        //Event handler for change in view
        int id = 0;

        try {
            switch (e.CommandName)
            {
            case "New": Response.Redirect("~/Client/BookQuote.aspx", false); break;

            case "Update":
                id = int.Parse(this.grdShipments.SelectedDataKey.Value.ToString());
                Response.Redirect("~/Client/BookQuote.aspx?id=" + id.ToString(), false);
                break;

            case "Cancel":
                //Cancel the selected pickup request
                id = int.Parse(this.grdShipments.SelectedDataKey.Value.ToString());
                bool cancelled = false;     //new Argix.Freight.FreightGateway().CancelLTLShipment(id);

                //Send confirmation message to client and sales rep (if applicable)
                Argix.Freight.LTLShipment shipment = null;      //new Argix.Freight.FreightGateway().ReadLTLShipment(id);
                //new NotifyService().NotifyShipmentCancelled(Master.CurrentClient.ContactEmail,id.ToString(),shipment);
                //if (Master.SalesRep != null && Master.CurrentClient.ID != Master.SalesRep.ID) new NotifyService().NotifyShipmentCancelled(Master.SalesRep.ContactEmail,id.ToString(),pickup);

                //Update log
                this.grdShipments.DataBind();

                //Notify client
                Master.ShowMessageBox("Shipment " + id.ToString() + " has been cancelled.");
                break;
            }
        }
        catch (Exception ex) { Master.ReportError(ex, 4); }
        finally { OnValidateForm(null, EventArgs.Empty); }
    }
Example #11
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);
        }
Example #12
0
 public void NotifyShipmentCreated(LTLClient client, LTLShipper shipper, LTLConsignee consignee, LTLShipment shipment, int shipmentID, LTLClient salesRep)
 {
     try {
         //Send conformation email
         if (client.ContactEmail.Trim().Length > 0)
         {
             string body = getHTMLBody(System.Web.Hosting.HostingEnvironment.MapPath(HTML_SHIPMENT_CREATED));
             body = body.Replace("*shipmentNumber*", shipmentID.ToString());
             body = body.Replace("*clientName*", client.Name);
             body = body.Replace("*clientAddress*", client.AddressLine1 + " " + client.City + ", " + client.State + " " + client.Zip);
             body = body.Replace("*clientContact*", client.ContactName);
             body = body.Replace("txtShipDate", shipment.ShipDate.ToString("MM/dd/yyyy"));
             body = body.Replace("txtOrigin", shipper.Name + " (" + shipper.Zip + ")");
             body = body.Replace("txtDest", consignee.Name + " (" + consignee.Zip + ")");
             body = body.Replace("txtPallets", shipment.Pallets.ToString());
             body = body.Replace("txtWeight", shipment.Weight.ToString());
             body = body.Replace("txtRate", shipment.PalletRate.ToString());
             body = body.Replace("txtFSC", shipment.FuelSurcharge.ToString());
             body = body.Replace("txtAccessorial", shipment.AccessorialCharge.ToString());
             body = body.Replace("txtInsurance", shipment.InsuranceCharge.ToString());
             body = body.Replace("txtTSC", shipment.TollCharge.ToString());
             body = body.Replace("txtCharges", shipment.TotalCharge.ToString());
             new Argix.Enterprise.SMTPGateway().SendMailMessage(this.mEmailAdmin, client.ContactEmail, "Shipment Booked", true, body);
             if (salesRep != null)
             {
                 new Argix.Enterprise.SMTPGateway().SendMailMessage(this.mEmailAdmin, salesRep.ContactEmail, "Shipment Booked", true, body);
             }
         }
     }
     catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
 }