/// <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); }
public WebServiceRequest(string method) { Timeout = 900000; Method = method; _rnConnectService = RightNowConnectService.GetService(); string webServiceLoginValue = _rnConnectService.GetConfigValue("CUSTOM_CFG_EBS_WS_LOGIN"); if (webServiceLoginValue != null) { var s = new JavaScriptSerializer(); var loginValue = s.Deserialize <WebServiceLoginCredential>(webServiceLoginValue); _userName = loginValue.UserName; _password = loginValue.Password; } }
public static RightNowConnectService GetService() { if (_rightnowConnectService != null) { return(_rightnowConnectService); } try { lock (_sync) { if (_rightnowConnectService == null) { // Initialize client with current interface soap url string url = WorkspaceAddIn._globalContext.GetInterfaceServiceUrl(ConnectServiceType.Soap); EndpointAddress endpoint = new EndpointAddress(url); BasicHttpBinding binding = new BasicHttpBinding(BasicHttpSecurityMode.TransportWithMessageCredential); binding.Security.Message.ClientCredentialType = BasicHttpMessageCredentialType.UserName; // Optional depending upon use cases binding.MaxReceivedMessageSize = 1024 * 1024; binding.MaxBufferSize = 1024 * 1024; binding.MessageEncoding = WSMessageEncoding.Mtom; _rightNowClient = new RightNowSyncPortClient(binding, endpoint); BindingElementCollection elements = _rightNowClient.Endpoint.Binding.CreateBindingElements(); elements.Find <SecurityBindingElement>().IncludeTimestamp = false; _rightNowClient.Endpoint.Binding = new CustomBinding(elements); WorkspaceAddIn._globalContext.PrepareConnectSession(_rightNowClient.ChannelFactory); _rightnowConnectService = new RightNowConnectService(); } } } catch (Exception e) { _rightnowConnectService = null; MessageBox.Show(e.Message); } return(_rightnowConnectService); }
public SupplierCreditModel() { _rnConnectService = RightNowConnectService.GetService(); string partsOrderConfigValue = _rnConnectService.GetConfigValue("CUSTOM_CFG_SUPPLIER_CREDIT"); if (partsOrderConfigValue != null) { var s = new JavaScriptSerializer(); var configVerb = s.Deserialize <WebServiceConfigVerbs.RootObject>(partsOrderConfigValue); _curlURL = configVerb.URL; _headerURL = configVerb.xmlns; _xmlnsURL = configVerb.RESTHeader.xmlns; _respApplication = configVerb.RESTHeader.RespApplication; _responsibility = configVerb.RESTHeader.Responsibility; _securityGroup = configVerb.RESTHeader.SecurityGroup; _nlsLanguage = configVerb.RESTHeader.NLSLanguage; _orgID = configVerb.RESTHeader.Org_Id; } }
/// <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); } }