/// <summary> /// 数字转中文,数字转中文不能直接逐个数字去读,要按照个、十、百、位去读 /// </summary> /// <param name="num">字符串类型的数字</param> /// <returns></returns> public static string NumConvertToChinese(string num) { string beforeNumPart = num.Contains('.')?FindDataHelper.FindDataBySuffix(num, "."): num; StringBuilder beforeChinesePart = new StringBuilder(); for (int j = 0, i = beforeNumPart.Length - 1; i >= 0; i--, j++) { char n = ChineseNumMap[beforeNumPart[i]]; if (n != '〇') { beforeChinesePart.Insert(0, ChineseUnits[j]); } beforeChinesePart.Insert(0, n); } string full = beforeChinesePart.ToString(); full = full.StartsWith("一十") ? full.Substring(1) : full; while (full.IndexOf("〇〇") > -1) { full = full.Replace("〇〇", "〇"); } if (!full.StartsWith("〇")) { full = full.TrimEnd('〇'); } string afterChinesePart = num.Contains('.')? "点" + NoConvertToChinese(FindDataHelper.FindDataByPrefix(num, ".")):""; return(full + afterChinesePart); }
/// <summary> /// 刷新web项目 /// </summary> /// <param name="webRootPath">web项目根目录(例如:E:\git_projects\myhelper\c#\web\WebApplication1)</param> public static void RefreshVersion(string webRootPath) { string version = DateTime.Now.ToString("yyyyMMddHHmmss"); File.WriteAllText($"{webRootPath}index.aspx", $"<script type='text/javascript'>location.href = '/Content/ie8/index.html?v={version}';</script>", Encoding.UTF8); HtmlDocument doc = new HtmlDocument(); doc.Load($"{webRootPath}Content{Path.DirectorySeparatorChar}index.html", Encoding.UTF8); HtmlNode node = doc.DocumentNode; node.SelectSingleNode("//div[@ng-include]").SetAttributeValue("ng-include", $"x.url+'?v={version}'"); foreach (HtmlNode script in node.SelectNodes("//script[starts-with(@src,'my-js/')]")) { script.SetAttributeValue("src", $"{FindDataHelper.FindDataBySuffix(script.GetAttributeValue("src", ""), "?")}?v={version}"); } doc.Save($"{webRootPath}Content{Path.DirectorySeparatorChar}index.html", Encoding.UTF8); }