Update_RealTimeJob.cs 3.1 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586
  1. using System;
  2. using System.Collections.Generic;
  3. using System.Diagnostics;
  4. using System.Linq;
  5. using System.Text;
  6. using System.Threading;
  7. using System.Threading.Tasks;
  8. using FCS.Common;
  9. using FCS.Crawler.ZCLotteryAgainst;
  10. using FCS.Crawler.ZCLotteryAsianDish;
  11. using FCS.Crawler.ZCLotteryGames;
  12. using FCS.Crawler.ZCLotteryGrouping;
  13. using FCS.Crawler.ZCLotteryIP;
  14. using FCS.Crawler.ZCLotteryMatchs;
  15. using FCS.Crawler.ZCLotteryScore;
  16. using FCS.Crawler.ZCLotterySizeIndex;
  17. using FCS.Crawler.ZCLotteryTeam;
  18. using FCS.Interface;
  19. using FCS.Models;
  20. using Quartz;
  21. namespace FCS.Crawler
  22. {
  23. public class Update_RealTimeJob : CommonJob, IJob
  24. {
  25. public Update_RealTimeJob()
  26. {
  27. logName = "Update_RealTimeJob";
  28. }
  29. public void Execute(IJobExecutionContext context)
  30. {
  31. Config = CommonHelper.GetConfigFromDataMap(context.JobDetail.JobDataMap);
  32. Click();
  33. }
  34. public void Click()
  35. {
  36. ThreadPool.SetMaxThreads(500, 500);
  37. CommonHelper.LogBD("开始Update_RealTime", logName);
  38. new GamesJob().Click();
  39. #region 当天
  40. var query = services.Query<F_Games>(" and StartDateTime>'" + DateTime.Now.AddDays(0).ToString("yyyy-MM-dd") + "' and StartDateTime < '" + DateTime.Now.AddDays(1).AddHours(1).ToString("yyyy-MM-dd") + "'").Where(a => a.StartDateTime < Convert.ToDateTime(DateTime.Now.AddDays(1)) && a.StartDateTime > Convert.ToDateTime(DateTime.Now.ToShortDateString())).ToList();
  41. query = query.Where((x, i) => query.FindIndex(z => z.Id == x.Id) == i).ToList();//Lambda表达式去重
  42. int page = query.Count % 500 == 0 ? query.Count / 500 : query.Count / 500 + 1;
  43. for (int i = 0; i < page; i++)
  44. {
  45. var query1 = query.Skip(i * 500).Take(500).ToList();
  46. // list = query;
  47. var task1 = new Task(() =>
  48. {
  49. new OddsJob().Click(query1, query1);
  50. });
  51. var task2 = new Task(() =>
  52. {
  53. new AsianDishJob().Click(query1, query1);
  54. });
  55. var task3 = new Task(() =>
  56. {
  57. new SizeIndexJob().Click(query1, query1);
  58. });
  59. task1.Start();
  60. task2.Start();
  61. task3.Start();
  62. Task.WaitAll(task1, task2, task3);
  63. List<string> listint = new List<string>();
  64. foreach (var item in query1)
  65. {
  66. listint.Add(item.Id);
  67. }
  68. if (listint.Count > 0)
  69. services.Update<F_Games>(" and Id in ('" + string.Join("','", listint) + "')");
  70. }
  71. #endregion
  72. //Task.Run(() => new GamesDetailsJob().Click());
  73. //Task.Run(() => new ScoreJob().Click());
  74. //Task.Run(() => new AgainstJob().Click());
  75. //while (!CommonHelper.ThreadsFinsh())
  76. // continue;
  77. CommonHelper.LogBD("结束Update_RealTime", logName);
  78. }
  79. }
  80. }