예제 #1
0
        public order GetOrderObjectRequestByExternalRef(long external_ref, string status_description)
        {
            order o = new order();
            using (var dc = new stylusDataContext())
            {
                List<item> itm = new List<item>();
                List<tracking> trk = new List<tracking>();
                ISingleResult<sp_get_order_by_external_refResult> res = dc.sp_get_order_by_external_ref(external_ref);
                foreach (sp_get_order_by_external_refResult ret in res)
                {

                    o.id = ret.order_external_ref;
                    o.status = status_description;

                    item i = new item();
                    i.id = ret.item_external_ref;
                    itm.Add(i);

                    o.item = itm;

                    tracking t = new tracking();
                    t.number = ret.tracking;
                    trk.Add(t);

                    o.tracking = trk;
                }
            }
            return o;
        }
예제 #2
0
        /// <summary>
        /// Add a tracking by providing EID and location details
        /// </summary>
        /// <param name="trackWithEID"></param>
        /// <returns></returns>
        public HttpResponseMessage Post([FromBody] trackingWithEID trackWithEID)
        {
            try
            {
                using (ebuilderEntities entities = new ebuilderEntities())
                {
                    var DLID = entities.duty_leave.FirstOrDefault(dl => dl.EID == trackWithEID.EID && dl.date.Year == DateTime.Now.Year &&
                                                                  dl.date.Month == DateTime.Now.Month && dl.date.Day == DateTime.Now.Day).DLID;
                    tracking newTracking = new tracking();
                    newTracking.DLID      = DLID;
                    newTracking.latitude  = trackWithEID.latitude;
                    newTracking.longitude = trackWithEID.longitude;
                    newTracking.time      = new TimeSpan(DateTime.Now.Hour + 5, DateTime.Now.Minute + 30, DateTime.Now.Second);

                    entities.trackings.Add(newTracking);
                    entities.SaveChanges();
                    var message = Request.CreateResponse(HttpStatusCode.OK, newTracking);
                    message.Headers.Location = new Uri(Request.RequestUri + trackWithEID.TRID.ToString());
                    return(message);
                }
            }
            catch (Exception ex)
            {
                return(Request.CreateErrorResponse(HttpStatusCode.BadRequest, ex));
            }
        }
        /// <summary>
        /// Converts this instance of <see cref="tracking"/> to an instance of <see cref="trackingDto"/>.
        /// </summary>
        /// <param name="entity"><see cref="tracking"/> to convert.</param>
        public static trackingDto ToDTO(this tracking entity)
        {
            if (entity == null)
            {
                return(null);
            }

            var dto = new trackingDto();

            dto.v_SeguroId       = entity.v_SeguroId;
            dto.v_PersonId       = entity.v_PersonId;
            dto.i_Agenda         = entity.i_Agenda;
            dto.i_CartaGarantia  = entity.i_CartaGarantia;
            dto.i_AtencionMedica = entity.i_AtencionMedica;
            dto.i_PreLiquidacion = entity.i_PreLiquidacion;
            dto.i_ControlCalidad = entity.i_ControlCalidad;
            dto.i_Facturacion    = entity.i_Facturacion;
            dto.i_Culminado      = entity.i_Culminado;
            dto.v_ServiceId      = entity.v_ServiceId;

            entity.OnDTO(dto);

            return(dto);
        }
        /// <summary>
        /// Converts this instance of <see cref="trackingDto"/> to an instance of <see cref="tracking"/>.
        /// </summary>
        /// <param name="dto"><see cref="trackingDto"/> to convert.</param>
        public static tracking ToEntity(this trackingDto dto)
        {
            if (dto == null)
            {
                return(null);
            }

            var entity = new tracking();

            entity.v_SeguroId       = dto.v_SeguroId;
            entity.v_PersonId       = dto.v_PersonId;
            entity.i_Agenda         = dto.i_Agenda;
            entity.i_CartaGarantia  = dto.i_CartaGarantia;
            entity.i_AtencionMedica = dto.i_AtencionMedica;
            entity.i_PreLiquidacion = dto.i_PreLiquidacion;
            entity.i_ControlCalidad = dto.i_ControlCalidad;
            entity.i_Facturacion    = dto.i_Facturacion;
            entity.i_Culminado      = dto.i_Culminado;
            entity.v_ServiceId      = dto.v_ServiceId;

            dto.OnEntity(entity);

            return(entity);
        }
        public static FedExTrackingViewModel ConvertFedExTracking(string fedExTracking)
        {
            FedExTrackingViewModel model      = new FedExTrackingViewModel();
            List <activity>        activities = new List <activity>();
            detail   det      = new detail();
            tracking tracking = new tracking();

            if (fedExTracking.Length > 50)
            {
                JObject request = JObject.Parse(File.ReadAllText(fedExTracking));
                request.Remove("?xml");

                var activityTokens = request["tracking"]["detail"]["activities"].Children();
                var detailTokens   = request["tracking"]["detail"].Children();

                foreach (JToken child in activityTokens.Children())
                {
                    foreach (JToken grandChild in child)
                    {
                        activity act = new activity();
                        foreach (JToken grandGrandChild in grandChild)
                        {
                            var property = grandGrandChild as JProperty;

                            if (property != null)
                            {
                                if (property.Name == "datetime")
                                {
                                    act.datetime = property.Value != null?property.Value.ToString() : "";
                                }

                                if (property.Name == "scan")
                                {
                                    act.scan = property.Value != null?property.Value.ToString() : "";
                                }

                                if (property.Name == "location")
                                {
                                    act.location = property.Value != null?property.Value.ToString() : "";
                                }

                                if (property.Name == "details")
                                {
                                    act.details = property.Value != null?property.Value.ToString() : "";
                                }
                            }
                        }
                        activities.Add(act);
                    }
                }


                foreach (JToken child in detailTokens)
                {
                    var property = child as JProperty;
                    if (property != null)
                    {
                        if (property.Name == "tn")
                        {
                            det.tn = property.Value.ToString();
                        }
                        if (property.Name == "ptn")
                        {
                            det.ptn = property.Value != null?property.Value.ToString() : "";
                        }
                        if (property.Name == "destination")
                        {
                            if (property.Value != null)
                            {
                                det.destination = property.Value.ToString();
                            }
                        }
                        if (property.Name == "shipdate")
                        {
                            if (property.Value != null)
                            {
                                det.shipdate = property.Value.ToString();
                            }
                        }
                        if (property.Name == "sentby")
                        {
                            if (property.Value != null)
                            {
                                det.sentby = property.Value.ToString();
                            }
                        }
                        if (property.Name == "deliveredto")
                        {
                            if (property.Value != null)
                            {
                                det.deliveredto = property.Value.ToString();
                            }
                        }
                        if (property.Name == "signedforby")
                        {
                            if (property.Value != null)
                            {
                                det.signedforby = property.Value.ToString();
                            }
                        }
                        if (property.Name == "service")
                        {
                            if (property.Value != null)
                            {
                                det.service = property.Value.ToString();
                            }
                        }
                        if (property.Name == "deliverydate")
                        {
                            if (property.Value != null)
                            {
                                det.deliverydate = property.Value.ToString();
                            }
                        }
                        if (property.Name == "status")
                        {
                            if (property.Value != null)
                            {
                                det.status = property.Value.ToString();
                            }
                        }
                    }
                }
            }
            det.activities = activities;

            tracking.detail = det;

            model.tracking = tracking;

            return(model);
        }
예제 #6
0
    private Camera _camera;     // указатель на экземпляр объекта

    void Awake()
    {
        Instance = this;
    }
 /// <summary>
 /// Invoked when <see cref="ToEntity"/> operation is about to return.
 /// </summary>
 /// <param name="entity"><see cref="tracking"/> converted from <see cref="trackingDto"/>.</param>
 static partial void OnEntity(this trackingDto dto, tracking entity);
 /// <summary>
 /// Invoked when <see cref="ToDTO"/> operation is about to return.
 /// </summary>
 /// <param name="dto"><see cref="trackingDto"/> converted from <see cref="tracking"/>.</param>
 static partial void OnDTO(this tracking entity, trackingDto dto);