Example #1
0
        private UnloadPtCollection GetUnloadingPoints(string ShipToNumber)
        {
            // https://gq1.sap.sca.se:443/sap/opu/odata/sap/ZSD_UNLOADING_POINT_SRV/KunnrSet?$expand=Kun2UnloadNav&$filter=IKunnr eq '0000329780'
            // Get Unloading Points By ShiptoNumber

            string          requestURL = string.Format(sapGetUnLoadingPointsURL, ShipToNumber) + "&$format=json";
            HttpWebRequest  req        = (HttpWebRequest)WebRequest.Create(requestURL);
            HttpWebResponse resp; // No Use

            req.Credentials = new NetworkCredential(sapUserName, sapPassword);
            req.Method      = "GET";
            req.Headers.Add("X-CSRF-Token", "Fetch");
            req.Proxy.Credentials = System.Net.CredentialCache.DefaultCredentials;
            cookieJar             = new CookieContainer();
            // req.CookieContainer = cookieJar;
            UnloadPtCollection collection = null;

            using (HttpWebResponse response = (HttpWebResponse)req.GetResponse())
            {
                if (response.StatusCode == HttpStatusCode.OK)
                {
                    var rawJson = new StreamReader(response.GetResponseStream()).ReadToEnd();
                    collection = JsonConvert.DeserializeObject <UnloadPtCollection>(rawJson);

                    csrfToken     = response.Headers.GetValues("X-CSRF-TOKEN").FirstOrDefault();
                    setCookie     = response.Headers.Get("Set-Cookie");
                    cookiestopass = response.Cookies;
                }
            }
            return(collection);
        }
Example #2
0
        public List <UnloadingPoint> GetUnloadingPointsFromSAP(string shipToNumber)
        {
            List <UnloadingPoint> unloadingPointList = new List <UnloadingPoint>();

            try
            {
                UnloadPtCollection unloadingPoints = GetUnloadingPoints(shipToNumber);

                foreach (var item in unloadingPoints.d.results)
                {
                    foreach (var innerItem in item.Kun2UnloadNav.results)
                    {
                    }
                }
                // TODO: Map unloading Points
            }
            catch (Exception)
            {
                throw;
            }

            return(unloadingPointList);
        }