private void WatchForPriceLists(Object data) { try { using (var fbReader = new FbReader()) { fbReader.Text = _sqlGetActualPrices; fbReader.NewParameter(@"effective_date", DateTime.Now); using (var reader = fbReader.ReadMany()) { var readerHelper = new FbReaderHelper(reader); while (reader.Read()) { ProcessPrice(readerHelper.GetString(0)); } } } } catch (Exception ex) { _eventLink.Post(ConstHelper.EventSource, _priceProcessingId, ex); } }
private void ProcessPrice(String priceListId) { using (var fbExecutor = new FbExecutor()) { fbExecutor.Executor = (connection, transaction) => { // создаем команду для обновления цен using (var updateCommand = connection.CreateCommand()) { updateCommand.Transaction = transaction; updateCommand.CommandText = _sqlInsPrices; // создаем параметры команды updateCommand.AddParameter("@price_category"); updateCommand.AddParameter("@articul"); updateCommand.AddParameter("@series_id"); updateCommand.AddParameter("@price"); updateCommand.AddParameter("@update_mode", (Int32)Mode.Update); updateCommand.Prepare(); // читаем содержимое прайс-листа using (var fbReader = new FbReader()) { fbReader.Text = _sqlGetPriceBody; fbReader.NewParameter("@price_list_id", priceListId); using (var reader = fbReader.ReadMany()) { var readerHelper = new FbReaderHelper(reader); var recordCount = 0; while (reader.Read()) { // устанавливаем значения параметров команды updateCommand.SetParameter("@price_category", readerHelper.GetString(1)); updateCommand.SetParameter("@articul", readerHelper.GetString(2)); updateCommand.SetParameter("@series_id", reader.GetValue(3)); updateCommand.SetParameter("@price", readerHelper.GetDecimal(4)); // выполняем команду updateCommand.ExecuteNonQuery(); recordCount++; } _eventLink.Post(ConstHelper.EventSource, String.Format(_priceProcessed, priceListId, recordCount)); } } } // помечаем прайс, как обработанный MarkPriceAsHandled(connection, transaction, priceListId); }; fbExecutor.Execute(); } }
private void WatchForDelayedUpdates(Object data) { try { using (var fbReader = new FbReader()) { fbReader.Text = _sqlGetActualUpdates; fbReader.NewParameter("@apply_at", DateTime.Now); using (var reader = fbReader.ReadMany()) { var readerHelper = new FbReaderHelper(reader); while (reader.Read()) { EnqueueDelayedUpdate(readerHelper.GetInt64(0), (Mode)readerHelper.GetInt32(1)); } } } } catch (Exception ex) { _eventLink.Post(ConstHelper.EventSource, _delayedQueueId, ex); } }