using System;
using System.Collections.Generic;
using GB5Shared.DTO.Framework.Login;
namespace FrameworkDAL.DTO.ECM
{
using Guid = System.Guid;
// ── Enum ────────────────────────────────────────────────────
// Matches actual TATTACHMENT.ATTACHMENTOPTION CHECK constraint:
// 0=ALFRESCO, 1=FILENET, 2=AMAZON S3, 3=FILE BASED
public enum AttachmentOptionType
{
Alfresco = 0,
Filenet = 1,
AmazonS3 = 2,
FileBased = 3
}
// ── Upload Request / Response ────────────────────────────────
public class AttachmentUploadRequest
{
/// Links to MDOCUMENTSETDETAIL — determines templates, document type, etc.
public int DocumentSetDetailId { get; set; }
/// OBJECTTYPEID — FK to MENTITY(ENTITYID). Identifies the entity type.
public int ObjectTypeId { get; set; }
/// 0 when uploading before entity save (Phase 1). Real PK when entity exists.
public int ObjectId { get; set; }
public int BizTransactionTypeId { get; set; } = -1;
/// FE-generated UUID. Used as folder placeholder in Phase 1.
public Guid RowGuid { get; set; }
///
/// Entity-specific context values for dynamic token resolution.
/// e.g. { "poNumber": "PO-001", "vendor": { "vendorCode": "V001" } }
///
public Dictionary ContextDictionary { get; set; } = new();
public string? Remarks { get; set; }
public string Tags { get; set; } = string.Empty;
public byte AttachmentType { get; set; } = 0; // 0=File, 1=Link
}
public class AttachmentUploadResponse
{
public int AttachmentId { get; set; }
public string DisplayFileName { get; set; } = string.Empty;
public string FolderName { get; set; } = string.Empty;
public string AttachedFileName { get; set; } = string.Empty;
public long FileSizeBytes { get; set; }
public bool IsDeferred { get; set; }
public int Version { get; set; }
public int SlNo { get; set; }
}
// ── Template Resolution Context ──────────────────────────────
/// All input needed to resolve attachment paths at upload time.
public class AttachmentResolutionContext
{
public LoginDTO Login { get; set; } = null!;
public int ObjectTypeId { get; set; } // OBJECTTYPEID
public int ObjectId { get; set; } // 0 in Phase 1
public Guid RowGuid { get; set; }
public int BizTransactionTypeId { get; set; }
public int DocumentSetDetailId { get; set; }
public string FileExtension { get; set; } = string.Empty;
public int SlNo { get; set; }
public int Version { get; set; }
public DateTime UploadedOn { get; set; } = DateTime.UtcNow;
public Dictionary ContextDictionary { get; set; } = new();
}
/// Output of path resolution — all three TATTACHMENT path fields.
public class ResolvedAttachmentPaths
{
public string FolderName { get; set; } = string.Empty;
public string AttachedFileName { get; set; } = string.Empty;
public string DisplayFileName { get; set; } = string.Empty;
public string StorageKey { get; set; } = string.Empty;
public bool IsDeferred { get; set; }
}
// ── Template Data (loaded from DB) ───────────────────────────
public class AttachmentTemplateData
{
public int DocumentSetDetailId { get; set; }
public int DocumentSetId { get; set; }
public string? LocationTemplate { get; set; }
public string? DisplayNameTemplate { get; set; }
public string? DocumentNameTemplate { get; set; }
public string? TagFields { get; set; }
public string? PropertyFields { get; set; }
public int ModuleId { get; set; }
public string DocumentSetCode { get; set; } = string.Empty;
public string DocumentSetName { get; set; } = string.Empty;
public int DocumentTypeId { get; set; }
public string DocumentTypeCode { get; set; } = string.Empty;
public string DocumentTypeName { get; set; } = string.Empty;
public string ModuleCode { get; set; } = string.Empty;
public string ModuleName { get; set; } = string.Empty;
public byte IsVersion { get; set; }
}
// ── Phase 2 Deferred Path Resolution ────────────────────────
/// An attachment that needs Phase 2 path re-resolution (ISPATHDEFERRED=1).
public class DeferredAttachment
{
public int AttachmentId { get; set; }
public string RowGuidPlaceholder { get; set; } = string.Empty;
public int NewObjectId { get; set; }
public int ObjectTypeId { get; set; }
public string OldCmsId { get; set; } = string.Empty;
public string OldFolderName { get; set; } = string.Empty;
public string OldAttachedFileName { get; set; } = string.Empty;
public string DisplayFileName { get; set; } = string.Empty;
public byte StorageAdapterType { get; set; }
public short Version { get; set; }
}
/// Path movement computed by Phase 2 — ready for storage move and DB update.
public class PathMovement
{
public int AttachmentId { get; set; }
public string OldCmsId { get; set; } = string.Empty;
public string NewFolderName { get; set; } = string.Empty;
public string NewAttachedFileName { get; set; } = string.Empty;
public string NewCmsId { get; set; } = string.Empty;
public string NewDisplayFileName { get; set; } = string.Empty;
}
// ── Internal helpers ─────────────────────────────────────────
public class SlNoVersionResult
{
public short NextSlNo { get; set; }
public short NextVersion { get; set; }
}
}