2021-04-30 10:28:37 +08:00
|
|
|
|
namespace BLL
|
|
|
|
|
{
|
|
|
|
|
using Model;
|
2023-08-10 11:40:02 +08:00
|
|
|
|
using Quartz;
|
|
|
|
|
using RestSharp;
|
2021-04-30 10:28:37 +08:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Globalization;
|
2022-07-26 13:51:21 +08:00
|
|
|
|
using System.Linq;
|
2023-08-10 11:40:02 +08:00
|
|
|
|
using System.Net;
|
2021-04-30 10:28:37 +08:00
|
|
|
|
using System.Reflection;
|
|
|
|
|
using System.Text;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ͨ<>÷<EFBFBD><C3B7><EFBFBD><EFBFBD>ࡣ
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static class Funs
|
|
|
|
|
{
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ά<><CEAC>һ<EFBFBD><D2BB>DB<44><42><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static Dictionary<int, Model.SGGLDB> dataBaseLinkList = new System.Collections.Generic.Dictionary<int, Model.SGGLDB>();
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ά<><CEAC>һ<EFBFBD><D2BB>DB<44><42><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static System.Collections.Generic.Dictionary<int, Model.SGGLDB> DBList
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
return dataBaseLinkList;
|
|
|
|
|
}
|
|
|
|
|
}
|
2023-08-10 11:40:02 +08:00
|
|
|
|
public static IScheduler ScheduledTasks
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
2023-10-12 19:33:22 +08:00
|
|
|
|
public static Dictionary<string ,string >WebEditList= new Dictionary<string ,string >();
|
2021-04-30 10:28:37 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
private static string connString;
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static string ConnString
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
|
|
|
|
if (connString == null)
|
|
|
|
|
{
|
|
|
|
|
throw new NotSupportedException("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return connString;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
set
|
|
|
|
|
{
|
|
|
|
|
if (connString != null)
|
|
|
|
|
{
|
|
|
|
|
throw new NotSupportedException("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ã<EFBFBD>");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
connString = value;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ϵͳ<CFB5><CDB3><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static string SystemName
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static string RootPath
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD>ŷ<EFBFBD><C5B7><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD><C2B7>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static string CNCECPath
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
public static string SGGLUrl
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ʵ<><CAB5><EFBFBD>Ƶ<EFBFBD>ַ
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static string RealNameApiUrl
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
2021-10-19 17:50:34 +08:00
|
|
|
|
/// <20>ѿ<EFBFBD><D1BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static string ControlApiUrl
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
2021-04-30 10:28:37 +08:00
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>汾
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static string SystemVersion
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ÿҳ<C3BF><D2B3><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static int PageSize
|
|
|
|
|
{
|
|
|
|
|
get;
|
|
|
|
|
set;
|
|
|
|
|
} = 15;
|
|
|
|
|
|
2021-05-20 17:16:01 +08:00
|
|
|
|
///// <summary>
|
|
|
|
|
///// <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ<EFBFBD>
|
|
|
|
|
///// </summary>
|
|
|
|
|
//public static SGGLDB DB
|
|
|
|
|
//{
|
|
|
|
|
// get
|
|
|
|
|
// {
|
|
|
|
|
// if (!DBList.ContainsKey(System.Threading.Thread.CurrentThread.ManagedThreadId))
|
|
|
|
|
// {
|
|
|
|
|
// DBList.Add(System.Threading.Thread.CurrentThread.ManagedThreadId, new SGGLDB(connString));
|
|
|
|
|
// }
|
|
|
|
|
|
|
|
|
|
// // DBList[System.Threading.Thread.CurrentThread.ManagedThreadId].CommandTimeout = 1200;
|
|
|
|
|
// return DBList[System.Threading.Thread.CurrentThread.ManagedThreadId];
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
|
|
|
|
|
private static object locker = new object();
|
2022-07-26 13:51:21 +08:00
|
|
|
|
|
2021-04-30 10:28:37 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD>ݿ<EFBFBD><DDBF><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ġ<EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
public static SGGLDB DB
|
|
|
|
|
{
|
|
|
|
|
get
|
|
|
|
|
{
|
2021-05-20 17:16:01 +08:00
|
|
|
|
lock (locker)
|
2021-04-30 10:28:37 +08:00
|
|
|
|
{
|
2021-05-20 17:16:01 +08:00
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!DBList.ContainsKey(System.Threading.Thread.CurrentThread.ManagedThreadId))
|
|
|
|
|
{
|
|
|
|
|
DBList.Add(System.Threading.Thread.CurrentThread.ManagedThreadId, new SGGLDB(connString));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
// DBList[System.Threading.Thread.CurrentThread.ManagedThreadId].CommandTimeout = 1200;
|
|
|
|
|
return DBList[System.Threading.Thread.CurrentThread.ManagedThreadId];
|
|
|
|
|
}
|
|
|
|
|
catch
|
|
|
|
|
{
|
|
|
|
|
var db = new SGGLDB(connString);
|
|
|
|
|
if (DBList.ContainsKey(System.Threading.Thread.CurrentThread.ManagedThreadId))
|
|
|
|
|
{
|
|
|
|
|
DBList[System.Threading.Thread.CurrentThread.ManagedThreadId] = db;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
DBList.Add(System.Threading.Thread.CurrentThread.ManagedThreadId, db);
|
|
|
|
|
}
|
|
|
|
|
return db;
|
|
|
|
|
}
|
2021-04-30 10:28:37 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="password"><3E><><EFBFBD><EFBFBD>ǰ<EFBFBD><C7B0><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
/// <returns><3E><><EFBFBD>ܺ<EFBFBD><DCBA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></returns>
|
|
|
|
|
public static string EncryptionPassword(string password)
|
|
|
|
|
{
|
|
|
|
|
System.Security.Cryptography.MD5 md5 = System.Security.Cryptography.MD5.Create();
|
|
|
|
|
return BitConverter.ToString(md5.ComputeHash(Encoding.UTF8.GetBytes(password))).Replace("-", null);
|
|
|
|
|
|
|
|
|
|
//return System.Web.Security.FormsAuthentication.HashPasswordForStoringInConfigFile(password, "MD5");
|
|
|
|
|
}
|
|
|
|
|
|
2022-07-26 13:51:21 +08:00
|
|
|
|
#region <EFBFBD><EFBFBD>ȡ<EFBFBD>û<EFBFBD><EFBFBD><EFBFBD>ʼ<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><>ȡ<EFBFBD>û<EFBFBD><C3BB><EFBFBD>ʼ<EFBFBD><CABC><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="password"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string getInitialPassword(string unitId, string idCard)
|
|
|
|
|
{
|
|
|
|
|
string prefixValue = "CWCEC";
|
|
|
|
|
string suffixValue = "1234";
|
|
|
|
|
//var getUnit = UnitService.GetUnitByUnitId(unitId);
|
|
|
|
|
//if (getUnit != null)
|
|
|
|
|
//{
|
|
|
|
|
// if (!string.IsNullOrEmpty(getUnit.UnitCode))
|
|
|
|
|
// {
|
|
|
|
|
// if (getUnit.UnitCode.Length > 10)
|
|
|
|
|
// {
|
|
|
|
|
// prefixValue = getUnit.UnitCode.Substring(getUnit.UnitCode.Length - 10);
|
|
|
|
|
// }
|
|
|
|
|
// else
|
|
|
|
|
// {
|
|
|
|
|
// prefixValue = getUnit.UnitCode;
|
|
|
|
|
// }
|
|
|
|
|
// }
|
|
|
|
|
//}
|
|
|
|
|
if (!string.IsNullOrEmpty(idCard))
|
|
|
|
|
{
|
|
|
|
|
if (idCard.Length > 4)
|
|
|
|
|
{
|
|
|
|
|
suffixValue = idCard.Substring(idCard.Length - 4);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
suffixValue = idCard;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return prefixValue + "." + suffixValue;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
#region <EFBFBD><EFBFBD>֤<EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// <summary>
|
|
|
|
|
///
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="c"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static bool IsLetter(char c)
|
|
|
|
|
{
|
|
|
|
|
return (c >= 'a' && c <= 'z') || (c >= 'A' && c <= 'Z');
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool IsDigit(char c)
|
|
|
|
|
{
|
|
|
|
|
return c >= '0' && c <= '9';
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
static bool IsSymbol(char c)
|
|
|
|
|
{
|
|
|
|
|
return c > 32 && c < 127 && !IsDigit(c) && !IsLetter(c);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static bool IsValIDPassword(string password)
|
|
|
|
|
{
|
|
|
|
|
return
|
|
|
|
|
password.Any(c => IsLetter(c)) &&
|
|
|
|
|
password.Any(c => IsDigit(c)) &&
|
|
|
|
|
password.Any(c => IsSymbol(c));
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
2021-04-30 10:28:37 +08:00
|
|
|
|
/// <summary>
|
|
|
|
|
/// ΪĿ<CEAA><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<22><>ѡ<EFBFBD><D1A1>" <20><>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="DLL">Ŀ<><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
public static void PleaseSelect(System.Web.UI.WebControls.DropDownList DDL)
|
|
|
|
|
{
|
|
|
|
|
DDL.Items.Insert(0, new System.Web.UI.WebControls.ListItem("- <20><>ѡ<EFBFBD><D1A1> -", "0"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ΪĿ<CEAA><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<22><>ѡ<EFBFBD><D1A1>" <20><>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="DLL">Ŀ<><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
public static void FineUIPleaseSelect(FineUIPro.DropDownList DDL)
|
|
|
|
|
{
|
|
|
|
|
DDL.Items.Insert(0, new FineUIPro.ListItem("- <20><>ѡ<EFBFBD><D1A1> -", BLL.Const._Null));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ΪĿ<CEAA><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="DLL">Ŀ<><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
public static void FineUIPleaseSelect(FineUIPro.DropDownList DDL, string text)
|
|
|
|
|
{
|
|
|
|
|
DDL.Items.Insert(0, new FineUIPro.ListItem(text, BLL.Const._Null));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ΪĿ<CEAA><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD> "<22><><EFBFBD>±<EFBFBD><C2B1><EFBFBD>" <20><>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="DLL">Ŀ<><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
public static void ReCompileSelect(System.Web.UI.WebControls.DropDownList DDL)
|
|
|
|
|
{
|
|
|
|
|
DDL.Items.Insert(0, new System.Web.UI.WebControls.ListItem("<22><><EFBFBD>±<EFBFBD><C2B1><EFBFBD>", "0"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ҳ<><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="DLL">Ŀ<><C4BF><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
public static void DropDownPageSize(FineUIPro.DropDownList DDL)
|
|
|
|
|
{
|
|
|
|
|
DDL.Items.Insert(0, new FineUIPro.ListItem("10", "10"));
|
|
|
|
|
DDL.Items.Insert(1, new FineUIPro.ListItem("20", "20", true));
|
|
|
|
|
DDL.Items.Insert(2, new FineUIPro.ListItem("30", "30"));
|
|
|
|
|
DDL.Items.Insert(3, new FineUIPro.ListItem("50", "50"));
|
|
|
|
|
DDL.Items.Insert(4, new FineUIPro.ListItem("<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>", "1000000"));
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ƿ<EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="decimalStr">Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD></param>
|
|
|
|
|
/// <returns><3E><><EFBFBD><EFBFBD><EFBFBD>ǻ<EFBFBD><C7BB><EFBFBD></returns>
|
|
|
|
|
public static bool IsDecimal(string decimalStr)
|
|
|
|
|
{
|
|
|
|
|
if (String.IsNullOrEmpty(decimalStr))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Convert.ToDecimal(decimalStr, NumberFormatInfo.InvariantInfo);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ErrLogInfo.WriteLog(string.Empty, ex);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20>ж<EFBFBD>һ<EFBFBD><D2BB><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>Ƿ<EFBFBD><C7B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="integerStr">Ҫ<><D2AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD></param>
|
|
|
|
|
/// <returns><3E><><EFBFBD><EFBFBD><EFBFBD>ǻ<EFBFBD><C7BB><EFBFBD></returns>
|
|
|
|
|
public static bool IsInteger(string integerStr)
|
|
|
|
|
{
|
|
|
|
|
if (String.IsNullOrEmpty(integerStr))
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
Convert.ToInt32(integerStr, NumberFormatInfo.InvariantInfo);
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ErrLogInfo.WriteLog(string.Empty, ex);
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><>ȡ<EFBFBD>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="number">Ҫת<D2AA><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
/// <returns><3E>µ<EFBFBD><C2B5><EFBFBD><EFBFBD><EFBFBD></returns>
|
|
|
|
|
public static string InterceptDecimal(object number)
|
|
|
|
|
{
|
|
|
|
|
if (number == null)
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
decimal newNumber = 0;
|
|
|
|
|
string newNumberStr = "";
|
|
|
|
|
int an = -1;
|
|
|
|
|
string numberStr = number.ToString();
|
|
|
|
|
int n = numberStr.IndexOf(".");
|
|
|
|
|
if (n == -1)
|
|
|
|
|
{
|
|
|
|
|
return numberStr;
|
|
|
|
|
}
|
|
|
|
|
for (int i = n + 1; i < numberStr.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
string str = numberStr.Substring(i, 1);
|
|
|
|
|
if (str == "0")
|
|
|
|
|
{
|
|
|
|
|
if (GetStr(numberStr, i))
|
|
|
|
|
{
|
|
|
|
|
an = i;
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (an == -1)
|
|
|
|
|
{
|
|
|
|
|
newNumber = Convert.ToDecimal(numberStr);
|
|
|
|
|
}
|
|
|
|
|
else if (an == n + 1)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
newNumberStr = numberStr.Substring(0, an - 1);
|
|
|
|
|
newNumber = Convert.ToDecimal(newNumberStr);
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
newNumberStr = numberStr.Substring(0, an);
|
|
|
|
|
newNumber = Convert.ToDecimal(newNumberStr);
|
|
|
|
|
}
|
|
|
|
|
return newNumber.ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20>ж<EFBFBD><D0B6>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD>ӵ<EFBFBD>nλ<6E><CEBB>ʼ<EFBFBD>Ժ<EFBFBD><D4BA>Ƿ<EFBFBD><C7B7><EFBFBD>Ϊ0
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="number">Ҫ<>жϵ<D0B6><CFB5>ַ<EFBFBD><D6B7><EFBFBD></param>
|
|
|
|
|
/// <param name="n"><3E><>ʼ<EFBFBD><CABC>λ<EFBFBD><CEBB></param>
|
|
|
|
|
/// <returns>false<73><65><EFBFBD><EFBFBD>Ϊ0<CEAA><30>true<75><65>Ϊ0</returns>
|
|
|
|
|
public static bool GetStr(string number, int n)
|
|
|
|
|
{
|
|
|
|
|
for (int i = n; i < number.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (number.Substring(i, 1) != "0")
|
|
|
|
|
{
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><>ȡ<EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="str">Ҫ<><D2AA>ȡ<EFBFBD><C8A1><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD></param>
|
|
|
|
|
/// <param name="n"><3E><><EFBFBD><EFBFBD></param>
|
|
|
|
|
/// <returns><3E><>ȡ<EFBFBD><C8A1><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD></returns>
|
|
|
|
|
public static string GetSubStr(object str, object n)
|
|
|
|
|
{
|
|
|
|
|
if (str != null)
|
|
|
|
|
{
|
|
|
|
|
if (str.ToString().Length > Convert.ToInt32(n))
|
|
|
|
|
{
|
|
|
|
|
return str.ToString().Substring(0, Convert.ToInt32(n)) + "....";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return str.ToString();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return "";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD>ݱ<EFBFBD>ʶ<EFBFBD><CAB6><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD>list
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="str"></param>
|
|
|
|
|
/// <param name="n"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static List<string> GetStrListByStr(string str, char n)
|
|
|
|
|
{
|
|
|
|
|
List<string> strList = new List<string>();
|
|
|
|
|
if (!string.IsNullOrEmpty(str))
|
|
|
|
|
{
|
|
|
|
|
strList.AddRange(str.Split(n));
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return strList;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region <EFBFBD><EFBFBD><EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static decimal GetNewDecimalOrZero(string value)
|
|
|
|
|
{
|
|
|
|
|
decimal revalue = 0;
|
|
|
|
|
if (!String.IsNullOrEmpty(value))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
revalue = decimal.Parse(value);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ErrLogInfo.WriteLog(string.Empty, ex);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return revalue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static decimal? GetNewDecimal(string value)
|
|
|
|
|
{
|
|
|
|
|
decimal? revalue = null;
|
|
|
|
|
if (!String.IsNullOrEmpty(value))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
revalue = decimal.Parse(value);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ErrLogInfo.WriteLog(string.Empty, ex);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return revalue;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static int? GetNewInt(string value)
|
|
|
|
|
{
|
|
|
|
|
if (!String.IsNullOrEmpty(value))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return Int32.Parse(value);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ErrLogInfo.WriteLog(string.Empty, ex);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static long? GetNewlong(string value)
|
|
|
|
|
{
|
|
|
|
|
if (!String.IsNullOrEmpty(value))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
return long.Parse(value);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ErrLogInfo.WriteLog(string.Empty, ex);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static int GetNewIntOrZero(string value)
|
|
|
|
|
{
|
|
|
|
|
int revalue = 0;
|
|
|
|
|
if (!String.IsNullOrEmpty(value))
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
revalue = Int32.Parse(value);
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ErrLogInfo.WriteLog(string.Empty, ex);
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return revalue;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ָ<><D6B8><EFBFBD>ϴ<EFBFBD><CFB4>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string GetNewFileName()
|
|
|
|
|
{
|
|
|
|
|
Random rm = new Random(Environment.TickCount);
|
|
|
|
|
return DateTime.Now.ToString("yyyyMMddhhmmss") + rm.Next(1000, 9999).ToString();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ָ<><D6B8><EFBFBD>ϴ<EFBFBD><CFB4>ļ<EFBFBD><C4BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string GetNewFileName(DateTime? dateTime)
|
|
|
|
|
{
|
|
|
|
|
string str = string.Empty;
|
|
|
|
|
Random rm = new Random(System.Environment.TickCount);
|
|
|
|
|
if (dateTime.HasValue)
|
|
|
|
|
{
|
|
|
|
|
str= dateTime.Value.ToString("yyyyMMddhhmmss") + rm.Next(1000, 9999).ToString();
|
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region ʱ<EFBFBD><EFBFBD>ת<EFBFBD><EFBFBD>
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>ת<EFBFBD><D7AA>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static DateTime? GetNewDateTime(string time)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!String.IsNullOrEmpty(time))
|
|
|
|
|
{
|
2021-12-29 18:38:36 +08:00
|
|
|
|
DateTime dateTime = DateTime.Parse(time);
|
|
|
|
|
if (dateTime.Year > 1753 && dateTime.Year < 9999)
|
|
|
|
|
{
|
|
|
|
|
return dateTime;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
2021-04-30 10:28:37 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ErrLogInfo.WriteLog(string.Empty, ex);
|
|
|
|
|
return null;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>ı<EFBFBD>ת<EFBFBD><D7AA>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD>ʱ<EFBFBD><CAB1>Ĭ<EFBFBD>ϵ<EFBFBD>ǰʱ<C7B0>䣩
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static DateTime GetNewDateTimeOrNow(string time)
|
|
|
|
|
{
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
if (!String.IsNullOrEmpty(time))
|
|
|
|
|
{
|
2021-12-29 18:38:36 +08:00
|
|
|
|
DateTime dateTime = DateTime.Parse(time);
|
|
|
|
|
if (dateTime.Year > 1753 && dateTime.Year < 9999)
|
|
|
|
|
{
|
|
|
|
|
return dateTime;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
return DateTime.Now;
|
|
|
|
|
}
|
2021-04-30 10:28:37 +08:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2021-12-29 18:38:36 +08:00
|
|
|
|
return DateTime.Now;
|
2021-04-30 10:28:37 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
catch (Exception ex)
|
|
|
|
|
{
|
|
|
|
|
ErrLogInfo.WriteLog(string.Empty, ex);
|
|
|
|
|
return System.DateTime.Now;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string GetQuarterlyByTime(DateTime time)
|
|
|
|
|
{
|
|
|
|
|
string quarterly = string.Empty;
|
|
|
|
|
string yearName = time.Year.ToString();
|
|
|
|
|
int month = time.Month;
|
|
|
|
|
string name = string.Empty;
|
|
|
|
|
if (month >= 1 && month <= 3)
|
|
|
|
|
{
|
|
|
|
|
name = "<22><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>";
|
|
|
|
|
}
|
|
|
|
|
else if (month >= 4 && month <= 6)
|
|
|
|
|
{
|
|
|
|
|
name = "<22>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD>";
|
|
|
|
|
}
|
|
|
|
|
else if (month >= 7 && month <= 9)
|
|
|
|
|
{
|
|
|
|
|
name = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|
|
|
|
}
|
|
|
|
|
else if (month >= 10 && month <= 12)
|
|
|
|
|
{
|
|
|
|
|
name = "<22><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
quarterly = yearName + "<22><>" + name;
|
|
|
|
|
return quarterly;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static int GetNowQuarterlyByTime(DateTime time)
|
|
|
|
|
{
|
|
|
|
|
int quarterly = 0;
|
|
|
|
|
int month = time.Month;
|
|
|
|
|
if (month >= 1 && month <= 3)
|
|
|
|
|
{
|
|
|
|
|
quarterly = 1;
|
|
|
|
|
}
|
|
|
|
|
else if (month >= 4 && month <= 6)
|
|
|
|
|
{
|
|
|
|
|
quarterly = 2;
|
|
|
|
|
}
|
|
|
|
|
else if (month >= 7 && month <= 9)
|
|
|
|
|
{
|
|
|
|
|
quarterly = 3;
|
|
|
|
|
}
|
|
|
|
|
else if (month >= 10 && month <= 12)
|
|
|
|
|
{
|
|
|
|
|
quarterly = 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return quarterly;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>»<EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static int GetNowQuarterlyByMonth(int month)
|
|
|
|
|
{
|
|
|
|
|
int quarterly = 0;
|
|
|
|
|
if (month >= 1 && month <= 3)
|
|
|
|
|
{
|
|
|
|
|
quarterly = 1;
|
|
|
|
|
}
|
|
|
|
|
else if (month >= 4 && month <= 6)
|
|
|
|
|
{
|
|
|
|
|
quarterly = 2;
|
|
|
|
|
}
|
|
|
|
|
else if (month >= 7 && month <= 9)
|
|
|
|
|
{
|
|
|
|
|
quarterly = 3;
|
|
|
|
|
}
|
|
|
|
|
else if (month >= 10 && month <= 12)
|
|
|
|
|
{
|
|
|
|
|
quarterly = 4;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return quarterly;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ĸ<EFBFBD><C4B8><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string GetQuarterlyNameByMonth(int month)
|
|
|
|
|
{
|
|
|
|
|
string name = string.Empty;
|
|
|
|
|
if (month >= 1 && month <= 3)
|
|
|
|
|
{
|
|
|
|
|
name = "<22><>һ<EFBFBD><D2BB><EFBFBD><EFBFBD>";
|
|
|
|
|
}
|
|
|
|
|
else if (month >= 4 && month <= 6)
|
|
|
|
|
{
|
|
|
|
|
name = "<22>ڶ<EFBFBD><DAB6><EFBFBD><EFBFBD><EFBFBD>";
|
|
|
|
|
}
|
|
|
|
|
else if (month >= 7 && month <= 9)
|
|
|
|
|
{
|
|
|
|
|
name = "<22><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>";
|
|
|
|
|
}
|
|
|
|
|
else if (month >= 10 && month <= 12)
|
|
|
|
|
{
|
|
|
|
|
name = "<22><><EFBFBD>ļ<EFBFBD><C4BC><EFBFBD>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return name;
|
|
|
|
|
}
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ϡ<EFBFBD><CFA1>°<EFBFBD><C2B0><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static int GetNowHalfYearByTime(DateTime time)
|
|
|
|
|
{
|
|
|
|
|
int quarterly = 1;
|
|
|
|
|
int month = time.Month;
|
|
|
|
|
if (month >= 1 && month <= 6)
|
|
|
|
|
{
|
|
|
|
|
quarterly = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
quarterly = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return quarterly;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ϡ<EFBFBD><CFA1>°<EFBFBD><C2B0><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static int GetNowHalfYearByMonth(int month)
|
|
|
|
|
{
|
|
|
|
|
int halfYear = 1;
|
|
|
|
|
if (month >= 1 && month <= 6)
|
|
|
|
|
{
|
|
|
|
|
halfYear = 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
halfYear = 2;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return halfYear;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD>ʱ<EFBFBD><CAB1><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>ϡ<EFBFBD><CFA1>°<EFBFBD><C2B0><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string GetNowHalfYearNameByTime(DateTime time)
|
|
|
|
|
{
|
|
|
|
|
string quarterly = "<22>ϰ<EFBFBD><CFB0><EFBFBD>";
|
|
|
|
|
int month = time.Month;
|
|
|
|
|
if (month >= 1 && month <= 6)
|
|
|
|
|
{
|
|
|
|
|
quarterly = "<22>ϰ<EFBFBD><CFB0><EFBFBD>";
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
quarterly = "<22>°<EFBFBD><C2B0><EFBFBD>";
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
return quarterly;
|
|
|
|
|
}
|
2021-07-06 15:16:17 +08:00
|
|
|
|
|
|
|
|
|
public static DateTime ConvertToDateTime(Int32 d)
|
|
|
|
|
{
|
|
|
|
|
DateTime startTime = new DateTime(1970, 1, 1, 0, 0, 0);
|
|
|
|
|
startTime = startTime.AddSeconds(d).ToLocalTime();
|
|
|
|
|
return startTime;
|
|
|
|
|
}
|
|
|
|
|
public static Int32 ConvertDateTimeToInt32(DateTime dtime)
|
|
|
|
|
{
|
|
|
|
|
string dt = string.Format("{0:yyyy-MM-dd HH:mm:ss}", dtime);
|
|
|
|
|
DateTime dt1 = new DateTime(1970, 1, 1, 8, 0, 0);
|
|
|
|
|
DateTime dt2 = Convert.ToDateTime(dt);
|
|
|
|
|
return Convert.ToInt32((dt2 - dt1).TotalSeconds);
|
|
|
|
|
}
|
2021-04-30 10:28:37 +08:00
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD><EFBFBD><EFBFBD>·<EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="datetime2"></param>
|
|
|
|
|
/// <param name="datetime2"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static int CompareMonths(DateTime datetime1, DateTime datetime2)
|
|
|
|
|
{
|
|
|
|
|
DateTime dt = datetime1;
|
|
|
|
|
DateTime dt2 = datetime2;
|
|
|
|
|
if (DateTime.Compare(dt, dt2) < 0)
|
|
|
|
|
{
|
|
|
|
|
dt2 = dt;
|
|
|
|
|
dt = datetime2;
|
|
|
|
|
}
|
|
|
|
|
int year = dt.Year - dt2.Year;
|
|
|
|
|
int month = dt.Month - dt2.Month;
|
|
|
|
|
month = year * 12 + month;
|
|
|
|
|
if (dt.Day - dt2.Day < -15)
|
|
|
|
|
{
|
|
|
|
|
month--;
|
|
|
|
|
}
|
|
|
|
|
else if (dt.Day - dt2.Day > 14)
|
|
|
|
|
{
|
|
|
|
|
month++;
|
|
|
|
|
}
|
|
|
|
|
return month;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
public static DateTime GetQuarterlyMonths(string year, string quarterly)
|
|
|
|
|
{
|
|
|
|
|
string startMonth = string.Empty;
|
|
|
|
|
if (quarterly == "1")
|
|
|
|
|
{
|
|
|
|
|
startMonth = "1";
|
|
|
|
|
}
|
|
|
|
|
else if (quarterly == "2")
|
|
|
|
|
{
|
|
|
|
|
startMonth = "4";
|
|
|
|
|
}
|
|
|
|
|
else if (quarterly == "3")
|
|
|
|
|
{
|
|
|
|
|
startMonth = "7";
|
|
|
|
|
}
|
|
|
|
|
else if (quarterly == "4")
|
|
|
|
|
{
|
|
|
|
|
startMonth = "10";
|
|
|
|
|
}
|
|
|
|
|
return Funs.GetNewDateTimeOrNow(year + "-" + startMonth + "-01");
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><>ȡ<EFBFBD><C8A1>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="projectType"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string GetUnitWorkType(string projectType)
|
|
|
|
|
{
|
|
|
|
|
string type = string.Empty;
|
|
|
|
|
if (projectType == "1")
|
|
|
|
|
{
|
|
|
|
|
type = "<22><><EFBFBD><EFBFBD>";
|
|
|
|
|
}
|
|
|
|
|
if (projectType == "2")
|
|
|
|
|
{
|
|
|
|
|
type = "<22><>װ";
|
|
|
|
|
}
|
|
|
|
|
return type;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
#region <EFBFBD><EFBFBD>ȡ<EFBFBD><EFBFBD>д<EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>¼<EFBFBD>
|
|
|
|
|
public static string NumericCapitalization(decimal num)
|
|
|
|
|
{
|
|
|
|
|
string str1 = "<22><>Ҽ<EFBFBD><D2BC><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>½<EFBFBD><C2BD><EFBFBD>ƾ<EFBFBD>"; //0-9<><39><EFBFBD><EFBFBD>Ӧ<EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
|
|
|
|
|
string str2 = "<22><>Ǫ<EFBFBD><C7AA>ʰ<EFBFBD><CAB0>Ǫ<EFBFBD><C7AA>ʰ<EFBFBD><CAB0>Ǫ<EFBFBD><C7AA>ʰԪ<CAB0>Ƿ<EFBFBD>"; //<2F><><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>Ӧ<EFBFBD>ĺ<EFBFBD><C4BA><EFBFBD>
|
|
|
|
|
string str3 = ""; //<2F><>ԭnumֵ<6D><D6B5>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
string str4 = ""; //<2F><><EFBFBD>ֵ<EFBFBD><D6B5>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ʽ
|
|
|
|
|
string str5 = ""; //<2F><><EFBFBD><EFBFBD><EFBFBD>Ҵ<EFBFBD>д<EFBFBD><D0B4><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ʽ
|
|
|
|
|
int i; //ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
int j; //num<75><6D>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>100<30><30><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
string ch1 = ""; //<2F><><EFBFBD>ֵĺ<D6B5><C4BA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
string ch2 = ""; //<2F><><EFBFBD><EFBFBD>λ<EFBFBD>ĺ<EFBFBD><C4BA>ֶ<EFBFBD><D6B6><EFBFBD>
|
|
|
|
|
int nzero = 0; //<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ<EFBFBD>Ǽ<EFBFBD><C7BC><EFBFBD>
|
|
|
|
|
int temp; //<2F><>ԭnumֵ<6D><D6B5>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
|
|
|
|
|
num = Math.Round(Math.Abs(num), 2); //<2F><>numȡ<6D><C8A1><EFBFBD><EFBFBD>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ȡ2λС<CEBB><D0A1>
|
|
|
|
|
str4 = ((long)(num * 100)).ToString(); //<2F><>num<75><6D>100<30><30>ת<EFBFBD><D7AA><EFBFBD><EFBFBD><EFBFBD>ַ<EFBFBD><D6B7><EFBFBD><EFBFBD><EFBFBD>ʽ
|
|
|
|
|
j = str4.Length; //<2F>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD><EFBFBD>λ
|
|
|
|
|
if (j > 15) { return "<22><><EFBFBD><EFBFBD>"; }
|
|
|
|
|
str2 = str2.Substring(15 - j); //ȡ<><C8A1><EFBFBD><EFBFBD>Ӧλ<D3A6><CEBB><EFBFBD><EFBFBD>str2<72><32>ֵ<EFBFBD><D6B5><EFBFBD>磺200.55,jΪ5<CEAA><35><EFBFBD><EFBFBD>tr2=<3D><>ʰԪ<CAB0>Ƿ<EFBFBD>
|
|
|
|
|
|
|
|
|
|
//ѭ<><D1AD>ȡ<EFBFBD><C8A1>ÿһλ<D2BB><CEBB>Ҫת<D2AA><D7AA><EFBFBD><EFBFBD>ֵ
|
|
|
|
|
for (i = 0; i < j; i++)
|
|
|
|
|
{
|
|
|
|
|
str3 = str4.Substring(i, 1); //ȡ<><C8A1><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>ijһλ<D2BB><CEBB>ֵ
|
|
|
|
|
temp = Convert.ToInt32(str3); //ת<><D7AA>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD>
|
|
|
|
|
if (i != (j - 3) && i != (j - 7) && i != (j - 11) && i != (j - 15))
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>ȡλ<C8A1><CEBB><EFBFBD><EFBFBD>ΪԪ<CEAA><D4AA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ڡ<EFBFBD><DAA1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>ʱ
|
|
|
|
|
if (str3 == "0")
|
|
|
|
|
{
|
|
|
|
|
ch1 = "";
|
|
|
|
|
ch2 = "";
|
|
|
|
|
nzero = nzero + 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (str3 != "0" && nzero != 0)
|
|
|
|
|
{
|
|
|
|
|
ch1 = "<22><>" + str1.Substring(temp * 1, 1);
|
|
|
|
|
ch2 = str2.Substring(i, 1);
|
|
|
|
|
nzero = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ch1 = str1.Substring(temp * 1, 1);
|
|
|
|
|
ch2 = str2.Substring(i, 1);
|
|
|
|
|
nzero = 0;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
//<2F><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD><EFBFBD>ڣ<EFBFBD><DAA3>ڣ<EFBFBD><DAA3><EFBFBD><EFBFBD><EFBFBD>Ԫλ<D4AA>ȹؼ<C8B9>λ
|
|
|
|
|
if (str3 != "0" && nzero != 0)
|
|
|
|
|
{
|
|
|
|
|
ch1 = "<22><>" + str1.Substring(temp * 1, 1);
|
|
|
|
|
ch2 = str2.Substring(i, 1);
|
|
|
|
|
nzero = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (str3 != "0" && nzero == 0)
|
|
|
|
|
{
|
|
|
|
|
ch1 = str1.Substring(temp * 1, 1);
|
|
|
|
|
ch2 = str2.Substring(i, 1);
|
|
|
|
|
nzero = 0;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (str3 == "0" && nzero >= 3)
|
|
|
|
|
{
|
|
|
|
|
ch1 = "";
|
|
|
|
|
ch2 = "";
|
|
|
|
|
nzero = nzero + 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (j >= 11)
|
|
|
|
|
{
|
|
|
|
|
ch1 = "";
|
|
|
|
|
nzero = nzero + 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
ch1 = "";
|
|
|
|
|
ch2 = str2.Substring(i, 1);
|
|
|
|
|
nzero = nzero + 1;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (i == (j - 11) || i == (j - 3))
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>λ<EFBFBD><CEBB>Ԫλ<D4AA><CEBB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>д<EFBFBD><D0B4>
|
|
|
|
|
ch2 = str2.Substring(i, 1);
|
|
|
|
|
}
|
|
|
|
|
str5 = str5 + ch1 + ch2;
|
|
|
|
|
|
|
|
|
|
if (i == j - 1 && str3 == "0")
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>һλ<D2BB><CEBB><EFBFBD>֣<EFBFBD>Ϊ0ʱ<30><CAB1><EFBFBD><EFBFBD><EFBFBD>ϡ<EFBFBD><CFA1><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
str5 = str5 + '<EFBFBD><EFBFBD>';
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (num == 0)
|
|
|
|
|
{
|
|
|
|
|
str5 = "<22><>Ԫ<EFBFBD><D4AA>";
|
|
|
|
|
}
|
|
|
|
|
return str5;
|
|
|
|
|
}
|
|
|
|
|
#endregion
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ȥ<><C8A5>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ѡ<EFBFBD><D1A1>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="projectType"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string[] RemoveDropDownListNull(string[] selectedValueArray)
|
|
|
|
|
{
|
|
|
|
|
List<string> str = new List<string>();
|
|
|
|
|
foreach (var item in selectedValueArray)
|
|
|
|
|
{
|
|
|
|
|
if (item != BLL.Const._Null)
|
|
|
|
|
{
|
|
|
|
|
str.Add(item);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return str.ToArray();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string GetStringByArray(string[] array)
|
|
|
|
|
{
|
|
|
|
|
string str = string.Empty;
|
|
|
|
|
foreach (var item in array)
|
|
|
|
|
{
|
|
|
|
|
if (item != BLL.Const._Null)
|
|
|
|
|
{
|
|
|
|
|
str += item + ",";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
if (!string.IsNullOrEmpty(str))
|
|
|
|
|
{
|
|
|
|
|
str = str.Substring(0, str.LastIndexOf(","));
|
|
|
|
|
}
|
|
|
|
|
return str;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><>IEnumerable<T><3E><><EFBFBD>͵ļ<CDB5><C4BC><EFBFBD>ת<EFBFBD><D7AA>ΪDataTable<6C><65><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <typeparam name="T"></typeparam>
|
|
|
|
|
/// <param name="varlist"></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static DataTable LINQToDataTable<T>(IEnumerable<T> varlist)
|
|
|
|
|
{
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA><EFBFBD>ص<EFBFBD>DataTable<6C><65><EFBFBD><EFBFBD>
|
|
|
|
|
DataTable dtReturn = new DataTable();
|
|
|
|
|
// <20><><EFBFBD><EFBFBD><EFBFBD>м<EFBFBD><D0BC>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD>
|
|
|
|
|
PropertyInfo[] oProps = null;
|
|
|
|
|
if (varlist == null) return dtReturn;//<2F><>ȫ<EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>
|
|
|
|
|
//ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ϣ<EFBFBD>ʹ<EFBFBD>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD>ȡ<EFBFBD><C8A1><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ
|
|
|
|
|
foreach (T rec in varlist)
|
|
|
|
|
{
|
|
|
|
|
//ʹ<>÷<EFBFBD><C3B7><EFBFBD><EFBFBD><EFBFBD>ȡT<C8A1><54><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϣ<EFBFBD><CFA2><EFBFBD><EFBFBD><EFBFBD><EFBFBD>һ<EFBFBD><D2BB>PropertyInfo<66><6F><EFBFBD>͵ļ<CDB5><C4BC><EFBFBD>
|
|
|
|
|
if (oProps == null)
|
|
|
|
|
{
|
|
|
|
|
oProps = ((Type)rec.GetType()).GetProperties();
|
|
|
|
|
//ѭ<><D1AD>PropertyInfo<66><6F><EFBFBD><EFBFBD>
|
|
|
|
|
foreach (PropertyInfo pi in oProps)
|
|
|
|
|
{
|
|
|
|
|
Type colType = pi.PropertyType;//<2F>õ<EFBFBD><C3B5><EFBFBD><EFBFBD>Ե<EFBFBD><D4B5><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
if ((colType.IsGenericType) && (colType.GetGenericTypeDefinition()
|
|
|
|
|
== typeof(Nullable<>)))
|
|
|
|
|
{ //<2F><>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>͵IJ<CDB5><C4B2><EFBFBD>
|
|
|
|
|
colType = colType.GetGenericArguments()[0];
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>͵<EFBFBD><CDB5><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ΪDataTable<6C><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
dtReturn.Columns.Add(new DataColumn(pi.Name, colType));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
//<2F>½<EFBFBD>һ<EFBFBD><D2BB><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ӵ<EFBFBD>DataTable<6C>е<EFBFBD>DataRow<6F><77><EFBFBD><EFBFBD>
|
|
|
|
|
DataRow dr = dtReturn.NewRow();
|
|
|
|
|
//ѭ<><D1AD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Լ<EFBFBD><D4BC><EFBFBD>
|
|
|
|
|
foreach (PropertyInfo pi in oProps)
|
|
|
|
|
{ //ΪDataRow<6F>е<EFBFBD>ָ<EFBFBD><D6B8><EFBFBD>и<EFBFBD>ֵ
|
|
|
|
|
dr[pi.Name] = pi.GetValue(rec, null) == null ?
|
|
|
|
|
DBNull.Value : pi.GetValue(rec, null);
|
|
|
|
|
}
|
|
|
|
|
//<2F><><EFBFBD><EFBFBD><EFBFBD>н<EFBFBD><D0BD><EFBFBD>ֵ<EFBFBD><D6B5>DataRow<6F><77><EFBFBD>ӵ<EFBFBD>DataTable<6C><65><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
dtReturn.Rows.Add(dr);
|
|
|
|
|
}
|
|
|
|
|
return dtReturn;//<2F><><EFBFBD><EFBFBD>DataTable<6C><65><EFBFBD><EFBFBD>
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD>趨<EFBFBD><E8B6A8><EFBFBD><EFBFBD>ֵ<EFBFBD>ڲ<EFBFBD><DAB2><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="num"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD></param>
|
|
|
|
|
/// <param name="minValue"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Сֵ</param>
|
|
|
|
|
/// <param name="maxValue"><3E><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ֵ</param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static int[] GetRandomNum(int num, int minValue, int maxValue)
|
|
|
|
|
{
|
|
|
|
|
if ((maxValue + 1 - minValue - num < 0))
|
|
|
|
|
maxValue += num - (maxValue + 1 - minValue);
|
|
|
|
|
Random ra = new Random(unchecked((int)DateTime.Now.Ticks));
|
|
|
|
|
int[] arrNum = new int[num];
|
|
|
|
|
int tmp = 0;
|
|
|
|
|
StringBuilder sb = new StringBuilder(num * maxValue.ToString().Trim().Length);
|
|
|
|
|
|
|
|
|
|
for (int i = 0; i <= num - 1; i++)
|
|
|
|
|
{
|
|
|
|
|
tmp = ra.Next(minValue, maxValue);
|
|
|
|
|
while (sb.ToString().Contains("#" + tmp.ToString().Trim() + "#"))
|
|
|
|
|
tmp = ra.Next(minValue, maxValue + 1);
|
|
|
|
|
arrNum[i] = tmp;
|
|
|
|
|
sb.Append("#" + tmp.ToString().Trim() + "#");
|
|
|
|
|
}
|
|
|
|
|
return arrNum;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD>ݵ<EFBFBD>һҳ<D2BB>͵ڶ<CDB5>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>ܼ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD>ȷ<EFBFBD><C8B7><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ӡ<EFBFBD><D3A1>ҳ
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="pageSize1"><3E><>һҳ<D2BB><D2B3><EFBFBD><EFBFBD></param>
|
|
|
|
|
/// <param name="pageSize2"><3E>ڶ<EFBFBD>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD></param>
|
|
|
|
|
/// <param name="count"><3E>ܼ<EFBFBD>¼<EFBFBD><C2BC></param>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static int GetPagesCountByPageSize(int pageSize1, int pageSize2, int count)
|
|
|
|
|
{
|
|
|
|
|
int pagesCount = 0;
|
|
|
|
|
if (pageSize1 >= count) //<2F>ܼ<EFBFBD>¼<EFBFBD><C2BC>С<EFBFBD>ڵ<EFBFBD><DAB5>ڵ<EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
pagesCount = 1;
|
|
|
|
|
}
|
|
|
|
|
else if (count > pageSize1 && count <= (pageSize1 + pageSize2)) //<2F>ܼ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>һҳ<D2BB><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>С<EFBFBD>ڵ<EFBFBD><DAB5>ڵ<EFBFBD>һҳ<D2BB>ӵڶ<D3B5>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
pagesCount = 2;
|
|
|
|
|
}
|
|
|
|
|
else //<2F>ܼ<EFBFBD>¼<EFBFBD><C2BC><EFBFBD><EFBFBD><EFBFBD>ڵ<EFBFBD>һҳ<D2BB>ӵڶ<D3B5>ҳ<EFBFBD><D2B3><EFBFBD><EFBFBD><EFBFBD><EFBFBD>
|
|
|
|
|
{
|
|
|
|
|
int lastCount = count - pageSize1;
|
|
|
|
|
decimal c = Convert.ToDecimal(Math.Round(Convert.ToDecimal(lastCount) / Convert.ToDecimal(pageSize2), 2));
|
|
|
|
|
if (c.ToString().IndexOf(".") > 0 && c.ToString().Substring(c.ToString().IndexOf("."), c.ToString().Length - c.ToString().IndexOf(".")) != ".00")
|
|
|
|
|
{
|
|
|
|
|
string c1 = c.ToString().Substring(0, c.ToString().IndexOf("."));
|
|
|
|
|
pagesCount = Convert.ToInt32(c1) + 1;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
pagesCount = Convert.ToInt32(c);
|
|
|
|
|
}
|
|
|
|
|
pagesCount = pagesCount + 1;
|
|
|
|
|
}
|
|
|
|
|
return pagesCount;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// <20><><EFBFBD>ݷ<EFBFBD><DDB7><EFBFBD><EFBFBD>ж<EFBFBD><D0B6>Ƿ<EFBFBD><C7B7>ϸ<EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <returns></returns>
|
|
|
|
|
public static string ReturnEvaluationResultByScore(decimal? score)
|
|
|
|
|
{
|
|
|
|
|
string value = string.Empty;
|
|
|
|
|
if (score.HasValue)
|
|
|
|
|
{
|
|
|
|
|
if (score >= 80)
|
|
|
|
|
{
|
|
|
|
|
value = "<22>ϸ<EFBFBD>";
|
|
|
|
|
}
|
|
|
|
|
else if (score >= 71 && score <= 79)
|
|
|
|
|
{
|
|
|
|
|
value = "<22><><EFBFBD><EFBFBD><EFBFBD>ϸ<EFBFBD>";
|
|
|
|
|
}
|
|
|
|
|
else if (score <= 70)
|
|
|
|
|
{
|
|
|
|
|
value = "<22><><EFBFBD>ϸ<EFBFBD>";
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
return value;
|
|
|
|
|
}
|
2021-09-17 15:22:38 +08:00
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// ʱ<><CAB1><EFBFBD><EFBFBD>ת<EFBFBD><D7AA><EFBFBD><EFBFBD>
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="timestamp"></param>
|
|
|
|
|
/// <returns></returns>
|
2021-09-18 13:26:51 +08:00
|
|
|
|
public static DateTime IntToDateTime(long timestamp)
|
2021-09-17 15:22:38 +08:00
|
|
|
|
{
|
2021-09-18 13:26:51 +08:00
|
|
|
|
var date = TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1));
|
|
|
|
|
date = date.AddMilliseconds(timestamp);
|
|
|
|
|
return date;
|
|
|
|
|
|
|
|
|
|
//return TimeZone.CurrentTimeZone.ToLocalTime(new DateTime(1970, 1, 1)).AddSeconds(timestamp);
|
2023-08-10 11:40:02 +08:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string RequestGet(string Baseurl, string Token)
|
|
|
|
|
{
|
|
|
|
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
|
|
|
|
|
|
|
|
|
var client = new RestClient(Baseurl);
|
|
|
|
|
client.Timeout = -1;
|
|
|
|
|
var request = new RestRequest(Method.GET);
|
|
|
|
|
request.AddHeader("token", Token);
|
2023-09-27 09:10:09 +08:00
|
|
|
|
request.AddHeader("ClientId", SysConstSetService.ClientId);
|
|
|
|
|
request.AddHeader("OperationCode", Baseurl.Substring(Baseurl.LastIndexOf("/", StringComparison.Ordinal) + 1));
|
2023-08-10 11:40:02 +08:00
|
|
|
|
IRestResponse response = client.Execute(request);
|
|
|
|
|
Console.WriteLine(response.Content);
|
|
|
|
|
return response.Content;
|
|
|
|
|
}
|
|
|
|
|
public static string RequestPost(string Baseurl, string Token, string JsonBody)
|
|
|
|
|
{
|
|
|
|
|
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
|
|
|
|
|
|
|
|
|
|
var client = new RestClient(Baseurl);
|
|
|
|
|
client.Timeout = -1;
|
|
|
|
|
var request = new RestRequest(Method.POST);
|
|
|
|
|
request.AddHeader("token", Token);
|
2023-09-27 09:10:09 +08:00
|
|
|
|
request.AddHeader("ClientId", SysConstSetService.ClientId);
|
|
|
|
|
request.AddHeader("OperationCode", Baseurl.Substring(Baseurl.LastIndexOf("/", StringComparison.Ordinal) + 1));
|
2023-08-10 11:40:02 +08:00
|
|
|
|
if (!string.IsNullOrEmpty(JsonBody))
|
|
|
|
|
{
|
|
|
|
|
request.AddJsonBody(JsonBody);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
IRestResponse response = client.Execute(request);
|
|
|
|
|
return response.Content;
|
|
|
|
|
}
|
2023-09-27 09:10:09 +08:00
|
|
|
|
|
2021-04-30 10:28:37 +08:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|