/// <summary> /// 添加合同 /// </summary> public void add() { ContractAddRequest contractAddRequest = new ContractAddRequest(); contractAddRequest.name = "合同测试"; contractAddRequest.user_id = "00765245060136194048"; contractAddRequest.description = "这是个新加合同"; contractAddRequest.file_id = "0026adc7ba67382d02e7e5a4502ca90e"; try { ContractAddResponse response = client.Contract.add(contractAddRequest); Console.WriteLine("添加合同-响应数据:" + JSONUtil.getJsonStringFromObject(response)); } catch (SignApplicationException sae) { // 捕获网关校验数据 Console.WriteLine("添加合同-网关异常状态码为:" + sae.return_code); Console.WriteLine("添加合同-网关异常信息为:" + sae.return_message); } catch (SignServerException sse) { // 捕获网关校验数据 Console.WriteLine("添加合同-业务异常状态码为:" + sse.result_code); Console.WriteLine("添加合同-业务异常信息为:" + sse.result_message); } }
/// <summary> /// 合同添加接口 /// </summary> /// <param name="contractAddRequest"></param> /// <returns></returns> public ContractAddResponse add(ContractAddRequest contractAddRequest) { SignRequest signRequest = new SignRequest(contractAddRequest); signRequest.apiUrl = ApiUrlConstant.Contract.Add; ContractAddResponse response = base.Send <ContractAddResponse>(signRequest); return(response); }
/// <summary> /// 合同添加并添加合同文件 /// </summary> /// <param name="contractFileAddRequest"></param> /// <returns></returns> public ContractAddResponse addContractAndFile(ContractFileAddRequest contractFileAddRequest) { //上传合同文件 FileUploadRequest fileUploadRequest = contractFileAddRequest.fileUploadRequest; fileUploadRequest.fileType = FileType.contract; FileUploadResponse fileUploadResponse = base.fileUpload(fileUploadRequest); //添加合同 ContractAddRequest contractAddRequest = contractFileAddRequest.contractAddRequest; contractAddRequest.file_id = fileUploadResponse.file_id; SignRequest signRequest = new SignRequest(contractAddRequest); signRequest.apiUrl = ApiUrlConstant.Contract.Add; ContractAddResponse response = base.Send <ContractAddResponse>(signRequest); return(response); }
/// <summary> /// 合同添加并添加合同文件 /// </summary> public void addContractAndFile() { // 创建合同以及文件 ContractFileAddRequest contractFileAddRequest = new ContractFileAddRequest(); // 合同请求数据 ContractAddRequest contractAddRequest = new ContractAddRequest(); contractAddRequest.name = "合同测试"; contractAddRequest.user_id = "00765245060136194048"; contractAddRequest.description = "这是个新加合同"; contractFileAddRequest.contractAddRequest = contractAddRequest; try { //合同文件上传 FileUploadRequest fileUploadRequest = new FileUploadRequest("D://contract//我的合同.pdf", "我的合同.pdf", FileType.contract, "00765245060136194048"); contractFileAddRequest.fileUploadRequest = fileUploadRequest; ContractAddResponse response = client.Contract.addContractAndFile(contractFileAddRequest); Console.WriteLine("合同以及文件添加-响应数据:" + JSONUtil.getJsonStringFromObject(response)); } catch (SignApplicationException sae) { // 捕获网关校验数据 Console.WriteLine("合同以及文件添加-网关异常状态码为:" + sae.return_code); Console.WriteLine("合同以及文件添加-网关异常信息为:" + sae.return_message); } catch (SignServerException sse) { // 捕获网关校验数据 Console.WriteLine("合同以及文件添加-业务异常状态码为:" + sse.result_code); Console.WriteLine("合同以及文件添加-业务异常信息为:" + sse.result_message); } catch (Exception e) { Console.WriteLine("合同以及文件添加-异常为:" + e.Message); } }