forked from hechenqingyuan/gitwms
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathTNumProivder.cs
146 lines (135 loc) · 4.58 KB
/
TNumProivder.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
/*******************************************************************************
* Copyright (C) Git Corporation. All rights reserved.
*
* Author: 情缘
* Create Date: 2013-09-26 22:05:08
*
* Description: Git.Framework
* http://www.cnblogs.com/qingyuan/
*
* Revision History:
* Date Author Description
* 2013-09-26 22:05:08 情缘
*********************************************************************************/
using Git.Framework.DataTypes;
using Git.Framework.Log;
using Git.Framework.ORM;
using Git.Storage.Entity.Base;
using Git.Storage.Entity.Procedure;
using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
namespace Git.Storage.Provider
{
public partial class TNumProivder : DataFactory
{
private Log log = Log.Instance(typeof(TNumProivder));
private static Random random = new Random(DateTime.Now.Millisecond);
/// <summary>
/// 构造方法
/// </summary>
public TNumProivder() { }
/// <summary>
/// 生成时间格式唯一编号
/// </summary>
/// <returns></returns>
public static string UniqueNum()
{
return DateTime.Now.ToString("yyyyMMddHHmmssffff") + random.Next(1000, 9999);
}
/// <summary>
/// 获得GUID
/// </summary>
/// <returns></returns>
public static string CreateGUID()
{
return Guid.NewGuid().ToString();
}
/// <summary>
/// 获得不间断流水
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public virtual string GetSwiftNum(Type type)
{
TableInfo tableInfo = EntityTypeCache.Get(type);
Proc_SwiftNumEntity entity = new Proc_SwiftNumEntity();
entity.Day = string.Empty;
entity.TabName = tableInfo.Table.Name;
this.Proc_SwiftNum.ExecuteNonQuery(entity);
if (entity != null)
{
return entity.Num.ToString();
}
return string.Empty;
}
/// <summary>
/// 获得日期的流水号
/// </summary>
/// <param name="type"></param>
/// <returns></returns>
public virtual string GetSwiftNumByDay(Type type)
{
TableInfo tableInfo = EntityTypeCache.Get(type);
Proc_SwiftNumEntity entity = new Proc_SwiftNumEntity();
entity.Day = DateTime.Now.ToString("yyyy-MM-dd");
entity.TabName = tableInfo.Table.Name;
this.Proc_SwiftNum.ExecuteNonQuery(entity);
if (entity != null)
{
return entity.Num.ToString();
}
return string.Empty;
}
/// <summary>
/// 获得流水号
/// </summary>
/// <param name="type"></param>
/// <param name="length"></param>
/// <returns></returns>
public virtual string GetSwiftNum(Type type, int length)
{
string num = GetSwiftNum(type);
string returnValue = string.Empty;
for (int i = 0; i < length - num.Length; i++)
{
returnValue += "0";
}
returnValue += num;
return returnValue;
}
/// <summary>
/// 获得日期的流水号
/// </summary>
/// <param name="type"></param>
/// <param name="length"></param>
/// <returns></returns>
public virtual string GetSwiftNumByDay(Type type, int length)
{
string num = GetSwiftNumByDay(type);
string returnValue = string.Empty;
for (int i = 0; i < length - num.Length; i++)
{
returnValue += "0";
}
returnValue += num;
return returnValue;
}
/// <summary>
/// 查询分页
/// </summary>
/// <param name="entity"></param>
/// <param name="pageInfo"></param>
/// <returns></returns>
public List<TNumEntity> GetList(TNumEntity entity, ref PageInfo pageInfo)
{
entity.IncludeAll();
entity.OrderBy(a => a.ID, EOrderBy.DESC);
int rowCount = 0;
List<TNumEntity> listResult = this.TNum.GetList(entity,pageInfo.PageSize,pageInfo.PageIndex,out rowCount);
pageInfo.RowCount = rowCount;
return listResult;
}
}
}