Skip to content

Commit e2bd334

Browse files
committed
文胜鼎公司专属服务端,简单tcp通信,json协议
1 parent 0ead8cd commit e2bd334

40 files changed

+4485
-0
lines changed

.gitignore

+1
Original file line numberDiff line numberDiff line change
@@ -30,3 +30,4 @@ set.config
3030
/Avatars
3131
/BinServer
3232
/BinClient
33+
/BinVsd

Vsd.Data/Entity/产品.Biz.cs

+105
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,105 @@
1+
using System;
2+
using System.Collections.Generic;
3+
using System.ComponentModel;
4+
using System.IO;
5+
using System.Linq;
6+
using System.Reflection;
7+
using System.Text;
8+
using System.Threading.Tasks;
9+
using System.Web;
10+
using System.Xml.Serialization;
11+
using NewLife;
12+
using NewLife.Data;
13+
using NewLife.Log;
14+
using NewLife.Model;
15+
using NewLife.Reflection;
16+
using NewLife.Security;
17+
using NewLife.Threading;
18+
using NewLife.Web;
19+
using XCode;
20+
using XCode.Cache;
21+
using XCode.Configuration;
22+
using XCode.DataAccessLayer;
23+
using XCode.Membership;
24+
25+
namespace Vsd.Entity
26+
{
27+
/// <summary>产品</summary>
28+
public partial class Product : Entity<Product>
29+
{
30+
#region 对象操作
31+
static Product()
32+
{
33+
// 累加字段
34+
//var df = Meta.Factory.AdditionalFields;
35+
//df.Add(__.Status);
36+
37+
// 过滤器 UserModule、TimeModule、IPModule
38+
Meta.Modules.Add<UserModule>();
39+
Meta.Modules.Add<TimeModule>();
40+
Meta.Modules.Add<IPModule>();
41+
42+
// 单对象缓存
43+
var sc = Meta.SingleCache;
44+
sc.FindSlaveKeyMethod = k => Find(__.Name, k);
45+
sc.GetSlaveKeyMethod = e => e.Name;
46+
}
47+
48+
/// <summary>验证数据,通过抛出异常的方式提示验证失败。</summary>
49+
/// <param name="isNew">是否插入</param>
50+
public override void Valid(Boolean isNew)
51+
{
52+
// 如果没有脏数据,则不需要进行任何处理
53+
if (!HasDirty) return;
54+
55+
if (isNew)
56+
{
57+
// 自动生成产品证书密钥
58+
if (Code.IsNullOrEmpty()) Code = Rand.NextString(4);
59+
if (Secret.IsNullOrEmpty()) Secret = Rand.NextString(8);
60+
}
61+
}
62+
#endregion
63+
64+
#region 扩展属性
65+
#endregion
66+
67+
#region 扩展查询
68+
/// <summary>根据编号查找</summary>
69+
/// <param name="id">编号</param>
70+
/// <returns>实体对象</returns>
71+
public static Product FindByID(Int32 id)
72+
{
73+
if (id <= 0) return null;
74+
75+
// 实体缓存
76+
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.ID == id);
77+
78+
// 单对象缓存
79+
return Meta.SingleCache[id];
80+
81+
//return Find(_.ID == id);
82+
}
83+
84+
/// <summary>根据名称查找</summary>
85+
/// <param name="name">名称</param>
86+
/// <returns>实体对象</returns>
87+
public static Product FindByName(String name)
88+
{
89+
// 实体缓存
90+
if (Meta.Session.Count < 1000) return Meta.Cache.Find(e => e.Name == name);
91+
92+
// 单对象缓存
93+
//return Meta.SingleCache.GetItemWithSlaveKey(name) as Product;
94+
95+
return Find(_.Name == name);
96+
}
97+
#endregion
98+
99+
#region 高级查询
100+
#endregion
101+
102+
#region 业务操作
103+
#endregion
104+
}
105+
}

0 commit comments

Comments
 (0)