B_EventsJob.cs 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Configuration;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading.Tasks;
  7. using FCS.Common;
  8. using FCS.Interface;
  9. using FCS.Models.Entity;
  10. using Quartz;
  11. namespace FCS.Crawler.Basketball
  12. {
  13. /// <summary>
  14. /// 篮球赛事
  15. /// 制作人:海棠
  16. /// </summary>
  17. public class B_EventsJob : CommonJob
  18. {
  19. private List<B_Events> eventsList;
  20. public B_EventsJob()
  21. {
  22. eventsList = services.Query<B_Events>().ToList();
  23. }
  24. public List<B_Events> GetEventList()
  25. {
  26. var id = string.Empty;
  27. if (eventsList.Count == 2)
  28. return eventsList;
  29. else
  30. {
  31. services.Delete<B_Events>();
  32. services.SqlBulkCopyAdd<B_Events>(GetAddData());
  33. eventsList = services.Query<B_Events>().ToList();
  34. }
  35. return eventsList;
  36. }
  37. /// <summary>
  38. /// 得到新增数据
  39. /// </summary>
  40. /// <returns></returns>
  41. private IEnumerable<B_Events> GetAddData()
  42. {
  43. var eventNameList = new List<string>() {
  44. ConfigurationManager.AppSettings["NBAEventName"],
  45. ConfigurationManager.AppSettings["CBAEventName"],
  46. };
  47. foreach (var item in eventNameList)
  48. {
  49. yield return new B_Events
  50. {
  51. Id = CommonHelper.GetGuid().ToString(),
  52. Name = item,
  53. CreateDateTime = DateTime.Now,
  54. Describe = item,
  55. Sort = 1
  56. };
  57. }
  58. }
  59. }
  60. }