Exemplo n.º 1
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);
        }
Exemplo n.º 2
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);
                        }
                    }
                }
            }
        }