LotteryConfigInfo.cs 2.4 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172
  1. using System;
  2. using System.IO;
  3. namespace CB.LotteryCatchData.Entity
  4. {
  5. /// <summary>
  6. /// 彩种配置信息
  7. /// </summary>
  8. public class LotteryConfigInfo
  9. {
  10. /// <summary>
  11. /// 彩票名称
  12. /// </summary>
  13. public string Name { get; set; }
  14. /// <summary>
  15. /// 临时配置存放路劲
  16. /// </summary>
  17. public string Path { get; set; }
  18. /// <summary>
  19. /// 数据抓取地址
  20. /// </summary>
  21. public string DataUrl { get; set; }
  22. /// <summary>
  23. /// HTTP请求超时时间
  24. /// </summary>
  25. public int TimeOut { get; set; }
  26. /// <summary>
  27. /// 周期内起始开奖时间格式
  28. /// </summary>
  29. public string OpenTimeFomart { get; set; }
  30. /// <summary>
  31. /// 周期内起始时间
  32. /// </summary>
  33. public TimeSpan StartTime { get; set; }
  34. /// <summary>
  35. /// 开奖频率、开奖周期(分钟)
  36. /// </summary>
  37. public int OpenPeriod { get; set; }
  38. /// <summary>
  39. /// 周期内结束时间
  40. /// </summary>
  41. public TimeSpan EndTime { get; set; }
  42. /// <summary>
  43. /// 实现彩种数据抓取ICatchDataProvider接口的类类型
  44. /// </summary>
  45. public string CatchDataProvider { get; set; }
  46. /// <summary>
  47. /// 序列化xml
  48. /// </summary>
  49. /// <returns></returns>
  50. public override string ToString()
  51. {
  52. return string.Format("<Lottery Name=\"{0}\" Path=\"{1}\" TimeOut=\"{2}\" OpenTimeFomart=\"{3}\" StartTime=\"{4}\" OpenPeriod=\"{5}\" EndTime=\"{6}\" CatchDataProvider=\"{7}\">{8}</Lottery>",
  53. this.Name, this.Path, this.TimeOut, this.OpenTimeFomart, this.StartTime, this.OpenPeriod, this.EndTime, this.CatchDataProvider, this.DataUrl);
  54. }
  55. /// <summary>
  56. /// 获取临时配置文件路劲
  57. /// </summary>
  58. /// <returns></returns>
  59. public string GetParamKeyPath()
  60. {
  61. if (string.IsNullOrEmpty(this.Path))
  62. throw new FileNotFoundException("请设置Config\\CatchDataConfig.xml配置文件对应【" + this.Name + "】彩种的Path属性值");
  63. string path = AppDomain.CurrentDomain.BaseDirectory + "Config\\" + this.Path + "\\";
  64. if (!Directory.Exists(path))
  65. Directory.CreateDirectory(path);
  66. return path + "tmpDataConfig";
  67. }
  68. }
  69. }