问卷设定 强制默认需要登录

master
xiaochanghai 2 weeks ago
parent 45b895beb3
commit 428842561f
  1. BIN
      Lib/Tiobon.Core.Base.dll
  2. BIN
      Lib/Tiobon.Core.dll
  3. 229
      Lib/Tiobon.Core.xml
  4. 429
      Tiobon.Core.Common/Helper/FileHelper.cs
  5. 431
      Tiobon.Core.Common/Helper/UtilHelper.cs
  6. 1
      Tiobon.Core.Common/Https/HttpPolly/HttpPollyHelper.cs
  7. 1
      Tiobon.Core.Common/LogHelper/LogLock.cs
  8. 1
      Tiobon.Core.Common/Seed/DBSeed.cs
  9. 3
      Tiobon.Core.DataAccess/ReportHelper.cs
  10. 6
      Tiobon.Core.Serilog/Tiobon.Core.Serilog.csproj
  11. 6
      Tiobon.Core.Services/Ghre/Ghre_CertificateRuleServices.cs
  12. 2
      Tiobon.Core.Services/Ghre/Ghre_SurveyServices.cs

Binary file not shown.

Binary file not shown.

@ -204,6 +204,235 @@
<param name="ms"></param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.Helper.FileHelper.GetPostfixStr(System.String)">
<summary>
取后缀名
</summary>
<param name="filename">文件名</param>
<returns>.gif|.html格式</returns>
</member>
<member name="M:Tiobon.Core.Helper.FileHelper.GetAvailableFileWithPrefixOrderSize(System.String,System.String,System.Int32,System.String)">
<summary>
根据文件大小获取指定前缀的可用文件名
</summary>
<param name="folderPath">文件夹</param>
<param name="prefix">文件前缀</param>
<param name="size">文件大小(1m)</param>
<param name="ext">文件后缀(.log)</param>
<returns>可用文件名</returns>
</member>
<member name="M:Tiobon.Core.Helper.FileHelper.WriteFile(System.String,System.String)">
<summary>
写文件
</summary>
<param name="Path">文件路径</param>
<param name="Strings">文件内容</param>
</member>
<member name="M:Tiobon.Core.Helper.FileHelper.WriteFile(System.String,System.Byte[])">
<summary>
写文件
</summary>
<param name="Path">文件路径</param>
<param name="Strings">文件内容</param>
</member>
<member name="M:Tiobon.Core.Helper.FileHelper.WriteFile(System.String,System.String,System.Text.Encoding)">
<summary>
写文件
</summary>
<param name="Path">文件路径</param>
<param name="Strings">文件内容</param>
<param name="encode">编码格式</param>
</member>
<member name="M:Tiobon.Core.Helper.FileHelper.ReadFile(System.String)">
<summary>
读文件
</summary>
<param name="Path">文件路径</param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.Helper.FileHelper.ReadFile(System.String,System.Text.Encoding)">
<summary>
读文件
</summary>
<param name="Path">文件路径</param>
<param name="encode">编码格式</param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.Helper.FileHelper.FileAdd(System.String,System.String)">
<summary>
追加文件
</summary>
<param name="Path">文件路径</param>
<param name="strings">内容</param>
</member>
<member name="M:Tiobon.Core.Helper.FileHelper.FileCoppy(System.String,System.String)">
<summary>
拷贝文件
</summary>
<param name="OrignFile">原始文件</param>
<param name="NewFile">新文件路径</param>
</member>
<member name="M:Tiobon.Core.Helper.FileHelper.FileDel(System.String)">
<summary>
删除文件
</summary>
<param name="Path">路径</param>
</member>
<member name="M:Tiobon.Core.Helper.FileHelper.FileMove(System.String,System.String)">
<summary>
移动文件
</summary>
<param name="OrignFile">原始路径</param>
<param name="NewFile">新路径</param>
</member>
<member name="M:Tiobon.Core.Helper.FileHelper.FolderCreate(System.String,System.String)">
<summary>
在当前目录下创建目录
</summary>
<param name="OrignFolder">当前目录</param>
<param name="NewFloder">新目录</param>
</member>
<member name="M:Tiobon.Core.Helper.FileHelper.DeleteFolder(System.String)">
<summary>
递归删除文件夹目录及文件
</summary>
<param name="dir"></param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.Helper.FileHelper.CopyDir(System.String,System.String)">
<summary>
指定文件夹下面的所有内容copy到目标文件夹下面
</summary>
<param name="srcPath">原始路径</param>
<param name="aimPath">目标文件夹</param>
</member>
<member name="M:Tiobon.Core.Helper.FileHelper.GetPhysicsPath">
<summary>
获取文件根目录
</summary>
<returns></returns>
</member>
<member name="M:Tiobon.Core.Helper.FileHelper.CreateDirectory(System.String)">
<summary>
创建文件夹
</summary>
<param name="path"></param>
</member>
<member name="T:Tiobon.Core.UtilHelper">
<summary>
</summary>
</member>
<member name="M:Tiobon.Core.UtilHelper.ObjToInt(System.Object)">
<summary>
</summary>
<param name="thisValue"></param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.UtilHelper.ObjToInt(System.Object,System.Int32)">
<summary>
</summary>
<param name="thisValue"></param>
<param name="errorValue"></param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.UtilHelper.ObjToMoney(System.Object)">
<summary>
</summary>
<param name="thisValue"></param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.UtilHelper.ObjToMoney(System.Object,System.Double)">
<summary>
</summary>
<param name="thisValue"></param>
<param name="errorValue"></param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.UtilHelper.ObjToString(System.Object)">
<summary>
</summary>
<param name="thisValue"></param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.UtilHelper.IsNotEmptyOrNull(System.Object)">
<summary>
</summary>
<param name="thisValue"></param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.UtilHelper.ObjToString(System.Object,System.String)">
<summary>
</summary>
<param name="thisValue"></param>
<param name="errorValue"></param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.UtilHelper.ObjToDecimal(System.Object)">
<summary>
</summary>
<param name="thisValue"></param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.UtilHelper.ObjToDecimal(System.Object,System.Decimal)">
<summary>
</summary>
<param name="thisValue"></param>
<param name="errorValue"></param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.UtilHelper.RemoveZero(System.Nullable{System.Decimal})">
<summary>
去除后面多余的零
</summary>
<param name="dValue"></param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.UtilHelper.RemoveZero(System.Decimal)">
<summary>
去除后面多余的零
</summary>
<param name="dValue"></param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.UtilHelper.ObjToDate(System.Object)">
<summary>
</summary>
<param name="thisValue"></param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.UtilHelper.ObjToDate(System.Object,System.DateTime)">
<summary>
</summary>
<param name="thisValue"></param>
<param name="errorValue"></param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.UtilHelper.ObjToBool(System.Object)">
<summary>
</summary>
<param name="thisValue"></param>
<returns></returns>
</member>
<member name="M:Tiobon.Core.UtilHelper.DateToTimeStamp(System.DateTime)">
<summary>
获取当前时间的时间戳
</summary>
<param name="thisValue"></param>
<returns></returns>
</member>
<member name="P:Tiobon.Core.Model.Entity.BasePoco.Id">
<summary>
表主键

@ -1,429 +0,0 @@
using System.Text;
namespace Tiobon.Core.Common.Helper;
public class FileHelper : IDisposable
{
private bool _alreadyDispose = false;
#region 构造函数
public FileHelper()
{
//
// TODO: 在此处添加构造函数逻辑
//
}
~FileHelper()
{
Dispose(); ;
}
protected virtual void Dispose(bool isDisposing)
{
if (_alreadyDispose) return;
_alreadyDispose = true;
}
#endregion
#region IDisposable 成员
public void Dispose()
{
Dispose(true);
GC.SuppressFinalize(this);
}
#endregion
#region 取得文件后缀名
/****************************************
* GetPostfixStr
*
* filename:
*
* string filename = "aaa.aspx";
* string s = EC.FileObj.GetPostfixStr(filename);
*****************************************/
/// <summary>
/// 取后缀名
/// </summary>
/// <param name="filename">文件名</param>
/// <returns>.gif|.html格式</returns>
public static string GetPostfixStr(string filename)
{
int start = filename.LastIndexOf(".");
int length = filename.Length;
string postfix = filename.Substring(start, length - start);
return postfix;
}
#endregion
#region 根据文件大小获取指定前缀的可用文件名
/// <summary>
/// 根据文件大小获取指定前缀的可用文件名
/// </summary>
/// <param name="folderPath">文件夹</param>
/// <param name="prefix">文件前缀</param>
/// <param name="size">文件大小(1m)</param>
/// <param name="ext">文件后缀(.log)</param>
/// <returns>可用文件名</returns>
public static string GetAvailableFileWithPrefixOrderSize(string folderPath, string prefix, int size = 1 * 1024 * 1024, string ext = ".log")
{
//var allFiles = new DirectoryInfo(folderPath);
//var selectFiles = allFiles.GetFiles().Where(fi => fi.Name.ToLower().Contains(prefix.ToLower()) && fi.Extension.ToLower() == ext.ToLower() && fi.Length < size).OrderByDescending(d => d.Name).ToList();
//if (selectFiles.Count > 0)
//{
// return selectFiles.FirstOrDefault().FullName;
//}
return Path.Combine(folderPath, $@"{prefix}.log");
}
public static string GetAvailableFileNameWithPrefixOrderSize(string _contentRoot, string prefix, int size = 1 * 1024 * 1024, string ext = ".log")
{
var folderPath = Path.Combine(_contentRoot, "Log");
if (!Directory.Exists(folderPath))
{
Directory.CreateDirectory(folderPath);
}
var allFiles = new DirectoryInfo(folderPath);
var selectFiles = allFiles.GetFiles().Where(fi => fi.Name.ToLower().Contains(prefix.ToLower()) && fi.Extension.ToLower() == ext.ToLower() && fi.Length < size).OrderByDescending(d => d.Name).ToList();
if (selectFiles.Count > 0)
{
return selectFiles.FirstOrDefault().Name.Replace(".log", "");
}
return $@"{prefix}_{DateTime.Now.DateToTimeStamp()}";
}
#endregion
#region 写文件
/****************************************
* WriteFile
* ,
* Path:,Strings:
*
* string Path = Server.MapPath("Default2.aspx");
* string Strings = "这是我写的内容啊";
* EC.FileObj.WriteFile(Path,Strings);
*****************************************/
/// <summary>
/// 写文件
/// </summary>
/// <param name="Path">文件路径</param>
/// <param name="Strings">文件内容</param>
public static void WriteFile(string Path, string Strings)
{
if (!File.Exists(Path))
{
FileStream f = File.Create(Path);
f.Close();
}
StreamWriter f2 = new StreamWriter(Path, false, System.Text.Encoding.GetEncoding("gb2312"));
f2.Write(Strings);
f2.Close();
f2.Dispose();
}
/// <summary>
/// 写文件
/// </summary>
/// <param name="Path">文件路径</param>
/// <param name="Strings">文件内容</param>
public static void WriteFile(string Path, byte[] buf)
{
if (!File.Exists(Path))
{
FileStream f = File.Create(Path);
f.Close();
}
FileStream f2 = new FileStream(Path, FileMode.Create, FileAccess.Write);
f2.Write(buf, 0, buf.Length);
f2.Close();
f2.Dispose();
}
/// <summary>
/// 写文件
/// </summary>
/// <param name="Path">文件路径</param>
/// <param name="Strings">文件内容</param>
/// <param name="encode">编码格式</param>
public static void WriteFile(string Path, string Strings, Encoding encode)
{
if (!File.Exists(Path))
{
FileStream f = File.Create(Path);
f.Close();
}
StreamWriter f2 = new StreamWriter(Path, false, encode);
f2.Write(Strings);
f2.Close();
f2.Dispose();
}
#endregion
#region 读文件
/****************************************
* ReadFile
*
* Path:
*
* string Path = Server.MapPath("Default2.aspx");
* string s = EC.FileObj.ReadFile(Path);
*****************************************/
/// <summary>
/// 读文件
/// </summary>
/// <param name="Path">文件路径</param>
/// <returns></returns>
public static string ReadFile(string Path)
{
string s = "";
if (!File.Exists(Path))
s = "不存在相应的目录";
else
{
StreamReader f2 = new StreamReader(Path, System.Text.Encoding.GetEncoding("gb2312"));
s = f2.ReadToEnd();
f2.Close();
f2.Dispose();
}
return s;
}
/// <summary>
/// 读文件
/// </summary>
/// <param name="Path">文件路径</param>
/// <param name="encode">编码格式</param>
/// <returns></returns>
public static string ReadFile(string Path, Encoding encode)
{
string s = "";
if (!File.Exists(Path))
s = "不存在相应的目录";
else
{
StreamReader f2 = new StreamReader(Path, encode);
s = f2.ReadToEnd();
f2.Close();
f2.Dispose();
}
return s;
}
#endregion
#region 追加文件
/****************************************
* FileAdd
*
* Path:,strings:
*
* string Path = Server.MapPath("Default2.aspx");
* string Strings = "新追加内容";
* EC.FileObj.FileAdd(Path, Strings);
*****************************************/
/// <summary>
/// 追加文件
/// </summary>
/// <param name="Path">文件路径</param>
/// <param name="strings">内容</param>
public static void FileAdd(string Path, string strings)
{
StreamWriter sw = File.AppendText(Path);
sw.Write(strings);
sw.Flush();
sw.Close();
}
#endregion
#region 拷贝文件
/****************************************
* FileCoppy
*
* OrignFile:,NewFile:
*
* string orignFile = Server.MapPath("Default2.aspx");
* string NewFile = Server.MapPath("Default3.aspx");
* EC.FileObj.FileCoppy(OrignFile, NewFile);
*****************************************/
/// <summary>
/// 拷贝文件
/// </summary>
/// <param name="OrignFile">原始文件</param>
/// <param name="NewFile">新文件路径</param>
public static void FileCoppy(string orignFile, string NewFile)
{
File.Copy(orignFile, NewFile, true);
}
#endregion
#region 删除文件
/****************************************
* FileDel
*
* Path:
*
* string Path = Server.MapPath("Default3.aspx");
* EC.FileObj.FileDel(Path);
*****************************************/
/// <summary>
/// 删除文件
/// </summary>
/// <param name="Path">路径</param>
public static void FileDel(string Path)
{
File.Delete(Path);
}
#endregion
#region 移动文件
/****************************************
* FileMove
*
* OrignFile:,NewFile:
*
* string orignFile = Server.MapPath("../说明.txt");
* string NewFile = Server.MapPath("http://www.cnTiobons.com/说明.txt");
* EC.FileObj.FileMove(OrignFile, NewFile);
*****************************************/
/// <summary>
/// 移动文件
/// </summary>
/// <param name="OrignFile">原始路径</param>
/// <param name="NewFile">新路径</param>
public static void FileMove(string orignFile, string NewFile)
{
File.Move(orignFile, NewFile);
}
#endregion
#region 在当前目录下创建目录
/****************************************
* FolderCreate
*
* OrignFolder:,NewFloder:
*
* string orignFolder = Server.MapPath("test/");
* string NewFloder = "new";
* EC.FileObj.FolderCreate(OrignFolder, NewFloder);
*****************************************/
/// <summary>
/// 在当前目录下创建目录
/// </summary>
/// <param name="OrignFolder">当前目录</param>
/// <param name="NewFloder">新目录</param>
public static void FolderCreate(string orignFolder, string NewFloder)
{
Directory.SetCurrentDirectory(orignFolder);
Directory.CreateDirectory(NewFloder);
}
#endregion
#region 递归删除文件夹目录及文件
/****************************************
* DeleteFolder
*
* dir:
*
* string dir = Server.MapPath("test/");
* EC.FileObj.DeleteFolder(dir);
*****************************************/
/// <summary>
/// 递归删除文件夹目录及文件
/// </summary>
/// <param name="dir"></param>
/// <returns></returns>
public static void DeleteFolder(string dir)
{
if (Directory.Exists(dir)) //如果存在这个文件夹删除之
{
foreach (string d in Directory.GetFileSystemEntries(dir))
{
if (File.Exists(d))
File.Delete(d); //直接删除其中的文件
else
DeleteFolder(d); //递归删除子文件夹
}
Directory.Delete(dir); //删除已空文件夹
}
}
#endregion
#region 将指定文件夹下面的所有内容copy到目标文件夹下面 果目标文件夹为只读属性就会报错。
/****************************************
* CopyDir
* copy到目标文件夹下面
* srcPath:,aimPath:
*
* string srcPath = Server.MapPath("test/");
* string aimPath = Server.MapPath("test1/");
* EC.FileObj.CopyDir(srcPath,aimPath);
*****************************************/
/// <summary>
/// 指定文件夹下面的所有内容copy到目标文件夹下面
/// </summary>
/// <param name="srcPath">原始路径</param>
/// <param name="aimPath">目标文件夹</param>
public static void CopyDir(string srcPath, string aimPath)
{
try
{
// 检查目标目录是否以目录分割字符结束如果不是则添加之
if (aimPath[aimPath.Length - 1] != Path.DirectorySeparatorChar)
aimPath += Path.DirectorySeparatorChar;
// 判断目标目录是否存在如果不存在则新建之
if (!Directory.Exists(aimPath))
Directory.CreateDirectory(aimPath);
// 得到源目录的文件列表,该里面是包含文件以及目录路径的一个数组
//如果你指向copy目标文件下面的文件而不包含目录请使用下面的方法
//string[] fileList = Directory.GetFiles(srcPath);
string[] fileList = Directory.GetFileSystemEntries(srcPath);
//遍历所有的文件和目录
foreach (string file in fileList)
{
//先当作目录处理如果存在这个目录就递归Copy该目录下面的文件
if (Directory.Exists(file))
CopyDir(file, aimPath + Path.GetFileName(file));
//否则直接Copy文件
else
File.Copy(file, aimPath + Path.GetFileName(file), true);
}
}
catch (Exception ee)
{
throw new Exception(ee.ToString());
}
}
#endregion
#region 获取文件根目录
/// <summary>
/// 获取文件根目录
/// </summary>
/// <returns></returns>
public static string GetPhysicsPath() => $"{Environment.CurrentDirectory}{Path.DirectorySeparatorChar}wwwroot";
#endregion
#region 创建文件夹
/// <summary>
/// 创建文件夹
/// </summary>
/// <param name="path"></param>
public static void CreateDirectory(string path)
{
var physicsPath = GetPhysicsPath();
if (!Directory.Exists(physicsPath + path))
Directory.CreateDirectory(physicsPath + path);
}
#endregion
}

@ -1,431 +0,0 @@
using Newtonsoft.Json;
using SqlSugar;
namespace Tiobon.Core;
/// <summary>
///
/// </summary>
public static class UtilHelper
{
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static int ObjToInt(this object thisValue)
{
int reval = 0;
if (thisValue == null) return 0;
if (thisValue != DBNull.Value && int.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return reval;
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <param name="errorValue"></param>
/// <returns></returns>
public static int ObjToInt(this object thisValue, int errorValue)
{
int reval = 0;
if (thisValue != null && thisValue != DBNull.Value && int.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return errorValue;
}
public static long ObjToLong(this object thisValue)
{
long reval = 0;
if (thisValue == null) return 0;
if (thisValue != DBNull.Value && long.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return reval;
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static double ObjToMoney(this object thisValue)
{
double reval = 0;
if (thisValue != null && thisValue != DBNull.Value && double.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return 0;
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <param name="errorValue"></param>
/// <returns></returns>
public static double ObjToMoney(this object thisValue, double errorValue)
{
double reval = 0;
if (thisValue != null && thisValue != DBNull.Value && double.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return errorValue;
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static string ObjToString(this object thisValue)
{
if (thisValue != null) return thisValue.ToString().Trim();
return "";
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static bool IsNotEmptyOrNull(this object thisValue)
{
return ObjToString(thisValue) != "" && ObjToString(thisValue) != "undefined" &&
ObjToString(thisValue) != "null";
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <param name="errorValue"></param>
/// <returns></returns>
public static string ObjToString(this object thisValue, string errorValue)
{
if (thisValue != null) return thisValue.ToString().Trim();
return errorValue;
}
public static bool IsNullOrEmpty(this object thisValue) => thisValue == null || thisValue == DBNull.Value ||
string.IsNullOrWhiteSpace(thisValue.ToString());
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static Decimal ObjToDecimal(this object thisValue)
{
Decimal reval = 0;
if (thisValue != null && thisValue != DBNull.Value && decimal.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return 0;
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <param name="errorValue"></param>
/// <returns></returns>
public static Decimal ObjToDecimal(this object thisValue, decimal errorValue)
{
Decimal reval = 0;
if (thisValue != null && thisValue != DBNull.Value && decimal.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return errorValue;
}
#region 去除后面多余的零
/// <summary>
/// 去除后面多余的零
/// </summary>
/// <param name="dValue"></param>
/// <returns></returns>
public static string RemoveZero(this decimal? dValue)
{
if (dValue.IsNullOrEmpty())
return null;
return RemoveZero(dValue.Value);
}
///// <summary>
///// 去除后面多余的零
///// </summary>
///// <param name="dValue"></param>
///// <returns></returns>
//public static string RemoveZero(decimal? dValue)
//{
// if (dValue.IsNullOrEmpty())
// return null;
// return RemoveZero(dValue.Value);
//}
/// <summary>
/// 去除后面多余的零
/// </summary>
/// <param name="dValue"></param>
/// <returns></returns>
public static string RemoveZero(decimal dValue)
{
string sResult = dValue.ToString();
if (sResult.IndexOf(".") < 0)
return sResult;
int iIndex = sResult.Length - 1;
for (int i = sResult.Length - 1; i >= 0; i--)
{
if (sResult.Substring(i, 1) != "0")
{
iIndex = i;
break;
}
}
sResult = sResult.Substring(0, iIndex + 1);
if (sResult.EndsWith("."))
sResult = sResult.Substring(0, sResult.Length - 1);
return sResult;
}
public static string TrimDecimalString(this decimal? value1, int reservedDigit)
{
try
{
var value = value1.RemoveZero();
string result = string.Empty;
if (!string.IsNullOrEmpty(value))
{
Decimal tmp = Decimal.Parse(value);
if (reservedDigit == -1)
result = string.Format("{0:#0.##########}", tmp);
else
{
result = String.Format("{0:N" + reservedDigit.ToString() + "}", tmp);
result = result.Replace(",", "");
}
}
return result;
}
catch (Exception) { return null; }
}
public static decimal? TrimDecimal(this decimal? value1, int reservedDigit)
{
try
{
var value = value1.TrimDecimalString(reservedDigit);
string result = string.Empty;
if (!string.IsNullOrEmpty(value))
{
Decimal tmp = Decimal.Parse(value);
if (reservedDigit == -1)
result = string.Format("{0:#0.##########}", tmp);
else
{
result = String.Format("{0:N" + reservedDigit.ToString() + "}", tmp);
result = result.Replace(",", "");
}
}
return Convert.ToDecimal(result);
}
catch (Exception) { return null; }
}
#endregion
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static DateTime ObjToDate(this object thisValue)
{
DateTime reval = DateTime.MinValue;
if (thisValue != null && thisValue != DBNull.Value && DateTime.TryParse(thisValue.ToString(), out reval))
{
reval = Convert.ToDateTime(thisValue);
}
else
{
//时间戳转为时间
var seconds = ObjToLong(thisValue);
if (seconds > 0)
{
var startTime = TimeZoneInfo.ConvertTime(new DateTime(1970, 1, 1), TimeZoneInfo.Local);
reval = startTime.AddSeconds(Convert.ToDouble(thisValue));
}
}
return reval;
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <param name="errorValue"></param>
/// <returns></returns>
public static DateTime ObjToDate(this object thisValue, DateTime errorValue)
{
DateTime reval = DateTime.MinValue;
if (thisValue != null && thisValue != DBNull.Value && DateTime.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return errorValue;
}
/// <summary>
///
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static bool ObjToBool(this object thisValue)
{
bool reval = false;
if (thisValue != null && thisValue != DBNull.Value && bool.TryParse(thisValue.ToString(), out reval))
{
return reval;
}
return reval;
}
/// <summary>
/// 获取当前时间的时间戳
/// </summary>
/// <param name="thisValue"></param>
/// <returns></returns>
public static string DateToTimeStamp(this DateTime thisValue)
{
TimeSpan ts = thisValue - new DateTime(1970, 1, 1, 0, 0, 0, 0);
return Convert.ToInt64(ts.TotalSeconds).ToString();
}
public static object ChangeType(this object value, Type type)
{
if (value == null && type.IsGenericType) return Activator.CreateInstance(type);
if (value == null) return null;
if (type == value.GetType()) return value;
if (type.IsEnum)
{
if (value is string)
return Enum.Parse(type, value as string);
else
return Enum.ToObject(type, value);
}
if (!type.IsInterface && type.IsGenericType)
{
Type innerType = type.GetGenericArguments()[0];
object innerValue = ChangeType(value, innerType);
return Activator.CreateInstance(type, new object[] { innerValue });
}
if (value is string && type == typeof(Guid)) return new Guid(value as string);
if (value is string && type == typeof(Version)) return new Version(value as string);
if (!(value is IConvertible)) return value;
return Convert.ChangeType(value, type);
}
public static object ChangeTypeList(this object value, Type type)
{
if (value == null) return default;
var gt = typeof(List<>).MakeGenericType(type);
dynamic lis = Activator.CreateInstance(gt);
var addMethod = gt.GetMethod("Add");
string values = value.ToString();
if (values != null && values.StartsWith("(") && values.EndsWith(")"))
{
string[] splits;
if (values.Contains("\",\""))
{
splits = values.Remove(values.Length - 2, 2)
.Remove(0, 2)
.Split("\",\"");
}
else
{
splits = values.Remove(0, 1)
.Remove(values.Length - 2, 1)
.Split(",");
}
foreach (var split in splits)
{
var str = split;
if (split.StartsWith("\"") && split.EndsWith("\""))
{
str = split.Remove(0, 1)
.Remove(split.Length - 2, 1);
}
addMethod.Invoke(lis, new object[] { ChangeType(str, type) });
}
}
return lis;
}
public static string ToJson(this object value)
{
return JsonConvert.SerializeObject(value);
}
public static bool AnyNoException<T>(this ICollection<T> source)
{
if (source == null) return false;
return source.Any() && source.All(s => s != null);
}
public static bool IsNull(this long? thisValue)
{
return thisValue is null;
}
public static bool IsNull(this int? thisValue)
{
return thisValue is null;
}
public static bool IsNull(this decimal? thisValue)
{
return thisValue is null;
}
public static bool IsNull(this string thisValue)
{
return string.IsNullOrWhiteSpace(thisValue);
}
public static bool IsNull(this DateTime? thisValue)
{
return thisValue is null;
}
public static bool IsNull<T>(this T entity) where T : class
{
return entity == null;
}
public static long GetSysId() => SnowFlakeSingle.instance.getID();
}

@ -1,6 +1,7 @@
using Newtonsoft.Json;
using System.Text;
using Tiobon.Core.Common.Helper;
using Tiobon.Core.Helper;
using Tiobon.Core.Model;
namespace Tiobon.Core.Common.Https.HttpPolly;

@ -4,6 +4,7 @@ using Serilog;
using Tiobon.Core.Common.Helper;
using Tiobon.Core.Model;
using Tiobon.Core.Common.DB.Dapper;
using Tiobon.Core.Helper;
namespace Tiobon.Core.Common.LogHelper;

@ -9,6 +9,7 @@ using System.Diagnostics;
using System.Reflection;
using System.Text;
using Tiobon.Core.Common.Const;
using Tiobon.Core.Helper;
namespace Tiobon.Core.Common.Seed;

@ -21,6 +21,7 @@ using System.Threading.Tasks;
using Tiobon.Core.Common;
using Tiobon.Core.Common.Extensions;
using Tiobon.Core.Common.Helper;
using Tiobon.Core.Helper;
using Tiobon.Core.Model.Entity;
using Tiobon.Core.Model.Models;
@ -834,7 +835,7 @@ public static class ReportHelper
{
var dict = new Dictionary<string, object>
{
{ "Id", UtilHelper.GetSysId() },
{ "Id", SnowFlakeSingle.instance.getID() },
{ "CreateBy", App.User.ID },
{ "CreateTime", DateTime.Now }
};

@ -10,4 +10,10 @@
<ProjectReference Include="..\Tiobon.Core.Common\Tiobon.Core.Common.csproj" />
</ItemGroup>
<ItemGroup>
<Reference Include="Tiobon.Core">
<HintPath>..\Lib\Tiobon.Core.dll</HintPath>
</Reference>
</ItemGroup>
</Project>

@ -128,7 +128,7 @@ public class Ghre_CertificateRuleServices : BaseServices<Ghre_CertificateRule, G
item.id1 = entity.CertificateDesignerData.containerItems[i].id;
item.CertificateRuleId = result;
item.CertificateDesignId = designId;
item.Id = UtilHelper.GetSysId();
item.Id = SnowFlakeSingle.instance.getID();
await Db.Insertable(item).ExecuteReturnSnowflakeIdAsync();
}
@ -156,7 +156,7 @@ public class Ghre_CertificateRuleServices : BaseServices<Ghre_CertificateRule, G
item.id1 = editModel.CertificateDesignerData.containerItems[i].id;
item.CertificateRuleId = Id;
item.CertificateDesignId = designId;
item.Id = UtilHelper.GetSysId();
item.Id = SnowFlakeSingle.instance.getID();
await Db.Insertable(item).ExecuteReturnSnowflakeIdAsync();
}
@ -192,7 +192,7 @@ public class Ghre_CertificateRuleServices : BaseServices<Ghre_CertificateRule, G
item.id1 = editModel.CertificateDesignerData.containerItems[i].id;
item.CertificateRuleId = Id;
item.CertificateDesignId = designId;
item.Id = UtilHelper.GetSysId();
item.Id = SnowFlakeSingle.instance.getID();
await Db.Insertable(item).ExecuteReturnSnowflakeIdAsync();
}

@ -33,6 +33,7 @@ public class Ghre_SurveyServices : BaseServices<Ghre_Survey, Ghre_SurveyDto, Ins
public override async Task<long> Add(InsertGhre_SurveyInput entity)
{
entity.IsRequireLogin = true;
var result = await base.Add(entity);
return result;
@ -40,6 +41,7 @@ public class Ghre_SurveyServices : BaseServices<Ghre_Survey, Ghre_SurveyDto, Ins
public override async Task<bool> Update(long Id, EditGhre_SurveyInput editModel)
{
editModel.IsRequireLogin = true;
var result = await base.Update(Id, editModel, null, ["Status"]);
return result;
}

Loading…
Cancel
Save