public void Write(DbWorkersContainer container) { SafeExecute(WriteCategories, container, "update category error"); SafeExecute(UpdateShopStatistics, container, "update shop statistics error"); SafeExecute(WriteShopProcessLog, container, "update shop process log error"); SafeExecute(UpdateShopUpdateDate, container, "update shop update date error"); }
private void SafeExecute(Action <DbWorkersContainer> action, DbWorkersContainer container, string message) { try { action(container); } catch (Exception e) { _addMessage($"{DateTime.Now} { message }", false); _logger.Error(e); } }
private void WriteCategories(DbWorkersContainer container) { var shopCategories = _shopData.Categories.Values.ToList(); if (shopCategories.Any()) { container.UpdateShopCategory(_shopData.Name, shopCategories); _addMessage($"Updated {shopCategories.Count} shop categories", false); } else { _addMessage("The shop has no categories", false); } }
private void UpdateShopStatistics(DbWorkersContainer container) { container.UpdateShopStatistics(_product); }
private void WriteShopProcessLog(DbWorkersContainer container) { container.WriteShopProcessLog(this); }
private void UpdateShopUpdateDate(DbWorkersContainer container) { container.UpdateShopUpdateDate(_info.ShopId, _info.StartTime); }