booking_auth_dev
wet 2 years ago
commit 4f8bde9e55

@ -1,10 +1,13 @@
using Furion;
using Furion.Logging;
using Furion.RemoteRequest.Extensions;
using Microsoft.Extensions.Logging;
using Myshipping.Application.ConfigOption;
using Myshipping.Application.Entity;
using Myshipping.Core;
using Myshipping.Core.Entity;
using Myshipping.Core.Service;
using Newtonsoft.Json.Linq;
using SqlSugar;
using System;
using System.Collections.Generic;
@ -13,25 +16,25 @@ using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application.EDI.Yard
namespace Myshipping.Application.EDI
{
/// <summary>
/// 下货纸辅助类
/// </summary>
public static class XiahuozhiHelpler
{
private static readonly string EdiFilePath = "XHZ";
public static bool Send(
//SqlSugarRepository<BookingOrder> repOrder,
//SqlSugarRepository<BookingCtn> repCtn,
//SqlSugarRepository<SysDictType> repDictType,
//SqlSugarRepository<SysDictData> repDictData,
//SqlSugarRepository<BookingFile> repBookingFile,
//SqlSugarRepository<DjyEdiSetting> repEdiSetting,
long bookingId, string filerole, out string msg, string attShowName = "系统")
long bookingId, string filerole, out string msg)
{
var sugerClient = App.GetService<ISqlSugarClient>();
var repOrder = App.GetService<SqlSugarRepository<BookingOrder>>();
var repCtn = App.GetService<SqlSugarRepository<BookingCtn>>();
var repBookingFile = App.GetService<SqlSugarRepository<BookingFile>>();
var cacheService = App.GetService<ISysCacheService>();
var order = sugerClient.Queryable<BookingOrder>().First(o => o.Id == bookingId);
var order = repOrder.FirstOrDefault(o => o.Id == bookingId);
if (order == null)
{
msg = "订舱信息未找到";
@ -64,9 +67,9 @@ namespace Myshipping.Application.EDI.Yard
}
var fileOpt = App.GetOptions<BookingAttachOptions>();
if (!Directory.Exists(fileOpt.basePath))
if (string.IsNullOrEmpty(fileOpt.basePath))
{
Directory.CreateDirectory(fileOpt.basePath);
fileOpt.basePath = AppDomain.CurrentDomain.BaseDirectory;
}
@ -91,20 +94,23 @@ namespace Myshipping.Application.EDI.Yard
var paraXHZ = GetAllTenantParam().Result.FirstOrDefault(p => p.TenantId == order.TenantId && p.ParaCode == "CODE_GLJ_XHZ");
if (paraXHZ == null || string.IsNullOrEmpty(paraXHZ.ItemCode))
{
msg = "下货纸代号未找到或配置有误";
msg = $"{order.TenantName} 港联捷场站 下货纸代号未找到或配置有误";
return false;
}
var ediFileName = $"{paraXHZ.ItemCode}_{order.MBLNO}_{DateTime.Now.Ticks}.txt";
var ediFileRela = Path.Combine("XHZ", ediFileName);
var ediFileAbs = Path.Combine(fileOpt.basePath, ediFileRela);
var ediFileRela = Path.Combine(EdiFilePath, ediFileName);
var ediPathAbs = Path.Combine(fileOpt.basePath, EdiFilePath);
var ediFileAbs = Path.Combine(ediPathAbs, ediFileRela);
if (!Directory.Exists(ediPathAbs))
{
Directory.CreateDirectory(ediPathAbs);
}
//港联捷所有用户使用一个ftp用户名和密码发送报文使用文件名中的下货纸代号进行区分
var dicTypeGLJ = repDictType.FirstOrDefault(x => x.Code == "booking_ftp_setting_glj");
var dicDataGLJ = repDictData.Where(x => x.TypeId == dicTypeGLJ.Id).ToList();
var paraServer = dicDataGLJ.FirstOrDefault(x => x.Code == "ftp_server").Value;
var paraUser = dicDataGLJ.FirstOrDefault(x => x.Code == "username").Value;
var paraPwd = dicDataGLJ.FirstOrDefault(x => x.Code == "pwd").Value;
var paraServer = cacheService.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "booking_ftp_setting_glj" && x.Code == "ftp_server");
var paraUser = cacheService.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "booking_ftp_setting_glj" && x.Code == "username");
var paraPwd = cacheService.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "booking_ftp_setting_glj" && x.Code == "pwd");
if (paraServer == null || paraUser == null || paraPwd == null)
{
@ -132,7 +138,7 @@ namespace Myshipping.Application.EDI.Yard
var ctnCodes = GetAllCodeCtn().Result.Select(x => new { x.Code, x.Size }).ToList();
var ctnEdiList = GetAllMappingCtn().Result.AsQueryable().Where(x => x.Module == "XHZ_GLJ" && x.CarrierCode == order.CARRIERID).ToList();
var ctns = sugerClient.Queryable<BookingCtn>().Where(c => c.BILLID == bookingId).ToList();
var ctns = repCtn.Where(c => c.BILLID == bookingId).ToList();
foreach (var ctn in ctns)
{
var ctnFind = ctnCodes.FirstOrDefault(c => c.Code == ctn.CTNCODE);
@ -156,15 +162,27 @@ namespace Myshipping.Application.EDI.Yard
File.WriteAllText(ediFileAbs, sbData.ToString());
//发送ftp
//BackgroundTaskFtp ftpTask = new BackgroundTaskFtp();
//ftpTask.GID = Guid.NewGuid().ToString();
//ftpTask.FtpHost = paraServer.PARAMVALUE;
//ftpTask.FtpUser = paraUser.PARAMVALUE;
//ftpTask.FtpPassword = paraPwd.PARAMVALUE;
//ftpTask.FtpData = FtpTaskHelper.GenTaskJson("", ediFile, null);
//ftpTask.Type = BackgroundTaskFtp.TypeFtpUpload;
//commonData.BackgroundTaskFtp.Add(ftpTask);
//commonData.SaveChanges();
var ftpPostObj = new
{
host = paraServer.Value,
username = paraUser.Value,
pwd = paraPwd.Value,
path = "/"
};
var ftpSpiderUrl = cacheService.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "booking_edi_ftp_server").Value;
Log.Information($"准备请求发送ftp{ftpSpiderUrl} ,参数:{ftpPostObj.ToJsonString()},文件:{ediFileName}");
var res = ftpSpiderUrl
.SetContentType("multipart/form-data")
.SetBody(ftpPostObj)
.SetBodyBytes(("file", Encoding.UTF8.GetBytes(sbData.ToString()), ediFileName))
.PostAsStringAsync();
Log.Information($"发送ftp返回{res}");
var jobjRetn = JObject.Parse(res.Result);
if (jobjRetn.GetStringValue("status") != "1")
{
msg = $"ftp发送失败{jobjRetn.GetStringValue("message")}";
return false;
}
//挂载附件
var attFile = new BookingFile();
@ -174,7 +192,7 @@ namespace Myshipping.Application.EDI.Yard
attFile.TypeCode = "xiahuozhi";
attFile.TypeName = "下货纸";
attFile.TenantName = order.TenantName;
sugerClient.Insertable(attFile).ExecuteCommand();
repBookingFile.Insert(attFile);
msg = "已发送";
return true;
@ -209,17 +227,22 @@ namespace Myshipping.Application.EDI.Yard
}
var ediFileName = $"{order.VESSEL}_{order.VOYNO}_{order.MBLNO}_{DateTime.Now.Ticks}.txt";
var ediFileRela = Path.Combine("XHZ", ediFileName);
var ediFileAbs = Path.Combine(fileOpt.basePath, ediFileRela);
var ediFileRela = Path.Combine(EdiFilePath, ediFileName);
var ediPathAbs = Path.Combine(fileOpt.basePath, EdiFilePath);
var ediFileAbs = Path.Combine(ediPathAbs, ediFileRela);
if (!Directory.Exists(ediPathAbs))
{
Directory.CreateDirectory(ediPathAbs);
}
DjyEdiSetting ftpset = null;
if (order.YARD == "港捷丰场站")
{
ftpset = repEdiSetting.FirstOrDefault(f => f.EDINAME == "XHZ_GJF" && f.TenantId == order.TenantId);
ftpset = cacheService.GetAllEdiSetting().Result.FirstOrDefault(f => f.EDINAME == "XHZ_GJF" && f.TenantId == order.TenantId);
}
else if (order.YARD == "捷丰场站")
{
ftpset = repEdiSetting.FirstOrDefault(f => f.EDINAME == "XHZ_JIEFENG" && f.TenantId == order.TenantId);
ftpset = cacheService.GetAllEdiSetting().Result.FirstOrDefault(f => f.EDINAME == "XHZ_JIEFENG" && f.TenantId == order.TenantId);
}
if (ftpset == null)
@ -406,15 +429,27 @@ namespace Myshipping.Application.EDI.Yard
File.WriteAllText(ediFileAbs, strJoin, Encoding.Default);
//后续发送
//BackgroundTaskFtp ftpTask = new BackgroundTaskFtp();
//ftpTask.GID = Guid.NewGuid().ToString();
//ftpTask.FtpHost = ftpset.SERVERIP;
//ftpTask.FtpUser = ftpset.USERNAME;
//ftpTask.FtpPassword = ftpset.PASSWORD;
//ftpTask.FtpData = FtpTaskHelper.GenTaskJson(ftpset.FOLDERNAME, ediFile, null);
//ftpTask.Type = BackgroundTaskFtp.TypeFtpUpload;
//commonData.BackgroundTaskFtp.Add(ftpTask);
//commonData.SaveChanges();
var ftpPostObj = new
{
host = ftpset.SERVERIP,
username = ftpset.USERNAME,
pwd = ftpset.PASSWORD,
path = ftpset.FOLDERNAME
};
var ftpSpiderUrl = cacheService.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "booking_edi_ftp_server").Value;
Log.Information($"准备请求发送ftp{ftpSpiderUrl} ,参数:{ftpPostObj.ToJsonString()},文件:{ediFileName}");
var res = ftpSpiderUrl
.SetContentType("multipart/form-data")
.SetBody(ftpPostObj)
.SetBodyBytes(("file", Encoding.UTF8.GetBytes(strJoin), ediFileName))
.PostAsStringAsync();
Log.Information($"发送ftp返回{res}");
var jobjRetn = JObject.Parse(res.Result);
if (jobjRetn.GetStringValue("status") != "1")
{
msg = $"ftp发送失败{jobjRetn.GetStringValue("message")}";
return false;
}
//挂载附件
@ -439,7 +474,7 @@ namespace Myshipping.Application.EDI.Yard
var pGlxEdi = GetAllTenantParam().Result.FirstOrDefault(p => p.TenantId == order.TenantId && p.ParaCode == "XIAHUOZHI_GLX_SEND_TYPE");
if (order.YARD == "港联欣场站" && pGlxEdi != null && pGlxEdi.ItemCode == "EDI_GLJ")
{
var ftpset = repEdiSetting.FirstOrDefault(f => f.EDINAME == "XHZ_GLX" && f.TenantId == order.TenantId);
var ftpset = cacheService.GetAllEdiSetting().Result.FirstOrDefault(f => f.EDINAME == "XHZ_GLX" && f.TenantId == order.TenantId);
if (ftpset == null)
{
msg = "港联欣下货纸ftp设置未找到";
@ -454,8 +489,13 @@ namespace Myshipping.Application.EDI.Yard
}
var ediFileName = $"{paraXHZ.ItemCode}_{order.MBLNO}_{DateTime.Now.Ticks}.txt";
var ediFileRela = Path.Combine("XHZ", ediFileName);
var ediFileAbs = Path.Combine(fileOpt.basePath, ediFileRela);
var ediFileRela = Path.Combine(EdiFilePath, ediFileName);
var ediPathAbs = Path.Combine(fileOpt.basePath, EdiFilePath);
var ediFileAbs = Path.Combine(ediPathAbs, ediFileRela);
if (!Directory.Exists(ediPathAbs))
{
Directory.CreateDirectory(ediPathAbs);
}
StringBuilder sbData = new StringBuilder();
sbData.AppendLine($"01:{order.VESSEL}:{order.VOYNO}"); //船名 航次
@ -495,15 +535,27 @@ namespace Myshipping.Application.EDI.Yard
File.WriteAllText(ediFileAbs, sbData.ToString());
//后续发送
//BackgroundTaskFtp ftpTask = new BackgroundTaskFtp();
//ftpTask.GID = Guid.NewGuid().ToString();
//ftpTask.FtpHost = ftpset.SERVERIP;
//ftpTask.FtpUser = ftpset.USERNAME;
//ftpTask.FtpPassword = ftpset.PASSWORD;
//ftpTask.FtpData = FtpTaskHelper.GenTaskJson("", ediFile, null);
//ftpTask.Type = BackgroundTaskFtp.TypeFtpUpload;
//commonData.BackgroundTaskFtp.Add(ftpTask);
//commonData.SaveChanges();
var ftpPostObj = new
{
host = ftpset.SERVERIP,
username = ftpset.USERNAME,
pwd = ftpset.PASSWORD,
path = ftpset.FOLDERNAME
};
var ftpSpiderUrl = cacheService.GetAllDictData().Result.FirstOrDefault(x => x.TypeCode == "url_set" && x.Code == "booking_edi_ftp_server").Value;
Log.Information($"准备请求发送ftp{ftpSpiderUrl} ,参数:{ftpPostObj.ToJsonString()},文件:{ediFileName}");
var res = ftpSpiderUrl
.SetContentType("multipart/form-data")
.SetBody(ftpPostObj)
.SetBodyBytes(("file", Encoding.UTF8.GetBytes(sbData.ToString()), ediFileName))
.PostAsStringAsync();
Log.Information($"发送ftp返回{res}");
var jobjRetn = JObject.Parse(res.Result);
if (jobjRetn.GetStringValue("status") != "1")
{
msg = $"ftp发送失败{jobjRetn.GetStringValue("message")}";
return false;
}
//挂载附件
var attFile = new BookingFile();
@ -522,53 +574,53 @@ namespace Myshipping.Application.EDI.Yard
msg = "场站联系人邮箱不能为空";
return false;
}
// MailDataContext mailData = new MailDataContext();
// var userMail = mailData.UserAccounts.AsNoTracking().FirstOrDefault(ua => ua.UserId == order.USERID);
// if (userMail == null
// || string.IsNullOrEmpty(userMail.SmtpServer)
// || userMail.SmtpPort == 0)
// {
// msg = "发件邮箱未配置";
// return false;
// }
// var userbase = sugerClient.Queryable<SysUser>().First(u => u.Id == order.CreatedUserId);
// var title = $"下货纸:{order.MBLNO}/{order.CARRIER}/{order.VESSEL}/{order.VOYNO}/{order.TenantName}";
// var bodyExt = string.Empty;
// if (order.CARGOID == "R")
// {
// bodyExt = $@"温度:{order.TEMPSET}{order.TEMPID}<br/>
//通风:{order.REEFERF}<br/>
//湿度:{order.HUMIDITY}<br/>";
// }
// else if (order.CARGOID == "D")
// {
// bodyExt = $@"危险品等级:{order.DCLASS}<br/>
//危险品编号:{order.DUNNO}<br/>
//危险品联系方式:{order.LINKMAN}<br/>";
// }
// var body = $@"提单号:{order.MBLNO}<br/>
//船名航次:{order.VESSEL}/{order.VOYNO}<br/>
//起运港:{order.PORTLOAD},{order.PORTLOADID}<br/>
//目的港:{order.PORTDISCHARGE},{order.PORTDISCHARGEID}<br/>
//目的地:{order.DESTINATION},{order.DESTINATIONID}<br/>
//预计船期:{(order.ETD.HasValue ? order.ETD.Value.ToString("yyyy-MM-dd") : "")}<br/>
//箱型箱量:{order.CNTRTOTAL}<br/>
//件重尺:{order.PKGS} {order.KINDPKGS}/{order.KGS}KGS/{order.CBM}CBM<br/>
//货物描述:{order.DESCRIPTION}<br/>
//{bodyExt}
//备注:{order.YARDREMARK}<br/>
//<br/>
//订舱代理:{order.TenantName}<br/>
//联系人:{order.CreatedUserName}<br/>
//电话:{userbase.Tel} 手机:{userbase.Phone}<br/>
//邮箱:{userbase.Email}<br/>
//";
// MailHelper.SendMail(userMail.GID, title, body, order.YardContractEmail, customerSend: true);
// MailDataContext mailData = new MailDataContext();
// var userMail = mailData.UserAccounts.AsNoTracking().FirstOrDefault(ua => ua.UserId == order.USERID);
// if (userMail == null
// || string.IsNullOrEmpty(userMail.SmtpServer)
// || userMail.SmtpPort == 0)
// {
// msg = "发件邮箱未配置";
// return false;
// }
// var userbase = sugerClient.Queryable<SysUser>().First(u => u.Id == order.CreatedUserId);
// var title = $"下货纸:{order.MBLNO}/{order.CARRIER}/{order.VESSEL}/{order.VOYNO}/{order.TenantName}";
// var bodyExt = string.Empty;
// if (order.CARGOID == "R")
// {
// bodyExt = $@"温度:{order.TEMPSET}{order.TEMPID}<br/>
//通风:{order.REEFERF}<br/>
//湿度:{order.HUMIDITY}<br/>";
// }
// else if (order.CARGOID == "D")
// {
// bodyExt = $@"危险品等级:{order.DCLASS}<br/>
//危险品编号:{order.DUNNO}<br/>
//危险品联系方式:{order.LINKMAN}<br/>";
// }
// var body = $@"提单号:{order.MBLNO}<br/>
//船名航次:{order.VESSEL}/{order.VOYNO}<br/>
//起运港:{order.PORTLOAD},{order.PORTLOADID}<br/>
//目的港:{order.PORTDISCHARGE},{order.PORTDISCHARGEID}<br/>
//目的地:{order.DESTINATION},{order.DESTINATIONID}<br/>
//预计船期:{(order.ETD.HasValue ? order.ETD.Value.ToString("yyyy-MM-dd") : "")}<br/>
//箱型箱量:{order.CNTRTOTAL}<br/>
//件重尺:{order.PKGS} {order.KINDPKGS}/{order.KGS}KGS/{order.CBM}CBM<br/>
//货物描述:{order.DESCRIPTION}<br/>
//{bodyExt}
//备注:{order.YARDREMARK}<br/>
//<br/>
//订舱代理:{order.TenantName}<br/>
//联系人:{order.CreatedUserName}<br/>
//电话:{userbase.Tel} 手机:{userbase.Phone}<br/>
//邮箱:{userbase.Email}<br/>
//";
// MailHelper.SendMail(userMail.GID, title, body, order.YardContractEmail, customerSend: true);
}
msg = "已发送";
return true;

@ -13,7 +13,6 @@
</ItemGroup>
<ItemGroup>
<Compile Remove="EDI\Yard\XiahuozhiHelpler.cs" />
<Compile Remove="Entity\DjyBooking.cs" />
<Compile Remove="Service\BookingCtnDetail\BookingCtnDetailService.cs" />
<Compile Remove="Service\BookingCtnDetail\IBookingCtnDetailService.cs" />
@ -35,8 +34,4 @@
<ProjectReference Include="..\Myshipping.Core\Myshipping.Core.csproj" />
</ItemGroup>
<ItemGroup>
<Folder Include="EDI\Yard\" />
</ItemGroup>
</Project>

@ -34,6 +34,81 @@
订舱附件文件配置
</summary>
</member>
<member name="T:Myshipping.Application.EDI.XiahuozhiHelpler">
<summary>
下货纸辅助类
</summary>
</member>
<member name="M:Myshipping.Application.EDI.XiahuozhiHelpler.formatEdiStr(System.String,System.String)">
<summary>
各种文本转义字符东胜7移植
</summary>
<param name="fileType">文件类型例如txt、xml</param>
<param name="str">文本字符串</param>
<returns></returns>
</member>
<member name="M:Myshipping.Application.EDI.XiahuozhiHelpler.GetCtnEDICode(System.String,System.String)">
<summary>
获取箱型的EDI代码
</summary>
<param name="ctnCode"></param>
<param name="EDINAME"></param>
<returns></returns>
</member>
<member name="M:Myshipping.Application.EDI.XiahuozhiHelpler.GetAllCodeCtn">
<summary>
获取所有箱型(使用缓存)
</summary>
<returns></returns>
</member>
<member name="M:Myshipping.Application.EDI.XiahuozhiHelpler.GetAllCodeCarrier">
<summary>
获取所有船司(使用缓存)
</summary>
<returns></returns>
</member>
<member name="M:Myshipping.Application.EDI.XiahuozhiHelpler.GetAllMappingCtn">
<summary>
获取所有箱型映射(使用缓存)
</summary>
<returns></returns>
</member>
<member name="M:Myshipping.Application.EDI.XiahuozhiHelpler.GetAllMappingCarrier">
<summary>
获取所有船司映射(使用缓存)
</summary>
<returns></returns>
</member>
<member name="M:Myshipping.Application.EDI.XiahuozhiHelpler.GetAllCodeFrt">
<summary>
获取所有付费方式(使用缓存)
</summary>
<returns></returns>
</member>
<member name="M:Myshipping.Application.EDI.XiahuozhiHelpler.GetAllMappingFrt">
<summary>
获取所有付费方式映射(使用缓存)
</summary>
<returns></returns>
</member>
<member name="M:Myshipping.Application.EDI.XiahuozhiHelpler.GetAllTenantParam">
<summary>
获取所有公司参数(使用缓存)
</summary>
<returns></returns>
</member>
<member name="M:Myshipping.Application.EDI.XiahuozhiHelpler.GetAllCodeVessel">
<summary>
获取所有船名(使用缓存)
</summary>
<returns></returns>
</member>
<member name="M:Myshipping.Application.EDI.XiahuozhiHelpler.GetAllMappingVessel">
<summary>
获取所有船名映射(使用缓存)
</summary>
<returns></returns>
</member>
<member name="T:Myshipping.Application.Entity.BookingCtn">
<summary>

@ -30,6 +30,7 @@ using Myshipping.Core.Entity;
using Furion.RemoteRequest.Extensions;
using System.Net.Http;
using Myshipping.Core.Service;
using Myshipping.Application.EDI;
namespace Myshipping.Application
{

@ -14,6 +14,8 @@ using Myshipping.Application.ConfigOption;
using System.IO;
using Yitter.IdGenerator;
using Furion.FriendlyException;
using Furion.RemoteRequest.Extensions;
using System.Text;
namespace Myshipping.Application
{
@ -202,5 +204,6 @@ namespace Myshipping.Application
//{
// return await _rep.ToListAsync();
//}
}
}

@ -0,0 +1,134 @@
using Newtonsoft.Json.Linq;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Core
{
public static class JsonExtension
{
/// <summary>
/// 获取JObject
/// </summary>
/// <param name="jobj"></param>
/// <param name="prop"></param>
/// <returns></returns>
public static JObject GetJObjectValue(this JObject jobj, string prop)
{
var jt = jobj[prop];
if (jt == null)
{
return null;
}
return jt as JObject;
}
/// <summary>
/// 获取字符串值
/// </summary>
/// <param name="jobj"></param>
/// <param name="prop"></param>
/// <returns></returns>
public static string GetStringValue(this JObject jobj, string prop)
{
var jt = jobj[prop];
if (jt == null)
{
return string.Empty;
}
return jt.ToString();
}
/// <summary>
/// 获取int值
/// </summary>
/// <param name="jobj"></param>
/// <param name="prop"></param>
/// <returns></returns>
public static int GetIntValue(this JObject jobj, string prop)
{
var jt = jobj[prop];
if (jt == null)
{
return 0;
}
var strVal = jt.ToString();
int rtnVal = 0;
int.TryParse(strVal, out rtnVal);
return rtnVal;
}
/// <summary>
/// 获取decimal值
/// </summary>
/// <param name="jobj"></param>
/// <param name="prop"></param>
/// <returns></returns>
public static decimal GetDecimalValue(this JObject jobj, string prop)
{
var jt = jobj[prop];
if (jt == null)
{
return 0;
}
var strVal = jt.ToString();
decimal rtnVal = 0;
decimal.TryParse(strVal, out rtnVal);
return rtnVal;
}
/// <summary>
/// 获取datetime值
/// </summary>
/// <param name="jobj"></param>
/// <param name="prop"></param>
/// <returns></returns>
public static DateTime? GetDateTimeValue(this JObject jobj, string prop)
{
var jt = jobj[prop];
if (jt == null)
{
return null;
}
var strVal = jt.ToString();
DateTime rtnVal = DateTime.MinValue;
if (DateTime.TryParse(strVal, out rtnVal))
{
return rtnVal;
}
return null;
}
/// <summary>
/// 获取datetime值不带秒yyyy-MM-dd HH:mm
/// </summary>
/// <param name="jobj"></param>
/// <param name="prop"></param>
/// <returns></returns>
public static DateTime? GetDateTimeMinuteValue(this JObject jobj, string prop)
{
var jt = jobj[prop];
if (jt == null)
{
return null;
}
var strVal = jt.ToString() + ":00";
DateTime rtnVal = DateTime.MinValue;
if (DateTime.TryParse(strVal, out rtnVal))
{
return rtnVal;
}
return null;
}
}
}

@ -4492,6 +4492,54 @@
降序排序(不要问我为什么是descend不是desc前端约定参数就是这样)
</summary>
</member>
<member name="M:Myshipping.Core.JsonExtension.GetJObjectValue(Newtonsoft.Json.Linq.JObject,System.String)">
<summary>
获取JObject
</summary>
<param name="jobj"></param>
<param name="prop"></param>
<returns></returns>
</member>
<member name="M:Myshipping.Core.JsonExtension.GetStringValue(Newtonsoft.Json.Linq.JObject,System.String)">
<summary>
获取字符串值
</summary>
<param name="jobj"></param>
<param name="prop"></param>
<returns></returns>
</member>
<member name="M:Myshipping.Core.JsonExtension.GetIntValue(Newtonsoft.Json.Linq.JObject,System.String)">
<summary>
获取int值
</summary>
<param name="jobj"></param>
<param name="prop"></param>
<returns></returns>
</member>
<member name="M:Myshipping.Core.JsonExtension.GetDecimalValue(Newtonsoft.Json.Linq.JObject,System.String)">
<summary>
获取decimal值
</summary>
<param name="jobj"></param>
<param name="prop"></param>
<returns></returns>
</member>
<member name="M:Myshipping.Core.JsonExtension.GetDateTimeValue(Newtonsoft.Json.Linq.JObject,System.String)">
<summary>
获取datetime值
</summary>
<param name="jobj"></param>
<param name="prop"></param>
<returns></returns>
</member>
<member name="M:Myshipping.Core.JsonExtension.GetDateTimeMinuteValue(Newtonsoft.Json.Linq.JObject,System.String)">
<summary>
获取datetime值不带秒yyyy-MM-dd HH:mm
</summary>
<param name="jobj"></param>
<param name="prop"></param>
<returns></returns>
</member>
<member name="T:Myshipping.Core.PagedQueryableExtensions">
<summary>
分页拓展类

Loading…
Cancel
Save