ConfigureHelper.cs 2.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192
  1. //-----------------------------------------------------------------------
  2. // <copyright company="偶偶阅读网" file="ConfigureHelper.cs">
  3. // Copyright (c) V1.0
  4. // 作者:季健国
  5. // 功能:配置参数
  6. // 历史版本:2013-11-26 新增
  7. // </copyright>
  8. //-----------------------------------------------------------------------
  9. using System;
  10. using System.Collections.Generic;
  11. using System.Linq;
  12. using System.Text;
  13. using System.Web;
  14. using System.Xml;
  15. namespace Ant.Common
  16. {
  17. public class ConfigureHelper
  18. {
  19. private static string configpath = string.Empty;
  20. /// <summary>
  21. /// 账号配置信息文件路径
  22. /// </summary>
  23. private static string ConfigPath
  24. {
  25. get
  26. {
  27. if (string.IsNullOrEmpty(configpath))
  28. {
  29. if (GlobalFileHelper.IsInner())
  30. {
  31. configpath = HttpContext.Current.Server.MapPath(GlobalFileHelper.ApplicationPath + "/App_Data/OOConfig/OOReadConfigure_Test.config");
  32. }
  33. else
  34. {
  35. configpath = HttpContext.Current.Server.MapPath(GlobalFileHelper.ApplicationPath + "/App_Data/OOConfig/OOReadConfigure_Line.config");
  36. }
  37. }
  38. return configpath;
  39. }
  40. }
  41. /// <summary>
  42. /// xmlDoc
  43. /// </summary>
  44. private static XmlDocument xmlDoc = null;
  45. /// <summary>
  46. /// XmlDoc
  47. /// </summary>
  48. private static XmlDocument XmlDoc
  49. {
  50. get
  51. {
  52. if (xmlDoc == null)
  53. {
  54. xmlDoc = LoadXmlHelper.XmlLoading(ConfigPath);
  55. }
  56. return xmlDoc;
  57. }
  58. }
  59. /// <summary>
  60. /// 获取配置文件节点值
  61. /// </summary>
  62. /// <param name="AppKey">AppKey 是 key Name</param>
  63. /// <returns></returns>
  64. public static string GetConfigureValue(string AppKey)
  65. {
  66. string appValue = string.Empty;
  67. XmlNode xmlNode;
  68. XmlElement xmlEle;
  69. xmlNode = XmlDoc.SelectSingleNode("//appSettings");
  70. xmlEle = (XmlElement)xmlNode.SelectSingleNode("//add[@key='" + AppKey + "']");
  71. if (xmlEle != null)
  72. {
  73. appValue = xmlEle.GetAttribute("value");
  74. }
  75. return appValue;
  76. }
  77. }
  78. }