acumatica - 如何在 Acumatica 中获取数据库时间和时区?
问题描述
我使用下面的代码在 Acumatica 中获取数据库时间。首先我在数据库中创建了一个存储过程,我通过如下代码调用它。
这在 SQL Server 中运行良好,但不适用于 MySQL。
存储过程:
DROP PROCEDURE IF EXISTS GetDBtime;
CREATE PROCEDURE GetDBtime()
BEGIN
SELECT SYSDATE();
END
C#代码:
protected void UserPreferences_UsrKNDBTime_FieldSelecting(PXCache cache, PXFieldSelectingEventArgs e)
{
var row = (UserPreferences)e.Row;
if (row != null)
{
foreach (var results in PXDatabase.Execute("GetDBtime", new PXSPParameter[] { new PXSPOutParameter("dateTimere", PXDbType.DateTime, null) }))
{
DateTime? dbTime = (DateTime)results;
if (dbTime != null)
{
e.ReturnValue = dbTime;
}
break;
}
}
}
}
解决方案
您不必自己实现 - Acumatica 框架中已经有一个函数可以为您提供服务器日期时间。只需调用PXTransactionScope.GetServerDateTime
.
推荐阅读
- github - GitHub 代码没有更新到网页
- android - Android - 在华为通话时以编程方式启用扬声器
- c++ - 计算不重复字符的子字符串(具有唯一字符的子字符串总数)
- python - 谷歌浏览器没有在非活动模式下渲染 DOM?
- c# - C#错误:该文件被另一个进程使用...(试图使用文件杀死进程但不起作用)
- java - 我们如何在 Android 的 Jvdroid IDE 上使用 Abstract Widget Toolkit(AWT)/Swing
- java - 如何在 2D 中检查两条线段是否相交
- javascript - 将 find() 与等待/异步一起使用
- python - 无法使用谷歌广告测试账号:QuotaCheckError.INVALID_TOKEN_HEADER@;触发器:'新开发者必须使用 Google Ads API。'
- javascript - `new Function()` 是否会在 JavaScript 中创建闭包概念的异常?