using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using Lskj.IPersonnelConnection;
namespace Lskj.IPersonnelConnection
{
public static class PersonnelReplaceHelper
{
///
/// i人事 许可信息
///
private static readonly string _iPersonnelAllowInformation = "{iPersonnelAllowInformation}";
///
/// i人事 客户唯一身份标识
///
private static readonly string _iPersonnelCustomerId = "{iPersonnelCustomerId}";
///
/// i人事 私钥
///
private static readonly string _iPersonnelPrivateKey = "{iPersonnelPrivateKey}";
///
/// i人事 加密的签名信息
///
private static readonly string _iPersonnelEncryptedMessage = "{iPersonnelEncryptedMessage}";
///
/// 说明:替换i人事接口中的参数
/// 创建人:
/// 创建日期:2023-04-21
/// 修改人:
/// 修改日期:
/// 修改备注:
/// 版本:1.0
///
/// url地址
/// 许可信息
/// 客户标识
/// 私钥
/// 登录人电话
/// System.String.
public static string UrlEncryption(string Url, string iPersonnelAllowInformation, string iPersonnelCustomerId, string iPersonnelPrivateKey,string UserLinkPhone)
{
if (Url.Contains("{iPersonnelAllowInformation}") || Url.Contains("{iPersonnelEncryptedMessage}"))
{
//替换许可
Url = Url.Replace(_iPersonnelAllowInformation, iPersonnelAllowInformation);
//替换加密的签名信息
TimeSpan ts = DateTime.Now.ToUniversalTime() - new DateTime(1970, 1, 1);
long time = (long)ts.TotalMilliseconds;//当前时间的时间戳
string EncryptedMessage = string.Format("company_id={0}&mobile_no={1}×tamp={2}", iPersonnelCustomerId, UserLinkPhone, time);
string value = EncryptByPrivateKey.encryptByPrivateKey(EncryptedMessage, iPersonnelPrivateKey);
Url = Url.Replace(_iPersonnelEncryptedMessage, value);
}
return Url;
}
}
}