CloudContract.Standard 4.3.0

云合同API 4.3.0版本

Install-Package CloudContract.Standard -Version 4.3.0
dotnet add package CloudContract.Standard --version 4.3.0
<PackageReference Include="CloudContract.Standard" Version="4.3.0" />
For projects that support PackageReference, copy this XML node into the project file to reference the package.
paket add CloudContract.Standard --version 4.3.0
The NuGet Team does not provide support for this client. Please contact its maintainers for support.

没有全部封装,只封装了合同签署需要用到的这些接口(含存证、下载)

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using CloudContract.Standard;
using CloudContract.Standard.Models;
using CloudContract.Standard.Models.Contract;
using CloudContract.Standard.Models.Moulage;
using CloudContract.Standard.Models.User;

namespace Demo
{
    class Program
    {
        static string appId = "";
        static string appKey = "";
        static string baseAddress = BaseApi.BASE_ADDRESS;
        static string token = "";
        static async Task Main(string[] args)
        {
            try
            {
                await TestAuthApi();
                // await TestUserApi();
                // await TestMoulageApi();
                await TestContractApi();
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{ex.Message}\r\n\t{ex.StackTrace}");
            }
        }

        static async Task TestAuthApi()
        {
            var api = new AuthApi()
            {
                AppId = appId,
                AppKey = appKey,
                BaseAddress = baseAddress,
            };
           // 平台自己登录
            token = await api.Login(null);
           // 平台的用户登录
            // token = await api.Login("xxx");

            Console.WriteLine($"AuthApi.Login() => Token:{token}");
        }

        static async Task TestUserApi()
        {
            var api = new UserApi()
            {
                AppId = appId,
                AppKey = appKey,
                BaseAddress = baseAddress,
            };
            api.SetToken(token);

            //var res = await api.CreatePerson(new CreatePersonModel
            //{
            //    UserName = "xx",
            //    IdentityRegion = "0",
            //    CertifyNum = "xxxx",
            //    PhoneRegion = "0",
            //    PhoneNo = "xxx",
            //    CaType = "B2",
            //});

            //var res = await api.CreateCompany(new CreateCompanyModel
            //{
            //    UserName = "xxx股份有限公司",
            //    CertifyType = "1", // 社会信用代码
            //    CertifyNum = "xxx",
            //    PhoneNo = "xxx",
            //    CaType = "B2",
            //});
            //Console.WriteLine($"TestUserApi.CreatePerson() => Token:{res}");
        }

        static async Task TestMoulageApi()
        {
            var api = new MoulageApi()
            {
                AppId = appId,
                AppKey = appKey,
                BaseAddress = baseAddress,
            };
            api.SetToken(token);

            var id1 = await api.CreatePersonMoulage(new CreatePersonMoulage
            {
                SignerId = "xxx",
            });

            var id2 = await api.CreateCompanyMoulage(new CreateCompanyMoulageModel
            {
                SignerId = "xxx",
            });
            Console.WriteLine($"TestMoulageApi.Create() => Id1:{id1},  Id2:{id2}");
        }
        static async Task TestContractApi()
        {
            var api = new ContractApi()
            {
                AppId = appId,
                AppKey = appKey,
                BaseAddress = baseAddress,
            };
            api.SetToken(token);
            #region 存证合同
            var res = await api.RetainEvidenceContac(new RetainEvidenceContactModel
            {
                IdType = "0",
                IdContent = "1903040109xxx",
            });
            Console.WriteLine($"TestContractApi.RetainEvidenceContac() => 存证id:{res}");
            #endregion 

            #region 下载合同
            //var bytes = await api.DownloadContact(new DownloadContactModel
            //{
            //    IdType = "0",
            //    IdContent = "1903040109385484",
            //});

            //System.IO.File.WriteAllBytes(@"C:\Users\kunge\Desktop\test111.pdf", bytes);
            #endregion 

            #region 根据模板创建合同
            //var placeholder = new Dictionary<string, string>
            //{
            //    {"${乙方姓名}", "xx" },
            //    {"${工程地点}", "xxxxx" },
            //};
            //var res = await api.CreateContract(new CreateContractModel
            //{
            //    ContractNo = "",
            //    ContractTitle = "xx合同",
            //    TemplateId = "TEM1007793",
            //    ContractData = new ContractdataModel
            //    {
            //        Placeholder = placeholder,
            //        Tables = new List<TableModel>
            //         {
            //             new TableModel
            //             {
            //                Index = 0,
            //                Table = new List<Dictionary<string, object>>
            //                {
            //                    new Dictionary<string, object>
            //                    {
            //                        { "1", "111"},
            //                        { "2", "2019年3月4日"},
            //                        { "3", "2019年3月6日"},
            //                    },
            //                    new Dictionary<string, object>
            //                    {
            //                        { "1", "aaa"},
            //                        { "2", "2019年4月1日"},
            //                        { "3", "2019年4月19日"},
            //                    },
            //                }
            //             },
            //         },
            //    },
            //});
            //Console.WriteLine($"TestContractApi.CreateContract() => Token:{res}");
            #endregion

            #region 添加签署者
            //await api.AddContractSigner(new AddContractSignerModel
            //{
            //    IdType = "0", // 合同id
            //    IdContent = res,
            //    Signers = new List<SignerModel>
            //    {
            //        new SignerModel
            //        {
            //            SignerId ="xx",
            //            SignPositionType = "0", // 关键字定位
            //            PositionContent = "",
            //            SignValidateType = "0", // 不校验
            //            SignMode = "0", // 每次绘制印章
            //        },
            //        new SignerModel
            //        {
            //            SignerId ="xx",
            //            SignPositionType = "1", // 标签定位
            //            PositionContent ="76603",
            //            SignValidateType = "0", // 不校验
            //            SignMode = "1", // 每次绘制印章
            //        },
            //    },
            //});
            //Console.WriteLine($"TestContractApi.AddContractSigner() => 添加签署者");
            #endregion

            #region 签署合同
            //await api.SignContract(new SignContractModel
            //{
            //    IdType = "0",
            //    IdContent = res,
            //    SignerId = "xx",
            //});
            //Console.WriteLine($"TestContractApi.SignContract() => 签署合同");
            #endregion

        }
    }
}

没有全部封装,只封装了合同签署需要用到的这些接口(含存证、下载)

using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using CloudContract.Standard;
using CloudContract.Standard.Models;
using CloudContract.Standard.Models.Contract;
using CloudContract.Standard.Models.Moulage;
using CloudContract.Standard.Models.User;

namespace Demo
{
    class Program
    {
        static string appId = "";
        static string appKey = "";
        static string baseAddress = BaseApi.BASE_ADDRESS;
        static string token = "";
        static async Task Main(string[] args)
        {
            try
            {
                await TestAuthApi();
                // await TestUserApi();
                // await TestMoulageApi();
                await TestContractApi();
                Console.ReadLine();
            }
            catch (Exception ex)
            {
                Console.WriteLine($"{ex.Message}\r\n\t{ex.StackTrace}");
            }
        }

        static async Task TestAuthApi()
        {
            var api = new AuthApi()
            {
                AppId = appId,
                AppKey = appKey,
                BaseAddress = baseAddress,
            };
           // 平台自己登录
            token = await api.Login(null);
           // 平台的用户登录
            // token = await api.Login("xxx");

            Console.WriteLine($"AuthApi.Login() => Token:{token}");
        }

        static async Task TestUserApi()
        {
            var api = new UserApi()
            {
                AppId = appId,
                AppKey = appKey,
                BaseAddress = baseAddress,
            };
            api.SetToken(token);

            //var res = await api.CreatePerson(new CreatePersonModel
            //{
            //    UserName = "xx",
            //    IdentityRegion = "0",
            //    CertifyNum = "xxxx",
            //    PhoneRegion = "0",
            //    PhoneNo = "xxx",
            //    CaType = "B2",
            //});

            //var res = await api.CreateCompany(new CreateCompanyModel
            //{
            //    UserName = "xxx股份有限公司",
            //    CertifyType = "1", // 社会信用代码
            //    CertifyNum = "xxx",
            //    PhoneNo = "xxx",
            //    CaType = "B2",
            //});
            //Console.WriteLine($"TestUserApi.CreatePerson() => Token:{res}");
        }

        static async Task TestMoulageApi()
        {
            var api = new MoulageApi()
            {
                AppId = appId,
                AppKey = appKey,
                BaseAddress = baseAddress,
            };
            api.SetToken(token);

            var id1 = await api.CreatePersonMoulage(new CreatePersonMoulage
            {
                SignerId = "xxx",
            });

            var id2 = await api.CreateCompanyMoulage(new CreateCompanyMoulageModel
            {
                SignerId = "xxx",
            });
            Console.WriteLine($"TestMoulageApi.Create() => Id1:{id1},  Id2:{id2}");
        }
        static async Task TestContractApi()
        {
            var api = new ContractApi()
            {
                AppId = appId,
                AppKey = appKey,
                BaseAddress = baseAddress,
            };
            api.SetToken(token);
            #region 存证合同
            var res = await api.RetainEvidenceContac(new RetainEvidenceContactModel
            {
                IdType = "0",
                IdContent = "1903040109xxx",
            });
            Console.WriteLine($"TestContractApi.RetainEvidenceContac() => 存证id:{res}");
            #endregion 

            #region 下载合同
            //var bytes = await api.DownloadContact(new DownloadContactModel
            //{
            //    IdType = "0",
            //    IdContent = "1903040109385484",
            //});

            //System.IO.File.WriteAllBytes(@"C:\Users\kunge\Desktop\test111.pdf", bytes);
            #endregion 

            #region 根据模板创建合同
            //var placeholder = new Dictionary<string, string>
            //{
            //    {"${乙方姓名}", "xx" },
            //    {"${工程地点}", "xxxxx" },
            //};
            //var res = await api.CreateContract(new CreateContractModel
            //{
            //    ContractNo = "",
            //    ContractTitle = "xx合同",
            //    TemplateId = "TEM1007793",
            //    ContractData = new ContractdataModel
            //    {
            //        Placeholder = placeholder,
            //        Tables = new List<TableModel>
            //         {
            //             new TableModel
            //             {
            //                Index = 0,
            //                Table = new List<Dictionary<string, object>>
            //                {
            //                    new Dictionary<string, object>
            //                    {
            //                        { "1", "111"},
            //                        { "2", "2019年3月4日"},
            //                        { "3", "2019年3月6日"},
            //                    },
            //                    new Dictionary<string, object>
            //                    {
            //                        { "1", "aaa"},
            //                        { "2", "2019年4月1日"},
            //                        { "3", "2019年4月19日"},
            //                    },
            //                }
            //             },
            //         },
            //    },
            //});
            //Console.WriteLine($"TestContractApi.CreateContract() => Token:{res}");
            #endregion

            #region 添加签署者
            //await api.AddContractSigner(new AddContractSignerModel
            //{
            //    IdType = "0", // 合同id
            //    IdContent = res,
            //    Signers = new List<SignerModel>
            //    {
            //        new SignerModel
            //        {
            //            SignerId ="xx",
            //            SignPositionType = "0", // 关键字定位
            //            PositionContent = "",
            //            SignValidateType = "0", // 不校验
            //            SignMode = "0", // 每次绘制印章
            //        },
            //        new SignerModel
            //        {
            //            SignerId ="xx",
            //            SignPositionType = "1", // 标签定位
            //            PositionContent ="76603",
            //            SignValidateType = "0", // 不校验
            //            SignMode = "1", // 每次绘制印章
            //        },
            //    },
            //});
            //Console.WriteLine($"TestContractApi.AddContractSigner() => 添加签署者");
            #endregion

            #region 签署合同
            //await api.SignContract(new SignContractModel
            //{
            //    IdType = "0",
            //    IdContent = res,
            //    SignerId = "xx",
            //});
            //Console.WriteLine($"TestContractApi.SignContract() => 签署合同");
            #endregion

        }
    }
}

Release Notes

云合同API对接4.3.0版本

This package is not used by any popular GitHub repositories.

Version History

Version Downloads Last updated
4.3.0 119 3/3/2019