| 12345678910111213141516171819202122232425262728293031323334353637 |
- namespace Admin.NET.Core;
- /// <summary>
- /// 通用工具类
- /// </summary>
- public static class CommonUtil
- {
- /// <summary>
- /// 生成百分数
- /// </summary>
- /// <param name="PassCount"></param>
- /// <param name="allCount"></param>
- /// <returns></returns>
- public static string ExecPercent(decimal PassCount, decimal allCount)
- {
- string res = "";
- if (allCount > 0)
- {
- var value = (double)Math.Round(PassCount / allCount * 100, 1);
- if (value < 0)
- res = Math.Round(value + 5 / Math.Pow(10, 0 + 1), 0, MidpointRounding.AwayFromZero).ToString();
- else
- res = Math.Round(value, 0, MidpointRounding.AwayFromZero).ToString();
- }
- if (res == "") res = "0";
- return res + "%";
- }
- /// <summary>
- /// 获取服务地址
- /// </summary>
- /// <returns></returns>
- public static string GetLocalhost()
- {
- return $"{App.HttpContext.Request.Scheme}://{App.HttpContext.Request.Host.Value}";
- }
- }
|