logging, new unique ID and improve start case
This commit is contained in:
@@ -42,16 +42,16 @@ return [
|
||||
|
||||
'single' => [
|
||||
'driver' => 'single',
|
||||
'path' => storage_path('logs/processmaker.log'),
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => 'debug',
|
||||
],
|
||||
|
||||
'daily' => [
|
||||
'driver' => 'daily',
|
||||
'tap' => [App\Logging\CustomizeFormatter::class],
|
||||
'path' => storage_path('logs/processmaker.log'),
|
||||
'path' => storage_path('logs/laravel.log'),
|
||||
'level' => 'debug',
|
||||
'days' => $app->make('config')->get('app.log_max_files', 60),
|
||||
'days' => $app->make('config')->get('app.log_max_files', 30),
|
||||
],
|
||||
|
||||
'audit' => [
|
||||
@@ -59,7 +59,7 @@ return [
|
||||
'tap' => [App\Logging\CustomizeFormatter::class],
|
||||
'path' => storage_path('logs/audit.log'),
|
||||
'level' => 'debug',
|
||||
'days' => $app->make('config')->get('app.log_max_files', 60),
|
||||
'days' => $app->make('config')->get('app.log_max_files', 30),
|
||||
],
|
||||
|
||||
'taskScheduler' => [
|
||||
@@ -67,25 +67,7 @@ return [
|
||||
'tap' => [App\Logging\CustomizeFormatter::class],
|
||||
'path' => storage_path('logs/taskScheduler.log'),
|
||||
'level' => 'debug',
|
||||
'days' => $app->make('config')->get('app.log_max_files', 60),
|
||||
],
|
||||
|
||||
'slack' => [
|
||||
'driver' => 'slack',
|
||||
'url' => env('LOG_SLACK_WEBHOOK_URL'),
|
||||
'username' => 'Laravel Log',
|
||||
'emoji' => ':boom:',
|
||||
'level' => 'critical',
|
||||
],
|
||||
|
||||
'papertrail' => [
|
||||
'driver' => 'monolog',
|
||||
'level' => 'debug',
|
||||
'handler' => SyslogUdpHandler::class,
|
||||
'handler_with' => [
|
||||
'host' => env('PAPERTRAIL_URL'),
|
||||
'port' => env('PAPERTRAIL_PORT'),
|
||||
],
|
||||
'days' => $app->make('config')->get('app.log_max_files', 30),
|
||||
],
|
||||
|
||||
'stderr' => [
|
||||
|
||||
@@ -2858,6 +2858,31 @@ class G
|
||||
//return strtoupper(substr(uniqid(rand(0, 9), false),0,14));
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate random number
|
||||
*
|
||||
* @author Fernando Ontiveros Lira <fernando@colosa.com>
|
||||
* @access public
|
||||
* @return int
|
||||
*/
|
||||
public static function generateUid($prefix = '')
|
||||
{
|
||||
// Ensure the prefix is exactly 3 alphabetical characters if not return default prefix
|
||||
if (strlen($prefix) !== 3 || !ctype_alpha($prefix)) {
|
||||
$prefix = "abc";
|
||||
}
|
||||
|
||||
// Generate a unique ID based on the current time in microseconds
|
||||
$uniqueId = uniqid('', true);
|
||||
|
||||
// Remove the prefix from the unique ID and ensure it's 29 characters long
|
||||
$uniqueId = date('YmdH') . str_replace('.', '', $uniqueId); // Remove any dots
|
||||
$uniqueId = substr($uniqueId, -29); // Trim to 29 characters
|
||||
|
||||
// Combine the prefix with the unique ID
|
||||
return strtolower($prefix) . $uniqueId; // Convert prefix to uppercase
|
||||
}
|
||||
|
||||
/**
|
||||
* Generate a numeric or alphanumeric code
|
||||
*
|
||||
@@ -2873,19 +2898,23 @@ class G
|
||||
if (($sType != 'NUMERIC') && ($sType != 'ALPHA') && ($sType != 'ALPHANUMERIC')) {
|
||||
$sType = 'NUMERIC';
|
||||
}
|
||||
$aValidCharacters = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', 'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N', 'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z');
|
||||
// Define a character set excluding visually similar characters
|
||||
$aValidCharacters = array(
|
||||
'2', '3', '4', '5', '6', '7', '8', '9', // Numbers excluding 0 and 1
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'J', 'K', 'M', 'N', 'P', 'Q', 'R', 'T', 'U', 'V', 'W', 'X', 'Y' // Uppercase letters excluding O, I, L, S, Z
|
||||
);
|
||||
switch ($sType) {
|
||||
case 'NUMERIC':
|
||||
$iMin = 0;
|
||||
$iMax = 9;
|
||||
$iMax = 7;
|
||||
break;
|
||||
case 'ALPHA':
|
||||
$iMin = 10;
|
||||
$iMax = 35;
|
||||
$iMin = 8;
|
||||
$iMax = 28;
|
||||
break;
|
||||
case 'ALPHANUMERIC':
|
||||
$iMin = 0;
|
||||
$iMax = 35;
|
||||
$iMax = 28;
|
||||
break;
|
||||
}
|
||||
$sCode = '';
|
||||
|
||||
@@ -2163,10 +2163,11 @@ class Cases
|
||||
$event = new Event();
|
||||
$event->createAppEvents($proUid, $appUid, $delIndex, $tasUid);
|
||||
|
||||
//todo: remove Solr
|
||||
// Update solr
|
||||
if ($this->appSolr != null) {
|
||||
$this->appSolr->updateApplicationSearchIndex($appUid);
|
||||
}
|
||||
//if ($this->appSolr != null) {
|
||||
// $this->appSolr->updateApplicationSearchIndex($appUid);
|
||||
//}
|
||||
|
||||
$fields['TAS_UID'] = $tasUid;
|
||||
$fields['USR_UID'] = $usrUid;
|
||||
@@ -2197,7 +2198,7 @@ class Cases
|
||||
|
||||
// Log
|
||||
$message = 'Create case';
|
||||
$context = $data = [
|
||||
$context = [
|
||||
"appUid" => $appUid,
|
||||
"usrUid" => $usrUid,
|
||||
"tasUid" => $tasUid,
|
||||
@@ -2207,14 +2208,17 @@ class Cases
|
||||
"appInitDate" => $fields['APP_INIT_DATE']
|
||||
];
|
||||
Log::channel(':CreateCase')->info($message, Bootstrap::context($context));
|
||||
|
||||
// Call plugin
|
||||
if (class_exists('folderData')) {
|
||||
$folderData = new folderData($proUid, $proFields['PRO_TITLE'], $appUid, '', $usrUid);
|
||||
$oPluginRegistry = PluginRegistry::loadSingleton();
|
||||
$oPluginRegistry->executeTriggers(PM_CREATE_CASE, $folderData);
|
||||
}
|
||||
$this->getExecuteTriggerProcess($appUid, 'CREATE', false);
|
||||
//end plugin
|
||||
|
||||
//Exceute trigger if any configured for this create case
|
||||
$this->getExecuteTriggerProcess($appUid, 'CREATE', false);
|
||||
return [
|
||||
'APPLICATION' => $appUid,
|
||||
'INDEX' => $delIndex,
|
||||
|
||||
@@ -181,22 +181,29 @@ class Application extends BaseApplication
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates an Application
|
||||
* Creates a new Application entry in the database.
|
||||
*
|
||||
* @param string $processUid
|
||||
* @param string $userUid
|
||||
* @param string $sequenceType
|
||||
* @throws PropelException
|
||||
* @throws Exception
|
||||
* @return string
|
||||
*/
|
||||
* This method initializes a new application with default values and saves it to the database.
|
||||
* It generates a unique application ID, sets various properties related to the application,
|
||||
* and handles the creation process within a database transaction.
|
||||
*
|
||||
* @param string $processUid The unique identifier for the process associated with the application.
|
||||
* @param string $userUid The unique identifier for the user initiating the application.
|
||||
* @param string $sequenceType The type of sequence to be used for generating the application number NORMAL or WEBENTRY.
|
||||
*
|
||||
* @throws PropelException If the application cannot be created due to validation failures or database errors.
|
||||
* @throws Exception If an unexpected error occurs during the application creation process.
|
||||
*
|
||||
* @return string Returns the unique identifier of the newly created application.
|
||||
*/
|
||||
|
||||
public function create($processUid, $userUid, $sequenceType)
|
||||
{
|
||||
$con = Propel::getConnection('workflow');
|
||||
|
||||
try {
|
||||
// Fill the default values for new application row
|
||||
$this->setAppUid(G::generateUniqueID());
|
||||
$this->setAppUid(G::generateUid('app'));
|
||||
$this->setAppParent('');
|
||||
$this->setAppStatus('DRAFT');
|
||||
$this->setAppStatusId(1);
|
||||
|
||||
@@ -35,6 +35,7 @@ if (! function_exists( $_REQUEST['action'] ) || !G::isUserFunction($_REQUEST['ac
|
||||
die();
|
||||
}
|
||||
|
||||
|
||||
$functionName = $_REQUEST['action'];
|
||||
$functionParams = isset( $_REQUEST['params'] ) ? $_REQUEST['params'] : array ();
|
||||
|
||||
@@ -209,7 +210,6 @@ function startCase()
|
||||
try {
|
||||
// Initializing variables
|
||||
$sequenceType = (!empty($_REQUEST['actionFrom']) && $_REQUEST['actionFrom'] === 'webEntry') ? AppSequence::APP_TYPE_WEB_ENTRY : AppSequence::APP_TYPE_NORMAL;
|
||||
|
||||
// Update CONTENT table
|
||||
lookinginforContentProcess($_POST['processId']);
|
||||
|
||||
@@ -237,11 +237,13 @@ function startCase()
|
||||
$newCase['status'] = 'success';
|
||||
|
||||
// Print JSON response
|
||||
print (G::json_encode($newCase));
|
||||
ob_end_clean();
|
||||
header('Content-Type: application/json');
|
||||
print (json_encode($newCase));
|
||||
} catch (Exception $e) {
|
||||
$newCase['status'] = 'failure';
|
||||
$newCase['message'] = $e->getMessage();
|
||||
print_r(G::json_encode($newCase));
|
||||
print_r(json_encode($newCase));
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user