You cannot select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

34 lines
961 B
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace Myshipping.Application
{
public static class ConstCommon
{
/// <summary>
/// 订舱货物状态分类-单证补料
/// </summary>
public const string BookingStatusLogCateDocSupplement = "doc_supplement";
/// <summary>
/// 验证集装箱号是否符合规则
/// </summary>
/// <param name="code"></param>
/// <returns></returns>
public static bool VerifyContainerCode(string code)
{
const string cc = "0123456789A?BCDEFGHIJK?LMNOPQRSTU?VWXYZ";
var num = code.ToUpper().ToCharArray().Take(10).Select((c, i) => new
{
idx = (int)(cc.IndexOf(c) * Math.Pow(2, i))
}).Sum(p => p.idx);
return int.Parse(code.Substring(10, 1)) == num % 11 % 10;
}
}
}