Esempio n. 1
0
        public SkyPostalTrackingModel MappingTracking(string trackingNumber)
        {
            SkyPostalTrackingModel track = new SkyPostalTrackingModel()
            {
                copa_id  = 665,
                extr_nmr = trackingNumber,
                Key      = "ok",
                lang_cdg = "ENG",
                method   = "search_tracking_info_by_external_tracking"
            };

            return(track);
        }
Esempio n. 2
0
        public SkyPostalTrackingResponseModel SkyPostalTrackWebApiCalling(SkyPostalTrackingModel trackModel)
        {
            SkyPostalTrackingResponseModel result = new SkyPostalTrackingResponseModel();
            string response = string.Empty;

            try
            {
                var logisticIntegration = UtilityRepository.getLogisticIntegration(UtilityRepository.GetOperationZone().OperationZoneId, AppSettings.ApplicationMode, FrayteIntegration.SKYPOSTAL);

                var skyPostalJson = Newtonsoft.Json.JsonConvert.SerializeObject(trackModel);

                WebClient client = new WebClient();
                client.UseDefaultCredentials         = true;
                client.Credentials                   = CredentialCache.DefaultCredentials;
                ServicePointManager.SecurityProtocol = SecurityProtocolType.Ssl3;
                SslProtocols         _Tls12 = (SslProtocols)0x00000C00;
                SecurityProtocolType Tls12  = (SecurityProtocolType)_Tls12;
                ServicePointManager.SecurityProtocol = Tls12;

                response = client.UploadString(logisticIntegration.ServiceUrl, "POST", skyPostalJson);
                if (!string.IsNullOrWhiteSpace(response))
                {
                    result = Newtonsoft.Json.JsonConvert.DeserializeObject <SkyPostalTrackingResponseModel>(response);
                }
                else
                {
                    result = null;
                }
            }
            catch (Exception ex)
            {
                result = null;
            }

            return(result);
        }