AX 2012 中批处理作业状态的可能值和文本描述是什么?
What are the possible values and text description for batch job status in AX 2012?
我正在创建一份报告以显示 Microsoft AX 2012 中批处理作业的问题,但无法找到 link table 中 BATCHJOB table 中的整数状态值的任何内容14=] 服务器到应用程序中显示的文本描述。有人告诉我这应该存在于枚举的模型数据库中,但我无法确定该数据库中数据之间的正确 links。我也无法在网络搜索或 Microsoft 提供的任何文档中找到此信息。谁能提供这些值,或者告诉我在哪里可以找到它们?
SELECT bj.[STATUS] AS [bj_STATUS]
-- 1: Didn't run - what else?
-- 2: Canceled - what else?
-- 3: Error?
-- 4: Success?
-- 5: ?
-- 6: ?
-- 7: ?
-- 8: Withhold?
-- Waiting
-- Ended
-- Withhold
-- Executing
-- Ready
-- Finished
-- Error
-- Didn't run
,bj.[CAPTION] AS [bj_CAPTION]
,bjh.[STARTDATETIME] AS [bjh_STARTDATETIME]
,bjh.[ENDDATETIME] AS [bjh_ENDDATETIME]
,bjh.[BATCHCREATEDBY] AS [bjh_BATCHCREATEDBY]
,bjh.[CANCELEDBY] AS [bjh_CANCELEDBY]
,bg.[GROUP_] AS [bg_GROUP]
,bg.[DESCRIPTION] AS [bg_DESCRIPTION]
,bh.[SERVERID] AS [bh_SERVERID]
FROM [MicrosoftDynamicsAX].[dbo].[BATCHJOB] bj WITH(NOLOCK)
INNER JOIN [MicrosoftDynamicsAX].[dbo].[BATCHJOBHISTORY] bjh WITH(NOLOCK)
ON bjh.[BATCHJOBID] = bj.[RECID]
INNER JOIN [MicrosoftDynamicsAX].[dbo].[BATCH] b WITH(NOLOCK)
ON b.[BATCHJOBID] = bj.[RECID]
INNER JOIN [MicrosoftDynamicsAX].[dbo].[BATCHGROUP] bg WITH(NOLOCK)
ON bg.[GROUP_] = b.[GROUPID]
INNER JOIN [MicrosoftDynamicsAX].[dbo].[BATCHHISTORY] bh WITH(NOLOCK)
ON bh.[BATCHID] = b.[RECID]
AND bh.[BATCHJOBID] = bj.[RECID]
AND bh.[BATCHJOBHISTORYID] = bjh.[RECID]
WHERE bjh.[STARTDATETIME] > GETDATE() - 1 -- AND bj.[STATUS] NOT IN(1, 2, 4)
枚举是 BatchStatus
,它存储在模型存储数据库中,但我不认为枚举名称 and/or 值被存储。它最终代表一个整数。
下面是整数值 0-8 的基本枚举:
除以下例外情况外,文本标签与名称(即英文)相同。
- 0 - 保留(保留)
- 4 - 结束(已完成)
- 6 - 没有 运行 (NotRun)
您可能只使用 CASE 语句创建一个 SQL 存储过程,因为这些状态很少从基本代码中更改。
感谢@Alex Kwitny 提供的信息,我能够弄清楚如何从数据库中获取它。一旦我有了枚举的名称,我就能够在 ModelElement table 中找到它,然后 link 它返回到 ElementHandle 值上的 ModelElementData table 。 ModelElementData table 有一个 Properties 字段存储在 varbinary 中,可以将其分解成多个部分以读取主数据库中每个整数值的值。我花了一些时间来解析所有内容并将二进制文件转换为文本,但现在我可以通过将我的查询转换为可以从我的主查询中调用的函数来引用枚举值以防将来发生任何变化报告。
DECLARE @name AS VARCHAR(40) = 'BatchStatus'
, @value AS INT = 1
, @language AS VARCHAR(8) = 'en_us';
DECLARE @bin AS VARBINARY(MAX);
SET @bin =
(
SELECT TOP (1)
med.[Properties]
FROM [MicrosoftDynamicsAX_Model].[dbo].[ModelElement] me
INNER JOIN [MicrosoftDynamicsAX_Model].[dbo].[ModelElementData] med
ON med.[ElementHandle] = me.[ElementHandle]
WHERE me.[Name] = @name
AND me.[ElementType] = 40
ORDER BY med.[LayerId] DESC
);
DECLARE @pos AS INT;
DECLARE @flags AS INT;
DECLARE @count AS INT;
DECLARE @idx AS INT;
DECLARE @off AS INT;
DECLARE @result AS VARCHAR(255);
SET @pos = 3;
SET @off = CAST(SUBSTRING(@bin, @pos, 1) AS INT) - 1;
SET @pos = @pos + 1;
WHILE @off > 0
BEGIN
WHILE SUBSTRING(@bin, @pos, 2) <> 0x0000
SET @pos = @pos + 2;
SET @pos = @pos + 2;
SET @off = @off - 1;
END;
SET @flags = CAST(SUBSTRING(@bin, @pos, 3) AS INT);
SET @pos = @pos + 3;
IF @flags & 0x008000 = 0x008000
BEGIN
WHILE SUBSTRING(@bin, @pos, 2) <> 0x0000
SET @pos = @pos + 2;
SET @pos = @pos + 2;
END;
IF @flags & 0x000002 = 0x000002
SET @pos = @pos + 1;
SET @pos = @pos + 1;
SET @count = CAST(SUBSTRING(@bin, @pos, 1) AS INT);
IF @count > 0
BEGIN
SET @pos = @pos + 1;
IF @flags & 0x000200 = 0x000200
SET @idx = @value;
ELSE
BEGIN
SET @idx = 0;
SET @off = 2 + CAST(CAST(REVERSE(SUBSTRING(@bin, @pos, 2)) AS BINARY(2)) AS INT) * 2;
SET @off = @off + 2 + CAST(CAST(REVERSE(SUBSTRING(@bin, @pos + @off, 2)) AS BINARY(2)) AS INT) * 2;
WHILE CAST(SUBSTRING(@bin, @pos + @off + @idx, 1) AS INT) <> @value
AND @idx < @count
SET @idx = @idx + 1;
IF CAST(SUBSTRING(@bin, @pos + @off + @idx, 1) AS INT) <> @value
SET @idx = -1;
END;
IF @idx >= 0
BEGIN
SET @pos = @pos + 2;
WHILE 1 = 1
BEGIN
SET @off = 0;
SET @result = '';
WHILE SUBSTRING(@bin, @pos + @off, 2) <> 0x0000
BEGIN
SET @result = @result + CHAR(CAST(REVERSE(SUBSTRING(@bin, @pos + @off, 2)) AS BINARY(2)));
SET @off = @off + 2;
END;
SET @pos = @pos + @off + 2;
IF @idx <= 0
BREAK;
SET @idx = @idx - 1;
END;
END;
ELSE
SET @result = '~ENUM NOT FOUND~';
END;
ELSE
SET @result = '~ERROR~';
IF SUBSTRING(@result, 1, 1) = '@'
BEGIN
DECLARE @module AS VARCHAR(3);
DECLARE @label AS INT;
SET @module = SUBSTRING(@result, 2, 3);
SET @label = CAST(SUBSTRING(@result, 5, DATALENGTH(@result) - 4) AS INT);
SET @result =
(
SELECT TOP (1)
[Text]
FROM [MicrosoftDynamicsAX_Model].[dbo].[ModelElementLabel]
WHERE [LabelId] = @label
AND [Module] = @module
AND [Language] = @language
ORDER BY [LayerId] DESC
);
END;
SELECT @value AS [Id]
, @result AS [Status];
我正在创建一份报告以显示 Microsoft AX 2012 中批处理作业的问题,但无法找到 link table 中 BATCHJOB table 中的整数状态值的任何内容14=] 服务器到应用程序中显示的文本描述。有人告诉我这应该存在于枚举的模型数据库中,但我无法确定该数据库中数据之间的正确 links。我也无法在网络搜索或 Microsoft 提供的任何文档中找到此信息。谁能提供这些值,或者告诉我在哪里可以找到它们?
SELECT bj.[STATUS] AS [bj_STATUS]
-- 1: Didn't run - what else?
-- 2: Canceled - what else?
-- 3: Error?
-- 4: Success?
-- 5: ?
-- 6: ?
-- 7: ?
-- 8: Withhold?
-- Waiting
-- Ended
-- Withhold
-- Executing
-- Ready
-- Finished
-- Error
-- Didn't run
,bj.[CAPTION] AS [bj_CAPTION]
,bjh.[STARTDATETIME] AS [bjh_STARTDATETIME]
,bjh.[ENDDATETIME] AS [bjh_ENDDATETIME]
,bjh.[BATCHCREATEDBY] AS [bjh_BATCHCREATEDBY]
,bjh.[CANCELEDBY] AS [bjh_CANCELEDBY]
,bg.[GROUP_] AS [bg_GROUP]
,bg.[DESCRIPTION] AS [bg_DESCRIPTION]
,bh.[SERVERID] AS [bh_SERVERID]
FROM [MicrosoftDynamicsAX].[dbo].[BATCHJOB] bj WITH(NOLOCK)
INNER JOIN [MicrosoftDynamicsAX].[dbo].[BATCHJOBHISTORY] bjh WITH(NOLOCK)
ON bjh.[BATCHJOBID] = bj.[RECID]
INNER JOIN [MicrosoftDynamicsAX].[dbo].[BATCH] b WITH(NOLOCK)
ON b.[BATCHJOBID] = bj.[RECID]
INNER JOIN [MicrosoftDynamicsAX].[dbo].[BATCHGROUP] bg WITH(NOLOCK)
ON bg.[GROUP_] = b.[GROUPID]
INNER JOIN [MicrosoftDynamicsAX].[dbo].[BATCHHISTORY] bh WITH(NOLOCK)
ON bh.[BATCHID] = b.[RECID]
AND bh.[BATCHJOBID] = bj.[RECID]
AND bh.[BATCHJOBHISTORYID] = bjh.[RECID]
WHERE bjh.[STARTDATETIME] > GETDATE() - 1 -- AND bj.[STATUS] NOT IN(1, 2, 4)
枚举是 BatchStatus
,它存储在模型存储数据库中,但我不认为枚举名称 and/or 值被存储。它最终代表一个整数。
下面是整数值 0-8 的基本枚举:
除以下例外情况外,文本标签与名称(即英文)相同。
- 0 - 保留(保留)
- 4 - 结束(已完成)
- 6 - 没有 运行 (NotRun)
您可能只使用 CASE 语句创建一个 SQL 存储过程,因为这些状态很少从基本代码中更改。
感谢@Alex Kwitny 提供的信息,我能够弄清楚如何从数据库中获取它。一旦我有了枚举的名称,我就能够在 ModelElement table 中找到它,然后 link 它返回到 ElementHandle 值上的 ModelElementData table 。 ModelElementData table 有一个 Properties 字段存储在 varbinary 中,可以将其分解成多个部分以读取主数据库中每个整数值的值。我花了一些时间来解析所有内容并将二进制文件转换为文本,但现在我可以通过将我的查询转换为可以从我的主查询中调用的函数来引用枚举值以防将来发生任何变化报告。
DECLARE @name AS VARCHAR(40) = 'BatchStatus'
, @value AS INT = 1
, @language AS VARCHAR(8) = 'en_us';
DECLARE @bin AS VARBINARY(MAX);
SET @bin =
(
SELECT TOP (1)
med.[Properties]
FROM [MicrosoftDynamicsAX_Model].[dbo].[ModelElement] me
INNER JOIN [MicrosoftDynamicsAX_Model].[dbo].[ModelElementData] med
ON med.[ElementHandle] = me.[ElementHandle]
WHERE me.[Name] = @name
AND me.[ElementType] = 40
ORDER BY med.[LayerId] DESC
);
DECLARE @pos AS INT;
DECLARE @flags AS INT;
DECLARE @count AS INT;
DECLARE @idx AS INT;
DECLARE @off AS INT;
DECLARE @result AS VARCHAR(255);
SET @pos = 3;
SET @off = CAST(SUBSTRING(@bin, @pos, 1) AS INT) - 1;
SET @pos = @pos + 1;
WHILE @off > 0
BEGIN
WHILE SUBSTRING(@bin, @pos, 2) <> 0x0000
SET @pos = @pos + 2;
SET @pos = @pos + 2;
SET @off = @off - 1;
END;
SET @flags = CAST(SUBSTRING(@bin, @pos, 3) AS INT);
SET @pos = @pos + 3;
IF @flags & 0x008000 = 0x008000
BEGIN
WHILE SUBSTRING(@bin, @pos, 2) <> 0x0000
SET @pos = @pos + 2;
SET @pos = @pos + 2;
END;
IF @flags & 0x000002 = 0x000002
SET @pos = @pos + 1;
SET @pos = @pos + 1;
SET @count = CAST(SUBSTRING(@bin, @pos, 1) AS INT);
IF @count > 0
BEGIN
SET @pos = @pos + 1;
IF @flags & 0x000200 = 0x000200
SET @idx = @value;
ELSE
BEGIN
SET @idx = 0;
SET @off = 2 + CAST(CAST(REVERSE(SUBSTRING(@bin, @pos, 2)) AS BINARY(2)) AS INT) * 2;
SET @off = @off + 2 + CAST(CAST(REVERSE(SUBSTRING(@bin, @pos + @off, 2)) AS BINARY(2)) AS INT) * 2;
WHILE CAST(SUBSTRING(@bin, @pos + @off + @idx, 1) AS INT) <> @value
AND @idx < @count
SET @idx = @idx + 1;
IF CAST(SUBSTRING(@bin, @pos + @off + @idx, 1) AS INT) <> @value
SET @idx = -1;
END;
IF @idx >= 0
BEGIN
SET @pos = @pos + 2;
WHILE 1 = 1
BEGIN
SET @off = 0;
SET @result = '';
WHILE SUBSTRING(@bin, @pos + @off, 2) <> 0x0000
BEGIN
SET @result = @result + CHAR(CAST(REVERSE(SUBSTRING(@bin, @pos + @off, 2)) AS BINARY(2)));
SET @off = @off + 2;
END;
SET @pos = @pos + @off + 2;
IF @idx <= 0
BREAK;
SET @idx = @idx - 1;
END;
END;
ELSE
SET @result = '~ENUM NOT FOUND~';
END;
ELSE
SET @result = '~ERROR~';
IF SUBSTRING(@result, 1, 1) = '@'
BEGIN
DECLARE @module AS VARCHAR(3);
DECLARE @label AS INT;
SET @module = SUBSTRING(@result, 2, 3);
SET @label = CAST(SUBSTRING(@result, 5, DATALENGTH(@result) - 4) AS INT);
SET @result =
(
SELECT TOP (1)
[Text]
FROM [MicrosoftDynamicsAX_Model].[dbo].[ModelElementLabel]
WHERE [LabelId] = @label
AND [Module] = @module
AND [Language] = @language
ORDER BY [LayerId] DESC
);
END;
SELECT @value AS [Id]
, @result AS [Status];