Пример #1
0
        public LTLConsignee ReadLTLConsignee(int consigneeID)
        {
            LTLConsignee consignee = null;

            try {
                DataSet ds = new LTLGateway().ReadLTLConsignee(consigneeID);
                if (ds != null && ds.Tables["LTLConsigneeTable"] != null && ds.Tables["LTLConsigneeTable"].Rows.Count > 0)
                {
                    DataRow _consignee = ds.Tables["LTLConsigneeTable"].Rows[0];
                    consignee                 = new LTLConsignee();
                    consignee.ID              = int.Parse(_consignee["ID"].ToString());
                    consignee.ClientID        = int.Parse(_consignee["ClientID"].ToString());
                    consignee.Name            = _consignee["Name"].ToString();
                    consignee.AddressLine1    = _consignee["AddressLine1"].ToString();
                    consignee.AddressLine2    = !_consignee.IsNull("AddressLine2") ? _consignee["AddressLine2"].ToString() : "";
                    consignee.City            = _consignee["City"].ToString();
                    consignee.State           = _consignee["State"].ToString();
                    consignee.Zip             = _consignee["Zip"].ToString();
                    consignee.Zip4            = !_consignee.IsNull("Zip4") ? _consignee["Zip4"].ToString() : "";
                    consignee.WindowStartTime = !_consignee.IsNull("WindowStartTime") ? DateTime.Parse(_consignee["WindowStartTime"].ToString()) : DateTime.MinValue;
                    consignee.WindowEndTime   = !_consignee.IsNull("WindowEndTime") ? DateTime.Parse(_consignee["WindowEndTime"].ToString()) : DateTime.MinValue;
                    consignee.ContactName     = _consignee["ContactName"].ToString();
                    consignee.ContactPhone    = !_consignee.IsNull("ContactPhone") ? _consignee["ContactPhone"].ToString() : "";
                    consignee.ContactEmail    = _consignee["ContactEmail"].ToString();
                    consignee.Status          = _consignee["Status"].ToString();
                    consignee.LastUpdated     = DateTime.Parse(_consignee["LastUpdated"].ToString());
                    consignee.UserID          = _consignee["UserID"].ToString();
                }
            }
            catch (Exception ex) { throw new FaultException <LTLFault>(new LTLFault(ex.Message), "Service Error"); }
            return(consignee);
        }
Пример #2
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);
        }
Пример #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); }
 }
Пример #4
0
        public bool UpdateLTLConsignee(LTLConsignee ltlConsignee)
        {
            //Update an existing LTL consignee
            bool updated = false;
            LTLClientServiceClient client = new LTLClientServiceClient();

            try {
                updated = client.UpdateLTLConsignee(ltlConsignee);
            }
            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);
        }
Пример #5
0
        public LTLConsignee ReadLTLConsignee(int consigneeID)
        {
            LTLConsignee           consignee = new LTLConsignee();
            LTLClientServiceClient client    = new LTLClientServiceClient();

            try {
                consignee = client.ReadLTLConsignee(consigneeID);
                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(consignee);
        }
Пример #6
0
        public int CreateLTLConsignee(LTLConsignee ltlConsignee)
        {
            //Create a new LTL consignee
            int consigneeID = 0;
            LTLClientServiceClient client = new LTLClientServiceClient();

            try {
                consigneeID = client.CreateLTLConsignee(ltlConsignee);
            }
            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(consigneeID);
        }
Пример #7
0
        public bool UpdateLTLConsignee(LTLConsignee consignee)
        {
            //Update an existing LTL consignee
            bool updated = false;

            try {
                updated = new DataService().ExecuteNonQuery(SQL_CONNID, USP_CONSIGNEE_UPDATE,
                                                            new object[] {
                    consignee.ID,
                    consignee.AddressLine1, consignee.AddressLine2,
                    consignee.WindowStartTime, consignee.WindowEndTime, consignee.ContactName, consignee.ContactPhone, consignee.ContactEmail,
                    consignee.LastUpdated, consignee.UserID
                });
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(updated);
        }
Пример #8
0
        public int CreateLTLConsignee(LTLConsignee consignee)
        {
            //Create a new LTL consignee
            int id = 0;

            try {
                object o = new DataService().ExecuteNonQueryWithReturn(SQL_CONNID, USP_CONSIGNEE_CREATE,
                                                                       new object[] {
                    0, consignee.ClientID,
                    consignee.Name, consignee.AddressLine1, consignee.AddressLine2, consignee.City, consignee.State, consignee.Zip, consignee.Zip4,
                    consignee.WindowStartTime, consignee.WindowEndTime, consignee.ContactName, consignee.ContactPhone, consignee.ContactEmail,
                    consignee.Status, consignee.LastUpdated, consignee.UserID
                });
                id = (int)o;
            }
            catch (Exception ex) { throw new ApplicationException(ex.Message, ex); }
            return(id);
        }
Пример #9
0
        public bool UpdateLTLConsignee(LTLConsignee consignee)
        {
            //Update an existing LTL consignee
            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().UpdateLTLConsignee(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(updated);
        }
Пример #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);
        }