public class CEBSignClient { public void StartSignClient() { } private static SignClientConfig _signClientConfig; public static SignClientConfig CebSi ...
public class CEBSignClient
{
public void StartSignClient()
{
}
private static SignClientConfig _signClientConfig;
public static SignClientConfig CebSignClientConfig
{
get { return _signClientConfig; }
set { _signClientConfig = value; }
}
public static SignClientConfig GetCebSignClientConfig()
{
if (_signClientConfig == null)
{
_signClientConfig = new SignClientConfig();
}
return _signClientConfig;
}
public static void SetCebSignClientConfig(SignClientConfig CebSignClientConfig)
{
_signClientConfig = CebSignClientConfig;
}
/// <summary>
/// 處理報文加簽服務64位
/// </summary>
/// <param name="CEBMessagesXml"></param>
/// <param name="FileName"></param>
/// <returns></returns>
public static string StartSignTransform(string CEBMessagesXml, string FileName, ref bool retunValue)
{
string StatusCode = string.Empty;
string StatusMessage = string.Empty;
retunValue = true;
SignHelper signHelper = new SignHelper();
GetCebSignClientConfig();
string centiNo = "";
signHelper.Password = CebSignClientConfig.SignPwd;
signHelper.MsgType = CebSignClientConfig.MsgType;
signHelper.ReceiverId = CebSignClientConfig.ReceiverId;
signHelper.SenderId = CebSignClientConfig.SenderId;
try
{
if (signHelper.IsICOrUKeyOk(out centiNo))
{
string text = CebSignClientConfig.ReceiveSignin;//接收文件夾
string text2 = CebSignClientConfig.SendIn;//發送文件夾
//改造
string text4;
try
{
signHelper.CopMsgId = Guid.NewGuid().ToString();
text4 = signHelper.SignInfo(CEBMessagesXml, centiNo);
//是否生成終端報文
if (CebSignClientConfig.CheckedTerminal)
{
text4 = signHelper.ShellInfo(text4);
}
}
catch (Exception ex)
{
//this.TransformException("文件" + text3 + "異常:" + ex.Message);
StatusMessage = ex.Message;
return StatusMessage;
}
//拼接目標文件夾和文件路徑
//string path = Path.Combine(text2, Path.GetFileName(FileName));
var CEBMessage = SignHelper.FormatXml(text4);
StatusMessage = CEBMessage;
//File.WriteAllText(path, CEBMessage);
//File.Delete(FileName);
}
else
{
//this.TransformException("卡信息讀取失敗");
StatusMessage = "卡信息讀取失敗";
retunValue = false;
}
}
catch (Exception ex)
{
//this.TransformException(ex.Message);
StatusMessage = ex.Message;
retunValue = false;
}
return StatusMessage;
}
/// <summary>
/// 處理報文加簽服務64位
/// </summary>
/// <param name="CEBMessagesXml"></param>
/// <param name="FileName"></param>
/// <returns></returns>
public static string StartSignTransform(string CEBMessagesXml, ref bool retunValue)
{
string StatusCode = string.Empty;
string StatusMessage = string.Empty;
retunValue = true;
SignHelper signHelper = new SignHelper();
GetCebSignClientConfig();
string centiNo = "";
signHelper.Password = CebSignClientConfig.SignPwd;
signHelper.MsgType = CebSignClientConfig.MsgType;
signHelper.ReceiverId = CebSignClientConfig.ReceiverId;
signHelper.SenderId = CebSignClientConfig.SenderId;
try
{
if (signHelper.IsICOrUKeyOk(out centiNo))
{
string text = CebSignClientConfig.ReceiveSignin;//接收文件夾
string text2 = CebSignClientConfig.SendIn;//發送文件夾
//改造
string text4;
try
{
signHelper.CopMsgId = Guid.NewGuid().ToString();
text4 = signHelper.SignInfo(CEBMessagesXml, centiNo);
//是否生成終端報文
if (CebSignClientConfig.CheckedTerminal)
{
text4 = signHelper.ShellInfo(text4);
}
}
catch (Exception ex)
{
//this.TransformException("文件" + text3 + "異常:" + ex.Message);
StatusMessage = ex.Message;
return StatusMessage;
}
//拼接目標文件夾和文件路徑
//string path = Path.Combine(text2, Path.GetFileName(FileName));
var CEBMessage = SignHelper.FormatXml(text4);
StatusMessage = CEBMessage;
//File.WriteAllText(path, CEBMessage);
//File.Delete(FileName);
}
else
{
//this.TransformException("卡信息讀取失敗");
StatusMessage = "卡信息讀取失敗";
retunValue = false;
}
}
catch (Exception ex)
{
//this.TransformException(ex.Message);
StatusMessage = ex.Message;
retunValue = false;
}
return StatusMessage;
}
}
public class SignClientConfig
{
public SignClientConfig()
{
SignPwd = "88888888";
ReceiveSignin = @"D:\跨境通\CustomsDeclarationWebMvcWMS3.5\DotNet.WinForm\bin\Debug\EportExchange\signin";
SendIn = @"D:\跨境通\CustomsDeclarationWebMvcWMS3.5\DotNet.WinForm\bin\Debug\EportExchange\in";
CheckedTerminal = false;
MsgType = "";
ReceiverId = "";
SenderId = "";
}
/// <summary>
/// 密碼
/// </summary>
public string SignPwd { get; set; }
/// <summary>
/// 加簽後的文件夾 接收文件夾
/// </summary>
public string ReceiveSignin { get; set; }
/// <summary>
/// 待加簽文件夾 發送文件夾
/// </summary>
public string SendIn { get; set; }
/// <summary>
/// 消息類型
/// </summary>
public string MsgType { get; set; }
/// <summary>
/// 接收Id
/// </summary>
public string ReceiverId { get; set; }
/// <summary>
/// 發送Id
/// </summary>
public string SenderId { get; set; }
/// <summary>
/// 是否生成終端報文
/// </summary>
public bool CheckedTerminal { get; set; }
}
//杭州版報文組裝 //報文組裝 按多條訂單批量發送
foreach (KcyCeb311messageorderheadEntity item in Ceb311messageList)
{
progress.SetProgressValue(1);
if (string.IsNullOrWhiteSpace(item.Waybills))
{
StatusMessage = "發現訂單運單不存在!";
return;
}
//每條訂單不同的GUID
Ceb311HZSendmodel.Guid = CEBHelpUtilities.GetGuid();
CEB311MessageOrderSendModel Sendmodel = new CEB311MessageOrderSendModel();
Sendmodel.Ceb311OrderheadInfo = item;//主體信息
Condition = new SearchCondition();
SqlCondition = string.Empty;
Condition.AddCondition(KcyCeb311messageorderlistEntity.FieldOrderheadid, item.Orderheadid, SqlOperator.Equal)//
.AddCondition(KcyCeb311messageorderlistEntity.FieldCompanyid, UserInfo.CompanyId, SqlOperator.Equal)
.AddCondition(KcyCeb311messageorderlistEntity.FieldDeletionStateCode, 0, SqlOperator.Equal)//刪除狀態
.AddCondition(KcyCeb311messageorderlistEntity.FieldEnabled, 1, SqlOperator.Equal);//有效的
SqlCondition = Condition.BuildConditionSql(DatabaseType.SQLServer);
List<KcyCeb311messageorderlistEntity> ceb311messageorderlist = new List<KcyCeb311messageorderlistEntity>();
ceb311messageorderlist = new KcyCeb311messageorderlistManager().GetList<KcyCeb311messageorderlistEntity>(SqlCondition);
Sendmodel.Ceb311OrderDateilList = ceb311messageorderlist;//明細信息
Ceb311HZSendmodel.CEB311MessageHZSendList.Add(Sendmodel);
bool returnValue = true;
//報文校驗
returnValue = HZCEB311Message.CheckCEB311Message(Ceb311HZSendmodel, out StatusCode, out StatusMessage);
if (!returnValue)
{
// 消息提醒
LoadingUtil.ShowInformationMessage(StatusMessage, AppMessage.MSG0000);
return;
}
if (StatusCode.Equals("IsStockQty"))
{
}
StatusMessage = "杭州報文發送";
progress.SetProgressValue(10);
progress.SetStatusInfo.Text = string.Format("操作{0}:{1}條 " + "錯誤:{2} 條", StatusMessage, itemCount, itemErrcount);
progress.SetStatusInfo.Update();
//生成杭州版報文
string CEB311MessageXml = HZCEB311Message.GetCareateHZOrderXml(Ceb311HZSendmodel);
Ceb311HZSendmodel.CebSoapOrdersXml = CEB311MessageXml;//原始報文
Ceb311HZSendmodel.SendOrdersXml = CEB311MessageXml;//杭州版報文
//報文加密私鑰
Ceb311HZSendmodel.Secretkey = Ceb311HZSendmodel.Ceb311StoresorderdeclareparameterInfo.Aessign;//AES
Ceb311HZSendmodel.Privatekey = Ceb311HZSendmodel.Ceb311StoresorderdeclareparameterInfo.Privatekey.Trim();
Ceb311HZSendmodel.SendUrl = Ceb311HZSendmodel.Ceb311StoresorderdeclareparameterInfo.Declareaddress;//訂單申報地址
//AES加密
Ceb311HZSendmodel.SendOrdersXml = KuangBaseAESUtil.Encrypt(Ceb311HZSendmodel.SendOrdersXml, Ceb311HZSendmodel.Secretkey);
CEBMessageHZJkfSignModel.Sign(ref Ceb311HZSendmodel);
if (!Ceb311HZSendmodel.Status)
{
// 消息提醒
LoadingUtil.ShowInformationMessage(Ceb311HZSendmodel.StatusMessage, AppMessage.MSG0000);
return;
}
Ceb311HZSendmodel.SendOrdersXml = HzOperationHttp.DataSoap(Ceb311HZSendmodel.SendOrdersXml, Ceb311HZSendmodel.BusinessType, Ceb311HZSendmodel.DataDigest, Ceb311HZSendmodel.CompanyCode);
Ceb311HZSendmodel.ResponseOrdersXml = HzOperationHttp.HttpPost(Ceb311HZSendmodel);
if (Ceb311HZSendmodel.Status)
{
StatusMessage = "處理回執消息";
progress.SetProgressValue(10);
progress.SetStatusInfo.Text = string.Format("操作{0}:{1}條 " + "錯誤:{2} 條", StatusMessage, itemCount, itemErrcount);
progress.SetStatusInfo.Update();
//讀取返回消息處理狀態
HZJKFOrderResultModel ResponseOrdersResultModel = new HZJKFOrderResultModel();
//處理返回的Xml報文
ResponseOrdersResultModel.DeccontentXml = JKFMessageXmlOperation.ReadReturnXml(Ceb311HZSendmodel.ResponseOrdersXml.Trim());
List<BaseJKFOrderMessageModel> ListbaseJKFMessageModel = JKFMessageXmlOperation.ReadJkfResultMessage(ResponseOrdersResultModel);
foreach (var Jkfitem in ListbaseJKFMessageModel)
{
Jkfitem.JKFCustomsorderlogInfo.Orderno = Jkfitem.JkfResultInfo.BusinessNo;
Jkfitem.JKFCustomsorderlogInfo.Servicename = "CEB311訂單服務";
Jkfitem.JKFCustomsorderlogInfo.Operationname = "CEB311杭州申報";
Jkfitem.JKFCustomsorderlogInfo.CreateUserId = UserInfo.Id;
Jkfitem.JKFCustomsorderlogInfo.CreateBy = UserInfo.RealName;
Jkfitem.JKFCustomsorderlogInfo.Operation = UserInfo.UserName;
Jkfitem.JKFCustomsorderlogInfo.Companyid = UserInfo.CompanyId;
}
bool returnLogValue = HZJKFOrderResultService.AddJKFResponseResult(ListbaseJKFMessageModel);
}
//發送成功,再發送總署報文
if (Ceb311HZSendmodel.Status)
{
StatusMessage = "進行總署加簽";
progress.SetStatusInfo.Text = string.Format("操作{0}:{1}條 " + "錯誤:{2} 條", StatusMessage, itemCount, itemErrcount);
progress.SetProgressValue(50);
progress.SetStatusInfo.Update();
//總署版報文生成 //生成報文 本地加簽
Ceb311HZSendmodel = HZCEB311Message.GetSendSignatureCEB311Message(Ceb311HZSendmodel);
//生成報文 本地加簽
bool retunValue = true;
string FileName = "CEB311_ZONGSHU_" + Ceb311HZSendmodel.Guid + ".xml";
//是否生成終端報文
SignClientConfig signClientConfig = CEBSignClient.GetCebSignClientConfig();
signClientConfig.CheckedTerminal = true;
signClientConfig.SignPwd = Ceb311HZSendmodel.CebBasetransferInfo.Note;// "88888888";
signClientConfig.SenderId = Ceb311HZSendmodel.DXPId;
signClientConfig.ReceiverId = Ceb311HZSendmodel.ReceiverId;
signClientConfig.MsgType = Ceb311HZSendmodel.MessageType;
CEBSignClient.SetCebSignClientConfig(signClientConfig);
//進行簽名
Ceb311HZSendmodel.CEBDeclareServiceXml = CEBSignClient.StartSignTransform(Ceb311HZSendmodel.SendOrdersXml, FileName, ref retunValue);
if (!retunValue)
{
StatusMessage = Ceb311HZSendmodel.CEBDeclareServiceXml;
//消息提醒
//LoadingUtil.ShowInformationMessage(StatusMessage, AppMessage.MSG0000);
return;
}
else
{
StatusMessage = "加簽完成";
progress.SetStatusInfo.Text = string.Format("操作{0}:{1}條 " + "錯誤:{2} 條", StatusMessage, itemCount, itemErrcount);
progress.SetProgressValue(50);
progress.SetStatusInfo.Update();
Ceb311HZSendmodel.EportExchangePath = AppDomain.CurrentDomain.BaseDirectory + @"\EportExchange\in";
string path = Path.Combine(Ceb311HZSendmodel.EportExchangePath, FileName);
File.WriteAllText(path, Ceb311HZSendmodel.CEBDeclareServiceXml);
}
//包裝總署發送報文 包裝SAOP格式發送
Ceb311HZSendmodel.CebSoapOrdersXml = HzOperationHttp.CEBDeclareDataSoap(Ceb311HZSendmodel.CEBDeclareServiceXml);
Ceb311HZSendmodel.SendUrl = "http://api.kjeport.com/newyorkWS/ws/ReceiveCebDeclare";
//測試環璋地址 "http://122.224.230.4:18003/newyorkWS/ws/ReceiveCebDeclare";正試環璋地址//http://api.kjeport.com/newyorkWS/ws/ReceiveCebDeclare?wsdl//
Ceb311HZSendmodel.ResponseOrdersXml = HzOperationHttp.CEBDeclareServiceHttpPost(Ceb311HZSendmodel);//發送總署申報
//處理總署發送報文返回消息
#region 處理總署發送報文返回消息
//處理返回的Xml報文
Ceb311HZSendmodel.ResponseOrdersXml = JKFMessageXmlOperation.ReadCEBZONGSHUReturnXml(Ceb311HZSendmodel.ResponseOrdersXml.Trim());
List<BaseJKFOrderMessageModel> ListbaseJKFMessageModel = JKFMessageXmlOperation.ReadCEB311HZZONGSHUResultMessage(Ceb311HZSendmodel, Sendmodel);
bool returnLogValue = false;
foreach (BaseJKFOrderMessageModel Jkfitem in ListbaseJKFMessageModel)
{
//Jkfitem.JKFCustomsorderlogInfo.Orderno = Jkfitem.JkfResultInfo.BusinessNo;
Jkfitem.JKFCustomsorderlogInfo.Servicename = "CEB311杭州總署申報";
Jkfitem.JKFCustomsorderlogInfo.Operationname = "CEB311杭州總署申報";
Jkfitem.JKFCustomsorderlogInfo.CreateUserId = UserInfo.Id;
Jkfitem.JKFCustomsorderlogInfo.CreateBy = UserInfo.RealName;
Jkfitem.JKFCustomsorderlogInfo.Operation = UserInfo.UserName;
Jkfitem.JKFCustomsorderlogInfo.Companyid = UserInfo.CompanyId;
}
returnLogValue = HZJKFOrderResultService.AddJKFResponseResult(ListbaseJKFMessageModel);
#endregion
//申報中狀態
if (returnLogValue)
{
int StateInt = ((int)OrderState.InDeclaration);//訂單狀態申報中
CEB311MessageOrderService.UptateCEB311OrderState(Sendmodel.Ceb311OrderheadInfo.Orderno, StateInt);
//生成總署報文發送成功
StatusCode = Status.OK.ToString();
StatusMessage = "發送成功!";
itemCount++;
progress.SetProgressValue(100);
progress.SetStatusInfo.Text = string.Format("操作{0}:{1}條 " + "錯誤:{2} 條", StatusMessage, itemCount, itemErrcount);
progress.Update();
}
else
{
StatusCode = Status.Error.ToString();
StatusMessage = "發送失敗!";
itemErrcount++;
progress.SetProgressValue(100);
progress.SetStatusInfo.Text = string.Format("操作{0}:{1}條 " + "錯誤:{2} 條", StatusMessage, itemCount, itemErrcount);
progress.Update();
}
}
}
這是本人的關於跨境的倉儲管理系統,跨境申報,打單發貨一體,支持普貿中境一起操作。
這是本人的關於跨境的倉儲管理系統,跨境申報,打單發貨一體,支持普貿中境一起操作。
插上IC卡即可加簽發送申報,目前支持杭州,海南,上海,深圳等海關對接申報。
就展示到這裡了,希望有關做這方面的公司使用幫你快速進行跨境貿易通關服務。15557148372,QQ:183840232