From 9a717144ef086a92a34adfc0763dfa9f6cb4b0ba Mon Sep 17 00:00:00 2001 From: Li Jun <buli@deloitte.com.cn> Date: 星期六, 12 三月 2022 16:54:21 +0800 Subject: [PATCH] Merge PIPL Function code 20220311 --- force-app/main/default/classes/PIHelper.cls | 17 +++++++++++++---- 1 files changed, 13 insertions(+), 4 deletions(-) diff --git a/force-app/main/default/classes/PIHelper.cls b/force-app/main/default/classes/PIHelper.cls index 48cc2cd..a1217ab 100644 --- a/force-app/main/default/classes/PIHelper.cls +++ b/force-app/main/default/classes/PIHelper.cls @@ -18,19 +18,22 @@ } } // confirm file transaction - @future(callout =true) + // @future(callout =true) public static void confirmFileTrans(String module,Integer isSuccess, String sfRecordId ,String transId ,String token,String transUrl){ Boolean result =false; Transaction_Log__c traLog = new Transaction_Log__c(); traLog.Module__c = 'ConfirmFileTransaction '+module; traLog.Interface_URL__c = transUrl; traLog.TransId__c = transId; - traLog.SFRecordId__c=sfRecordId; + // traLog.SFRecordId__c=sfRecordId; + Integer MaxLogColumnLength = 131072; try { Http http = new Http(); HttpRequest request = new HttpRequest(); request.setEndpoint(transUrl); request.setMethod('POST'); + request.setHeader('pi-token',token); + request.setHeader('Content-Type', 'application/json'); TransRequestBody requestBody =new TransRequestBody(); requestBody.isSuccess=isSuccess; requestBody.sfRecordId=sfRecordId; @@ -44,7 +47,9 @@ result = (Boolean)results.get('success'); System.debug('result = ' + result); traLog.Status__c = 'success'; - traLog.Response__c=response.getBody(); + String res=response.getBody(); + traLog.Response__c=res.substring(0, (res.length() > MaxLogColumnLength ? MaxLogColumnLength : res.length())); + } catch (Exception e) { traLog.Status__c = 'fail'; traLog.Response__c = e.getMessage(); @@ -59,6 +64,7 @@ traLog.Module__c = 'Confirm Transaction '+module; traLog.Interface_URL__c = transUrl; traLog.TransId__c = transId; + Integer MaxLogColumnLength = 131072; if (!String.isEmpty(sfRecordId)) { traLog.SFRecordId__c=sfRecordId; }else { @@ -70,6 +76,8 @@ HttpRequest request = new HttpRequest(); request.setEndpoint(transUrl); request.setMethod('POST'); + request.setHeader('pi-token',token); + request.setHeader('Content-Type', 'application/json'); TransactionRequestBody requestBody =new TransactionRequestBody(); requestBody.isSuccess=isSuccess; requestBody.sfRecordId=sfRecordId; @@ -83,7 +91,8 @@ result = (Boolean)results.get('success'); System.debug('result = ' + result); traLog.Status__c = 'success'; - traLog.Response__c=response.getBody(); + String res=response.getBody(); + traLog.Response__c=res.substring(0, (res.length() > MaxLogColumnLength ? MaxLogColumnLength : res.length())); } catch (Exception e) { traLog.Status__c = 'fail'; traLog.Response__c = e.getMessage(); -- Gitblit v1.9.1