using FrameworkDAL.DTO.Workflow;
using GB5Shared.DTO.Framework.Criteria;
using GB5Shared.DTO.Framework.Login;
using GB5Shared.DTO.WorkFlow;
using System;
using System.Collections.Generic;
using System.Threading.Tasks;
using static GB5Shared.DTO.WorkFlow.ContractsDTO;
using WorkflowDTO = FrameworkDAL.DTO.Workflow.WorkflowDTO;
namespace FrameworkDAL.CustomCode.WorkFlow
{
public interface IWorkFlowDAL
{
// ── Applicability check ───────────────────────────────────────────────
///
/// Checks MWORKFLOWCONFIG to determine whether a workflow applies
/// and returns the result with the resolved workflow id.
///
Task CheckApplicability(
WorkflowCheckContext context,
LoginDTO loginDTO);
// ── Start workflow ────────────────────────────────────────────────────
///
/// Starts a new workflow instance for the given document.
/// Returns the full including any
/// PendingNotifications (tasks created at the first approval level).
///
Task StartWorkflow(
WorkflowStartRequest request,
LoginDTO loginDTO);
// ── Action handling ───────────────────────────────────────────────────
///
/// Processes workflow actions. Returns WorkflowActionResult which may contain
/// PendingDispatches for WIP instances that reached final approval.
/// Caller (BLL) must dispatch these AFTER committing the transaction.
///
Task Actions(
WorkFlowActionDTO workFlowActionDTO,
LoginDTO loginDTO);
///
/// Friendly MENTITY.ENTITYNAME for an EntityId. Used by the BLL to label the
/// success message for entity types it doesn't have a hardcoded name for.
///
Task GetEntityNameAsync(int entityId, LoginDTO loginDTO);
// ── Approval list ─────────────────────────────────────────────────────
///
/// WorkflowType: 1 = RequestToMe, other = RequestByMe.
///
Task> WorkflowApprovalList(
int workflowType,
int firstNumber,
int maxResult,
CriteriaDTO criteriaDTO,
LoginDTO loginDTO);
// ── History and status ────────────────────────────────────────────────
Task> WorkflowHistory(
int workflowType,
CriteriaDTO criteriaDTO,
LoginDTO loginDTO);
Task> WorkflowStatus(
CriteriaDTO criteriaDTO,
LoginDTO loginDTO);
///
/// Returns real-time approval status for a specific document
/// (current level, pending approvers, completed approvers, history).
///
Task> CurrentApprovalStatus(
int entityId,
int objectId,
LoginDTO loginDTO);
// ── Auto-approve ─────────────────────────────────────────────────────
///
/// Returns all pending tasks whose DUEON has passed and step has ISAUTOAPPROVE = 0 (0=Yes).
///
Task> GetOverdueAutoApproveTasks(LoginDTO loginDTO);
// ── Monitor dashboard ─────────────────────────────────────────────────
Task GetWorkflowMonitor(
int entityId, DateTime? dateFrom, DateTime? dateTo,
int page, int pageSize,
LoginDTO loginDTO);
// ── Workflow CRUD ─────────────────────────────────────────────────────
Task GetWorkflow(int WorkflowId, LoginDTO LoginDTO);
Task SaveWorkflow(WorkflowDTO workflowDTO, LoginDTO login);
Task UpdateWorkflow(WorkflowDTO workflowDTO, LoginDTO login);
Task DeleteWorkflowDetail(int WorkflowId, LoginDTO LoginDTO);
Task DeleteWorkflow(int WorkflowId, LoginDTO LoginDTO);
Task> GetSelectListWorkflow(CriteriaDTO criteriaDTO, LoginDTO LoginDTO);
}
}