コード例 #1
0
        public PrintDepartureResponseType PrintDeparture(PrintDepartureRequestType 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_PrintDeparture"));
                }

                PrintDepartureResponseType response = client.PrintDeparture(request);
                client.Close();

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

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

            catch (CommunicationException)
            {
                Tracing.TraceEvent(TraceEventType.Error, 0, "Error calling PrintDeparture.");
                client.Abort();
                throw;
            }
            catch (TimeoutException)
            {
                Tracing.TraceEvent(TraceEventType.Error, 0, "Error calling PrintDeparture.");
                throw;
            }
        }
コード例 #2
0
        public PrintDepartureRequestType Map(CentiroPrintDepartureType report, string documentType)
        {
            if (report == null)
            {
                return(null);
            }
            PrintDepartureRequestType request = new PrintDepartureRequestType();

            if (report.createCarrierDoc.Equals("1"))
            {
                request.CreateCarrierDoc = true;
            }
            else
            {
                request.CreateCarrierDoc = false;
            }

            if (report.createCustomerSpec.Equals("1"))
            {
                request.CreateCustomerSpec = true;
            }
            else
            {
                request.CreateCustomerSpec = false;
            }
            request.DocumentType = (CentiroService.DocumentType)Enum.Parse(typeof(CentiroService.DocumentType), documentType);
            request.RouteNo      = report.routeNo;
            request.SenderCode   = report.senderCode;
            request.TripNo       = report.tripNo;
            request.MessageId    = Convert.ToString(DateTime.Now.Ticks);
            return(request);
        }
コード例 #3
0
        private void PrintDeparture(string requestClob)
        {
            CentiroPrintDepartureType report  = _printDepartureSerializer.Deserialize(new StringReader(requestClob)) as CentiroPrintDepartureType;
            PrintDepartureRequestType request = _businessDataMapper.Map(report, _documentType);

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

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

                CentiroServiceAgent        csAdapter = GetCachedAdapter(report.url);
                PrintDepartureResponseType ur        = csAdapter.PrintDeparture(request, _isXmlDumpEnabled);

                if (ur == null)
                {
                    throw new CentiroAdapterException(
                              string.Format("No data in PrintDeparture response. MessageId = {0}", request.MessageId));
                }
                else
                {
                    if (ur.CarrierDocCode != null)
                    {
                        foreach (string d in ur.CarrierDocCode)
                        {
                            GenericReport document = new GenericReport();
                            document.MetaData = new MetaDataType();
                            document.MetaData.applicationIdentity = "Warehouse";
                            document.MetaData.documentType        = "C*CPS";
                            document.MetaData.documentSubType     = "";
                            document.MetaData.terminalIdentity    = report.terminal;
                            document.MetaData.userIdentity        = report.user;
                            document.MetaData.printerIdentity     = "";
                            document.MetaData.numberOfCopies      = (sbyte)report.numberOfCopies;
                            document.Data = d;

                            _receivedDocuments.Add(document);
                        }
                    }

                    if (ur.CustomerSpecCode != null)
                    {
                        foreach (string d in ur.CustomerSpecCode)
                        {
                            GenericReport document = new GenericReport();
                            document.MetaData = new MetaDataType();
                            document.MetaData.applicationIdentity = "Warehouse";
                            document.MetaData.documentType        = "C*CPS";
                            document.MetaData.documentSubType     = "";
                            document.MetaData.terminalIdentity    = report.terminal;
                            document.MetaData.userIdentity        = report.user;
                            document.MetaData.printerIdentity     = "";
                            document.MetaData.numberOfCopies      = (sbyte)report.numberOfCopies;
                            document.Data = d;

                            _receivedDocuments.Add(document);
                        }
                    }
                }
            }
        }