GetConnStr.cs 1.5 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374
  1. using System;
  2. namespace CommonTool
  3. {
  4. public class GetConnStr
  5. {
  6. public GetConnStr()
  7. {
  8. //string connStr = AppEnv.ReadConnectionConfig();
  9. //SnXmlNode conXmlNode = SnXmlNode.ParseGenericXml(connStr);
  10. //ConnStr = conXmlNode.GetChildValue("ConnectionStr");
  11. ConnStr = new GetRsdbNodeValue("ConnectionStr").ValueStr;
  12. }
  13. public string ConnStr { get; }
  14. }
  15. public class AppEnv
  16. {
  17. public static string ReadConnectionConfig()
  18. {
  19. return FileFuns.ReadEncryptedFile("RSDB.cfg", "qwertyuiopasdfgh");
  20. }
  21. public static string ConfigFile
  22. {
  23. get
  24. {
  25. //string text1 = LocalPath + "Config.rsc";
  26. string text1 = "Config.rsc";
  27. string text2 = FileFuns.GetFullPathFileName(text1);
  28. if (text2 != "")
  29. {
  30. text1 = text2;
  31. }
  32. else
  33. text1 = LocalPath + "Config.rsc";
  34. return text1;
  35. }
  36. }
  37. public static string LocalPath => AppDomain.CurrentDomain.BaseDirectory;
  38. }
  39. /// <summary>
  40. /// 获取配置文件RSDB中相应节点的str
  41. /// </summary>
  42. public class GetRsdbNodeValue
  43. {
  44. /// <summary>
  45. /// 节点
  46. /// </summary>
  47. public string XmlNodeStr { get; set; }
  48. /// <summary>
  49. /// 节点值
  50. /// </summary>
  51. public string ValueStr { get; }
  52. /// <summary>
  53. /// 构造函数
  54. /// </summary>
  55. /// <param name="xmlNodeStr">需要获取的节点</param>
  56. public GetRsdbNodeValue(string xmlNodeStr)
  57. {
  58. XmlNodeStr = xmlNodeStr;
  59. ValueStr =
  60. SnXmlNode.ParseGenericXml(FileFuns.ReadEncryptedFile("RSDB.cfg", "qwertyuiopasdfgh")).GetChildValue(XmlNodeStr);
  61. }
  62. }
  63. }