示例#1
0
        private StatusInfoCollection GetStatus(string eSalesDocument)
        {
            // Get Order Satus By eSalesDocumentNumber
            sapGetStatusURL = sapGetStatusURL + "?$filter=Salesdocument eq '{0}'&$format=json";
            string          requestURL = string.Format(sapGetStatusURL, eSalesDocument);
            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;
            StatusInfoCollection collection = null;

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

                    csrfToken     = response.Headers.GetValues("X-CSRF-TOKEN").FirstOrDefault();
                    setCookie     = response.Headers.Get("Set-Cookie");
                    cookiestopass = response.Cookies;
                }
            }

            return(collection);
        }
示例#2
0
        public Order GetStatusFromSAP(string eSalesDocument)
        {
            Order order = new Order();

            try
            {
                // Get Status Info Collection
                StatusInfoCollection statusCollection = GetStatus(eSalesDocument);

                // Map Status to Order Data
            }
            catch (Exception ex)
            {
                if (ex.Message.Contains("(400)"))
                {
                    // Bad Request. There is some error on the Input
                }
                throw;
            }

            return(order);
        }