private static void displayDebugInfo(TrackingResponse response)
 {
     Console.WriteLine("DEBUG_LAST_REQUESTED_URL :");
     Console.WriteLine(PiwikTracker.DEBUG_LAST_REQUESTED_URL);
     Console.Write("\r\n");
     Console.WriteLine(response.HttpStatusCode);
 }
Ejemplo n.º 2
0
        public void CreateTrackRequest(string trackingNumber)
        {
            trackWebRequest             = HttpWebRequest.Create(DHL_API_URL);
            trackWebRequest.ContentType = "application/x-www-form-urlencoded";
            trackWebRequest.Method      = "POST";

            // request stream
            using (var stream = trackWebRequest.GetRequestStream())
            {
                var arrBytes = System.Text.ASCIIEncoding.ASCII.GetBytes(String.Format(requestText, DateTime.Now.ToString("yyyy-MM-ddThh:mm:ss.fff-07:00"), SITEID, PASSWORD, trackingNumber));
                stream.Write(arrBytes, 0, arrBytes.Length);
                stream.Close();
            }

            trackWebResponse = trackWebRequest.GetResponse();

            // response stream
            using (var stream = trackWebResponse.GetResponseStream())
            {
                var           reader     = new StreamReader(stream, System.Text.Encoding.ASCII);
                XmlSerializer serializer = new XmlSerializer(typeof(TrackingResponse));
                this.trackReply = (TrackingResponse)serializer.Deserialize(reader);
                stream.Close();
            }
        }
Ejemplo n.º 3
0
 static private void DisplayDebugInfo(TrackingResponse response)
 {
     Debug.Log("DEBUG_LAST_REQUESTED_URL :");
     Debug.Log(response.RequestedUrl);
     Debug.Log("\r\n");
     Debug.Log(response.HttpStatusCode);
 }
Ejemplo n.º 4
0
        private void SendNotification(TrackingResponse response)
        {
            using (var client = new WebClient())
            {
                client.Headers[HttpRequestHeader.ContentType] = "application/json";
                var notificationDto = new TrackingNotificationDto
                {
                    Distance          = response.Distance,
                    DistanceMetric    = response.DistanceMetric,
                    Duration          = response.Duration,
                    DurationMetric    = response.DurationMetric,
                    Latitude          = response.Latitude,
                    Longitude         = response.Longitude,
                    TruckRegistration = response.TruckRegistration,
                    Id = Guid.NewGuid()
                };

                var json   = Newtonsoft.Json.JsonConvert.SerializeObject(notificationDto);
                var result = client.UploadString(GetTrackingNotificationUri(), json);
                var dto    = Newtonsoft.Json.JsonConvert.DeserializeObject <TrackingResponseDto>(result);
                response.NotificationWasCreated = dto.Accepted;
                response.RequestGuid            = dto.NotificationId;
                response.DispatchNoteId         = dto.DispatchNoteId;
                response.Error = dto.Error;
                var r = dto;
            }
        }
        private void RecordResponse()
        {
            TrackingRequest request = _repository.GetLastTrackingRequest(_person.PersonId);

            if (request != null)
            {
                TextMessageParser parser = new TextMessageParser(_body, _person.PersonId, _repository.GetMealType(request.TrackingRequestId).MealTypeId);
                if (parser.ExerciseRecord != null)
                {
                    _repository.Exercise.Add(parser.ExerciseRecord);
                }

                if (parser.NutritionRecord != null)
                {
                    _repository.NutritionHistory.Add(parser.NutritionRecord);
                }

                if (parser.WeightRecord != null)
                {
                    _repository.WeightHistory.Add(parser.WeightRecord);
                }

                TrackingResponse response = new TrackingResponse();
                response.TrackingRequestId = request.TrackingRequestId;
                response.ResponseText      = parser.ResponseText;

                _repository.TrackingResponses.Add(response);

                _repository.SaveChanges();

                _result = _repository.DATA_SAVED_TXT_MSG;
            }
        }
Ejemplo n.º 6
0
        public TrackingResponse Tracking(string trackingNumber)
        {
            TrackingResponse     result;
            KnownTrackingRequest track = setTracking(new string[] { trackingNumber });

            XmlSerializer serializer = new XmlSerializer(typeof(TrackingResponse));

            using (TextReader reader = new StringReader(SendRequest(track)))
            {
                try
                {
                    result = (TrackingResponse)serializer.Deserialize(reader);
                }
                catch (Exception e)
                {
                    result = new TrackingResponse()
                    {
                        AWBInfo = new AWBInfo[] {
                            new AWBInfo()
                            {
                                Status = new Status()
                                {
                                    ActionStatus = e.Message
                                }
                            }
                        }
                    };
                }
            }

            return(result);
        }
 static private void DisplayDebugInfo(TrackingResponse response)
 {
     Console.WriteLine("DEBUG_LAST_REQUESTED_URL :");
     Console.WriteLine(response.RequestedUrl);
     Console.Write("\r\n");
     Console.WriteLine(response.HttpStatusCode);
 }
Ejemplo n.º 8
0
        public void UsageTerms()
        {
            var xmlResponse = getSampleResponse("SummaryOnly.xml");
            var td          = TrackingResponse.GetCommonTrackingData(xmlResponse);
            var terms       = td.UsageRequirements;

            Assert.IsTrue(terms.Length > 20);
        }
Ejemplo n.º 9
0
        public TrackingResponse GetRouteDetails(string truckRegistration, double latitude, double longitude)
        {
            var response = new TrackingResponse
            {
              Latitude = latitude,
              Longitude = longitude
            };

              ProcessRequest(truckRegistration, latitude, longitude, response);
              return response;
        }
Ejemplo n.º 10
0
        public TrackingResponse GetRouteDetails(string truckRegistration, double latitude, double longitude)
        {
            var response = new TrackingResponse
            {
                Latitude  = latitude,
                Longitude = longitude
            };

            ProcessRequest(truckRegistration, latitude, longitude, response);
            return(response);
        }
Ejemplo n.º 11
0
        public static TrackingResponse MapToTrackingResponse(this TrackingInfo trackingInfo)
        {
            var trackingResponse = new TrackingResponse
            {
                TrackingTime = trackingInfo.TrackingTime,
                Latitude     = trackingInfo.Location.Coordinates.Latitude,
                Longitude    = trackingInfo.Location.Coordinates.Longitude
            };

            return(trackingResponse);
        }
Ejemplo n.º 12
0
 public bool CallTracking(TrackingResponse dataNotic, string imei)
 {
     try
     {
         var client  = new RestClient("https://tamroi-test.nostramap.com/tamroi/realtime/api/Tracking/" + imei);
         var request = new RestRequest(Method.PUT);
         request.AddHeader("Content-Type", "application/json");
         request.RequestFormat = DataFormat.Json;
         request.AddBody(new { latitude = dataNotic.latitude, longitude = dataNotic.longitude, inout_status = dataNotic.inout_status, battery = dataNotic.battery, current_datetime = dataNotic.current_datetime, thai_address = dataNotic.thai_address, english_address = dataNotic.english_address, online_status = dataNotic.online_status });
         IRestResponse response = client.Execute(request);
     }
     catch (Exception ex)
     {
         return(false);
     }
     return(true);
 }
Ejemplo n.º 13
0
        public ActionResult GetSnapshotHistory()
        {
            _logger.LogInformation("Getting snapshot history");

            try
            {
                var snapshotHistory = _inventoryService.GetTrackingHistory();

                var timelineMarkers = snapshotHistory
                                      .Select(t => t.TimeTracked)
                                      .Distinct()
                                      .ToList();

                // Get quantities grouped by id.
                var snapshots = snapshotHistory
                                .GroupBy(hist => hist.Product, hist => hist.AvailableQuantity,
                                         (key, g) => new InventoryTrackingViewModel
                {
                    ProductId      = key.Id,
                    QuantityOnHand = g.ToList()
                })
                                .OrderBy(hist => hist.ProductId)
                                .ToList();

                var viewModel = new TrackingResponse
                {
                    Timeline           = timelineMarkers,
                    InventoryTrackings = snapshots
                };

                return(Ok(viewModel));
            }
            catch (Exception e)
            {
                _logger.LogError("Error getting snapshot history.");
                _logger.LogError(e.StackTrace);
                return(BadRequest("Error retrieving history"));
            }
        }
Ejemplo n.º 14
0
        private TrackResult DHL_Track(CarrierAPI api, string trackingNumber)
        {
            TrackResult result = new TrackResult();

            DHL_API          DHL        = new DHL_API(api);
            TrackingResponse DHL_Result = DHL.Tracking(trackingNumber);

            TimeZoneConvert timeZone = new TimeZoneConvert();

            if (DHL_Result != null && DHL_Result.AWBInfo.Any(awb => awb.ShipmentInfo != null && !string.IsNullOrEmpty(awb.ShipmentInfo.ConsigneeName)))
            {
                List <ShipmentEvent> DHL_EventList = DHL_Result.AWBInfo.First(awb => awb.ShipmentInfo != null && !string.IsNullOrEmpty(awb.ShipmentInfo.ConsigneeName)).ShipmentInfo.Items.Skip(1).Cast <ShipmentEvent>().ToList();

                if (DHL_EventList.Any())
                {
                    if (DHL_EventList.Any(e => e.ServiceEvent.EventCode == "PU"))
                    {
                        result.PickupDate     = DHL_EventList.Where(e => e.ServiceEvent.EventCode == "PU").Select(e => timeZone.InitDateTime(e.Date.Add(e.Time.TimeOfDay), EnumData.TimeZone.TST).Utc).First();
                        result.DeliveryStatus = (int)OrderService.DeliveryStatusType.Intransit;
                    }

                    result.DeliveryNote = DHL_EventList.Select(e => timeZone.InitDateTime(e.Date.Add(e.Time.TimeOfDay), EnumData.TimeZone.TST).Utc.ToString() + " " + e.ServiceEvent.Description).Last();

                    if (DHL_EventList.Any(e => e.ServiceEvent.EventCode == "OK"))
                    {
                        result.DeliveryDate   = DHL_EventList.Where(e => e.ServiceEvent.EventCode == "OK").Select(e => timeZone.InitDateTime(e.Date.Add(e.Time.TimeOfDay), EnumData.TimeZone.TST).Utc).First();
                        result.DeliveryStatus = (int)OrderService.DeliveryStatusType.Delivered;
                    }
                }
            }
            else
            {
                result.DeliveryNote = DHL_Result.AWBInfo.First().Status.ActionStatus;
                //result.DeliveryStatus = (int)OrderService.DeliveryStatusType.Delivered;
            }

            return(result);
        }
Ejemplo n.º 15
0
        private void ProcessRequest(string truckRegistration, double latitude, double longitude, TrackingResponse response)
        {
            const string query =
            @"http://dev.virtualearth.net/REST/V1/Routes/Driving?o=json&wp.0={0},{1}&wp.1={2},{3}&optmz=distance&rpo=Points&key={4}";
              var origin = new[] {52.516071, 13.37698};
              var uri = new Uri(string.Format(query, latitude, longitude, origin[0], origin[1], GetKey()));

              var bingResponse = GetRouteDetails(uri);
              if (bingResponse.ResourceSets.Any() && bingResponse.ResourceSets[0].Resources.Any())
              {
            var routeDetails = bingResponse.ResourceSets[0].Resources[0] as Route;
            if (routeDetails != null)
            {
              response.Distance = routeDetails.TravelDistance;
              response.Duration = routeDetails.TravelDuration;
              response.DistanceMetric = routeDetails.DistanceUnit;
              response.DurationMetric = routeDetails.DurationUnit;
              response.TruckRegistration = truckRegistration;

              SendNotification(response);
            }
              }
        }
Ejemplo n.º 16
0
        private void SendNotification(TrackingResponse response)
        {
            using (var client = new WebClient())
              {
            client.Headers[HttpRequestHeader.ContentType] = "application/json";
            var notificationDto = new TrackingNotificationDto
              {
            Distance = response.Distance,
            DistanceMetric = response.DistanceMetric,
            Duration = response.Duration,
            DurationMetric = response.DurationMetric,
            Latitude = response.Latitude,
            Longitude = response.Longitude,
            TruckRegistration = response.TruckRegistration,
            Id = Guid.NewGuid()
              };

            var json = Newtonsoft.Json.JsonConvert.SerializeObject(notificationDto);
            var result = client.UploadString(GetTrackingNotificationUri(), json);
            var dto = Newtonsoft.Json.JsonConvert.DeserializeObject<TrackingResponseDto>(result);
            response.NotificationWasCreated = dto.Accepted;
            response.RequestGuid = dto.NotificationId;
            response.DispatchNoteId = dto.DispatchNoteId;
            response.Error = dto.Error;
            var r = dto;
              }
        }
Ejemplo n.º 17
0
        public HttpResponseMessage Get(HttpRequestMessage request)
        {
            string             error        = "";
            PersonBL           ConsumerAuth = new PersonBL();
            TrackingResponse   responseApi  = new TrackingResponse();
            GenericApiResponse response     = new GenericApiResponse();

            IEnumerable <string> AppVersion = null;

            request.Headers.TryGetValues("AppVersion", out AppVersion);

            IEnumerable <string> Platform = null;

            request.Headers.TryGetValues("Platform", out Platform);

            bool ApplyValidation = bool.Parse(ConfigurationManager.AppSettings["ApplyValidationAppVersion"].ToString());

            if (ApplyValidation == false || (AppVersion != null && Platform != null))
            {
                string versionRequired = "";

                var isValidVersion = (ApplyValidation == false) ? true : gameBL.IsValidAppVersion(AppVersion.FirstOrDefault(), Platform.FirstOrDefault(), ref error, ref versionRequired);

                if (isValidVersion)
                {
                    IEnumerable <string> key = null;
                    request.Headers.TryGetValues("authenticationKey", out key);
                    var consumerFb = ConsumerAuth.authenticateConsumer(key.FirstOrDefault().ToString());


                    if (consumerFb != null)
                    {
                        var tracking = gameBL.GetProgressGame(consumerFb.ConsumerID, ref error);

                        if (tracking != null)
                        {
                            responseApi.TotalWinCoins        = tracking.TotalWinCoins;
                            responseApi.TotalWinPrizes       = tracking.TotalWinPrizes;
                            responseApi.CurrentCoinsProgress = tracking.CurrentCoinsProgress;
                            responseApi.TotalSouvenirs       = tracking.TotalSouvenirs;
                            responseApi.AgeID    = tracking.AgeID;
                            responseApi.Nickname = tracking.Nickname;
                            return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, responseApi));
                        }
                        else
                        {
                            if (error == "")
                            {
                                return(Request.CreateResponse <IResponse>(HttpStatusCode.OK, responseApi));
                            }
                            else
                            {
                                response.HttpCode = 500;
                                response.Message  = "something went wrong";
                                return(Request.CreateResponse <IResponse>(HttpStatusCode.InternalServerError, response));
                            }
                        }
                    }
                    else
                    {
                        response.HttpCode = 404;
                        response.Message  = "Facebook information not found";
                        return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
                    }
                }
                else
                {
                    response.HttpCode     = 426;
                    response.InternalCode = versionRequired;
                    response.Message      = "Upgrade required";
                    return(Request.CreateResponse <IResponse>(HttpStatusCode.UpgradeRequired, response));
                }
            }
            else
            {
                response.HttpCode = 404;
                response.Message  = "Version or Platform parameter can not be null";
                return(Request.CreateResponse <IResponse>(HttpStatusCode.BadRequest, response));
            }
        }
Ejemplo n.º 18
0
        private void ProcessRequest(string truckRegistration, double latitude, double longitude, TrackingResponse response)
        {
            const string query =
                @"http://dev.virtualearth.net/REST/V1/Routes/Driving?o=json&wp.0={0},{1}&wp.1={2},{3}&rpo=Points&key={4}";
            var origin = new[] { 52.516071, 13.37698 };
            var uri    = new Uri(string.Format(query, latitude, longitude, origin[0], origin[1], GetKey()));

            var bingResponse = GetRouteDetails(uri);

            if (bingResponse.ResourceSets.Any() && bingResponse.ResourceSets[0].Resources.Any())
            {
                var routeDetails = bingResponse.ResourceSets[0].Resources[0] as Route;
                if (routeDetails != null)
                {
                    response.Distance          = routeDetails.TravelDistance;
                    response.Duration          = routeDetails.TravelDuration;
                    response.DistanceMetric    = routeDetails.DistanceUnit;
                    response.DurationMetric    = routeDetails.DurationUnit;
                    response.TruckRegistration = truckRegistration;

                    SendNotification(response);
                }
            }
        }
        public IHttpActionResult CheckPointSendNotic([FromBody] GetRequestDataRequests req)
        {
            int  stage;
            bool debugEmail = Convert.ToBoolean(ConfigurationManager.AppSettings["debugEmail"]);

            if (debugEmail == true)
            {
                MailCustom mailM = new MailCustom("*****@*****.**", "*****@*****.**", "bayernmunichm21");
                mailM.sendMail("DeviceDataChanged", JsonConvert.SerializeObject(req));
            }

            #region Check Token
            var    re          = Request;
            var    headers     = re.Headers;
            string tokenHeader = "";
            if (headers.Contains("Authorization"))
            {
                tokenHeader = headers.Authorization.Parameter;
            }
            DeTokenProperties detoken = new DeTokenProperties();
            detoken.inputIp    = GetUser_IP();
            detoken.inputToken = tokenHeader;
            if (!_authen.CheckToken(ref detoken))
            {
                return(Unauthorized());
            }
            #endregion

            try
            {
                TrackingResponse traksend    = new TrackingResponse();
                LogDatabase      updateLog   = new LogDatabase();
                CallService      callService = new CallService();

                int    countPosition = 0;
                string lastLatPoint, lastLonPoint, areaStatusInOut, lastDifCurrent, inOutSaveZone, a;
                string returnStatus = null;
                string nameTh       = string.Empty;
                string nameEn       = string.Empty;

                bool NoPosition = false;

                DataTable dtResultIden              = new DataTable();
                DataTable dtResultCallInOut         = new DataTable();
                DataTable dtUpdateDeviceCurrent     = new DataTable();
                DataTable dtInsertDataToLocationLog = new DataTable();
                DataTable dtReUpdateDeviceCurrent   = new DataTable();
                DataTable dtInsertActivityLog       = new DataTable();

                dtResultIden            = null;
                dtReUpdateDeviceCurrent = null;
                dtInsertActivityLog     = null;

                //ตรวจสอบข้อมูล เเละทำการส่ง SOS
                if (req.sos == 1)
                {
                    bool checkHaveTicket = callService.sosSend(req);
                }

                stage = 0;

                //ตรวจสอบมีจุดส่งมาหรือไม่ ถ้าไม่มีไม่ต้องไป Iden
                // ** จุดไม่มี , จุดมี
                if (req.position.Count() > 0)
                {
                    countPosition     = req.position.Count() - 1;
                    lastLatPoint      = req.position[countPosition].latitude.ToString();
                    lastLonPoint      = req.position[countPosition].longitude.ToString();
                    dtResultIden      = callService.Identify(lastLatPoint, lastLonPoint);
                    dtResultCallInOut = CheckInOutArea(lastLatPoint, lastLonPoint, req.deviceId);
                }
                else
                {
                    NoPosition   = true;
                    lastLatPoint = string.Empty;
                    lastLonPoint = string.Empty;
                    dtResultCallInOut.Columns.Add("AreaStatus");
                    dtResultCallInOut.Columns.Add("AreaId");
                    DataRow row = dtResultCallInOut.NewRow();
                    row["AreaStatus"] = null;
                    row["AreaId"]     = null;
                    dtResultCallInOut.Rows.Add(row);
                }

                if (dtResultCallInOut.Rows[0]["AreaStatus"].ToString() == "0" || dtResultCallInOut.Rows[0]["AreaStatus"].ToString() == null)
                {
                    dtResultCallInOut.Rows[0]["AreaStatus"] = DBNull.Value;
                }

                if (dtResultCallInOut.Rows[0]["AreaId"].ToString() == "0" || dtResultCallInOut.Rows[0]["AreaId"].ToString() == null)
                {
                    dtResultCallInOut.Rows[0]["AreaId"] = DBNull.Value;
                }


                //Call service :: Push Notification Event by Device
                // Online Offline
                dtInsertActivityLog = updateLog.InsertActivityLog(req, "onlineoffline", dtResultCallInOut.Rows[0]["AreaStatus"].ToString());
                bool dtPushEvent = callService.callMobilServiceEvent(dtInsertActivityLog);
                //battery Level

                dtInsertActivityLog = updateLog.InsertActivityLog(req, "baterryLevel", dtResultCallInOut.Rows[0]["AreaStatus"].ToString());
                dtPushEvent         = callService.callMobilServiceEvent(dtInsertActivityLog);

                // In out Area
                dtInsertActivityLog = updateLog.InsertActivityLog(req, "InoutArea", dtResultCallInOut.Rows[0]["AreaStatus"].ToString());
                dtPushEvent         = callService.callMobilServiceEvent(dtInsertActivityLog);

                stage = 4;

                // req : ตัวที่ได้มาจาก Raw data dtResultIden : ได้มาจาก Identify , NoPosition : ใช้ตรวจสอบว่ามี ตำแหน่งส่งมาหรือไม่ , dtResultCallInOut : ได้มาจากการ Update InoutArea , dtInsertActivityLog ได้มาจากตัว set Activitylog
                dtInsertDataToLocationLog = updateLog.InsertDataToLocationLog(req, dtResultIden, NoPosition, dtResultCallInOut);
                stage = 5;

                dtReUpdateDeviceCurrent = UpdateDeviceCurrent(dtResultIden, req, NoPosition, dtResultCallInOut);
                stage = 6;

                //การ set ค่า input status ที่จะส่งไปที่ signalR
                returnStatus = dtReUpdateDeviceCurrent.Rows[0]["AreaStatus"].ToString();

                if (dtResultIden != null)
                {
                    nameTh                = dtReUpdateDeviceCurrent.Rows[0]["locationNameTh"].ToString();
                    nameEn                = dtReUpdateDeviceCurrent.Rows[0]["locationNameEn"].ToString();
                    traksend.latitude     = Convert.ToDouble(dtReUpdateDeviceCurrent.Rows[0]["Latitude"]);
                    traksend.longitude    = Convert.ToDouble(dtReUpdateDeviceCurrent.Rows[0]["Longitude"]);
                    traksend.inout_status = returnStatus;

                    if (nameTh == "" || nameTh == null)
                    {
                        traksend.thai_address = dtReUpdateDeviceCurrent.Rows[0]["locationProvinceTh"].ToString() + "," + dtReUpdateDeviceCurrent.Rows[0]["locationDistrictTh"].ToString() + "," + dtReUpdateDeviceCurrent.Rows[0]["locationSubDistrictTh"].ToString();
                    }
                    else
                    {
                        traksend.thai_address = dtReUpdateDeviceCurrent.Rows[0]["locationNameTh"].ToString();
                    }

                    if (nameEn == "" || nameEn == null)
                    {
                        traksend.english_address = dtReUpdateDeviceCurrent.Rows[0]["locationProvinceEn"].ToString() + "," + dtReUpdateDeviceCurrent.Rows[0]["locationDistrictEn"].ToString() + "," + dtReUpdateDeviceCurrent.Rows[0]["locationSubDistrictEn"].ToString();
                    }
                    else
                    {
                        traksend.english_address = dtReUpdateDeviceCurrent.Rows[0]["locationNameEn"].ToString();
                    }

                    traksend.battery          = Convert.ToInt32(dtReUpdateDeviceCurrent.Rows[0]["BatteryLevel"]);
                    traksend.current_datetime = dtReUpdateDeviceCurrent.Rows[0]["Timestamp"].ToString();
                    traksend.online_status    = dtReUpdateDeviceCurrent.Rows[0]["OnlineStatus"].ToString();
                }
                else
                {   // ตรงนี้ไม่เข้านะ
                    if (countPosition > 0)
                    {
                        traksend.latitude        = Convert.ToDouble(req.position[countPosition].latitude);
                        traksend.longitude       = Convert.ToDouble(req.position[countPosition].longitude);
                        traksend.thai_address    = traksend.latitude.ToString() + "," + traksend.longitude.ToString();
                        traksend.english_address = traksend.latitude.ToString() + "," + traksend.longitude.ToString();

                        traksend.inout_status     = returnStatus;
                        traksend.battery          = Convert.ToInt32(req.batteryLevel);
                        traksend.current_datetime = req.position[countPosition].gpsDateTime.ToString();
                        traksend.online_status    = dtReUpdateDeviceCurrent.Rows[0]["OnlineStatus"].ToString();
                    }
                    else
                    {
                        traksend.latitude        = Convert.ToDouble(dtReUpdateDeviceCurrent.Rows[0]["Latitude"]);
                        traksend.longitude       = Convert.ToDouble(dtReUpdateDeviceCurrent.Rows[0]["Longitude"]);
                        traksend.thai_address    = dtReUpdateDeviceCurrent.Rows[0]["locationProvinceTh"].ToString() + "," + dtReUpdateDeviceCurrent.Rows[0]["locationDistrictTh"].ToString() + "," + dtReUpdateDeviceCurrent.Rows[0]["locationSubDistrictTh"].ToString();
                        traksend.english_address = dtReUpdateDeviceCurrent.Rows[0]["locationProvinceEn"].ToString() + "," + dtReUpdateDeviceCurrent.Rows[0]["locationDistrictEn"].ToString() + "," + dtReUpdateDeviceCurrent.Rows[0]["locationSubDistrictEn"].ToString();

                        traksend.battery          = Convert.ToInt32(req.batteryLevel);
                        traksend.inout_status     = returnStatus;
                        traksend.current_datetime = dtReUpdateDeviceCurrent.Rows[0]["Timestamp"].ToString();
                        traksend.online_status    = dtReUpdateDeviceCurrent.Rows[0]["OnlineStatus"].ToString();
                    }
                }

                //Call service :: Signal R
                bool Recalltrack = callService.CallTracking(traksend, req.imei);
                stage = 7;

                ReaponseNotic resPonse = new ReaponseNotic();
                resPonse.imei     = req.imei;
                resPonse.deviceId = req.deviceId;
                resPonse.stage    = stage;
                resPonse.userId   = req.userId;
                return(Ok(resPonse));
            }
            catch (Exception ex)
            {
                //MailCustom mailM = new MailCustom("*****@*****.**", "*****@*****.**", "gtpatchaya@005853");
                //mailM.sendMail("tamroi:error", ex.ToString());
                return(InternalServerError(ex));
            }
        }
        public void it_can_be_deserialized()
        {
            var expected = new TrackingResponse(new[]
            {
                new ConsignmentStatus(
                    "SHIPMENTNUMBER",
                    string.Empty,
                    16.5,
                    45.2,
                    new []
                {
                    new PackageStatus(
                        "Sendingen kan hentes på postkontor.",
                        "TESTPACKAGEATPICKUPPOINT",
                        string.Empty,
                        "KLIMANØYTRAL SERVICEPAKKE",
                        "1202",
                        "POSTEN",
                        41,
                        38,
                        29,
                        45.2,
                        16.5,
                        "AA11",
                        "01.12.2011",
                        "POSTEN NORGE AS",
                        new Address(
                            string.Empty,
                            string.Empty,
                            "1407",
                            "VINTERBRO",
                            string.Empty,
                            string.Empty
                            ),
                        new []
                    {
                        new TrackingEvent(
                            "Sendingen er ankommet postkontor",
                            "READY_FOR_PICKUP",
                            new RecipientSignature(string.Empty),
                            "122608",
                            new Uri("http://fraktguide.bring.no/fraktguide/api/pickuppoint/id/122608"),
                            "BRING",
                            "2341",
                            "LØTEN",
                            "NO",
                            "Norway",
                            DateTime.Parse("2010-10-01T08:30:25+02:00"),
                            "01.10.2010",
                            "08:30",
                            false,
                            Enumerable.Empty <TrackingEventDefinition>()
                            ),
                        new TrackingEvent(
                            "Sendingen er innlevert til terminal og videresendt",
                            "IN_TRANSIT",
                            new RecipientSignature(string.Empty),
                            "032850",
                            null,
                            "BRING",
                            "0024",
                            "OSLO",
                            "NO",
                            "Norway",
                            DateTime.Parse("2010-09-30T08:27:08+02:00"),
                            "30.09.2010",
                            "08:27",
                            false,
                            new []
                        {
                            new TrackingEventDefinition(
                                "terminal",
                                "Brev, pakke eller godsterminal som benyttes til sortering  og omlasting av sendinger som er underveis til mottaker."
                                )
                        })
                    })
                })
            });

            var actual = JsonConvert.DeserializeObject <TrackingResponse>(SuccessJsonResponse);

            expected.Should().BeEquivalentTo(actual);
        }
Ejemplo n.º 21
0
 private static void Print(TrackingResponse trackingResponse)
 {
     Console.WriteLine($"At: {trackingResponse.TrackingTime}, Latitude: {trackingResponse.Latitude}, Longitude: {trackingResponse.Longitude}");
 }