Update_RealTimeJobToDayOne.cs 3.0 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_RealTimeJobToDayOne : CommonJob, IJob
  24. {
  25. public Update_RealTimeJobToDayOne()
  26. {
  27. logName = "Update_RealTimeJobToDayOne";
  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(200, 200);
  37. CommonHelper.LogBD("开始Update_RealTimeJobToDayOne", logName);
  38. Trace.WriteLine("开始Update_RealTimeJobToDayOne" + DateTime.Now);
  39. //new GamesJob().Click();
  40. #region 当天
  41. 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();
  42. query = query.Where((x, i) => query.FindIndex(z => z.Id == x.Id) == i).ToList();//Lambda表达式去重
  43. int page = query.Count % 500 == 0 ? query.Count / 500 : query.Count / 500 + 1;
  44. for (int i = 0; i < page; i++)
  45. {
  46. var query1 = query.Skip(i * 500).Take(500).ToList();
  47. // list = query;
  48. var task1 = new Task(() =>
  49. {
  50. new OddsJob().Click(query1, query1);
  51. });
  52. var task2 = new Task(() =>
  53. {
  54. new AsianDishJob().Click(query1, query1);
  55. });
  56. var task3 = new Task(() =>
  57. {
  58. new SizeIndexJob().Click(query1, query1);
  59. });
  60. task1.Start();
  61. task2.Start();
  62. task3.Start();
  63. Task.WaitAll(task1, task2, task3);
  64. List<string> listint = new List<string>();
  65. foreach (var item in query1)
  66. {
  67. listint.Add(item.Id);
  68. }
  69. if (listint.Count > 0)
  70. services.Update<F_Games>(" and Id in ('" + string.Join("','", listint) + "')");
  71. }
  72. #endregion
  73. CommonHelper.LogBD("获取完Update_RealTimeJobToDayOne", logName);
  74. Trace.WriteLine("获取完Update_RealTimeJobToDayOne" + DateTime.Now);
  75. }
  76. }
  77. }