Пример #1
0
        /// <summary>
        /// 下载合同接口。调用该接口可以下载签署中和签署完成的合同。接口返回任务号,可调用DescribeTaskStatus接口查看任务执行结果。
        /// </summary>
        /// <param name="req"><see cref="DownloadContractRequest"/></param>
        /// <returns><see cref="DownloadContractResponse"/></returns>
        public DownloadContractResponse DownloadContractSync(DownloadContractRequest req)
        {
            JsonResponseModel <DownloadContractResponse> rsp = null;

            try
            {
                var strResp = this.InternalRequestSync(req, "DownloadContract");
                rsp = JsonConvert.DeserializeObject <JsonResponseModel <DownloadContractResponse> >(strResp);
            }
            catch (JsonSerializationException e)
            {
                throw new TencentCloudSDKException(e.Message);
            }
            return(rsp.Response);
        }
Пример #2
0
        /// <summary>
        /// 下载已签约/已存证文件
        /// </summary>
        /// <param name="client"></param>
        /// <param name="contractId">合同编号</param>
        /// <param name="filePath">文件的保存路径</param>
        /// <returns></returns>
        public void Download(SDKClient client, string contractId, string filePath)
        {
            DownloadContractRequest request = new DownloadContractRequest(contractId);

            try
            {
                Stream outputStream = new MemoryStream();
                client.Download(request, ref outputStream);

                MemoryStream memoryStream = (MemoryStream)outputStream;
                FileStream   fs           = new FileStream(filePath, FileMode.Create);
                BinaryWriter w            = new BinaryWriter(fs);
                w.Write(memoryStream.ToArray());
                fs.Close();
                memoryStream.Close();
            }
            catch (Exception e)
            {
                throw new Exception("取回文件失败,失败原因: " + e.Message);
            }
        }