private void DoSyncing(IEnumerable <dynamic> syncing) { foreach (var sync in syncing) { AwsHelper.SendMessage(sync.TypeName , sync.Composer); } }
private void IndexPromotionCode(ElasticClient client, DateTime benchDate) { ILog log = LogManager.GetLogger(this.GetType()); int cursor = 0; int size = 100; int successCount = 0; Stopwatch sw = new Stopwatch(); sw.Start(); using (var db = new YintaiHangzhouContext("YintaiHangzhouContext")) { var prods = from r in db.CouponHistories where (r.CreatedDate >= benchDate) select r; int totalCount = prods.Count(); while (cursor < totalCount) { var linq = prods.OrderByDescending(p => p.Id).Skip(cursor).Take(size).ToList(); foreach (var l in linq) { try { AwsHelper.SendMessage(l.TypeName , () => l.Composing()); successCount++; } catch (Exception ex) { log.Info(ex); } } cursor += size; } } sw.Stop(); log.Info(string.Format("{0} promotion codes in {1} => {2} docs/s", successCount, sw.Elapsed, successCount / sw.Elapsed.TotalSeconds)); }