No puede seleccionar más de 25 temas Los temas deben comenzar con una letra o número, pueden incluir guiones ('-') y pueden tener hasta 35 caracteres de largo.

81 líneas
2.7 KiB

  1. using System;
  2. using System.Collections.Generic;
  3. using System.Linq;
  4. using System.Web;
  5. /// <summary>
  6. /// 网站配置
  7. /// </summary>
  8. namespace Basic.BLL
  9. {
  10. public class siteconfig
  11. {
  12. private readonly Basic.DAL.siteconfig dal = new Basic.DAL.siteconfig();
  13. /// <summary>
  14. /// 读取配置文件
  15. /// </summary>
  16. public Basic.Model.siteconfig loadConfig(string configFilePath)
  17. {
  18. Basic.Model.siteconfig model = CacheHelper.Get<Basic.Model.siteconfig>(Keys.CACHE_SITE_CONFIG);
  19. if (model == null)
  20. {
  21. CacheHelper.Insert(Keys.CACHE_SITE_CONFIG, dal.loadConfig(configFilePath), configFilePath);
  22. model = CacheHelper.Get<Basic.Model.siteconfig>(Keys.CACHE_SITE_CONFIG);
  23. }
  24. return model;
  25. }
  26. /// <summary>
  27. /// 读取客户端站点配置信息
  28. /// </summary>
  29. public Basic.Model.siteconfig loadConfig(string configFilePath, bool isClient)
  30. {
  31. Basic.Model.siteconfig model = CacheHelper.Get<Basic.Model.siteconfig>(Keys.CACHE_SITE_CONFIG_CLIENT);
  32. if (model == null)
  33. {
  34. model = dal.loadConfig(configFilePath);
  35. model.templateskin = model.webpath + "templates/" + model.templateskin;
  36. CacheHelper.Insert(Keys.CACHE_SITE_CONFIG_CLIENT, model, configFilePath);
  37. }
  38. return model;
  39. }
  40. public static string getConfig(string valueName)
  41. {
  42. Basic.BLL.siteconfig bll = new Basic.BLL.siteconfig();
  43. Basic.Model.siteconfig model = bll.loadConfig(Basic.Tools.Utils.GetXmlMapPath(Basic.Keys.FILE_SITE_XML_CONFING));
  44. string strResult = "";
  45. if (model != null)
  46. {
  47. switch (valueName)
  48. {
  49. case "appid":
  50. strResult = model.Wechat_appid;
  51. break;
  52. case "appsecret":
  53. strResult = model.Wechat_appsecret;
  54. break;
  55. case "mchid":
  56. strResult = model.Wechat_hchid;
  57. break;
  58. case "key":
  59. strResult = model.Wechat_key;
  60. break;
  61. }
  62. }
  63. return strResult;
  64. }
  65. /// <summary>
  66. /// 保存配置文件
  67. /// </summary>
  68. public Basic.Model.siteconfig saveConifg(Basic.Model.siteconfig model, string configFilePath)
  69. {
  70. return dal.saveConifg(model, configFilePath);
  71. }
  72. }
  73. }