Пример #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>
        /// Funtion which gets call to handle ebs webservice response
        /// </summary>
        /// <param name="respJson">response in jSON string</param>
        /// <param name="woAddin">WorkspaceAddin instance</param>
        public void ExtractResponse(string respJson, WorkspaceAddIn woAddin)
        {
            // decode the Json response
            respJson = respJson.Replace("@xmlns:xsi", "@xmlns_xsi");
            respJson = respJson.Replace("@xsi:nil", "@xsi_nil");
            Dictionary <string, object> data        = (Dictionary <string, object>)WebServiceRequest.JsonDeSerialize(respJson);
            Dictionary <string, object> output      = (Dictionary <string, object>)data["OutputParameters"];
            Dictionary <string, object> cmReturnTbl = (Dictionary <string, object>)output["P_CM_RETURN_TBL"];

            //update supplier credit record info
            RightNowConnectService.GetService().upadteSupplierCredit((object[])cmReturnTbl["P_CM_RETURN_TBL_ITEM"], _supplierCreditIDs);
        }
Пример #3
0
        /// <summary>
        /// Method which is called to get casual supplier credit memo info
        /// </summary>
        /// <param name="wsAddin">WorkspaceAddin instance</param>
        public void GetSupplierCreditInfo(WorkspaceAddIn wsAddin)
        {
            try
            {
                _wsAddinObject = wsAddin;
                string operatingUnit = "";
                string busInfo       = "";
                //Get Incident Type
                string incType = _wsAddinObject.GetIncidentField("c", "Incident Type");
                if (incType == "30")//case of claim type, bus is stored at incident parent level
                {
                    string busID = _wsAddinObject.GetIncidentField("CO", "Bus");
                    if (busID != "")
                    {
                        //Get Customer ID and VIN
                        busInfo = _rnConnectService.GetBusInfo(Convert.ToInt32(busID), _wsAddinObject._sClaimRecord.Id);
                    }
                }
                else// Case of reported Inc, then BUS is stored at incident_vin level
                {
                    //Get Customer ID and VIN
                    busInfo = _rnConnectService.GetBusInfo(0, _wsAddinObject._sClaimRecord.Id);//Customer ID and VIN
                }

                string sClaimOrgID = _wsAddinObject.GetsClaimField("Organization");//Supplier ID

                string sClaimRefNum = _wsAddinObject.GetsClaimField("sclaim_ref_num");

                string[] supplierCredits = RightNowConnectService.GetService().GetSupplierCreditInfo(_wsAddinObject._sClaimRecord.Id);

                if (supplierCredits == null)
                {
                    _wsAddinObject.InfoLog("No new Credit Memo found");
                    return;
                }
                List <PCMHEADERREC> cmRecordList = new List <PCMHEADERREC>(); //credit memo record list
                foreach (string supplierCredit in supplierCredits)            //loop over all credit memo mapped with sClaim
                {
                    string[] supplierCreditInfo = supplierCredit.Split('~');
                    if (supplierCreditInfo[6] == "NFA")
                    {
                        operatingUnit = "SCL";
                    }
                    else if (supplierCreditInfo[6] == "NFI")
                    {
                        operatingUnit = "WPR";
                    }
                    else
                    {
                        wsAddin.InfoLog("'Credit To' is not set in supplier credit record");
                        return;
                    }
                    string supplierInfo = _rnConnectService.GetSupplierInfo(Convert.ToInt32(sClaimOrgID), operatingUnit);
                    if (supplierInfo == null)
                    {
                        wsAddin.InfoLog("No Info found for pay site");
                        return;
                    }

                    _supplierCreditIDs.Add(Convert.ToInt32(supplierCreditInfo[5])); // store the supplier credit record ids

                    PCMHEADERREC cmRecord = new PCMHEADERREC();                     //credit memo record
                    if (supplierCreditInfo[1] != "")
                    {
                        cmRecord.CLAIM_AMOUNT = Convert.ToDouble(supplierCreditInfo[1]);
                    }
                    cmRecord.VIN_NUMBER     = busInfo.Split('~')[1];
                    cmRecord.CREDIT_MEMO_NO = supplierCreditInfo[0];
                    cmRecord.CURRENCY       = supplierCreditInfo[2];
                    cmRecord.CUSTOMER_ID    = Convert.ToInt32(busInfo.Split('~')[0]);
                    cmRecord.SCLAIM_NO      = sClaimRefNum;
                    if (supplierCreditInfo[3] != "")
                    {
                        cmRecord.TAX_AMOUNT = Convert.ToDouble(supplierCreditInfo[3]);
                    }
                    cmRecord.TAX_CODE         = supplierCreditInfo[4];
                    cmRecord.SUPPLIER_ID      = Convert.ToInt32(supplierInfo.Split('~')[0]);
                    cmRecord.SUPPLIER_SITE_ID = Convert.ToInt32(supplierInfo.Split('~')[1]);

                    cmRecordList.Add(cmRecord);
                }
                var content = GetRequestParam(cmRecordList);

                //Call supplier Credit web-service
                var jsonContent = WebServiceRequest.JsonSerialize(content);
                jsonContent = jsonContent.Replace("xmlns", "@xmlns");
                string jsonResponse = WebServiceRequest.Get(_curlURL, jsonContent, "POST");

                if (jsonResponse == "")
                {
                    wsAddin.InfoLog("Server didn't returned any info");
                    return;
                }
                else
                {
                    ExtractResponse(jsonResponse, wsAddin);
                }
            }
            catch (Exception ex)
            {
                wsAddin.InfoLog(ex.Message);
            }
        }