public UpdateParcelsResponseType UpdateParcels(UpdateParcelsRequestType request, bool dumpXml)
        {
            WMSInterfaceClient client = new WMSInterfaceClient("BasicHttpBinding_IWMSInterface", _url);

            try
            {
                RenewTicket(false);
                request.Ticket = _ticket;

                if (dumpXml)
                {
                    new XMLHelper().DumpToFile(new XMLHelper().InterfaceClassToXml(request), LogFileName("DataToCentiro_UpdateParcel"));
                }

                UpdateParcelsResponseType response = client.UpdateParcels(request);
                client.Close();

                if (dumpXml)
                {
                    new XMLHelper().DumpToFile(new XMLHelper().InterfaceClassToXml(response), LogFileName("DataFromCentiro_UpdateParcels"));
                }

                if (response.StatusCode == CentiroService.StatusCode.Ok)
                {
                    return(response);
                }
                else if (response.StatusCode == CentiroService.StatusCode.InvalidTicket)
                {
                    if (!_invalidTicketError)
                    {
                        RenewTicket(true);
                        _invalidTicketError = true;
                        return(UpdateParcels(request, dumpXml));
                    }
                    else
                    {
                        return(response);
                    }
                }
                else
                {
                    Tracing.TraceEvent(TraceEventType.Error, 0, String.Format("Error for Update Parcel .\nError status = {0}\nError Message = {1}",
                                                                              response.StatusCode, GetErrorString(response.StatusMessages)));
                    throw new CentiroServiceAgentException(String.Format("Error for Update Parcel .\nError status = {0}\nError Message = {1}",
                                                                         response.StatusCode, GetErrorString(response.StatusMessages)));
                }
            }

            catch (CommunicationException)
            {
                Tracing.TraceEvent(TraceEventType.Error, 0, "Error calling UpdateParcel.");
                client.Abort();
                throw;
            }
            catch (TimeoutException)
            {
                Tracing.TraceEvent(TraceEventType.Error, 0, "Error calling UpdateParcel.");
                throw;
            }
        }
Exemplo n.º 2
0
        public UpdateParcelsRequestType Map(CentiroUpdateParcels report)
        {
            if (report == null)
            {
                return(null);
            }
            UpdateParcelsRequestType request = new UpdateParcelsRequestType();

            request.SenderCode         = SafeSubstring(report.senderCode, 0, 50);
            request.ShipmentIdentifier = report.shipmentIdentifier;
            if (report.aggregateParcels.Equals("1"))
            {
                request.AggregateParcels = true;
            }
            else
            {
                request.AggregateParcels = false;
            }
            List <CentiroService.Parcel> l       = new List <CentiroService.Parcel>();
            CentiroUpdateParcelsParcels  Parcels = report.Parcels;

            foreach (CentiroUpdateParcelType p in Parcels.Parcel)
            {
                CentiroService.Parcel Parcel = new CentiroService.Parcel();
                Parcel.DeliveryInstruction1 = SafeSubstring(p.deliveryInstructions, 0, 50);
                Parcel.DeliveryInstruction2 = SafeSubstring(p.deliveryInstructions, 50, 50);
                Parcel.DeliveryInstruction3 = SafeSubstring(p.deliveryInstructions, 100, 50);
                Parcel.DeliveryInstruction4 = SafeSubstring(p.deliveryInstructions, 150, 50);
                Parcel.Height                = Convert.ToDouble(p.height, _numFormatInfo);
                Parcel.LastModifiedBy        = p.lastModifiedBy;
                Parcel.Length                = Convert.ToDouble(p.length, _numFormatInfo);
                Parcel.LoadingMeasure        = Convert.ToDouble(p.loadingMeasure, _numFormatInfo);
                Parcel.NetWeight             = Convert.ToDouble(p.netWeight, _numFormatInfo);
                Parcel.ParcelIdentifier      = p.parcelIdentifier;
                Parcel.SequenceNo            = p.sequenceNo;
                Parcel.SequenceNoSSCC        = p.sequenceNoSSCC;
                Parcel.ShippingLocation      = p.shippingLocation;
                Parcel.TransportInstruction1 = SafeSubstring(p.transportInstructions, 0, 50);
                Parcel.TransportInstruction2 = SafeSubstring(p.transportInstructions, 50, 50);
                Parcel.TransportInstruction3 = SafeSubstring(p.transportInstructions, 100, 50);
                Parcel.TypeOfGoods           = p.typeOfGoods;
                Parcel.TypeOfPackage         = p.typeOfPackage;
                Parcel.Weight                = Convert.ToDouble(p.weight, _numFormatInfo);
                Parcel.Width  = Convert.ToDouble(p.width, _numFormatInfo);
                Parcel.Volume = Convert.ToDouble(p.volume, _numFormatInfo);
                l.Add(Parcel);
            }

            request.Parcels = l;

            return(request);
        }
Exemplo n.º 3
0
        private void UpdateParcel(string requestClob)
        {
            CentiroUpdateParcels     report  = _updateParcelSerializer.Deserialize(new StringReader(requestClob)) as CentiroUpdateParcels;
            UpdateParcelsRequestType request = _businessDataMapper.Map(report);

            if (request == null)
            {
                throw new CentiroAdapterException(
                          string.Format("Failed to deserialize UpdateParcel clob. Data = {0}", requestClob));
            }
            else
            {
                MessageId         = Convert.ToString(DateTime.Now.Ticks);
                request.MessageId = MessageId;

                if (_isXmlDumpEnabled)
                {
                    new XMLHelper().DumpToFile(new XMLHelper().InterfaceClassToXml(request), LogFileName("UpdateParcel_Request"));
                }

                CentiroServiceAgent       csAdapter = GetCachedAdapter(report.url);
                UpdateParcelsResponseType ur        = csAdapter.UpdateParcels(request, _isXmlDumpEnabled);
            }
        }