public void PurchaseForOverdue() { var when = _time.GetAppNowTime(); var date = when.AddHours(-4).Date; using (var db = _dbFactory.GetRWDb()) { var overdueOrderIds = GetOverdueOrderInfos(db, _time.GetAppNowTime()).Select(i => i.OrderId).ToList(); _log.Info("Overdue orders count=" + overdueOrderIds.Count); if (overdueOrderIds.Count > 5) //NOTE: print only when a lot of overdue { var orderIdList = overdueOrderIds; var batchName = date.ToString("MM/dd/yyyy") + " Overdue"; var batchId = _batchManager.CreateBatch(db, BatchType.AutoBuy, batchName, orderIdList, when, null); _batchManager.LockBatch(db, batchId, when); var actionId = _actionService.AddAction(db, SystemActionType.PrintBatch, batchId.ToString(), new PrintBatchInput() { BatchId = batchId, CompanyId = _companyId, UserId = null }, null, null); _log.Info("PrintLabelsForBatch, add print action, id=" + actionId); } } }
public static MessageResult CreateBatch(IUnitOfWork db, IBatchManager batchManager, string orderIds, string batchName, DateTime when, long?by) { if (!string.IsNullOrEmpty(orderIds)) { var stringOrderIdList = orderIds.Split(", ".ToCharArray(), StringSplitOptions.RemoveEmptyEntries); var orderIdList = stringOrderIdList.Select(long.Parse).ToList(); var batchId = batchManager.CreateBatch(db, BatchType.User, batchName, orderIdList, when, by); return(MessageResult.Success("", batchId.ToString())); } return(MessageResult.Error("Order list is empty")); }