예제 #1
0
        /// <summary>
        /// Get the response from EBS webservice
        /// </summary>
        /// <param name="url">url where need to post data</param>
        /// <param name="content">data in jSon string format</param>
        /// <param name="lstHeaders">http header required to make request to EBS</param>
        /// <param name="Method">Type of request ..POST in this case</param>
        /// <returns>Response in jSon string</returns>
        public static string Get(string url, string content, string Method)
        {
            string strResponse = "";

            try
            {
                using (var request = new WebServiceRequest(Method))
                {
                    request.Encoding = Encoding.UTF8;
                    request.Headers.Add("Accept", "application/json");
                    request.Headers.Add("Content-Type", "application/json");
                    // request.Headers.Add("connection", "close");
                    if (content == "")
                    {
                        strResponse = request.DownloadString(url);
                    }
                    else
                    {
                        strResponse = request.UploadString(url, content);
                    }
                }
            }
            catch (WebException w)
            {
                System.Windows.Forms.MessageBox.Show(w.Message);
            }
            catch (Exception e)
            {
                System.Windows.Forms.MessageBox.Show(e.Message);
            }
            return(strResponse);
        }
예제 #2
0
        /// <summary>
        /// Get required details to build WebRequest
        /// </summary>
        /// <param name="partNumber"></param>
        /// <param name="partQty"></param>
        /// <param name="incidentRecord"></param>
        /// <param name="partsOrderID"></param>
        public void GetDetails(List <OELINEREC> lineRecords, IIncident incidentRecord, int numOfVIN, POEHEADERREC partsHeaderRecord,
                               int shipToSiteID, int partOdrInstrID)
        {
            _incidentRecord    = incidentRecord;
            _lineRecords       = lineRecords;
            _partsHeaderRecord = partsHeaderRecord;

            //If all required info is valid then form jSon request parameter
            var content     = GetReqParam();
            var jsonContent = WebServiceRequest.JsonSerialize(content);

            jsonContent = jsonContent.Replace("xmlns", "@xmlns");

            //Call webservice
            string jsonResponse = WebServiceRequest.Get(_curlURL, jsonContent, "POST");

            if (jsonResponse == "")
            {
                //Destroy the partsorder objects
                _rnConnectService.DestroyPartsOrder(_lineRecords);
                ReportCommandAddIn.form.Hide();
                MessageBox.Show("Server didn't return any info");
            }
            else
            {
                ExtractResponse(jsonResponse, numOfVIN, shipToSiteID, partOdrInstrID);
            }
        }