QueryStringFormat.cs 3.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Text;
  5. namespace Bowin.Common
  6. {
  7. public static class QueryStringFormat
  8. {
  9. public static string GetFormatStr(string AStr)
  10. {
  11. if ("" == AStr)
  12. return "";
  13. else
  14. {
  15. AStr = AStr.Replace("<", "〈");
  16. AStr = AStr.Replace(">", "〉");
  17. AStr = AStr.Replace("'", "’");
  18. return AStr;
  19. }
  20. }//格式化字符串
  21. public static string GetFormatStrbjq(string AStr)
  22. {
  23. if ("" == AStr)
  24. return "";
  25. else
  26. {
  27. AStr = AStr.Replace("'", "’");
  28. return AStr;
  29. }
  30. }//格式化字符串——用编辑器的-录入的时候
  31. public static string GetFormatStrmb(string AStr)
  32. {
  33. if ("" == AStr)
  34. return "";
  35. else
  36. {
  37. AStr = AStr.Replace("'", "’");
  38. AStr = AStr.Replace("\"", "");
  39. return AStr;
  40. }
  41. }//格式化字符串——用编辑器的-设置模版的时候
  42. public static string GetFormatStrbjq_show(string AStr)
  43. {
  44. if ("" == AStr)
  45. return "";
  46. else
  47. {
  48. AStr = AStr.Replace("’", "'");
  49. return AStr;
  50. }
  51. }//格式化字符串——用编辑器的-显示的时候
  52. public static string GetFormatWorksheetName(string AStr)
  53. {
  54. if ("" == AStr)
  55. return "";
  56. else
  57. {
  58. AStr = AStr.Replace(":", " ");
  59. AStr = AStr.Replace(":", " ");
  60. AStr = AStr.Replace("/", " ");
  61. AStr = AStr.Replace(@"\", " ");
  62. AStr = AStr.Replace("?", " ");
  63. AStr = AStr.Replace("?", " ");
  64. AStr = AStr.Replace("*", " ");
  65. AStr = AStr.Replace("[", " ");
  66. AStr = AStr.Replace("]", " ");
  67. return AStr;
  68. }
  69. }//打印、excel导出时工作表名不能有特殊字符
  70. public static string TbToLb(string AStr)
  71. {
  72. if ("" == AStr)
  73. return "";
  74. else
  75. {
  76. AStr = AStr.Replace("\n", "<br>");
  77. AStr = AStr.Replace(" ", "&nbsp;&nbsp;");
  78. return AStr;
  79. }
  80. }//从textbox的数据转换到lable中
  81. public static string GetQueryStringByPath(this Uri path, string key)
  82. {
  83. if (string.IsNullOrEmpty(path.Query))
  84. {
  85. return "";
  86. }
  87. string queryKey = key.ToLower();
  88. Dictionary<string, string> parameters = path.Query
  89. .TrimStart('?')
  90. .Split('&')
  91. .Select(x => (!string.IsNullOrEmpty(x)) ? x.Split('=').ToList() : new List<string> { "", "" })
  92. .ToDictionary(x => x[0].Trim().ToLower(), x => x[1].Trim());
  93. string value;
  94. if (!parameters.TryGetValue(queryKey, out value))
  95. {
  96. return "";
  97. }
  98. else
  99. {
  100. return value;
  101. }
  102. }
  103. }
  104. }