This commit is contained in:
Manish Verma
2016-12-13 18:18:25 +05:30
parent fc98add11c
commit 2d8e640e9b
2314 changed files with 97798 additions and 75664 deletions

View File

@@ -2,11 +2,11 @@
namespace App\Console\Commands;
use App\Http\Controllers\Client\helpdesk\UnAuthController;
use Illuminate\Console\Command;
use App\Http\Controllers\Client\helpdesk\UnAuthController;
class CloseWork extends Command {
class CloseWork extends Command
{
/**
* The name and signature of the console command.
*
@@ -26,8 +26,7 @@ class CloseWork extends Command
*
* @return void
*/
public function __construct()
{
public function __construct() {
parent::__construct();
}
@@ -36,15 +35,15 @@ class CloseWork extends Command
*
* @return mixed
*/
public function handle()
{
public function handle() {
if (env('DB_INSTALL') == 1) {
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
$controller = new UnAuthController($PhpMailController);
$controller->autoCloseTickets();
loging('ticket-close-workflow', 'Close ticket workflow executed', 'info');
loging('ticket-close-workflow', 'Close ticket workflow executed','info');
//\Log::info('Close ticket workflow executed');
$this->info('Close ticket workflow executed');
}
}
}

View File

@@ -2,13 +2,13 @@
namespace App\Console\Commands;
use Illuminate\Console\Command;
use App\Http\Controllers\Agent\helpdesk\NotificationController;
use App\Http\Controllers\Common\PhpMailController;
use Exception;
use Illuminate\Console\Command;
class SendReport extends Command
{
class SendReport extends Command {
/**
* The name and signature of the console command.
*
@@ -28,8 +28,8 @@ class SendReport extends Command
*
* @return void
*/
public function __construct()
{
public function __construct() {
parent::__construct();
}
@@ -38,22 +38,21 @@ class SendReport extends Command
*
* @return mixed
*/
public function handle()
{
public function handle() {
try {
if (env('DB_INSTALL') == 1) {
$mail = new PhpMailController();
$mail->setQueue();
$this_report = new NotificationController($mail);
$report = $this_report->send_notification();
if ($report !== 0) {
loging('sending-mail-report', 'Report has send', 'info');
loging('sending-mail-report', 'Report has send','info');
//\Log::info("Report has send");
$this->info('Report has send');
$this->info("Report has send");
} else {
loging('sending-mail-report', 'Nothing to send', 'info');
$this->info('Nothing to send');
loging('sending-mail-report', 'Nothing to send','info');
$this->info("Nothing to send");
}
}
} catch (Exception $ex) {
@@ -61,4 +60,5 @@ class SendReport extends Command
$this->error($ex->getMessage());
}
}
}

View File

@@ -2,13 +2,13 @@
namespace App\Console\Commands;
use App\Http\Controllers\Agent\helpdesk\MailController;
use App\Http\Controllers\Agent\helpdesk\TicketWorkflowController;
use Event;
use Illuminate\Console\Command;
use App\Http\Controllers\Agent\helpdesk\MailController;
use Event;
use App\Http\Controllers\Agent\helpdesk\TicketWorkflowController;
class TicketFetch extends Command {
class TicketFetch extends Command
{
/**
* The name and signature of the console command.
*
@@ -28,8 +28,7 @@ class TicketFetch extends Command
*
* @return void
*/
public function __construct()
{
public function __construct() {
parent::__construct();
}
@@ -38,9 +37,9 @@ class TicketFetch extends Command
*
* @return mixed
*/
public function handle()
{
public function handle() {
if (env('DB_INSTALL') == 1) {
$controller = $this->mailController();
$emails = new \App\Model\helpdesk\Email\Emails();
$settings_email = new \App\Model\helpdesk\Settings\Email();
@@ -48,20 +47,19 @@ class TicketFetch extends Command
$ticket = new \App\Model\helpdesk\Settings\Ticket();
$controller->readmails($emails, $settings_email, $system, $ticket);
Event::fire('ticket.fetch', ['event' => '']);
loging('fetching-ticket', 'Ticket has read', 'info');
loging('fetching-ticket', 'Ticket has read','info');
//\Log::info('Ticket has read');
$this->info('Ticket has read');
}
}
public function mailController()
{
public function mailController() {
$PhpMailController = new \App\Http\Controllers\Common\PhpMailController();
$NotificationController = new \App\Http\Controllers\Common\NotificationController();
$ticket = new \App\Http\Controllers\Agent\helpdesk\TicketController($PhpMailController, $NotificationController);
$work = new TicketWorkflowController($ticket);
$controller = new MailController($work);
return $controller;
}
}

View File

@@ -2,12 +2,12 @@
namespace App\Console;
use App\Model\MailJob\Condition;
use Illuminate\Console\Scheduling\Schedule;
use Illuminate\Foundation\Console\Kernel as ConsoleKernel;
use App\Model\MailJob\Condition;
class Kernel extends ConsoleKernel {
class Kernel extends ConsoleKernel
{
/**
* The Artisan commands provided by your application.
*
@@ -27,91 +27,85 @@ class Kernel extends ConsoleKernel
*
* @return void
*/
protected function schedule(Schedule $schedule)
{
protected function schedule(Schedule $schedule) {
if (env('DB_INSTALL') == 1) {
$queue = $this->getCurrentQueue();
$schedule->command('queue:listen '.$queue, ['--tries' => 1])->everyMinute()->withoutOverlapping();
$schedule->command('queue:listen '.$queue, ['--tries' => 1])->everyMinute();
$this->execute($schedule, 'fetching');
$this->execute($schedule, 'notification');
$this->execute($schedule, 'work');
loging('cron', 'executed successfully', 'info');
}
}
public function execute($schedule, $task)
{
public function execute($schedule, $task) {
$condition = new Condition();
$command = $condition->getConditionValue($task);
switch ($task) {
case 'fetching':
case "fetching":
$this->getCondition($schedule->command('ticket:fetch'), $command);
break;
case 'notification':
case "notification":
$this->getCondition($schedule->command('report:send'), $command);
break;
case 'work':
case "work":
$this->getCondition($schedule->command('ticket:close'), $command);
break;
}
}
public function getCondition($schedule, $command)
{
public function getCondition($schedule, $command) {
$condition = $command['condition'];
$at = $command['at'];
switch ($condition) {
case 'everyMinute':
case "everyMinute":
$schedule->everyMinute()->withoutOverlapping();
break;
case 'everyFiveMinutes':
case "everyFiveMinutes":
$schedule->everyFiveMinutes()->withoutOverlapping();
break;
case 'everyTenMinutes':
case "everyTenMinutes":
$schedule->everyTenMinutes()->withoutOverlapping();
break;
case 'everyThirtyMinutes':
case "everyThirtyMinutes":
$schedule->everyThirtyMinutes()->withoutOverlapping();
break;
case 'hourly':
case "hourly":
$schedule->hourly()->withoutOverlapping();
break;
case 'daily':
case "daily":
$schedule->daily()->withoutOverlapping();
break;
case 'dailyAt':
case "dailyAt":
$this->getConditionWithOption($schedule, $condition, $at);
break;
case 'weekly':
case "weekly":
$schedule->weekly()->withoutOverlapping();
break;
case 'monthly':
case "monthly":
$schedule->monthly()->withoutOverlapping();
break;
case 'yearly':
case "yearly":
$schedule->yearly()->withoutOverlapping();
break;
}
}
public function getConditionWithOption($schedule, $command, $at)
{
public function getConditionWithOption($schedule, $command, $at) {
switch ($command) {
case 'dailyAt':
case "dailyAt":
$schedule->dailyAt($at)->withoutOverlapping();
break;
}
}
public function getCurrentQueue()
{
public function getCurrentQueue() {
$queue = 'database';
$services = new \App\Model\MailJob\QueueService();
$current = $services->where('status', 1)->first();
if ($current) {
$queue = $current->short_name;
}
return $queue;
}
}