private void DoJob() { var dataList = DalExpiringIntegral.GetTerribleIntegralIds(); if (dataList.Any()) { var dt = DalExpiringIntegral.ConvertToDataTable(dataList); var deleteResult = DalExpiringIntegral.DeleteTerribleItem(dt); if (deleteResult) { var insertResult = DalExpiringIntegral.InsertIntegralStatistics(dt); if (insertResult > 0) { Logger.Info("数据修补完成"); } else { Logger.Warn("数据插入失败"); } } else { Logger.Warn("数据删除失败"); } } }
public static void DoJob() { var val = DalExpiringIntegral.CheckIntegralData(); if (val) { Logger.Warn($"去年的统计数据已存在,请检查数据库数据后重试"); return; } int index = 0; int step = 1000; Stopwatch sw = new Stopwatch(); sw.Start(); var data = DalExpiringIntegral.GetIntegralID(index, step); while (data.Any()) { DataTable dt = new DataTable(); dt.Columns.AddRange(new DataColumn[] { new DataColumn("Id", typeof(Guid)) }); foreach (var item in data) { DataRow r = dt.NewRow(); r[0] = item.IntegralID; dt.Rows.Add(r); } try { index += 1; var dat = DalExpiringIntegral.InsertIntegralStatistics(dt); sw.Stop(); Logger.Info($"插入{dat}条数据,用时{sw.ElapsedMilliseconds}毫秒"); sw.Reset(); sw.Start(); data = DalExpiringIntegral.GetIntegralID(index, step); } catch (Exception ex) { Logger.Info($"统计第{index}批数据出现异常{ex.Message}"); } } }