301 lines
7.8 KiB
C#
301 lines
7.8 KiB
C#
using HRM.BO;
|
|
using System.Collections.Generic;
|
|
using System.Linq;
|
|
using System.Net;
|
|
using System.Net.Http;
|
|
using HRM.DA;
|
|
using Microsoft.AspNetCore.Mvc;
|
|
using Microsoft.Extensions.Configuration;
|
|
using Microsoft.AspNetCore.Http;
|
|
using Microsoft.AspNetCore.Authorization;
|
|
using System.Data;
|
|
using System;
|
|
using HRM.UI.Components;
|
|
using HRM.UI.MODELS;
|
|
using Microsoft.Extensions.Options;
|
|
using HRM.BO.Configuration;
|
|
|
|
namespace HRM.UI.Controllers
|
|
{
|
|
[ApiController]
|
|
[Route("api/Mobile/WorkFlow")]
|
|
[Authorize]
|
|
public class WorkFlowController : ControllerBase
|
|
{
|
|
private readonly IEmployeeService _employeeService;
|
|
private readonly IWFMovementTranService _WFMovementTranService;
|
|
private readonly IDailyAttnProcessService _DailyAttnProcessService;
|
|
private readonly ILeaveEntryService _leaveEntryService;
|
|
public WorkFlowController(
|
|
IEmployeeService employeeService,
|
|
IWFMovementTranService wFMovementTranService,
|
|
IDailyAttnProcessService dailyAttnProcessService,
|
|
ILeaveEntryService leaveEntryService)
|
|
{
|
|
this._employeeService = employeeService;
|
|
this._WFMovementTranService = wFMovementTranService;
|
|
this._DailyAttnProcessService = dailyAttnProcessService;
|
|
this._leaveEntryService = leaveEntryService;
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("GetJobCount")]
|
|
|
|
public ActionResult GetJobCount(int EmpID)
|
|
{
|
|
int ans;
|
|
try
|
|
{
|
|
ans = _WFMovementTranService.ReceivedItemsCount(EmpID);
|
|
|
|
int total = _DailyAttnProcessService.GetAttnDataByWFStatusCountForMobile(EmpID, EnumWFAttnStatus.EmpSubmitted);
|
|
ans = ans + total;
|
|
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(ans);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("GetPendingJobNotificationCount")]
|
|
public ActionResult GetPendingJobNotificationCount(int EmpID)
|
|
{
|
|
string countString = null;
|
|
|
|
try
|
|
{
|
|
//ans = _WFMovementTranService.ReceivedItemsCount(EmpID);
|
|
|
|
//int total = _DailyAttnProcessService.GetAttnDataByWFStatusCountForMobile(EmpID, EnumWFAttnStatus.EmpSubmitted);
|
|
//ans = ans + total;
|
|
|
|
countString = _WFMovementTranService.GetPendingJobNotificationCount(EmpID);
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(countString);
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("GetJobs")]
|
|
|
|
public ActionResult GetJobs(int EmpID)
|
|
{
|
|
try
|
|
{
|
|
List<PendingJobTModel> oWFModels = new List<PendingJobTModel>();
|
|
List<WFMovementTran> opjobs = _WFMovementTranService.ReceivedItems(EmpID);
|
|
opjobs.OrderByDescending(x => x.Senttime);
|
|
|
|
return Ok(opjobs.ConvertPendingJobTModels());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("GetPendingJobsMobile")]
|
|
|
|
public ActionResult GetPendingJobsMobile(int EmpID)
|
|
{
|
|
try
|
|
{
|
|
//List<PendingJobTModel> oWFModels = new List<PendingJobTModel>();
|
|
//List<WFMovementTran> opjobs = _WFMovementTranService.PendingJobsMobile(EmpID);
|
|
DataTable opjobs = _WFMovementTranService.PendingJobsMobile(EmpID); ;
|
|
|
|
|
|
return Ok(opjobs.ConvertPendingJobTModels());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
}
|
|
|
|
[HttpGet]
|
|
[Route("GetJob")]
|
|
|
|
public ActionResult GetJob(int EmpID, int TranID)
|
|
{
|
|
try
|
|
{
|
|
WFMovementTran otran = _WFMovementTranService.Get(TranID);
|
|
LeaveEntry le = _leaveEntryService.Get(otran.ObjectID);
|
|
return Ok(otran.ConvertPendingJobWithDetailTModel(EmpID, le));
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
}
|
|
|
|
//[HttpGet]
|
|
//[Route("GetNotificationCount")]
|
|
//
|
|
//public ActionResult GetNotificationCount(int EmpID)
|
|
//{
|
|
// List<NotificationTModel> oWFModels = new();
|
|
// try
|
|
// {
|
|
// List<WFMovementTask> onotifications = _WFMovementTranService.GetNotificationItems(EmpID);
|
|
|
|
// return Ok(onotifications.Count);
|
|
// }
|
|
// catch (Exception ex)
|
|
// {
|
|
// return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
// }
|
|
//}
|
|
|
|
[HttpGet]
|
|
[Route("GetNotificationCount")]
|
|
|
|
public ActionResult GetNotificationItemCount(int employeeId)
|
|
{
|
|
int ncount;
|
|
try
|
|
{
|
|
ncount = _WFMovementTranService.GetNotificationItemCount(employeeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(ncount);
|
|
}
|
|
|
|
|
|
[HttpGet]
|
|
[Route("GetNotifications")]
|
|
|
|
public ActionResult GetNotifications(int EmpID)
|
|
{
|
|
List<NotificationTModel> oWFModels = new List<NotificationTModel>();
|
|
try
|
|
{
|
|
List<WFMovementTask> onotifications = _WFMovementTranService.GetNotificationItems(EmpID);
|
|
return Ok(onotifications.ConvertToNotificationTModels());
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("ReadNotification")]
|
|
|
|
public ActionResult ReadNotification(NotificationTModel oNotification)
|
|
{
|
|
try
|
|
{
|
|
_WFMovementTranService.UpdateSysNotification(oNotification.PKID, true);
|
|
return Ok();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
}
|
|
|
|
[HttpPost]
|
|
[Route("SubmitJob")]
|
|
|
|
public ActionResult SubmitJob(PendingJobTModel oPendingJob)
|
|
{
|
|
List<NotificationTModel> oWFModels = new List<NotificationTModel>();
|
|
WFMovementTran approver = new WFMovementTranService().Get(oPendingJob.PKID);
|
|
approver.Remarks = oPendingJob.LMRemarks;
|
|
approver.FromEmployeeID = oPendingJob.UserID;
|
|
try
|
|
{
|
|
switch (oPendingJob.SubmitStatus)
|
|
{
|
|
case EnumWFSubmitStatus.Accept:
|
|
new LeaveEntryService().LeaveApplicationApprove(approver);
|
|
break;
|
|
case EnumWFSubmitStatus.Reject:
|
|
new LeaveEntryService().LeaveApplicationReject(approver);
|
|
break;
|
|
default:
|
|
break;
|
|
}
|
|
return Ok();
|
|
}
|
|
catch (Exception ex)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, ex.Message);
|
|
}
|
|
}
|
|
|
|
[HttpGet("getPendingJob/{employeeId}")]
|
|
public ActionResult GetPendingJob(int employeeId)
|
|
{
|
|
List<PendingItemDTO> items = new List<PendingItemDTO>();
|
|
try
|
|
{
|
|
items = _WFMovementTranService.GetPendingJob(employeeId);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
|
|
|
|
|
|
|
|
// WFMovementTran
|
|
[HttpGet("getWFMovementTranById/{id}")]
|
|
|
|
public ActionResult GetWFMovementTranById(int id)
|
|
{
|
|
WFMovementTran item = new WFMovementTran();
|
|
try
|
|
{
|
|
item = _WFMovementTranService.Get(id);
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(item);
|
|
}
|
|
|
|
//WFHistory
|
|
[HttpGet("getFlowHistory/{tranID}/{uniqueNumber}")]
|
|
|
|
public ActionResult GetFlowHistory(int tranid, int uniqueNumber)
|
|
{
|
|
List<WFFlowHistory> items = new List<WFFlowHistory>();
|
|
try
|
|
{
|
|
items = _WFMovementTranService.GetFlowHistories(tranid, uniqueNumber);
|
|
|
|
}
|
|
catch (Exception e)
|
|
{
|
|
return StatusCode(StatusCodes.Status500InternalServerError, e.Message);
|
|
}
|
|
|
|
return Ok(items);
|
|
}
|
|
}
|
|
}
|