示例#1
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);
        }
示例#2
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);
            }
        }