Ejemplo n.º 1
0
        public LTLShipper ReadLTLShipper(int shipperID)
        {
            LTLShipper shipper = null;

            try {
                DataSet ds = new LTLGateway().ReadLTLShipper(shipperID);
                if (ds != null && ds.Tables["LTLShipperTable"] != null && ds.Tables["LTLShipperTable"].Rows.Count > 0)
                {
                    DataRow _shipper = ds.Tables["LTLShipperTable"].Rows[0];
                    shipper                 = new LTLShipper();
                    shipper.ID              = int.Parse(_shipper["ID"].ToString());
                    shipper.ClientID        = int.Parse(_shipper["ClientID"].ToString());
                    shipper.Name            = _shipper["Name"].ToString();
                    shipper.AddressLine1    = _shipper["AddressLine1"].ToString();
                    shipper.AddressLine2    = !_shipper.IsNull("AddressLine2") ? _shipper["AddressLine2"].ToString() : "";
                    shipper.City            = _shipper["City"].ToString();
                    shipper.State           = _shipper["State"].ToString();
                    shipper.Zip             = _shipper["Zip"].ToString();
                    shipper.Zip4            = !_shipper.IsNull("AddressLine2") ? _shipper["Zip4"].ToString() : "";
                    shipper.WindowStartTime = !_shipper.IsNull("WindowStartTime") ? DateTime.Parse(_shipper["WindowStartTime"].ToString()) : DateTime.MinValue;
                    shipper.WindowEndTime   = !_shipper.IsNull("WindowEndTime") ? DateTime.Parse(_shipper["WindowEndTime"].ToString()) : DateTime.MinValue;
                    shipper.ContactName     = _shipper["ContactName"].ToString();
                    shipper.ContactPhone    = !_shipper.IsNull("AddressLine2") ? _shipper["ContactPhone"].ToString() : "";
                    shipper.ContactEmail    = _shipper["ContactEmail"].ToString();
                    shipper.Status          = _shipper["Status"].ToString();
                    shipper.LastUpdated     = DateTime.Parse(_shipper["LastUpdated"].ToString());
                    shipper.UserID          = _shipper["UserID"].ToString();
                }
            }
            catch (Exception ex) { throw new FaultException <LTLFault>(new LTLFault(ex.Message), "Service Error"); }
            return(shipper);
        }
Ejemplo n.º 2
0
        public int CreateLTLShipper(LTLShipper shipper)
        {
            //Add a new LTL shipper
            int id = 0;

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

                //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().CreateLTLShipper(shipper);

                    //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);
        }
Ejemplo n.º 3
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); }
 }
Ejemplo n.º 4
0
        public bool UpdateLTLShipper(LTLShipper ltlShipper)
        {
            //Update an existing LTL shipper
            bool updated = false;
            LTLClientServiceClient client = new LTLClientServiceClient();

            try {
                updated = client.UpdateLTLShipper(ltlShipper);
            }
            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(updated);
        }
Ejemplo n.º 5
0
        public LTLShipper ReadLTLShipper(int shipperID)
        {
            LTLShipper             shipper = new LTLShipper();
            LTLClientServiceClient client  = new LTLClientServiceClient();

            try {
                shipper = client.ReadLTLShipper(shipperID);
                client.Close();
            }
            catch (TimeoutException te) { client.Abort(); throw new ApplicationException(te.Message); }
            catch (FaultException <LTLFault> dfe) { client.Abort(); throw new ApplicationException(dfe.Detail.Message); }
            catch (FaultException fe) { client.Abort(); throw new ApplicationException(fe.Message); }
            catch (CommunicationException ce) { client.Abort(); throw new ApplicationException(ce.Message); }
            return(shipper);
        }
Ejemplo n.º 6
0
        public int CreateLTLShipper(LTLShipper ltlShipper)
        {
            //Create a new LTL shipper
            int shipperID = 0;
            LTLClientServiceClient client = new LTLClientServiceClient();

            try {
                shipperID = client.CreateLTLShipper(ltlShipper);
            }
            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(shipperID);
        }
Ejemplo n.º 7
0
        public bool UpdateLTLShipper(LTLShipper shipper)
        {
            //Update an existing LTL shipper
            bool updated = false;

            try {
                updated = new DataService().ExecuteNonQuery(SQL_CONNID, USP_SHIPPER_UPDATE,
                                                            new object[] {
                    shipper.ID,
                    shipper.AddressLine1, shipper.AddressLine2,
                    shipper.WindowStartTime, shipper.WindowEndTime, shipper.ContactName, shipper.ContactPhone, shipper.ContactEmail,
                    shipper.LastUpdated, shipper.UserID
                });
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(updated);
        }
Ejemplo n.º 8
0
        public int CreateLTLShipper(LTLShipper shipper)
        {
            //Create a new LTL shipper
            int id = 0;

            try {
                object o = new DataService().ExecuteNonQueryWithReturn(SQL_CONNID, USP_SHIPPER_CREATE,
                                                                       new object[] {
                    0, shipper.ClientID,
                    shipper.Name, shipper.AddressLine1, shipper.AddressLine2, shipper.City, shipper.State, shipper.Zip, shipper.Zip4,
                    shipper.WindowStartTime, shipper.WindowEndTime, shipper.ContactName, shipper.ContactPhone, shipper.ContactEmail,
                    shipper.Status, shipper.LastUpdated, shipper.UserID
                });
                id = (int)o;
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(id);
        }
Ejemplo n.º 9
0
        public bool UpdateLTLShipper(LTLShipper shipper)
        {
            //Update an existing LTL shipper
            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().UpdateLTLShipper(shipper);

                    //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);
        }
Ejemplo n.º 10
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);
        }