1C-Bitrix 25.700.0
Загрузка...
Поиск...
Не найдено
workflowpersister.php
См. документацию.
1<?
2require_once($_SERVER["DOCUMENT_ROOT"]."/bitrix/modules/bizproc/classes/general/workflowpersister.php");
3
5 extends CBPAllWorkflowPersister
6{
7 private static $instance;
8
9 private function __construct()
10 {
11 $this->serviceInstanceId = uniqid("", true);
12 $useGZipCompressionOption = \Bitrix\Main\Config\Option::get("bizproc", "use_gzip_compression", "");
13 if ($useGZipCompressionOption === "Y")
14 $this->useGZipCompression = true;
15 elseif ($useGZipCompressionOption === "N")
16 $this->useGZipCompression = false;
17 else
18 $this->useGZipCompression = function_exists("gzcompress");
19 }
20
21 public static function GetPersister()
22 {
23 if (!isset(self::$instance))
24 {
25 $c = __CLASS__;
26 self::$instance = new $c;
27 }
28
29 return self::$instance;
30 }
31
32 protected function RetrieveWorkflow($instanceId, $silent = false)
33 {
34 global $DB;
35
36 $queryCondition = $this->getLockerQueryCondition();
37
38 $buffer = "";
39 $dbResult = $DB->Query(
40 "SELECT WORKFLOW, IF (".$queryCondition.", 'Y', 'N') as UPDATEABLE ".
41 "FROM b_bp_workflow_instance ".
42 "WHERE ID = '".$DB->ForSql($instanceId)."' "
43 );
44 if ($arResult = $dbResult->Fetch())
45 {
46 if ($arResult["UPDATEABLE"] == "Y" && !$silent)
47 {
48 $DB->Query(
49 "UPDATE b_bp_workflow_instance SET ".
50 " OWNER_ID = '".$DB->ForSql($this->serviceInstanceId)."', ".
51 " OWNED_UNTIL = ".$DB->CharToDateFunction(date($GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATETIME), $this->GetOwnershipTimeout()))." ".
52 "WHERE ID = '".$DB->ForSql($instanceId)."'"
53 );
54 }
55 elseif (!$silent)
56 {
57 throw new Exception(GetMessage("BPCGWP_WF_LOCKED"));
58 }
59 $buffer = $arResult["WORKFLOW"];
60 }
61 else
62 {
63 throw new Exception(GetMessage("BPCGWP_INVALID_WF"));
64 }
65
66 return $buffer;
67 }
68
69 protected function InsertWorkflow($id, $buffer, $status, $bUnlocked)
70 {
71 global $DB;
72
73 $queryCondition = $this->getLockerQueryCondition();
74
76 {
77 $DB->Query(
78 "DELETE FROM b_bp_workflow_instance ".
79 "WHERE ID = '".$DB->ForSql($id)."'"
80 );
81 }
82 else
83 {
84 $dbResult = $DB->Query(
85 "SELECT ID, IF (".$queryCondition.", 'Y', 'N') as UPDATEABLE ".
86 "FROM b_bp_workflow_instance ".
87 "WHERE ID = '".$DB->ForSql($id)."' "
88 );
89 if ($arResult = $dbResult->Fetch())
90 {
91 if ($arResult["UPDATEABLE"] == "Y")
92 {
93 $DB->Query(
94 "UPDATE b_bp_workflow_instance SET ".
95 " WORKFLOW = '".$DB->ForSql($buffer)."', ".
96 " STATUS = ".intval($status).", ".
97 " MODIFIED = ".$DB->CurrentTimeFunction().", ".
98 " OWNER_ID = ".($bUnlocked ? "NULL" : "'".$DB->ForSql($this->serviceInstanceId)."'").", ".
99 " OWNED_UNTIL = ".($bUnlocked ? "NULL" : $DB->CharToDateFunction(date($GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATETIME), $this->GetOwnershipTimeout())))." ".
100 "WHERE ID = '".$DB->ForSql($id)."' "
101 );
102 }
103 else
104 {
105 throw new Exception(GetMessage('BPCGWP_WF_LOCKED'));
106 }
107 }
108 else
109 {
110 $DB->Query(
111 "INSERT INTO b_bp_workflow_instance (ID, WORKFLOW, STATUS, MODIFIED, OWNER_ID, OWNED_UNTIL) ".
112 "VALUES ('".$DB->ForSql($id)."', '".$DB->ForSql($buffer)."', ".intval($status).", ".$DB->CurrentTimeFunction().", ".($bUnlocked ? "NULL" : "'".$DB->ForSql($this->serviceInstanceId)."'").", ".($bUnlocked ? "NULL" : $DB->CharToDateFunction(date($GLOBALS["DB"]->DateFormatToPHP(FORMAT_DATETIME), $this->GetOwnershipTimeout()))).")"
113 );
114 }
115 }
116 }
117
118}
119?>
$arResult
Определения generate_coupon.php:16
RetrieveWorkflow($instanceId, $silent=false)
Определения workflowpersister.php:32
static GetPersister()
Определения workflowpersister.php:21
getLockerQueryCondition()
Определения workflowpersister.php:312
InsertWorkflow($id, $buffer, $status, $bUnlocked)
Определения workflowpersister.php:69
const Completed
Определения constants.php:83
const Terminated
Определения constants.php:85
if(!defined("ADMIN_AJAX_MODE") &&(($_REQUEST["mode"] ?? '') !='excel')) $buffer
Определения epilog_admin_after.php:40
$_SERVER["DOCUMENT_ROOT"]
Определения cron_frame.php:9
global $DB
Определения cron_frame.php:29
if(preg_match('/^ else[a-z0-9_]{2}$/i', $siteID)===1)
Определения cron_frame.php:23
const FORMAT_DATETIME
Определения include.php:64
$status
Определения session.php:10
GetMessage($name, $aReplace=null)
Определения tools.php:3397
return false
Определения prolog_main_admin.php:185
if( $daysToExpire >=0 &&$daysToExpire< 60 elseif)( $daysToExpire< 0)
Определения prolog_main_admin.php:393
$GLOBALS['_____370096793']
Определения update_client.php:1
$dbResult
Определения updtr957.php:3