public RemoveParcelsResponseType RemoveParcels(RemoveParcelsRequestType 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("RemoveParcels_Request"));
                }

                RemoveParcelsResponseType response = client.RemoveParcels(request);

                client.Close();

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

                if (response.StatusCode == CentiroService.StatusCode.Ok)
                {
                    return(response);
                }
                else if (response.StatusCode == CentiroService.StatusCode.InvalidTicket)
                {
                    if (!_invalidTicketError)
                    {
                        RenewTicket(true);
                        _invalidTicketError = true;
                        return(RemoveParcels(request, dumpXml));
                    }
                }

                Tracing.TraceEvent(TraceEventType.Error, 0, String.Format("Error calling RemoveParcels.\nError status = {0}\nError Message = {1}", response.StatusCode, GetErrorString(response.StatusMessages)));
                throw new CentiroServiceAgentException(String.Format("Error calling RemoveParcels.\nError status = {0}\nError Message = {1}",
                                                                     response.StatusCode, GetErrorString(response.StatusMessages)));
            }
            catch (CommunicationException)
            {
                Tracing.TraceEvent(TraceEventType.Error, 0, "Error calling RemoveParcels.");
                client.Abort();
                throw;
            }
            catch (TimeoutException)
            {
                Tracing.TraceEvent(TraceEventType.Error, 0, "Error calling RemoveParcels.");
                throw;
            }
        }
        private void RemoveParcel(string removeClob)
        {
            CentiroRemoveParcels     report        = _removeParcelRequestSerializer.Deserialize(new StringReader(removeClob)) as CentiroRemoveParcels;
            RemoveParcelsRequestType removeRequest = _businessDataMapper.Map(report);

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

                if (_isXmlDumpEnabled)
                {
                    new XMLHelper().DumpToFile(new XMLHelper().InterfaceClassToXml(removeRequest), LogFileName("RemoveParcel_Request"));
                }

                CentiroServiceAgent csAdapter = GetCachedAdapter(report.url);
                csAdapter.RemoveParcels(removeRequest, _isXmlDumpEnabled);
            }
        }
Example #3
0
        public RemoveParcelsRequestType Map(CentiroRemoveParcels report)
        {
            RemoveParcelsRequestType request = new RemoveParcelsRequestType();

            if (report.aggregateParcels.Equals("1"))
            {
                request.AggregateParcels = true;
            }
            else
            {
                request.AggregateParcels = false;
            }
            request.SenderCode           = report.senderCode;
            request.ParcelIdentifierList = new List <string>();
            request.ShipmentIdentifier   = report.shipmentIdentifier;
            foreach (CentiroRemoveParcelType p in report.Parcels.Parcel)
            {
                request.ParcelIdentifierList.Add(p.parcelIdentifier);
            }

            request.MessageId = Convert.ToString(DateTime.Now.Ticks);

            return(request);
        }