BllHttpSetting.cs 4.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. using System;
  2. using System.Collections.Generic;
  3. using System.ComponentModel.Composition;
  4. using System.IO;
  5. using System.Linq;
  6. using System.Reflection;
  7. using System.Text;
  8. using System.Threading.Tasks;
  9. using Com.FirmLib;
  10. using FWindSoft.Data;
  11. using SAGA.DotNetUtils.Extend;
  12. using SAGA.DotNetUtils.Utilities;
  13. namespace FirmHttpDao
  14. {
  15. public class BllHttpSetting
  16. {
  17. public static readonly BllHttpSetting Instance =new BllHttpSetting();
  18. public BllHttpSetting()
  19. {
  20. Default = new FileUrlValidate() { SystemId = "dev", Secret = "123" };
  21. }
  22. public string DeleteKey()
  23. {
  24. return "/delete";
  25. }
  26. public string InsertKey()
  27. {
  28. return "/create";
  29. }
  30. public string SearchKey()
  31. {
  32. return "/query";
  33. }
  34. public string UpdateKey()
  35. {
  36. return "/update";
  37. }
  38. public string EndUri
  39. {
  40. //get { return "http://101.201.234.108:28888/venders"; }
  41. get { return InnerSetting.Current.VenderAddress; }
  42. }
  43. public string DpUri
  44. {
  45. //get { return "http://101.201.234.108:28888/venders-dp"; }
  46. get { return InnerSetting.Current.DependencyAddress; }
  47. }
  48. public string EquipmentUri
  49. {
  50. //get { return "http://101.201.234.108:28888/data-platform-3/"; }
  51. get { return InnerSetting.Current.EquipmentFamilyAddress; }
  52. }
  53. public string FileUri
  54. { //get { return "http://101.201.234.108:28888/data-platform-3/"; }
  55. get { return InnerSetting.Current.FileAddress; }
  56. }
  57. //public string SaasUri
  58. //{ //get { return "http://101.201.234.108:28888/data-platform-3/"; }
  59. // get { return InnerSetting.Current.SaasAddress; }
  60. //}
  61. public string H5Url
  62. {
  63. get { return InnerSetting.Current.H5Address; }
  64. }
  65. public FileUrlValidate Default { get;private set; }
  66. }
  67. public class InnerSetting
  68. {
  69. #region 静态操作
  70. public static void SaveConfigureInfo(string key, string value)
  71. {
  72. IniOperator.Instance(ConfigPath).SetData("Configure", key, value);
  73. }
  74. public static string GetConfigureInfo(string key)
  75. {
  76. return IniOperator.Instance(ConfigPath).GetData("Configure", key);
  77. }
  78. #endregion
  79. private static string ConfigPath { get; set; }
  80. static InnerSetting()
  81. {
  82. string path=Path.Combine(Directory.GetParent(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)).FullName,
  83. "MBIResource", "Config", ConfigurationUtil.Default.GetSettingValue("HttpSetting") ?? "HttpSetting.ini");
  84. //string path =Path.Combine(Directory.GetParent(Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)).FullName, @"MBIResource\Config\HttpSetting.ini");
  85. ConfigPath = path;
  86. //XmlFileConfig<InnerSetting> config = new XmlFileConfig<InnerSetting>(path, "");
  87. //config.Load();
  88. //Current = config.RefObject;
  89. Current = new InnerSetting();
  90. Current.VenderAddress = GetConfigureInfo(nameof(Current.VenderAddress));
  91. Current.DependencyAddress = GetConfigureInfo(nameof(Current.DependencyAddress));
  92. Current.EquipmentFamilyAddress = GetConfigureInfo(nameof(Current.EquipmentFamilyAddress));
  93. Current.FileAddress = GetConfigureInfo(nameof(Current.FileAddress));
  94. Current.H5Address = GetConfigureInfo(nameof(Current.H5Address));
  95. }
  96. public InnerSetting()
  97. {
  98. VenderAddress = @"http://127.0.0.1";
  99. DependencyAddress = @"http://127.0.0.1";
  100. EquipmentFamilyAddress = @"http://127.0.0.1";
  101. FileAddress= @"http://127.0.0.1";
  102. //SaasAddress = @"http://127.0.0.1";
  103. }
  104. public static InnerSetting Current { get; private set; }
  105. /// <summary>
  106. /// 基地址
  107. /// </summary>
  108. public string VenderAddress { get; set; }
  109. /// <summary>
  110. /// 辅助地址
  111. /// </summary>
  112. public string DependencyAddress { get; set; }
  113. /// <summary>
  114. /// 辅助地址
  115. /// </summary>
  116. public string EquipmentFamilyAddress { get; set; }
  117. /// <summary>
  118. /// 文件服务器地址
  119. /// </summary>
  120. public string FileAddress { get; set; }
  121. /// <summary>
  122. /// H5网页展示
  123. /// </summary>
  124. public string H5Address { get; set; }
  125. public static void Save()
  126. {
  127. //XmlFileConfig<InnerSetting> config = new XmlFileConfig<InnerSetting>(@"c:\HttpSetting.xml", "");
  128. //config.RefObject = new InnerSetting();
  129. //config.Save();
  130. }
  131. }
  132. }