baseline: 小军 WMS 二开代码原始快照(含 SynOABusiness.cs Debugger.Break)

This commit is contained in:
Gaussian committed 2026-11-06 18:38:38 +08:00
commit c2b0e7be0d
6522 files changed
+3530643

No files matched your search

+26
View File
@@ -0,0 +1,26 @@
using Opsoft.NetCore.O3App.Shared;
namespace Opsoft.NetCore.O3App.Domain.Models
{
public class TraceContext
{
public TraceContext(string traceId, string header = TraceIdOptions.DefaultHeader)
{
Guard.ArgumentNotNullOrWhiteSpace(traceId, nameof(traceId));
Guard.ArgumentNotNullOrWhiteSpace(header, nameof(header));
TraceId = traceId;
Header = header;
}
/// <summary>
/// The Trace ID which is applicable to the current request.
/// </summary>
public string TraceId { get; }
/// <summary>
/// The name of the header from which the Trace ID is read/written.
/// </summary>
public string Header { get; }
}
}
+30
View File
@@ -0,0 +1,30 @@
using Opsoft.NetCore.O3App.Shared;
using System.Linq;
using System.Net;
using System.Security.Cryptography;
using System.Text;
namespace Opsoft.NetCore.O3App.Domain
{
public static class TraceUtility
{
public static string GenerateAgentId()
{
var host = IpHelper.GetIPv4().NullOrEmpty2Default("127.0.0.1");
if (!IPAddress.TryParse(host, out var address))
{
address = Dns.GetHostEntry(host).AddressList.First();
}
var hashValue = new MD5CryptoServiceProvider().ComputeHash(Encoding.Default.GetBytes(Shared.Constants.AppNames.Self));
var builder = new StringBuilder();
for (int index = 0; index < hashValue.Length; index++)
{
builder.Append(hashValue[index].ToString("x").PadLeft(1, '0'));
}
var appName = builder.ToString();
var start = appName.Length > 6 ? appName.Length - 6 : 0;
var length = appName.Length < 6 ? appName.Length : 6;
return $"{address}_{appName.Substring(start, length)}";
}
}
}
+161
View File
@@ -0,0 +1,161 @@
using Opsoft.NetCore.O3App.Shared;
using System;
using System.Linq;
namespace Opsoft.NetCore.O3App.Domain.Models
{
public struct TransactionId : IEquatable<TransactionId>
{
#region Private fields
private const char _delimiter = '^';
private readonly int _hashCode;
private string _description;
private readonly byte[] _bytes;
#endregion
#region Public properties
/// <summary>
/// Gets the current runing agent's identifier.
/// </summary>
/// <value>
/// The current runing agent's identifier.
/// </value>
public string AgentId { get; }
/// <summary>
/// Gets the agent start timestamp.
/// </summary>
/// <value>
/// The agent start timestamp.
/// </value>
public long AgentStartTimestamp { get; }
/// <summary>
/// Gets the sequence.
/// </summary>
/// <value>
/// The sequence.
/// </value>
public long Sequence { get; }
#endregion
#region Constructors
/// <summary>
/// Initializes a new instance of the <see cref="TransactionId"/> struct.
/// </summary>
/// <param name="agentId">The agent identifier.</param>
/// <param name="agentStartTimestamp">The agent start time.</param>
/// <param name="sequence">The sequence.</param>
public TransactionId(string agentId, long agentStartTimestamp, long sequence)
{
AgentId = agentId ?? throw new ArgumentNullException(nameof(agentId));
AgentStartTimestamp = agentStartTimestamp;
Sequence = sequence;
_description = $"{AgentId}{_delimiter}{agentStartTimestamp}{_delimiter}{Sequence}";
_hashCode = _description.GetHashCode();
_bytes = _description.ToArray().Select(it => (byte)it).ToArray();
}
#endregion
#region Public methods
/// <summary>
/// Tries to parse the specified string and generate a <see cref="TransactionId"/>.
/// </summary>
/// <param name="payload">The transaction ID payload to parse.</param>
/// <param name="transactionId">The generated <see cref="TransactionId"/></param>
/// <returns>A <see cref="bool"/> value indicating whether to successfully parse the payload.</returns>
public static bool TryParse(string payload, out TransactionId transactionId)
{
Guard.ArgumentNotNullOrWhiteSpace(payload, nameof(payload));
transactionId = default(TransactionId);
var split = payload.Split(_delimiter);
if (split.Length != 3)
{
return false;
}
var agentId = split[0];
long timestamp;
long sequence;
if (!long.TryParse(split[1], out timestamp))
{
return false;
}
if (!long.TryParse(split[2], out sequence))
{
return false;
}
transactionId = new TransactionId(agentId, timestamp, sequence);
return true;
}
/// <summary>
/// Indicates whether the current object is equal to another object of the same type.
/// </summary>
/// <param name="other">An object to compare with this object.</param>
/// <returns>
/// true if the current object is equal to the <paramref name="other">other</paramref> parameter; otherwise, false.
/// </returns>
public bool Equals(TransactionId other) => AgentId == other.AgentId && AgentStartTimestamp == other.AgentStartTimestamp && Sequence == other.Sequence;
/// <summary>
/// Determines whether the specified <see cref="System.Object" />, is equal to this instance.
/// </summary>
/// <param name="obj">The <see cref="System.Object" /> to compare with this instance.</param>
/// <returns>
/// <c>true</c> if the specified <see cref="System.Object" /> is equal to this instance; otherwise, <c>false</c>.
/// </returns>
public override bool Equals(object obj)
{
if (obj is TransactionId)
{
return Equals((TransactionId)obj);
}
return false;
}
/// <summary>
/// Returns a hash code for this instance.
/// </summary>
/// <returns>
/// A hash code for this instance, suitable for use in hashing algorithms and data structures like a hash table.
/// </returns>
public override int GetHashCode() => _hashCode;
/// <summary>
/// Returns a <see cref="string" /> that represents this instance.
/// </summary>
/// <returns>
/// A <see cref="string" /> that represents this instance.
/// </returns>
public override string ToString() => _description;
/// <summary>
/// Implements the operator ==.
/// </summary>
/// <param name="transactionId1">The transaction id1.</param>
/// <param name="transactionId2">The transaction id2.</param>
/// <returns>
/// The result of the operator.
/// </returns>
public static bool operator ==(TransactionId transactionId1, TransactionId transactionId2) => transactionId1.Equals(transactionId2);
/// <summary>
/// Implements the operator !=.
/// </summary>
/// <param name="transactionId1">The transaction id1.</param>
/// <param name="transactionId2">The transaction id2.</param>
/// <returns>
/// The result of the operator.
/// </returns>
public static bool operator !=(TransactionId transactionId1, TransactionId transactionId2) => !transactionId1.Equals(transactionId2);
/// <summary>
/// To the bytes.
/// </summary>
/// <returns>Serialize to byte array.</returns>
public byte[] ToBytes() => _bytes;
#endregion
}
}