Class SequenceNumberCounter
Represents a simple number sequence counter, which generated new numbers
Inheritance
Namespace: Simplic.Framework.Core
Assembly: Simplic.Framework.Base.dll
Syntax
public class SequenceNumberCounter : UI.MVC.ViewModelBase
Constructors
| Improve this Doc View SourceSequenceNumberCounter(SequenceNumber)
Create sequence
Declaration
public SequenceNumberCounter(SequenceNumber sequence)
Parameters
Type | Name | Description |
---|---|---|
SequenceNumber | sequence | Sequence instance |
Properties
| Improve this Doc View SourceCurrentPosition
Current position. The setter should only be used for serialization and deserialization.
Declaration
public long CurrentPosition { get; set; }
Property Value
Type | Description |
---|---|
System.Int64 |
DbSequenceName
Name of the sequence in the database
Declaration
public string DbSequenceName { get; set; }
Property Value
Type | Description |
---|---|
System.String |
FixedLength
Fixed length, 0 = no length
Declaration
public int FixedLength { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
Format
Optional format
Declaration
public string Format { get; set; }
Property Value
Type | Description |
---|---|
System.String |
Header
Header / Title of the tab
Declaration
public string Header { get; }
Property Value
Type | Description |
---|---|
System.String |
Id
Unique id of the counter
Declaration
public Guid Id { get; set; }
Property Value
Type | Description |
---|---|
System.Guid |
Maximum
End value of the counter
Declaration
public long Maximum { get; set; }
Property Value
Type | Description |
---|---|
System.Int64 |
Minimum
Start value of the counter
Declaration
public long Minimum { get; set; }
Property Value
Type | Description |
---|---|
System.Int64 |
RestartOnEnd
If set to true, the counter will restart when reaching the end
Declaration
public bool RestartOnEnd { get; set; }
Property Value
Type | Description |
---|---|
System.Boolean |
Sequence
Instance of the sequence, to which the counter belongs
Declaration
public SequenceNumber Sequence { get; }
Property Value
Type | Description |
---|---|
SequenceNumber |
Step
Step size
Declaration
public int Step { get; set; }
Property Value
Type | Description |
---|---|
System.Int32 |
TenantId
Gets or sets the current tenant id
Declaration
public Guid? TenantId { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.Guid> |
Tenants
Gets or sets all tenants
Declaration
public ObservableCollection<OrganizationTenant> Tenants { get; set; }
Property Value
Type | Description |
---|---|
System.Collections.ObjectModel.ObservableCollection<OrganizationTenant> |
ValidFrom
Start date of the counter
Declaration
public DateTime? ValidFrom { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTime> |
ValidTo
End date of the counter
Declaration
public DateTime? ValidTo { get; set; }
Property Value
Type | Description |
---|---|
System.Nullable<System.DateTime> |
Methods
| Improve this Doc View SourceCommit(String)
Commit number so it can't be reused
Declaration
public void Commit(string number)
Parameters
Type | Name | Description |
---|---|---|
System.String | number | Number to commit |
DeleteDbSequence()
Delete sequence from database
Declaration
public void DeleteDbSequence()
Generate(DateTime, Boolean)
Generate a new unique number with the current sequence
Declaration
public string Generate(DateTime date, bool useReservation = false)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | date | Date for generating the number |
System.Boolean | useReservation | Use reservation |
Returns
Type | Description |
---|---|
System.String | New number, or throws an exception if this fails at some point |
GenerateSequenceName()
Generate unique sequence name
Declaration
public string GenerateSequenceName()
Returns
Type | Description |
---|---|
System.String | Sequence name if not already existing |
IsDbSequenceExisting()
Proof whether the sequence exists in the db or not
Declaration
public bool IsDbSequenceExisting()
Returns
Type | Description |
---|---|
System.Boolean | True if it exists, else none |
IsValid(DateTime, Nullable<Guid>)
Check whether the counter is valid on a specific date
Declaration
public bool IsValid(DateTime date, Guid? tenantId = null)
Parameters
Type | Name | Description |
---|---|---|
System.DateTime | date | Dat time to proof whether the counter is valid |
System.Nullable<System.Guid> | tenantId | Tenant id of the data to generate the number for |
Returns
Type | Description |
---|---|
System.Boolean | True if the counter is valid |
LoadSequenceInformation()
Load information from the database sequence
Declaration
public void LoadSequenceInformation()
SaveDbSequence()
Save sequence information
Declaration
public void SaveDbSequence()
SetPosition(Int64)
Set sequence position
Declaration
public void SetPosition(long position)
Parameters
Type | Name | Description |
---|---|---|
System.Int64 | position | Position |