/// <summary> /// 向大红门集团接口提交数据XML文件 /// </summary> /// <param name="receiveinfoxml">票据信息XML文件,生成单据,修改单据状态,修改单据内容是应非空</param> /// <param name="loaninfoxml">代收放款信息XML文件,发放代收时应为非空</param> public static void UploadXml(string receiveinfoxml, string loaninfoxml) { //物流公司代码 const string comcode = "1112"; //将提交的Xml文件保存 FileSaveBackup(receiveinfoxml, loaninfoxml); //创建服务对象 TransitService ts = new TransitService(); //用“物流公司编码”获取加密密钥 string key = ts.GetDESKey(comcode); //用“yyyyMMdd”格式获取当前日期作为加密种子 string iv = DateTime.Now.ToString("yyyyMMdd"); //对密钥进行处理 byte[] outputb = Convert.FromBase64String(key);//解密Base64 key = Encoding.UTF8.GetString(outputb); //上传XML文件,单传票据时,loaninfoxml可为空值xml文件,传代收时,应均有数据。放代收时,receiveinfoxml应含有修改状态的票据信息 string xml1 = EncryptDES(receiveinfoxml, key, iv); string xml2 = EncryptDES(loaninfoxml, key, iv); UploadXml: try { //发布解除上传数据 //ts.SetInfo(xml1, xml2, comcode); } catch { //上传出错,持续提交 goto UploadXml; } }
public void GenerateKey_Manual() { // TODO: I have verified this works and am awaiting for guidance on how to handle the transaction keys before finalizing this piece string transactionKey = TransitService.GenerateTransactionKey( Environment.TEST, "887000003282", "TA5654114", "TransitCert2020!" //"3RDHBVQOYIGTC9WQ32CPBFMPGX5OTWN3" ); Assert.IsNotNull(transactionKey); }