Example #1
0
        /// <summary>
        /// Obtiene el listado de envios con los estados actualizados.
        /// </summary>
        /// <returns>Retorna la lista de estados actualizados</returns>
        public async Task <IEnumerable <Shipment> > GetShippingStatus()
        {
            List <Shipment> shipmentResult = new List <Shipment>();

            try
            {
                var             binding = new BasicHttpsBinding(BasicHttpsSecurityMode.Transport);
                EndpointAddress address = new EndpointAddress(_endpointUrl);
                RpcServerSoapManagerPortClient client = new RpcServerSoapManagerPortClient(binding, address);

                foreach (StatusShippimentDTO data in _listSeguimiento)
                {
                    Seguimiento_detalladoResponse detailedTrackingResponse = await client.Seguimiento_detalladoAsync(data.Seguimiento_detalladoIn);

                    if (detailedTrackingResponse != null)
                    {
                        if (detailedTrackingResponse.Seguimiento_detalladoResult.estados != null)
                        {
                            List <Seguimiento_detalle> states         = detailedTrackingResponse.Seguimiento_detalladoResult.estados.ToList();
                            List <ShipmentEvent>       shipmentEvents = new List <ShipmentEvent>();
                            foreach (Seguimiento_detalle state in states)
                            {
                                int statusCode = Convert.ToInt32(state.codigo);

                                if (statusCode >= 2 && !string.IsNullOrEmpty(state.fecha) && !string.IsNullOrEmpty(state.hora))
                                {
                                    string   date     = state.fecha + " " + state.hora;
                                    DateTime fullDate = DateTime.ParseExact(date, "yyyy-MM-dd HH:mm:ss", null);
                                    shipmentEvents.Add(new ShipmentEvent()
                                    {
                                        Name = state.descripcion, EventDate = fullDate, ShipmentId = data.Shipment.ShipmentId
                                    });
                                }
                            }

                            data.Shipment.StateId        = states.Max(q => Convert.ToInt32(q.codigo));
                            data.Shipment.ShipmentEvents = shipmentEvents;
                            shipmentResult.Add(data.Shipment);
                        }
                    }
                }
            }
            catch (Exception ex)
            {
                throw;
            }

            return(shipmentResult);
        }
Example #2
0
        public async Task <IEnumerable <Shipment> > GetShippingStatus()
        {
            try
            {
                var             endpointUrl            = "http://200.69.100.66/enviawsleec/service1.asmx";
                var             binding                = new BasicHttpsBinding(BasicHttpsSecurityMode.Transport);
                EndpointAddress address                = new EndpointAddress(endpointUrl);
                RpcServerSoapManagerPortClient client1 = new RpcServerSoapManagerPortClient(binding, address);

                foreach (Shipment shipment in _shippments)
                {
                    _body.codigo_remision = shipment.Tracking;
                    _body.nit             = "890900608";
                    _body.div             = "18";
                    _body.referencia      = shipment.Order;
                    _body.imagen          = 0;
                    _body.anexo           = 0;
                    _body.apikey          = "bd24d4ee-634a-11e7-907b-a6006ad3dba0";
                    _body.clave           = "2fh63EK12h7?77e";

                    var response = await client1.Seguimiento_detalladoAsync(_body);

                    Seguimiento_detalle[] states = response.Seguimiento_detalladoResult.estados;
                    if (states != null && states.Length > 0)
                    {
                        foreach (Seguimiento_detalle state in states)
                        {
                        }
                    }

                    var json = JsonConvert.SerializeObject(response);
                }
            }
            catch (Exception ex)
            {
                throw;
            }
            List <Shipment> listRestul = new List <Shipment>();

            return(listRestul);
        }