SoftNumericalOrder 类 | 
命名空间: HslCommunication.BasicFramework
SoftNumericalOrder 类型公开以下成员。
| 名称 | 说明 | |
|---|---|---|
| SoftNumericalOrder | 
            实例化一个流水号生成的对象
              | 
| 名称 | 说明 | |
|---|---|---|
| FileSavePath | 
            文件存储的路径
              (继承自 SoftFileSaveBase。) | |
| ILogNet | 
            日志记录类
              (继承自 SoftFileSaveBase。) | 
| 名称 | 说明 | |
|---|---|---|
| ClearNumericalOrder | 
            清除流水号计数,进行重新计数
              | |
| Equals | Determines whether the specified object is equal to the current object.  (继承自 Object。) | |
| GetHashCode | Serves as the default hash function.  (继承自 Object。) | |
| GetLongOrder | 
            单纯的获取数字形式的流水号
              | |
| GetNumericalOrder | 
            获取流水号数据
              | |
| GetNumericalOrder(String) | 
            获取流水号数据
              | |
| GetType | Gets the Type of the current instance.  (继承自 Object。) | |
| LoadByFile | 
            不使用解密方法从文件读取数据
              (继承自 SoftFileSaveBase。) | |
| LoadByFile(ConverterString, String) | 
            使用用户自定义的解密方法从文件读取数据
              (继承自 SoftFileSaveBase。) | |
| LoadByString | 
            加载流水号
              (重写 SoftFileSaveBaseLoadByString(String).) | |
| SaveToFile | 
            不使用加密方法保存数据到文件
              (继承自 SoftFileSaveBase。) | |
| SaveToFile(ConverterString, String) | 
            使用用户自定义的加密方法保存数据到文件
              (继承自 SoftFileSaveBase。) | |
| ToSaveString | 
            获取流水号的值
              (重写 SoftFileSaveBaseToSaveString.) | |
| ToString | Returns a string that represents the current object.  (继承自 Object。) | 
| 名称 | 说明 | |
|---|---|---|
| ToJsonString | 
            获取当前对象的JSON格式表示的字符串。  (由 HslExtension 定义。)Gets the string represented by the JSON format of the current object.  | 
| 序号生成器软件,当获取序列号,清空序列号操作后,会自动的将ID号存储到本地的文件中,存储方式采用乐观并发模型实现。 | 
| 百万次调用的实际耗时取决于计算机的性能,不同的计算机的表现存在差异,比如作者的:i5-4590cpu,内存ddr3-8G表示差不多在800毫秒左右 | 
public partial class FormSeqCreate : HslFormContent { public FormSeqCreate( ) { InitializeComponent( ); } private HslCommunication.BasicFramework.SoftNumericalOrder softNumericalOrder; // 序列号生成器对象 private void FormSeqCreate_Load( object sender, EventArgs e ) { label1.BackColor = FormLoad.ThemeColor; softNumericalOrder = new HslCommunication.BasicFramework.SoftNumericalOrder( "ABC", // "ABC201711090000001" 中的ABC前缀,代码中仍然可以更改ABC "yyyyMMdd", // "ABC201711090000001" 中的20171109,可以格式化时间,也可以为"",也可以设置为"yyyyMMddHHmmss"; 7, // "ABC201711090000001" 中的0000001,总位数为7,然后不停的累加,即使日期时间变了,也不停的累加,最好长度设置大一些 Application.StartupPath + @"\numericalOrder.txt" // 该生成器会自动存储当前值到文件去,实例化时从文件加载,自动实现数据同步 ); if (!Program.ShowAuthorInfomation) { label2.Visible = false; linkLabel1.Visible = false; } } private void userButton1_Click( object sender, EventArgs e ) { // 获取流水号,带有默认的数据头,也即实例化中的"ABC" string seqNumber = softNumericalOrder.GetNumericalOrder( ); textBox1.AppendText( seqNumber + Environment.NewLine ); } private void userButton3_Click( object sender, EventArgs e ) { // 获取流水号,带有自定义的数据头 string seqNumber = softNumericalOrder.GetNumericalOrder( "XYZ" ); textBox1.AppendText( seqNumber + Environment.NewLine ); } private void userButton2_Click( object sender, EventArgs e ) { // 百万次的流水号测试 DateTime start = DateTime.Now; for (int i = 0; i < 1000000; i++) { string seqNumber = softNumericalOrder.GetNumericalOrder( "XYZ" ); } double spend = (DateTime.Now - start).TotalMilliseconds; textBox1.AppendText( "耗时:" + spend + Environment.NewLine ); } // 忽略 private void linkLabel1_LinkClicked( object sender, LinkLabelLinkClickedEventArgs e ) { try { System.Diagnostics.Process.Start( linkLabel1.Text ); } catch (Exception ex) { HslCommunication.BasicFramework.SoftBasic.ShowExceptionMessage( ex ); } } }