Last active
June 9, 2021 11:20
-
-
Save Feiron/d644a14a239fc26afbfaabda29b9f7ee to your computer and use it in GitHub Desktop.
Revisions
-
Feiron revised this gist
Jun 9, 2021 . No changes.There are no files selected for viewing
-
Feiron revised this gist
Mar 6, 2019 . 1 changed file with 35 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,35 @@ <? require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/header.php"); $APPLICATION->SetTitle("Тестирование"); CModule::IncludeModule('gpw.testing'); CModule::IncludeModule('im'); CModule::IncludeModule('bizproc'); $iTemplateID = XXX; $ID = 15949; $arDocumentID = [ "crm", "CCrmDocumentDeal", "DEAL_" . $ID ]; $arFields = [ //'RATE' => 6, //'UF_CRM_EMAIL' => ['n0' => '[email protected]'] ]; try { GPW\Testing\Tests\Bitrix\BP::Run($iTemplateID, $arDocumentID, $arFields, ['STORE' => false]); } catch (\Exception $e) { ShowError($e->getMessage()); if(method_exists($e, 'getParameter')){ echo '<pre>'; var_dump($e->getParameter()); echo '</pre>'; } } require($_SERVER["DOCUMENT_ROOT"] . "/bitrix/footer.php"); ?> -
Feiron revised this gist
Mar 6, 2019 . 1 changed file with 68 additions and 40 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -13,6 +13,8 @@ namespace GPW\Testing\Tests\Bitrix; use Bitrix\Main\ArgumentException; if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die(); class BP @@ -30,9 +32,10 @@ public static function Run($iTemplateID, $arDocumentID, $arFields, $arParams) try { $wid = self::Start($iTemplateID, $arDocumentID, $arFields); $strLog = self::GetTrackingByWID($wid); if (!$arParams['SILENT']) { echo $strLog; } if (!$arParams['STORE']) { self::Delete($wid); @@ -63,18 +66,43 @@ public static function Delete($WID, $bTerminate = false, $arDocumentID = null) */ public static function Start($iTemplateID, $arDocumentID, $arFields = []) { $dbWorkflowTemplate = \CBPWorkflowTemplateLoader::GetList( array(), array( "ID" => $iTemplateID, ), false, false, array("ID", "NAME", "DESCRIPTION", "MODIFIED", "USER_ID", "PARAMETERS") ); if ($dbWorkflowTemplate->SelectedRowsCount() < 0) { throw new \Exception('TEMPLATE_NOT_FOUND'); } $arWorkflowTemplate = $dbWorkflowTemplate->Fetch(); $arWorkflowParameters = \CBPWorkflowTemplateLoader::CheckWorkflowParameters( $arWorkflowTemplate["PARAMETERS"], $arFields, $arDocumentID, $arErrors ); if (empty($arErrors)) { $wid = \CBPDocument::StartWorkflow( $iTemplateID, $arDocumentID, $arWorkflowParameters, $arErrors ); if (empty($arErrors)) { return $wid; } throw new \Exception('INVALID_PARAMETERS', $arErrors); } throw new ArgumentException('INVALID_PARAMETERS', $arErrors); } /** @@ -99,39 +127,39 @@ public static function GetTrackingByWID($WID) ob_start(); ?> <div><?= $arTask['ID'] ?></div> <div><?= $arTask['STARTED'] ?></div> <div><?= $arTask['TEMPLATE_DESCRIPTION'] ?></div> <div><?= $arTask['STATE_NAME'] ?><br><?= $arTask['STATE_TITLE'] ?></div> <table style="width: 700px;"> <thead> <tr> <th>Тип</th> <th>Дата</th> <th>Имя</th> <th>Статус</th> <th>Текст</th> </tr> </thead> <tbody> <? while ($arTrack = $dbTrack->Fetch()) { ?> <tr> <td><?= $arTrack['TYPE'] ?></td> <td><?= $arTrack['MODIFIED'] ?></td> <td><?= $arTrack['ACTION_NAME'] ?><br><?= $arTrack['ACTION_TITLE'] ?></td> <td><?= $arTrack['EXECUTION_STATUS'] ?></td> <td> <textarea readonly="" name="ACTION_NOTE" id="" cols="60" rows="4"><?= $arTrack['ACTION_NOTE'] ?></textarea> </td> </tr> <? } ?> </tbody> </table> <? return (string)ob_get_clean(); -
Feiron renamed this gist
Mar 6, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Feiron revised this gist
Mar 6, 2019 . 1 changed file with 6 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,6 @@ <?php $this->WriteToTrackingService($strAddInfo); $this->SetVariable("BB_ADDINFO", $strAddInfo); $this->GetVariable("BB_ADDINFO"); $RootActivity = $this->GetRootActivity(); $iUserID = $RootActivity->RESPONSIBLE; -
Feiron renamed this gist
Mar 5, 2019 . 1 changed file with 0 additions and 0 deletions.There are no files selected for viewing
File renamed without changes. -
Feiron revised this gist
Mar 5, 2019 . 1 changed file with 33 additions and 33 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -99,39 +99,39 @@ public static function GetTrackingByWID($WID) ob_start(); ?> <div><?= $arTask['ID'] ?></div> <div><?= $arTask['STARTED'] ?></div> <div><?= $arTask['TEMPLATE_DESCRIPTION'] ?></div> <div><?= $arTask['STATE_NAME'] ?><br><?= $arTask['STATE_TITLE'] ?></div> <table style="width: 700px;"> <thead> <tr> <th>Тип</th> <th>Дата</th> <th>Имя</th> <th>Статус</th> <th>Текст</th> </tr> </thead> <tbody> <? while ($arTrack = $dbTrack->Fetch()) { ?> <tr> <td><?= $arTrack['TYPE'] ?></td> <td><?= $arTrack['MODIFIED'] ?></td> <td><?= $arTrack['ACTION_NAME'] ?><br><?= $arTrack['ACTION_TITLE'] ?></td> <td><?= $arTrack['EXECUTION_STATUS'] ?></td> <td> <textarea readonly="" name="ACTION_NOTE" id="" cols="60" rows="4"><?= $arTrack['ACTION_NOTE'] ?></textarea> </td> </tr> <? } ?> </tbody> </table> <? return (string)ob_get_clean(); -
Feiron revised this gist
Mar 5, 2019 . 1 changed file with 2 additions and 3 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -30,10 +30,9 @@ public static function Run($iTemplateID, $arDocumentID, $arFields, $arParams) try { $wid = self::Start($iTemplateID, $arDocumentID, $arFields); if (!$arParams['SILENT']) { echo self::GetTrackingByWID($wid); } if (!$arParams['STORE']) { self::Delete($wid); -
Feiron created this gist
Mar 5, 2019 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,143 @@ <?php /** * User: Feiron * Date: 04.06.2018 * Time: 15:37 * * @var array $arParams * @var array $arResult * @global CMain $APPLICATION * * */ namespace GPW\Testing\Tests\Bitrix; if (!defined("B_PROLOG_INCLUDED") || B_PROLOG_INCLUDED !== true) die(); class BP { /** * @param $iTemplateID * @param $arDocumentID * @param $arFields * @param [] $arParams SILENT = Нет вывода трейса, STORE - Оставить результат * * @throws \Exception */ public static function Run($iTemplateID, $arDocumentID, $arFields, $arParams) { try { $wid = self::Start($iTemplateID, $arDocumentID, $arFields); $strLog = self::GetTrackingByWID($wid); if (!$arParams['SILENT']) { echo $strLog; } if (!$arParams['STORE']) { self::Delete($wid); } } catch (\Exception $e) { throw $e; } } /** * @param $WID * @param bool $bTerminate Останавливает, если нельзя дает ошибку * @param null $arDocumentID Необязательно */ public static function Delete($WID, $bTerminate = false, $arDocumentID = null) { \CBPDocument::killWorkflow($WID, $bTerminate, $arDocumentID); } /** * @param $iTemplateID * @param $arDocumentID ["crm", "CCrmDocumentDeal", "DEAL_11"] * @param $arFields * * @return string * @throws \Exception */ public static function Start($iTemplateID, $arDocumentID, $arFields = []) { $wid = \CBPDocument::StartWorkflow( $iTemplateID, $arDocumentID, $arFields, $arErrors ); if (empty($arErrors)) { return $wid; } throw new \Exception($arErrors); } /** * @param $WID * * @return string * @throws \Exception */ public static function GetTrackingByWID($WID) { $dbTrack = \CBPTrackingService::GetList( array("ID" => "desc"), array( "WORKFLOW_ID" => $WID, ) ); if ($dbTrack->SelectedRowsCount()) { $arTask = \CBPStateService::GetWorkflowState($WID); ob_start(); ?> <div><?= $arTask['ID'] ?></div> <div><?= $arTask['STARTED'] ?></div> <div><?= $arTask['TEMPLATE_DESCRIPTION'] ?></div> <div><?= $arTask['STATE_NAME'] ?><br><?= $arTask['STATE_TITLE'] ?></div> <table style="width: 700px;"> <thead> <tr> <th>Тип</th> <th>Дата</th> <th>Имя</th> <th>Статус</th> <th>Текст</th> </tr> </thead> <tbody> <? while ($arTrack = $dbTrack->Fetch()) { ?> <tr> <td><?= $arTrack['TYPE'] ?></td> <td><?= $arTrack['MODIFIED'] ?></td> <td><?= $arTrack['ACTION_NAME'] ?><br><?= $arTrack['ACTION_TITLE'] ?></td> <td><?= $arTrack['EXECUTION_STATUS'] ?></td> <td> <textarea readonly="" name="ACTION_NOTE" id="" cols="60" rows="4"><?= $arTrack['ACTION_NOTE'] ?></textarea> </td> </tr> <? } ?> </tbody> </table> <? return (string)ob_get_clean(); } else { throw new \Exception('CANT_GET_TRACE: ' . $WID); } } }