Skip to content

Commit

Permalink
合并
Browse files Browse the repository at this point in the history
  • Loading branch information
nnhy committed Aug 2, 2024
2 parents 6a6a4db + 33eb5af commit 6aa86e8
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 2 deletions.
3 changes: 3 additions & 0 deletions NewLife.Core/Data/Snowflake.cs
Original file line number Diff line number Diff line change
Expand Up @@ -348,6 +348,9 @@ public virtual Boolean TryParse(Int64 id, out DateTime time, out Int32 workerId,
/// <returns></returns>
public DateTime ConvertKind(DateTime time)
{
// 如果待转换时间未指定时区,则直接返回
if (time.Kind == DateTimeKind.Unspecified) return time;

return StartTimestamp.Kind switch
{
DateTimeKind.Utc => time.ToUniversalTime(),
Expand Down
15 changes: 13 additions & 2 deletions NewLife.Core/Extension/ProcessHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -424,6 +424,18 @@ public static Process ShellExecute(this String fileName, String? arguments = nul
/// <param name="returnError">没有标准输出时,是否返回错误内容。默认false</param>
/// <returns></returns>
public static String? Execute(this String cmd, String? arguments = null, Int32 msWait = 0, Boolean returnError = false)
{
return Execute(cmd, arguments, msWait, returnError, null);
}

/// <summary>执行命令并等待返回</summary>
/// <param name="cmd">命令</param>
/// <param name="arguments">命令参数</param>
/// <param name="msWait">等待退出的时间。默认0毫秒不等待</param>
/// <param name="returnError">没有标准输出时,是否返回错误内容。默认false</param>
/// <param name="outputEncoding">输出字符编码</param>
/// <returns></returns>
public static String? Execute(this String cmd, String? arguments = null, Int32 msWait = 0, Boolean returnError = false, Encoding? outputEncoding = null)
{
try
{
Expand All @@ -436,8 +448,7 @@ public static Process ShellExecute(this String fileName, String? arguments = nul
CreateNoWindow = true,
WindowStyle = ProcessWindowStyle.Hidden,
RedirectStandardOutput = true,
//RedirectStandardError = true,
StandardOutputEncoding = Encoding.UTF8,
StandardOutputEncoding = outputEncoding
};
var process = Process.Start(psi);
if (process == null) return null;
Expand Down

0 comments on commit 6aa86e8

Please sign in to comment.