async bindFormWorkItem(
conn: SQLServer,
controlTransaction: boolean,
formId: number,
workItemId: number,
formClassificationId: number,
recordUserId: number
) {
try {
if (controlTransaction) {
await conn.beginTransaction();
}
const previousJsonDescription = await this.selectOne(
conn,
{
workItemId,
formId,
}
);
const data: any = {
formId: formId,
workItemId: workItemId,
formClassificationId: formClassificationId,
recordUserId: recordUserId,
creationUserId: recordUserId
};
const newJsonDescription = await this.maintain(
conn,
data,
rtFullRecord
);
/*------------------------------------------LOGS-----------------------------------------*/
const logs: any = {
formId: formId,
creationUserId: recordUserId,
previousJsonDescription: null,
newJsonDescription
};
if (!previousJsonDescription && newJsonDescription) {
logs.logTypeId = FormLogType.ChangeFormClassificationWorkItem;
} else if (
(previousJsonDescription && newJsonDescription) &&
(JSON.stringify(previousJsonDescription) !== JSON.stringify(newJsonDescription))
) {
logs.logTypeId = FormLogType.CreateFormWorkItem;
}
if (logs.logTypeId) {
await new ROceFormsLogs().insert(
conn,
logs,
rtNone
);
}
if (controlTransaction) {
await conn.commitTransaction();
}
return newJsonDescription;
} catch (e) {
if (controlTransaction) {
await conn.rollbackTransaction();
}
throw e;
}
}