dy.cs 2.6 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. using dodohold.core;
  2. using CSRedis;
  3. using System.Data;
  4. namespace molilian.core
  5. {
  6. public partial class TkLogCore
  7. {
  8. static string queue_parse_dy_key = "queue:parse_logs:dy";
  9. public static int task_insert_parse_dy_logs(IDbConnection connection, IDbTransaction transaction, int limit, CSRedisClient redis)
  10. {
  11. int total = 0;
  12. for (int i = 0; i < limit; i++)
  13. {
  14. var data = redis.LPop<DyDataDTO>(queue_parse_dy_key);
  15. if (data == null) break;
  16. new DBContext.Table(connection, "tk_parse_logs")
  17. .Add("end_point", data.end_point)
  18. .Add("channel", (int)data.channel)
  19. .Add("accountId", data.accountId)
  20. .Add("accountName", data.accountName)
  21. .Add("rawContent", data.rawContent)
  22. .Add("success", data.success)
  23. .Add("message", data.message)
  24. .Add("reason", data.reason)
  25. .Add("content", data.content)
  26. .Add("itemId", data.itemId)
  27. .Add("itemName", data.itemName)
  28. .Add("pic", data.pic)
  29. .Add("couponAmount", data.couponAmount)
  30. .Add("promotionPrice", data.promotionPrice)
  31. .Add("taoToken", data.taoToken)
  32. .Add("shortLinkurl", data.shortLinkurl)
  33. .Add("deeplink_url", data.deeplink_url)
  34. .Add("elapsedTime", data.elapsedTime)
  35. .Add("subCode", data.subCode)
  36. .Add("ip", data.ip)
  37. .Add("oaid", data.oaid)
  38. .Add("create_time", data.create_time)
  39. .Create(DBContext.InsertType.NORMAL, transaction);
  40. total++;
  41. }
  42. return total;
  43. }
  44. public static async Task ParseLogAsync(DyDataDTO response)
  45. {
  46. try
  47. {
  48. var ts = DateTime.Now - response.create_time;
  49. response.elapsedTime = (int)ts.TotalMilliseconds;
  50. _ = RedisHelper.RPushAsync(queue_parse_dy_key, response);
  51. if (!response.ip.Contains("127.0.0"))
  52. {
  53. saveParseCache(response.channel.ToString(), response.accountId,
  54. response.accountName, response.success, response.message, response.reason,
  55. response.deeplink_url);
  56. }
  57. }
  58. catch (Exception ex) { }
  59. }
  60. }
  61. }