当前位置:网站首页>UOW of dev XPO comparison
UOW of dev XPO comparison
2022-07-01 06:06:00 【qq_ sixteen million two hundred and fifteen thousand nine hundr】
Producer XPObject:
using DevExpress.Data.Filtering;
//using DevExpress.Utils.Base;
using DevExpress.Xpo;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Linq;
using System.Text;
using DevExpress.Persistent.BaseImpl;
using DevExpress.Persistent.BaseImpl.PermissionPolicy;
namespace XYZ.Module.BusinessObjects
{
//[ImageName("BO_Contact")]
//[DefaultProperty("DisplayMemberNameForLookupEditorsOfThisType")]
//[DefaultListViewOptions(MasterDetailMode.ListViewOnly, false, NewItemRowPosition.None)]
//[Persistent("DatabaseTableName")]
// Specify more UI options using a declarative approach (https://documentation.devexpress.com/#eXpressAppFramework/CustomDocument112701).
public class XYZ_Producer : BaseObject
{ // Inherit from a different class to provide a custom primary key, concurrency and deletion behavior, etc. (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument113146.aspx).
// Use CodeRush to create XPO classes and properties with a few keystrokes.
// https://docs.devexpress.com/CodeRushForRoslyn/118557
public XYZ_Producer(Session session)
: base(session)
{
}
PermissionPolicyUser GetCurrentUser()
{
PermissionPolicyUser user = null;
try
{
//return Session.GetObjectByKey<PermissionPolicyUser>(SecuritySystem.CurrentUserId); // In XAF apps for versions older than v20.1.7.
user = Session.FindObject<PermissionPolicyUser>(CriteriaOperator.Parse("Oid=CurrentUserId()"));
}
catch (Exception ex)
{
}
return user; // In non-XAF apps where SecuritySystem.Instance is unavailable (v20.1.7+).
}
public override void AfterConstruction()
{
base.AfterConstruction();
CreatedOn = DateTime.Now;
CreatedBy = GetCurrentUser();
}
protected override void OnSaving()
{
base.OnSaving();
UpdatedOn = DateTime.Now;
UpdatedBy = GetCurrentUser();
}
//private string _PersistentProperty;
//[XafDisplayName("My display name"), ToolTip("My hint message")]
//[ModelDefault("EditMask", "(000)-00"), Index(0), VisibleInListView(false)]
//[Persistent("DatabaseColumnName"), RuleRequiredField(DefaultContexts.Save)]
//public string PersistentProperty {
// get { return _PersistentProperty; }
// set { SetPropertyValue(nameof(PersistentProperty), ref _PersistentProperty, value); }
//}
//[Action(Caption = "My UI Action", ConfirmationMessage = "Are you sure?", ImageName = "Attention", AutoCommit = true)]
//public void ActionMethod() {
// // Trigger a custom business logic for the current record in the UI (https://documentation.devexpress.com/eXpressAppFramework/CustomDocument112619.aspx).
// this.PersistentProperty = "Paid";
//}
string fCode;
[Size(255)]
//[XafDisplayName(" code ")]
public string Code
{
get { return fCode; }
set { SetPropertyValue<string>(nameof(Code), ref fCode, value); }
}
string fName;
[Size(255)]
//[XafDisplayName(" name ")]
public string Name
{
get { return fName; }
set { SetPropertyValue<string>(nameof(Name), ref fName, value); }
}
string fAddress;
[Size(255)]
//[XafDisplayName(" name ")]
public string Address
{
get { return fAddress; }
set { SetPropertyValue<string>(nameof(Address), ref fAddress, value); }
}
string fLegalRepresentative;
[Size(255)]
//[XafDisplayName(" person in charge ")]
//[ModelDefault("AllowEdit", "True")]
public string LegalRepresentative
{
get { return fLegalRepresentative; }
set { SetPropertyValue<string>(nameof(LegalRepresentative), ref fLegalRepresentative, value); }
}
string fContact;
[Size(255)]
//[XafDisplayName(" person in charge ")]
//[ModelDefault("AllowEdit", "True")]
public string Contact
{
get { return fContact; }
set { SetPropertyValue<string>(nameof(Contact), ref fContact, value); }
}
private string _Phone;
//[XafDisplayName(" Telephone ")]
public string Phone
{
get
{
return _Phone;
}
set
{
SetPropertyValue("Phone", ref _Phone, value);
}
}
string fRemark;
[Size(255)]
//[XafDisplayName(" remarks ")]
public string Remark
{
get { return fRemark; }
set { SetPropertyValue<string>(nameof(Remark), ref fRemark, value); }
}
PermissionPolicyUser createdBy;
//[ModelDefault("AllowEdit", "False")]
public PermissionPolicyUser CreatedBy
{
get { return createdBy; }
set { SetPropertyValue("CreatedBy", ref createdBy, value); }
}
DateTime createdOn;
//[ModelDefault("AllowEdit", "False"), ModelDefault("DisplayFormat", "G")]
public DateTime CreatedOn
{
get { return createdOn; }
set { SetPropertyValue("CreatedOn", ref createdOn, value); }
}
PermissionPolicyUser updatedBy;
//[ModelDefault("AllowEdit", "False")]
public PermissionPolicyUser UpdatedBy
{
get { return updatedBy; }
set { SetPropertyValue("UpdatedBy", ref updatedBy, value); }
}
DateTime updatedOn;
//[ModelDefault("AllowEdit", "False"), ModelDefault("DisplayFormat", "G")]
public DateTime UpdatedOn
{
get { return updatedOn; }
set { SetPropertyValue("UpdatedOn", ref updatedOn, value); }
}
}
}call :
string connectionString;
IDataLayer dataLayer = null;
UnitOfWork uow = null;
private void tESTUOWToolStripMenuItem_Click(object sender, EventArgs e)
{
KeepUOWConnect();
XYZ_Producer producer = new XYZ_Producer(uow);
producer.Name = "";
producer.Contact = "david";
producer.Save();
uow.CommitChanges();
}
public void KeepUOWConnect()
{
try
{
if (uow == null)
{
logHelper.InfoOnce($" Database connection is empty !");
if (connectionString == null)
connectionString = ConfigurationManager.ConnectionStrings["ConnectionString_XYZData"].ConnectionString;
if (dataLayer == null)
dataLayer = XpoDefault.GetDataLayer(connectionString, DevExpress.Xpo.DB.AutoCreateOption.DatabaseAndSchema);
logHelper.InfoOnce($" Database connected !");
uow = new UnitOfWork(dataLayer);
}
}
catch (Exception ex)
{
logHelper.ErrorOnce($" Database connection failed !{Environment.NewLine}Error Message:{Environment.NewLine}{ex.Message}{Environment.NewLine}StackTrace:{Environment.NewLine}{ex.StackTrace}");
}
finally
{
}
}
/// <summary>
///
/// </summary>
public void ReleaseUOWConnect()
{
try
{
if (uow != null)
{
uow.Disconnect();
uow.Dispose();
if (dataLayer != null)
{
dataLayer.Dispose();
}
dataLayer = null;
uow = null;
}
}
catch (Exception ex)
{
logHelper.ErrorOnce($" Failed to release database connection !{Environment.NewLine}Error Message:{Environment.NewLine}{ex.Message}{Environment.NewLine}StackTrace:{Environment.NewLine}{ex.StackTrace}");
}
finally
{
}
}边栏推荐
- Timer based on LabVIEW
- OpenGL es: (1) origin of OpenGL es (transfer)
- 从诺奖知“边缘计算”的未来!
- 浏览器端保存数据到本地文件
- ONEFLOW source code parsing: automatic inference of operator signature
- Transformer le village de tiantou en un village de betteraves sucrières
- 3D打印机穿线:5种简单的解决方案
- three.js小结
- DHT11 温湿度传感器
- Know the future of "edge computing" from the Nobel prize!
猜你喜欢

SystemVerilog学习-10-验证量化和覆盖率

Smartinstantiationawarebeanpostprocessor of the extension point series determines which construction method to execute - Chapter 432

TiDB单机模拟部署生产环境集群(闭坑实践,亲测有效)

DHT11 温湿度传感器

葫芦儿 APP 使用帮助

PLA不粘贴在床上:6个简单的解决方案

OpenGL es: (3) EGL, basic steps of EGL drawing, eglsurface, anativewindow

freeswitch拨打分机号

π disk, turning your computer into a personal private cloud

How to add a gourd pie plate
随机推荐
Pit of kotlin bit operation (bytes[i] and 0xff error)
jdbc-连接池
2022 年面向初学者的 10 大免费 3D 建模软件
MySQL里记录货币
OpenGL es: (5) basic concepts of OpenGL, the process of OpenGL es generating pictures on the screen, and OpenGL pipeline
【笔记】电商订单数据分析实战
Debug details under pycharm
Pla ne colle pas sur le lit: 6 solutions simples
OpenGL ES: (2) OpenGL ES 与 EGL、GLSL的关系
扩展点系列之SmartInstantiationAwareBeanPostProcessor确定执行哪一个构造方法 - 第432篇
The row and column numbers of each pixel of multi-source grid data in the same area are the same, that is, the number of rows and columns are the same, and the pixel size is the same
SystemVerilog学习-09-进程间同步、通信和虚方法
SystemVerilog学习-10-验证量化和覆盖率
Why use huluer pie disk instead of U disk?
C XML help class
Chip, an empire built on sand!
数据库问题,如何优化Oracle SQL查询语句更快,效率更高
Essay learning record essay multi label Global
uniapp树形层级选择器
three.js小结