/// <summary> /// 获取预览页URL /// </summary> /// <param name="contractId"></param> /// <returns></returns> public BaseResult <GetPreviewURLResult> GetPreviewURL(string contractId, string expireTime, string dpi = "", string account = "") { Dictionary <string, object> requestParams = new Dictionary <string, object>(); requestParams.Add("contractId", contractId); requestParams.Add("expireTime", expireTime); if (string.IsNullOrWhiteSpace(dpi)) { requestParams.Add("dpi", dpi); } if (string.IsNullOrWhiteSpace(account)) { requestParams.Add("account", account); } SortedDictionary <string, object> keyValues = new SortedDictionary <string, object>(); keyValues.Add("developerId", Constants.DeveloperID); keyValues.Add("rtick", SignUtils.ToUnixEpochDate(DateTime.Now).ToString() + SignUtils.ToRandom(1000, 9999)); keyValues.Add("signType", Constants.SignType); var signResult = SignUtils.GenerateSign(Constants.Path + Constants.Contract_GetPreviewURL, "", keyValues); var signEncryResult = RSAEncryption.SignData(signResult, Constants.PrivateKey); var signEncodeResult = SignUtils.SignUrlEncode(signEncryResult); keyValues.Add("sign", signEncodeResult); var originalUrl = Constants.Host + Constants.Path + Constants.Contract_GetPreviewURL; var requestUrl = SignUtils.GenerateUrl(originalUrl, keyValues); BaseResult <GetPreviewURLResult> result = httpService.HttpPost <BaseResult <GetPreviewURLResult> >(requestUrl, requestParams); return(result); }
/// <summary> /// 获取合同签署参数 /// </summary> /// <param name="contractId">合同编号</param> /// <param name="account">签署者</param> /// <returns></returns> public BaseResult <GetSignerConfigResult> GetSignerConfig(string contractId, string account) { Dictionary <string, object> requestParams = new Dictionary <string, object>(); requestParams.Add("contractId", contractId); requestParams.Add("account", account); SortedDictionary <string, object> keyValues = new SortedDictionary <string, object>(); keyValues.Add("developerId", Constants.DeveloperID); keyValues.Add("rtick", SignUtils.ToUnixEpochDate(DateTime.Now).ToString() + SignUtils.ToRandom(1000, 9999)); keyValues.Add("signType", Constants.SignType); var signResult = SignUtils.GenerateSign(Constants.Path + Constants.Contract_GetSignerConfig, SignUtils.GenerateMD5(requestParams), keyValues); var signEncryResult = RSAEncryption.SignData(signResult, Constants.PrivateKey); var signEncodeResult = SignUtils.SignUrlEncode(signEncryResult); keyValues.Add("sign", signEncodeResult); var originalUrl = Constants.Host + Constants.Path + Constants.Contract_GetSignerConfig; var requestUrl = SignUtils.GenerateUrl(originalUrl, keyValues); BaseResult <GetSignerConfigResult> result = httpService.HttpPost <BaseResult <GetSignerConfigResult> >(requestUrl, requestParams); return(result); }
/// <summary> /// 异步申请状态查询 /// </summary> /// <param name="account">用户唯一标识</param> /// <param name="taskId">任务单号</param> /// <returns></returns> public BaseResult <AsyncApplyCertStatusResult> AsyncApplyCertStatus(string account, string taskId) { Dictionary <string, object> requestParams = new Dictionary <string, object>(); requestParams.Add("account", account); requestParams.Add("taskId", taskId); SortedDictionary <string, object> keyValues = new SortedDictionary <string, object>(); keyValues.Add("developerId", Constants.DeveloperID); keyValues.Add("rtick", SignUtils.ToUnixEpochDate(DateTime.Now).ToString() + SignUtils.ToRandom(1000, 9999)); keyValues.Add("signType", Constants.SignType); var signResult = SignUtils.GenerateSign(Constants.Path + Constants.User_Async_ApplyCert_Status, SignUtils.GenerateMD5(requestParams), keyValues); var signEncryResult = RSAEncryption.SignData(signResult, Constants.PrivateKey); var signEncodeResult = SignUtils.SignUrlEncode(signEncryResult); keyValues.Add("sign", signEncodeResult); var originalUrl = Constants.Host + Constants.Path + Constants.User_Async_ApplyCert_Status; var requestUrl = SignUtils.GenerateUrl(originalUrl, keyValues); BaseResult <AsyncApplyCertStatusResult> result = httpService.HttpPost <BaseResult <AsyncApplyCertStatusResult> >(requestUrl, requestParams); return(result); }
/// <summary> /// 注册个人用户并申请证书 | 注册企业用户并申请证书 /// </summary> /// <param name="account">用户唯一标识</param> /// <param name="name">用户名称</param> /// <param name="userType">用户类型</param> /// <param name="credential">用户证件信息对象</param> /// <param name="applyCert"></param> /// <param name="mail">用户邮箱</param> /// <param name="mobile">用户手机号</param> /// <returns></returns> public BaseResult <RegResult> Reg(string account, string name, string userType, object credential, string applyCert, string mail = "", string mobile = "") { Dictionary <string, object> requestParams = new Dictionary <string, object>(); requestParams.Add("account", account); requestParams.Add("name", name); requestParams.Add("userType", userType); requestParams.Add("mail", mail); requestParams.Add("mobile", mobile); requestParams.Add("credential", credential); requestParams.Add("applyCert", applyCert); SortedDictionary <string, object> keyValues = new SortedDictionary <string, object>(); keyValues.Add("developerId", Constants.DeveloperID); keyValues.Add("rtick", SignUtils.ToUnixEpochDate(DateTime.Now).ToString() + SignUtils.ToRandom(1000, 9999)); keyValues.Add("signType", Constants.SignType); var signResult = SignUtils.GenerateSign(Constants.Path + Constants.User_Reg, SignUtils.GenerateMD5(requestParams), keyValues); var signEncryResult = RSAEncryption.SignData(signResult, Constants.PrivateKey); var signEncodeResult = SignUtils.SignUrlEncode(signEncryResult); keyValues.Add("sign", signEncodeResult); var originalUrl = Constants.Host + Constants.Path + Constants.User_Reg; var requestUrl = SignUtils.GenerateUrl(originalUrl, keyValues); BaseResult <RegResult> result = httpService.HttpPost <BaseResult <RegResult> >(requestUrl, requestParams); return(result); }
/// <summary> /// 上传用户签名/印章图片 /// </summary> /// <param name="account">用户唯一标识</param> /// <param name="imageData">图片文件内容</param> /// <param name="imageName">签名/印章图片名称</param> /// <returns></returns> public BaseResult <CommonResult> UserUpload(string account, string imageData, string imageName = "") { Dictionary <string, object> requestParams = new Dictionary <string, object>(); requestParams.Add("account", account); requestParams.Add("imageData", imageData); if (string.IsNullOrWhiteSpace(imageName)) { requestParams.Add("imageName", imageName); } SortedDictionary <string, object> keyValues = new SortedDictionary <string, object>(); keyValues.Add("developerId", Constants.DeveloperID); keyValues.Add("rtick", SignUtils.ToUnixEpochDate(DateTime.Now).ToString() + SignUtils.ToRandom(1000, 9999)); keyValues.Add("signType", Constants.SignType); var signResult = SignUtils.GenerateSign(Constants.Path + Constants.SignatureImage_User_Upload, SignUtils.GenerateMD5(requestParams), keyValues); var signEncryResult = RSAEncryption.SignData(signResult, Constants.PrivateKey); var signEncodeResult = SignUtils.SignUrlEncode(signEncryResult); keyValues.Add("sign", signEncodeResult); var originalUrl = Constants.Host + Constants.Path + Constants.SignatureImage_User_Upload; var requestUrl = SignUtils.GenerateUrl(originalUrl, keyValues); BaseResult <CommonResult> result = httpService.HttpPost <BaseResult <CommonResult> >(requestUrl, requestParams); return(result); }
/// <summary> /// 上传合同文件 /// </summary> /// <param name="account">用户唯一标识</param> /// <param name="fdata">文件数据,base64编码</param> /// <param name="fmd5">文件md5值</param> /// <param name="ftype">文件类型</param> /// <param name="fname">文件名</param> /// <param name="fpages">文件页数</param> /// <returns></returns> public BaseResult <StorageUploadResult> Upload(string account, string fdata, string fmd5, string ftype, string fname, int fpages) { Dictionary <string, object> requestParams = new Dictionary <string, object>(); requestParams.Add("account", account); requestParams.Add("fdata", fdata); requestParams.Add("fmd5", fmd5); requestParams.Add("ftype", ftype); requestParams.Add("fname", fname); requestParams.Add("fpages", fpages); SortedDictionary <string, object> keyValues = new SortedDictionary <string, object>(); keyValues.Add("developerId", Constants.DeveloperID); keyValues.Add("rtick", SignUtils.ToUnixEpochDate(DateTime.Now).ToString() + SignUtils.ToRandom(1000, 9999)); keyValues.Add("signType", Constants.SignType); var signResult = SignUtils.GenerateSign(Constants.Path + Constants.Storage_Upload, SignUtils.GenerateMD5(requestParams), keyValues); var signEncryResult = RSAEncryption.SignData(signResult, Constants.PrivateKey); var signEncodeResult = SignUtils.SignUrlEncode(signEncryResult); keyValues.Add("sign", signEncodeResult); var originalUrl = Constants.Host + Constants.Path + Constants.Storage_Upload; var requestUrl = SignUtils.GenerateUrl(originalUrl, keyValues); BaseResult <StorageUploadResult> result = httpService.HttpPost <BaseResult <StorageUploadResult> >(requestUrl, requestParams); return(result); }
/// <summary> /// PDF文件验签 /// </summary> /// <param name="pdfData">PDF文件</param> /// <returns></returns> public BaseResult <PDFVerifySignaturesResult> VerifySignatures(string pdfData) { Dictionary <string, object> requestParams = new Dictionary <string, object>(); requestParams.Add("pdfData", pdfData); SortedDictionary <string, object> keyValues = new SortedDictionary <string, object>(); keyValues.Add("developerId", Constants.DeveloperID); keyValues.Add("rtick", SignUtils.ToUnixEpochDate(DateTime.Now).ToString() + SignUtils.ToRandom(1000, 9999)); keyValues.Add("signType", Constants.SignType); var signResult = SignUtils.GenerateSign(Constants.Path + Constants.Pdf_VerifySignatures, "", keyValues); var signEncryResult = RSAEncryption.SignData(signResult, Constants.PrivateKey); var signEncodeResult = SignUtils.SignUrlEncode(signEncryResult); keyValues.Add("sign", signEncodeResult); var originalUrl = Constants.Host + Constants.Path + Constants.Pdf_VerifySignatures; var requestUrl = SignUtils.GenerateUrl(originalUrl, keyValues); BaseResult <PDFVerifySignaturesResult> result = httpService.HttpPost <BaseResult <PDFVerifySignaturesResult> >(requestUrl, requestParams); return(result); }
/// <summary> /// 签署合同(即自动签) /// </summary> /// <param name="contractId">合同编号</param> /// <param name="signer">签署者</param> /// <param name="signaturePositions">指定的签署位置,json array格式</param> /// <param name="signatureImageName">签名图片名称</param> /// <param name="signatureImageData">签名图片</param> /// <param name="signatureImageWidth">签名图片显示宽度</param> /// <param name="signatureImageHeight">签名图片显示高度</param> /// <returns></returns> public BaseResult <CommonResult> SignCert(string contractId, string signer, object signaturePositions, string signatureImageName = "", string signatureImageData = "", string signatureImageWidth = "", string signatureImageHeight = "") { Dictionary <string, object> requestParams = new Dictionary <string, object>(); requestParams.Add("contractId", contractId); requestParams.Add("signer", signer); requestParams.Add("signaturePositions", signaturePositions); if (!string.IsNullOrWhiteSpace(signatureImageName)) { requestParams.Add("signatureImageName", signatureImageName); } if (!string.IsNullOrWhiteSpace(signatureImageData)) { requestParams.Add("signatureImageData", signatureImageData); } if (!string.IsNullOrWhiteSpace(signatureImageWidth)) { requestParams.Add("signatureImageWidth", signatureImageWidth); } if (!string.IsNullOrWhiteSpace(signatureImageHeight)) { requestParams.Add("signatureImageHeight", signatureImageHeight); } SortedDictionary <string, object> keyValues = new SortedDictionary <string, object>(); keyValues.Add("developerId", Constants.DeveloperID); keyValues.Add("rtick", SignUtils.ToUnixEpochDate(DateTime.Now).ToString() + SignUtils.ToRandom(1000, 9999)); keyValues.Add("signType", Constants.SignType); var signResult = SignUtils.GenerateSign(Constants.Path + Constants.Storage_Contract_Sign_Cert, SignUtils.GenerateMD5(requestParams), keyValues); var signEncryResult = RSAEncryption.SignData(signResult, Constants.PrivateKey); var signEncodeResult = SignUtils.SignUrlEncode(signEncryResult); keyValues.Add("sign", signEncodeResult); var originalUrl = Constants.Host + Constants.Path + Constants.Storage_Contract_Sign_Cert; var requestUrl = SignUtils.GenerateUrl(originalUrl, keyValues); BaseResult <CommonResult> result = httpService.HttpPost <BaseResult <CommonResult> >(requestUrl, requestParams); return(result); }
/// <summary> /// 下载合同文件 /// </summary> /// <param name="contractId">合同编号</param> /// <returns></returns> public bool Download(string contractId, string path) { SortedDictionary <string, object> keyValues = new SortedDictionary <string, object>(); keyValues.Add("contractId", contractId); keyValues.Add("developerId", Constants.DeveloperID); keyValues.Add("rtick", SignUtils.ToUnixEpochDate(DateTime.Now).ToString() + SignUtils.ToRandom(1000, 9999)); keyValues.Add("signType", Constants.SignType); var signResult = SignUtils.GenerateSign(Constants.Path + Constants.Contract_Download, "", keyValues); var signEncryResult = RSAEncryption.SignData(signResult, Constants.PrivateKey); var signEncodeResult = SignUtils.SignUrlEncode(signEncryResult); keyValues.Add("sign", signEncodeResult); var originalUrl = Constants.Host + Constants.Path + Constants.Contract_Download; var requestUrl = SignUtils.GenerateUrl(originalUrl, keyValues); var result = httpService.HttpDownload(requestUrl, path); return(result); }
/// <summary> /// 下载文件 /// </summary> /// <param name="fid">文件编号</param> /// <returns></returns> public BaseResult <StorageUploadResult> Download(string fid) { SortedDictionary <string, object> keyValues = new SortedDictionary <string, object>(); keyValues.Add("fid", fid); keyValues.Add("developerId", Constants.DeveloperID); keyValues.Add("rtick", SignUtils.ToUnixEpochDate(DateTime.Now).ToString() + SignUtils.ToRandom(1000, 9999)); keyValues.Add("signType", Constants.SignType); var signResult = SignUtils.GenerateSign(Constants.Path + Constants.Storage_Download, "", keyValues); var signEncryResult = RSAEncryption.SignData(signResult, Constants.PrivateKey); var signEncodeResult = SignUtils.SignUrlEncode(signEncryResult); keyValues.Add("sign", signEncodeResult); var originalUrl = Constants.Host + Constants.Path + Constants.Storage_Download; var requestUrl = SignUtils.GenerateUrl(originalUrl, keyValues); BaseResult <StorageUploadResult> result = httpService.HttpGet <BaseResult <StorageUploadResult> >(requestUrl); return(result); }
/// <summary> /// 上传并创建合同 /// </summary> /// <param name="account">用户唯一标识</param> /// <param name="fmd5">文件md5值</param> /// <param name="ftype">文件类型</param> /// <param name="fname">文件名</param> /// <param name="fpages">文件页数</param> /// <param name="fdata">文件数据,base64编码</param> /// <param name="title">合同标题</param> /// <param name="expireTime">合同能够签署的截止时间</param> /// <param name="description">合同描述</param> /// <param name="hotStoragePeriod">热存周期</param> /// <returns></returns> public BaseResult <StorageContractUploadResult> Upload(string account, string fmd5, string ftype, string fname, string fpages, string fdata, string title, string expireTime, string description = "", string hotStoragePeriod = "") { Dictionary <string, object> requestParams = new Dictionary <string, object>(); requestParams.Add("account", account); requestParams.Add("fmd5", fmd5); requestParams.Add("ftype", ftype); requestParams.Add("fname", fname); requestParams.Add("fpages", fpages); requestParams.Add("fdata", fdata); requestParams.Add("title", title); requestParams.Add("expireTime", expireTime); if (!string.IsNullOrWhiteSpace(description)) { requestParams.Add("description", description); } if (!string.IsNullOrWhiteSpace(hotStoragePeriod)) { requestParams.Add("hotStoragePeriod", hotStoragePeriod); } SortedDictionary <string, object> keyValues = new SortedDictionary <string, object>(); keyValues.Add("developerId", Constants.DeveloperID); keyValues.Add("rtick", SignUtils.ToUnixEpochDate(DateTime.Now).ToString() + SignUtils.ToRandom(1000, 9999)); keyValues.Add("signType", Constants.SignType); var signResult = SignUtils.GenerateSign(Constants.Path + Constants.Storage_Contract_Upload, SignUtils.GenerateMD5(requestParams), keyValues); var signEncryResult = RSAEncryption.SignData(signResult, Constants.PrivateKey); var signEncodeResult = SignUtils.SignUrlEncode(signEncryResult); keyValues.Add("sign", signEncodeResult); var originalUrl = Constants.Host + Constants.Path + Constants.Storage_Contract_Upload; var requestUrl = SignUtils.GenerateUrl(originalUrl, keyValues); BaseResult <StorageContractUploadResult> result = httpService.HttpPost <BaseResult <StorageContractUploadResult> >(requestUrl, requestParams); return(result); }
/// <summary> /// 下载用户签名/印章图片 /// </summary> /// <param name="account">用户唯一标识</param> /// <param name="imageName">签名/印章图片名称</param> /// <returns></returns> public BaseResult <CommonResult> UserDownload(string account, string imageName = "default") { SortedDictionary <string, object> keyValues = new SortedDictionary <string, object>(); keyValues.Add("account", account); keyValues.Add("imageName", imageName); keyValues.Add("developerId", Constants.DeveloperID); keyValues.Add("rtick", SignUtils.ToUnixEpochDate(DateTime.Now).ToString() + SignUtils.ToRandom(1000, 9999)); keyValues.Add("signType", Constants.SignType); var signResult = SignUtils.GenerateSign(Constants.Path + Constants.SignatureImage_User_Download, "", keyValues); var signEncryResult = RSAEncryption.SignData(signResult, Constants.PrivateKey); var signEncodeResult = SignUtils.SignUrlEncode(signEncryResult); keyValues.Add("sign", signEncodeResult); var originalUrl = Constants.Host + Constants.Path + Constants.SignatureImage_User_Download; var requestUrl = SignUtils.GenerateUrl(originalUrl, keyValues); BaseResult <CommonResult> result = httpService.HttpGet <BaseResult <CommonResult> >(requestUrl); return(result); }
/// <summary> /// 发送合同(即手动签,指定图片大小) /// </summary> /// <param name="contractId">合同编号</param> /// <param name="signer">指定给哪个用户看</param> /// <param name="dpi">预览图片清晰度,枚举值:96-低清(默认),120-普清,160-高清,240-超清</param> /// <param name="signaturePositions">json array格式</param> /// <param name="isAllowChangeSignaturePosition">在有指定signaturePOSTion参数的情况下,是否允许拖动签名位置。取值1/0。(0:不允许,1:允许)</param> /// <param name="expireTime">签署链接的到期时间,unix时间戳格式(秒数)</param> /// <param name="returnUrl">签署页面指定回跳的页面地址</param> /// <param name="vcodeMobile">手动签署时指定接收手机验证码的手机号</param> /// <param name="isDrawSignatureImage">手动签署时是否手绘签名</param> /// <param name="signatureImageName">签名/印章图片</param> /// <param name="sid">开发者自定义的签署流水号</param> /// <param name="pushUrl">异步推送地址</param> /// <param name="version">手动签的版本</param> /// <param name="readAll">无需拖动到页面底部即可确认签署</param> /// <param name="app">人脸比对签署</param> /// <param name="signatureImageWidth">本次签署使用的签名/印章图片在合同PDF上显示的宽度</param> /// <param name="signatureImageHeight">本次签署使用的签名/印章图片在合同PDF上显示的高度</param> /// <param name="isShowHandwrittenTime">不显示该时间</param> /// <param name="isFaceAuth">是否使用刷脸签</param> /// <returns></returns> public BaseResult <CommonResult> Send(string contractId, string signer, string dpi, object signaturePositions, int isAllowChangeSignaturePosition = 0, long expireTime = 0, string returnUrl = "", string vcodeMobile = "", int isDrawSignatureImage = 1, string signatureImageName = "", string sid = "", string pushUrl = "", string version = "", int readAll = 0, string app = "", string signatureImageWidth = "", string signatureImageHeight = "", int isShowHandwrittenTime = 0, int isFaceAuth = 0) { Dictionary <string, object> requestParams = new Dictionary <string, object>(); requestParams.Add("contractId", contractId); requestParams.Add("signer", signer); requestParams.Add("signaturePositions", signaturePositions); if (isAllowChangeSignaturePosition != 0) { requestParams.Add("isAllowChangeSignaturePosition", isAllowChangeSignaturePosition); } if (expireTime != 0) { requestParams.Add("expireTime", expireTime); } if (!string.IsNullOrWhiteSpace(returnUrl)) { requestParams.Add("returnUrl", returnUrl); } if (!string.IsNullOrWhiteSpace(vcodeMobile)) { requestParams.Add("vcodeMobile", vcodeMobile); } if (isDrawSignatureImage != 1) { requestParams.Add("isDrawSignatureImage", isDrawSignatureImage); } if (!string.IsNullOrWhiteSpace(signatureImageName)) { requestParams.Add("signatureImageName", signatureImageName); } if (string.IsNullOrWhiteSpace(sid)) { requestParams.Add("sid", sid); } if (!string.IsNullOrWhiteSpace(pushUrl)) { requestParams.Add("pushUrl", pushUrl); } if (!string.IsNullOrWhiteSpace(version)) { requestParams.Add("version", version); } if (readAll != 0) { requestParams.Add("readAll", readAll); } if (!string.IsNullOrWhiteSpace(app)) { requestParams.Add("app", app); } if (!string.IsNullOrWhiteSpace(signatureImageWidth)) { requestParams.Add("signatureImageWidth", signatureImageWidth); } if (!string.IsNullOrWhiteSpace(signatureImageHeight)) { requestParams.Add("signatureImageHeight", signatureImageHeight); } if (isShowHandwrittenTime != 0) { requestParams.Add("isShowHandwrittenTime", isShowHandwrittenTime); } if (isFaceAuth != 0) { requestParams.Add("isFaceAuth", isFaceAuth); } SortedDictionary <string, object> keyValues = new SortedDictionary <string, object>(); keyValues.Add("developerId", Constants.DeveloperID); keyValues.Add("rtick", SignUtils.ToUnixEpochDate(DateTime.Now).ToString() + SignUtils.ToRandom(1000, 9999)); keyValues.Add("signType", Constants.SignType); var signResult = SignUtils.GenerateSign(Constants.Path + Constants.Contract_Send, SignUtils.GenerateMD5(requestParams), keyValues); var signEncryResult = RSAEncryption.SignData(signResult, Constants.PrivateKey); var signEncodeResult = SignUtils.SignUrlEncode(signEncryResult); keyValues.Add("sign", signEncodeResult); var originalUrl = Constants.Host + Constants.Path + Constants.Contract_Send; var requestUrl = SignUtils.GenerateUrl(originalUrl, keyValues); BaseResult <CommonResult> result = httpService.HttpPost <BaseResult <CommonResult> >(requestUrl, requestParams); return(result); }