一、摘要
在这里主要是写OEA设计方面的知识了。OEA 源码:
可以到的博客和中可以下到。虽然现在应经知道使用了,但是还是 需要了解框架相关知识运行机制,让我们更好的使用OEA进行开发。
二、本文大纲
a、摘要 。
b、UML图 (业务逻辑梳理,和父子关系的) 。
c、项目结构,效果图 。
d、OEA实现方法 。
三、UML图
这个图,我可是求高手求了好久才教我的 嘻嘻。
热点: 网关 设备 用户 小区
他们的关系是:
网关下面有多个设备
小区下面有多个用户
用户下面有多个设备
设备下面有多个 用户
他们的类图如下:
象下面这个图里面有个多对多,我们需要把它简化为这样的:这个是OEA提倡的分解关系
要用到OEA的外键,父子,界面扩展命令。
四、项目结构,效果图
项目结构图:
对应的数据库结构:
效果图:
五、OEA实现方法
关联表的代码也是主代码了
下面的代码主要是完成这个图啦
1: // 设备 用户 关联表2: [ChildEntity, Serializable]3: public class UDAssociation : MyEntity4: {5: public static readonly RefPropertyDeviceRefProperty = 6: P.RegisterRef(e => e.Device, ReferenceType.Normal); 7: public int DeviceId8: {9: get { return this.GetRefId(DeviceRefProperty); }10: set { this.SetRefId(DeviceRefProperty, value); }11: }12: public Device Device13: {14: get { return this.GetRefEntity(DeviceRefProperty); }15: set { this.SetRefEntity(DeviceRefProperty, value); }16: }17:18: public static readonly RefPropertyHouseHoldRefProperty = 19: P.RegisterRef(e => e.HouseHold, ReferenceType.Parent); 20: public int HouseHoldId21: {22: get { return this.GetRefId(HouseHoldRefProperty); }23: set { this.SetRefId(HouseHoldRefProperty, value); }24: }25: public HouseHold HouseHold26: {27: get { return this.GetRefEntity(HouseHoldRefProperty); }28: set { this.SetRefEntity(HouseHoldRefProperty, value); }29: }30:31: #region 视图属性32: public static readonly PropertyView_CodeProperty = P .RegisterReadOnly(e => e.View_Code, e => (e as UDAssociation).GetView_Code(), null); 33: public string View_Code34: {35: get { return this.GetProperty(View_CodeProperty); }36: }37: private string GetView_Code()38: {39: return this.Device.Id.ToString();40: }41:42: public static readonly PropertyView_NameProperty = P .RegisterReadOnly(e => e.View_Name, e => (e as UDAssociation).GetView_Name(), null); 43: public string View_Name44: {45: get { return this.GetProperty(View_NameProperty); }46: }47: private string GetView_Name()48: {49: return this.Device.Name;50: }51: #endregion52:53:54: }55:一个设备对应多个用户
1: // 一个设备对应多个用户2: [ChildEntity, Serializable]3: public class UDHouseHold : MyEntity4: {5: public static readonly RefPropertyUserDeviceRefProperty = 6: P.RegisterRef(e => e.UDAssociation, ReferenceType.Parent); 7: public int UDAssociationId8: {9: get { return this.GetRefId(UserDeviceRefProperty); }10: set { this.SetRefId(UserDeviceRefProperty, value); }11: }12: public UDAssociation UDAssociation13: {14: get { return this.GetRefEntity(UserDeviceRefProperty); }15: set { this.SetRefEntity(UserDeviceRefProperty, value); }16: }17: public static readonly RefPropertyHouseHoldRefProperty = 18: P.RegisterRef(e => e.HouseHold, ReferenceType.Normal); 19: public int HouseHoldId20: {21: get { return this.GetRefId(HouseHoldRefProperty); }22: set { this.SetRefId(HouseHoldRefProperty, value); }23: }24: public HouseHold HouseHold25: {26: get { return this.GetRefEntity(HouseHoldRefProperty); }27: set { this.SetRefEntity(HouseHoldRefProperty, value); }28: }29:30: #region 视ó图?属?性?31:32: public static readonly PropertyView_CodeProperty = P .RegisterReadOnly(e => e.View_Code, e => (e as UDHouseHold).GetView_Code(), null); 33: public string View_Code34: {35: get { return this.GetProperty(View_CodeProperty); }36: }37: private string GetView_Code()38: {39: return HouseHold.Id.ToString();40: }41:42: public static readonly PropertyView_NameProperty = P .RegisterReadOnly(e => e.View_Name, e => (e as UDHouseHold).GetView_Name(), null); 43: public string View_Name44: {45: get { return this.GetProperty(View_NameProperty); }46: }47: private string GetView_Name()48: {49: return HouseHold.Name;50: }51:52: #endregion53: }54:一个用户有多个设备
1: // 一?个?用?户§有D多à个?设è备?2: [ChildEntity, Serializable]3: public class UDDevices : MyEntity4: {5: public static readonly RefPropertyUDAssociationRefProperty = 6: P.RegisterRef(e => e.UDAssociation, ReferenceType.Parent); 7: public int UDAssociationId8: {9: get { return this.GetRefId(UDAssociationRefProperty); }10: set { this.SetRefId(UDAssociationRefProperty, value); }11: }12: public UDAssociation UDAssociation13: {14: get { return this.GetRefEntity(UDAssociationRefProperty); }15: set { this.SetRefEntity(UDAssociationRefProperty, value); }16: }17: public static readonly RefPropertyDeviceRefProperty = 18: P.RegisterRef(e => e.Device, ReferenceType.Normal); 19: public int DeviceId20: {21: get { return this.GetRefId(DeviceRefProperty); }22: set { this.SetRefId(DeviceRefProperty, value); }23: }24: public Device Device25: {26: get { return this.GetRefEntity(DeviceRefProperty); }27: set { this.SetRefEntity(DeviceRefProperty, value); }28: }29: }30:
啥也不说了,直接下载源码看了。