ConvertAnyStringToColor, etc...
This commit is contained in:
parent
7c320a939e
commit
14f0b65ef8
|
|
@ -130,19 +130,18 @@
|
|||
@{
|
||||
var tranferItem = (Transfer)context.DataItem;
|
||||
|
||||
var driverBgStyle = "border-radius: 10px; float: left; width: 20px; height: 20px; margin: 4px;";
|
||||
var firstTransferDriver = tranferItem.TransferToDrivers.FirstOrDefault();
|
||||
var firstDriverName = firstTransferDriver?.UserProductMapping?.User?.Profile?.Name;
|
||||
|
||||
if (!firstDriverName.IsNullOrWhiteSpace())
|
||||
{
|
||||
driverBgStyle += $" background-color: #{firstDriverName.GetHashCode():X8} !important";
|
||||
}
|
||||
var driverBgStyle = $"border-radius: 10px; float: left; width: 20px; height: 20px; margin: 4px; background-color: {ConvertAnyStringToColor(firstDriverName)} !important";
|
||||
|
||||
<div>
|
||||
<div style="@driverBgStyle"></div>
|
||||
<div style="position: relative; float: left; width: calc(100% - 28px)">@(string.Join(", ", tranferItem.TransferToDrivers.Select(x => x.UserProductMapping?.User?.Profile?.Name)))</div>
|
||||
</div>
|
||||
<div>
|
||||
<div style="@driverBgStyle"></div>
|
||||
<div style="position: relative; float: left; width: calc(100% - 28px)">@(string.Join(", ", tranferItem.TransferToDrivers.Select(x => x.UserProductMapping?.User?.Profile?.Name)))</div>
|
||||
</div>
|
||||
}
|
||||
}
|
||||
</CellDisplayTemplate>
|
||||
|
||||
|
|
@ -653,4 +652,10 @@
|
|||
_gridTransfer.Reload();
|
||||
}
|
||||
|
||||
private static string ConvertAnyStringToColor(string anyString)
|
||||
{
|
||||
var computeHash = SHA256.Create().ComputeHash(Encoding.UTF8.GetBytes(anyString));
|
||||
return $"#{BitConverter.ToUInt32(computeHash, 0) % 1000000:X8}";
|
||||
}
|
||||
|
||||
}
|
||||
Loading…
Reference in New Issue