public void Audit_formatter_changes() { var supplier = DataMother.CreateSupplier(); var oldFormat = OrderHandler.Formaters().First(); var rule = new OrderSendRules { Supplier = supplier, Formater = oldFormat, Sender = OrderHandler.Senders().First() }; supplier.OrderRules.Add(rule); Save(supplier); Flush(); Assert.That(rule.Id, Is.Not.EqualTo(0)); var newFormat = OrderHandler.Formaters().Skip(1).First(); rule.Formater = newFormat; session.Save(rule); Flush(); Reopen(); var logs = session.Query <AuditRecord>().Where(l => l.ObjectId == supplier.Id && l.Type == LogObjectType.Supplier).ToList(); Assert.That(logs.Count, Is.GreaterThan(0), "нет ни одного сообщения"); Assert.That(logs[0].Message, Is.EqualTo(String.Format("$$$Изменено 'Форматер' было '{0}' стало '{1}'", oldFormat.ClassName, newFormat.ClassName))); }
private static void BindRule(OrderSendRules rule, DataRow row) { var formaterId = Convert.ToUInt32(row["FormaterId"]); var senderId = Convert.ToUInt32(row["SenderId"]); rule.Sender = OrderHandler.Find(senderId); rule.Formater = OrderHandler.Find(formaterId); rule.SendDebugMessage = Convert.ToBoolean(row["SendDebugMessage"]); rule.ErrorNotificationDelay = Convert.ToUInt32(row["ErrorNotificationDelay"]); rule.RegionCode = Equals(row["RegionCode"], DBNull.Value) ? null : (ulong?)Convert.ToUInt64(row["RegionCode"]); }
private void BindRule(Supplier supplier, DataSet data) { foreach (var row in data.Tables["OrderSendConfig"].Rows.Cast <DataRow>()) { switch (row.RowState) { case DataRowState.Added: { var rule = new OrderSendRules(); rule.Supplier = supplier; BindRule(rule, row); CreateNewSpecialOrders(supplier, Convert.ToUInt32(row["FormaterId"]), "Специальный формат", HandlerTypes.Formatter); CreateNewSpecialOrders(supplier, Convert.ToUInt32(row["SenderId"]), "Специальная доставка", HandlerTypes.Sender); supplier.OrderRules.Add(rule); break; } case DataRowState.Deleted: { var rule = GetExistRule(supplier, row); if (rule == null) { continue; } DbSession.Delete(rule); supplier.OrderRules.Remove(rule); break; } case DataRowState.Modified: { var rule = GetExistRule(supplier, row); if (rule == null) { continue; } BindRule(rule, row); CreateNewSpecialOrders(supplier, Convert.ToUInt32(row["FormaterId"]), "Специальный формат", HandlerTypes.Formatter); CreateNewSpecialOrders(supplier, Convert.ToUInt32(row["SenderId"]), "Специальная доставка", HandlerTypes.Sender); break; } } } data.Tables["OrderSendConfig"].AcceptChanges(); }