|
|
|
@ -4,6 +4,7 @@ using Furion.RemoteRequest.Extensions;
|
|
|
|
|
using Microsoft.Extensions.Logging;
|
|
|
|
|
using Myshipping.Application.ConfigOption;
|
|
|
|
|
using Myshipping.Application.Entity;
|
|
|
|
|
using Myshipping.Application.Helper;
|
|
|
|
|
using Myshipping.Core;
|
|
|
|
|
using Myshipping.Core.Entity;
|
|
|
|
|
using Myshipping.Core.Helper;
|
|
|
|
@ -12,6 +13,7 @@ using Newtonsoft.Json.Linq;
|
|
|
|
|
using SqlSugar;
|
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Collections.Specialized;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Linq;
|
|
|
|
|
using System.Text;
|
|
|
|
@ -151,23 +153,24 @@ namespace Myshipping.Application.EDI
|
|
|
|
|
attFile.TenantName = order.TenantName;
|
|
|
|
|
repBookingFile.Insert(attFile);
|
|
|
|
|
|
|
|
|
|
SplitFtpServerAndPort(paraServer.Value, out string server, out int port);
|
|
|
|
|
//发送ftp
|
|
|
|
|
var ftpPostObj = new
|
|
|
|
|
{
|
|
|
|
|
host = server,
|
|
|
|
|
username = paraUser.Value,
|
|
|
|
|
pwd = paraPwd.Value,
|
|
|
|
|
path = "/",
|
|
|
|
|
port = port,
|
|
|
|
|
};
|
|
|
|
|
SplitFtpServerAndPort(paraServer.Value, out string server, out int port);
|
|
|
|
|
|
|
|
|
|
var ftpSpiderUrl = dicData.FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "booking_edi_ftp_server").Value;
|
|
|
|
|
Log.Information($"准备请求发送ftp:{ftpSpiderUrl} ,参数:{ftpPostObj.ToJsonString()},文件:{ediFileName}");
|
|
|
|
|
var res = await ftpSpiderUrl
|
|
|
|
|
.SetContentType("multipart/form-data")
|
|
|
|
|
.SetBody(ftpPostObj)
|
|
|
|
|
.SetBodyBytes(("file", Encoding.UTF8.GetBytes(sbData.ToString()), ediFileName))
|
|
|
|
|
.PostAsStringAsync();
|
|
|
|
|
NameValueCollection par = new NameValueCollection();
|
|
|
|
|
par.Add("host", server);
|
|
|
|
|
par.Add("port", port.ToString());
|
|
|
|
|
par.Add("username", paraUser.Value);
|
|
|
|
|
par.Add("pwd", paraPwd.Value);
|
|
|
|
|
par.Add("path", "/");
|
|
|
|
|
|
|
|
|
|
Log.Information($"准备请求发送ftp:{ftpSpiderUrl} ,参数:{par.ToJsonString()},文件:{ediFileName}");
|
|
|
|
|
var res = FTPHelper.TransmitFtpFile(ftpSpiderUrl, par, new
|
|
|
|
|
{
|
|
|
|
|
file = "file",
|
|
|
|
|
fileName = Path.GetFileName(ediFileName),
|
|
|
|
|
fileBytes = Encoding.UTF8.GetBytes(sbData.ToString())
|
|
|
|
|
});
|
|
|
|
|
Log.Information($"发送ftp返回:{res}");
|
|
|
|
|
var jobjRetn = JObject.Parse(res);
|
|
|
|
|
if (jobjRetn.GetStringValue("status") != "1")
|
|
|
|
@ -175,6 +178,7 @@ namespace Myshipping.Application.EDI
|
|
|
|
|
return new KeyValuePair<bool, string>(false, $"ftp发送失败:{jobjRetn.GetStringValue("message")}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
return new KeyValuePair<bool, string>(true, $"已发送");
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
@ -413,23 +417,24 @@ namespace Myshipping.Application.EDI
|
|
|
|
|
attFile.TenantName = order.TenantName;
|
|
|
|
|
await repBookingFile.InsertAsync(attFile);
|
|
|
|
|
|
|
|
|
|
//发送ftp
|
|
|
|
|
SplitFtpServerAndPort(ftpset.SERVERIP, out string server, out int port);
|
|
|
|
|
//后续发送
|
|
|
|
|
var ftpPostObj = new
|
|
|
|
|
{
|
|
|
|
|
host = server,
|
|
|
|
|
username = ftpset.USERNAME,
|
|
|
|
|
pwd = ftpset.PASSWORD,
|
|
|
|
|
path = ftpset.FOLDERNAME,
|
|
|
|
|
port = port,
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var ftpSpiderUrl = (await cacheService.GetAllDictData()).FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "booking_edi_ftp_server").Value;
|
|
|
|
|
Log.Information($"准备请求发送ftp:{ftpSpiderUrl} ,参数:{ftpPostObj.ToJsonString()},文件:{ediFileName}");
|
|
|
|
|
var res = await ftpSpiderUrl
|
|
|
|
|
.SetContentType("multipart/form-data")
|
|
|
|
|
.SetBody(ftpPostObj)
|
|
|
|
|
.SetBodyBytes(("file", Encoding.UTF8.GetBytes(strJoin), ediFileName))
|
|
|
|
|
.PostAsStringAsync();
|
|
|
|
|
NameValueCollection par = new NameValueCollection();
|
|
|
|
|
par.Add("host", server);
|
|
|
|
|
par.Add("port", port.ToString());
|
|
|
|
|
par.Add("username", ftpset.USERNAME);
|
|
|
|
|
par.Add("pwd", ftpset.PASSWORD);
|
|
|
|
|
par.Add("path", ftpset.FOLDERNAME);
|
|
|
|
|
|
|
|
|
|
Log.Information($"准备请求发送ftp:{ftpSpiderUrl} ,参数:{par.ToJsonString()},文件:{ediFileName}");
|
|
|
|
|
var res = FTPHelper.TransmitFtpFile(ftpSpiderUrl, par, new
|
|
|
|
|
{
|
|
|
|
|
file = "file",
|
|
|
|
|
fileName = Path.GetFileName(ediFileName),
|
|
|
|
|
fileBytes = Encoding.UTF8.GetBytes(strJoin)
|
|
|
|
|
});
|
|
|
|
|
Log.Information($"发送ftp返回:{res}");
|
|
|
|
|
var jobjRetn = JObject.Parse(res);
|
|
|
|
|
if (jobjRetn.GetStringValue("status") != "1")
|
|
|
|
@ -516,29 +521,31 @@ namespace Myshipping.Application.EDI
|
|
|
|
|
attFile.TenantName = order.TenantName;
|
|
|
|
|
repBookingFile.Insert(attFile);
|
|
|
|
|
|
|
|
|
|
//发送ftp
|
|
|
|
|
SplitFtpServerAndPort(ftpset.SERVERIP, out string server, out int port);
|
|
|
|
|
//后续发送
|
|
|
|
|
var ftpPostObj = new
|
|
|
|
|
{
|
|
|
|
|
host = server,
|
|
|
|
|
username = ftpset.USERNAME,
|
|
|
|
|
pwd = ftpset.PASSWORD,
|
|
|
|
|
path = ftpset.FOLDERNAME,
|
|
|
|
|
port = port
|
|
|
|
|
};
|
|
|
|
|
|
|
|
|
|
var ftpSpiderUrl = (await cacheService.GetAllDictData()).FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "booking_edi_ftp_server").Value;
|
|
|
|
|
Log.Information($"准备请求发送ftp:{ftpSpiderUrl} ,参数:{ftpPostObj.ToJsonString()},文件:{ediFileName}");
|
|
|
|
|
var res = await ftpSpiderUrl
|
|
|
|
|
.SetContentType("multipart/form-data")
|
|
|
|
|
.SetBody(ftpPostObj)
|
|
|
|
|
.SetBodyBytes(("file", Encoding.UTF8.GetBytes(sbData.ToString()), ediFileName))
|
|
|
|
|
.PostAsStringAsync();
|
|
|
|
|
NameValueCollection par = new NameValueCollection();
|
|
|
|
|
par.Add("host", server);
|
|
|
|
|
par.Add("port", port.ToString());
|
|
|
|
|
par.Add("username", ftpset.USERNAME);
|
|
|
|
|
par.Add("pwd", ftpset.PASSWORD);
|
|
|
|
|
par.Add("path", ftpset.FOLDERNAME);
|
|
|
|
|
|
|
|
|
|
Log.Information($"准备请求发送ftp:{ftpSpiderUrl} ,参数:{par.ToJsonString()},文件:{ediFileName}");
|
|
|
|
|
var res = FTPHelper.TransmitFtpFile(ftpSpiderUrl, par, new
|
|
|
|
|
{
|
|
|
|
|
file = "file",
|
|
|
|
|
fileName = Path.GetFileName(ediFileName),
|
|
|
|
|
fileBytes = Encoding.UTF8.GetBytes(sbData.ToString())
|
|
|
|
|
});
|
|
|
|
|
Log.Information($"发送ftp返回:{res}");
|
|
|
|
|
var jobjRetn = JObject.Parse(res);
|
|
|
|
|
if (jobjRetn.GetStringValue("status") != "1")
|
|
|
|
|
{
|
|
|
|
|
return new KeyValuePair<bool, string>(false, $"ftp发送失败:{jobjRetn.GetStringValue("message")}");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else //邮件方式
|
|
|
|
|
{
|
|
|
|
|