Business Numerators. Deleted Numbers

The Numerators provide the feature to store the numbers of deleted objects and reapply them to the newly created ones. For instance, the DeletedNumbersNumeration class exposes the Number property supported by the Numerator. After removing the DeletedNumbersAllNumeration_3 and DeletedNumbersAllNumeration_6 objects, the service can store all Number's values.

numerator_23

Then, the new object will automatically obtain the "003" value; and the next object will obtain the "006" value. Only from here the numbering will continue on.

numerator_24

This is the "All" use case of the Use Deleted Numbers feature; there is also the "Last" use case described below.

To be provided with the Use Deleted Numbers feature, it is required to perform two steps:

  • Implement a special interface in the business class.
  • Set the UseDeletedNumbers property when configuring the Numerator.

Since the Numerators support both XPO-objects and Domain Components, there are two corresponding interfaces that declare the Use Deleted Numbers support. The code snippets below demonstrate it:

XPO

  • c#
  • VB

[DefaultClassOptions]
public class DeletedNumbersNumeration : BaseObject, IDeletedNumbersSupport
{
  public DeletedNumbersNumeration(Session session)
    : base(session)
  {
  }
  public string Name
  {
    get
    {
      return this.GetPropertyValue<string>("Name");
    }
    set
    {
      SetPropertyValue("Name", value);
    }
  }
  public string Number
  {
    get
    {
      return this.GetPropertyValue<string>("Number");
    }
    set
    {
      SetPropertyValue("Number", value);
    }
  }
  private Dictionary<string, long> realIndex = new Dictionary<string, long>();
  [Browsable(false)]
  [ValueConverter(typeof(DictionaryToStringConverter))]
  public Dictionary<string, long> RealIndex
  {
    get
    {
      return realIndex;
    }
    set
    {
      this.SetPropertyValue("RealIndex", ref realIndex, value);
    }
  }
  long? IDeletedNumbersSupport.GetRealIndex(NumeratorBase numerator, string member)
  {
    return !RealIndex.ContainsKey(member) ? (long?)null : RealIndex[member];
  }
  void IDeletedNumbersSupport.SetRealIndex(NumeratorBase numerator, string member, long? value)
  {
    if (value.HasValue)
      this.RealIndex[member] = value.Value;
  }
}

<DefaultClassOptions> _
Public Class DeletedNumbersNumeration
  Inherits BaseObject
  Implements IDeletedNumbersSupport
  Public Sub New(ByVal session As Session)
    MyBase.New(session)
  End Sub
  Public Property Name As String
    Get
      Return Me.GetPropertyValue(Of String)("Name")
    End Get
    Set
      SetPropertyValue("Name", value)
    End Set
  End Property
  Public Property Number As String
    Get
      Return Me.GetPropertyValue(Of String)("Number")
    End Get
    Set
      SetPropertyValue("Number", value)
    End Set
  End Property
  Private _realIndex As Dictionary(Of String, long) = New Dictionary(Of String, long)()
  <Browsable(False)> _
<ValueConverter(GetType(DictionaryToStringConverter))> _
Public Property RealIndex As Dictionary(Of String, long)
    Get
      Return _realIndex
    End Get
    Set
      Me.SetPropertyValue("RealIndex", _realIndex, value)
    End Set
  End Property
  Private Function GetRealIndex(ByVal numerator As NumeratorBase, ByVal member As String) As long? Implements IDeletedNumbersSupport.GetRealIndex
    Return If(Not RealIndex.ContainsKey(member), CType(Nothing, long?), RealIndex(member))
  End Function
  Private Sub SetRealIndex(ByVal numerator As NumeratorBase, ByVal member As String, ByVal value As long?) Implements IDeletedNumbersSupport.SetRealIndex
    If value.HasValue Then
      Me.RealIndex(member) = value.Value
    End If
  End Sub
End Class

You can see this code in the Objects.cs file of the attached BusinessNumerators sample.

DC

  • c#
  • VB

[DomainComponent]
public interface SomeObject : DeletedNumbersSupport
{
  string Code { get; set; }
}

<DomainComponent> _
Public Interface SomeObject
  Inherits DeletedNumbersSupport
  Property Code As String
End Interface

Further, invoke the Model Editor, navigate to the required Numerator node, and set the UseDeletedNumbers property:

numerator_25

  • None: do not use deleted numbers.
  • All: use all deleted numbers.
  • Last: use only the last deleted number.

The Deleted Numbers option is also accessible via XAS:

numerator_14