Compare commits
7 Commits
9332a9161d
...
b71e451121
| Author | SHA1 | Date | |
|---|---|---|---|
| b71e451121 | |||
| d4ea68fc0e | |||
| 142a1a4faa | |||
| 66fe515518 | |||
| f54329ecd3 | |||
| 9b7475bb56 | |||
| 1d0ded0e84 |
12
src/WorkFlow.API/Base64File.cs
Normal file
12
src/WorkFlow.API/Base64File.cs
Normal file
File diff suppressed because one or more lines are too long
57
src/WorkFlow.API/Controllers/FileController.cs
Normal file
57
src/WorkFlow.API/Controllers/FileController.cs
Normal file
@ -0,0 +1,57 @@
|
|||||||
|
using Microsoft.AspNetCore.Authorization;
|
||||||
|
using Microsoft.AspNetCore.Mvc;
|
||||||
|
using System.Web;
|
||||||
|
|
||||||
|
namespace WorkFlow.API.Controllers;
|
||||||
|
|
||||||
|
[Route("api/[controller]")]
|
||||||
|
[ApiController]
|
||||||
|
[Authorize]
|
||||||
|
public class FileController : ControllerBase
|
||||||
|
{
|
||||||
|
[HttpGet("{path}")]
|
||||||
|
public IActionResult GetFile([FromRoute] string path, [FromQuery] bool icon = false)
|
||||||
|
{
|
||||||
|
string dPath = HttpUtility.UrlDecode(path);
|
||||||
|
|
||||||
|
byte[]? fileBytes = null;
|
||||||
|
string? contentType = null;
|
||||||
|
|
||||||
|
if (dPath == "docs/doc1.pdf" && !icon)
|
||||||
|
{
|
||||||
|
fileBytes = Convert.FromBase64String(Base64File.Doc1Base64);
|
||||||
|
contentType = "application/pdf";
|
||||||
|
}
|
||||||
|
else if (dPath == "icons/icon1.png" && icon)
|
||||||
|
{
|
||||||
|
fileBytes = Convert.FromBase64String(Base64File.Icon1Base64);
|
||||||
|
contentType = "image/png";
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
string fullPath = Path.Combine(AppContext.BaseDirectory, "files", dPath);
|
||||||
|
if (!System.IO.File.Exists(fullPath))
|
||||||
|
return NotFound();
|
||||||
|
|
||||||
|
fileBytes = System.IO.File.ReadAllBytes(fullPath);
|
||||||
|
contentType = GetContentType(fullPath);
|
||||||
|
}
|
||||||
|
|
||||||
|
return File(fileBytes, contentType ?? "application/octet-stream");
|
||||||
|
}
|
||||||
|
|
||||||
|
private string GetContentType(string path)
|
||||||
|
{
|
||||||
|
var ext = Path.GetExtension(path).ToLowerInvariant();
|
||||||
|
return ext switch
|
||||||
|
{
|
||||||
|
".pdf" => "application/pdf",
|
||||||
|
".png" => "image/png",
|
||||||
|
".jpg" => "image/jpeg",
|
||||||
|
".jpeg" => "image/jpeg",
|
||||||
|
".txt" => "text/plain",
|
||||||
|
".docx" => "application/vnd.openxmlformats-officedocument.wordprocessingml.document",
|
||||||
|
_ => "application/octet-stream",
|
||||||
|
};
|
||||||
|
}
|
||||||
|
}
|
||||||
@ -5,12 +5,12 @@
|
|||||||
<Nullable>enable</Nullable>
|
<Nullable>enable</Nullable>
|
||||||
<ImplicitUsings>enable</ImplicitUsings>
|
<ImplicitUsings>enable</ImplicitUsings>
|
||||||
<PackageId>WorkFlow.API</PackageId>
|
<PackageId>WorkFlow.API</PackageId>
|
||||||
<Version>1.1.0</Version>
|
<Version>1.2.0</Version>
|
||||||
<Company>Digital Data GmbH</Company>
|
<Company>Digital Data GmbH</Company>
|
||||||
<Product>WorkFlow.API</Product>
|
<Product>WorkFlow.API</Product>
|
||||||
<Title>WorkFlow.API</Title>
|
<Title>WorkFlow.API</Title>
|
||||||
<AssemblyVersion>1.1.0</AssemblyVersion>
|
<AssemblyVersion>1.2.0</AssemblyVersion>
|
||||||
<FileVersion>1.1.0</FileVersion>
|
<FileVersion>1.2.0</FileVersion>
|
||||||
</PropertyGroup>
|
</PropertyGroup>
|
||||||
|
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
|
|||||||
@ -8,7 +8,7 @@
|
|||||||
},
|
},
|
||||||
"TfFileIconUri": {
|
"TfFileIconUri": {
|
||||||
"Scheme": "https",
|
"Scheme": "https",
|
||||||
"Host": " dd-gan.digitaldata.works",
|
"Host": "dd-gan.digitaldata.works",
|
||||||
"Port": 8443,
|
"Port": 8443,
|
||||||
"Path": "api/file",
|
"Path": "api/file",
|
||||||
"Query": "icon=true"
|
"Query": "icon=true"
|
||||||
|
|||||||
@ -11,4 +11,6 @@ public class ObjectDto
|
|||||||
public ObjectStateDto? State { get; set; }
|
public ObjectStateDto? State { get; set; }
|
||||||
|
|
||||||
public IEnumerable<ObjectStateHistDto> StateHistories { get; set; } = Array.Empty<ObjectStateHistDto>();
|
public IEnumerable<ObjectStateHistDto> StateHistories { get; set; } = Array.Empty<ObjectStateHistDto>();
|
||||||
|
|
||||||
|
public IEnumerable<PControlsUpdateDto>? ControlsUpdates { get; set; } = Array.Empty<PControlsUpdateDto>();
|
||||||
}
|
}
|
||||||
|
|||||||
12
src/WorkFlow.Application/Dto/PControlsUpdateDto.cs
Normal file
12
src/WorkFlow.Application/Dto/PControlsUpdateDto.cs
Normal file
@ -0,0 +1,12 @@
|
|||||||
|
namespace WorkFlow.Application.Dto;
|
||||||
|
|
||||||
|
public record PControlsUpdateDto
|
||||||
|
{
|
||||||
|
public string? AttrName { get; set; }
|
||||||
|
|
||||||
|
public string? AttrValue { get; set; }
|
||||||
|
|
||||||
|
public string? AddedWho { get; set; }
|
||||||
|
|
||||||
|
public DateTime? AddedWhen { get; set; }
|
||||||
|
}
|
||||||
@ -31,5 +31,7 @@ public class MappingProfile : AutoMapper.Profile
|
|||||||
CreateMap<TfFile, TfFileDto>()
|
CreateMap<TfFile, TfFileDto>()
|
||||||
.ForMember(dest => dest.Url, opt => opt.MapFrom<TfFileUriResolver>())
|
.ForMember(dest => dest.Url, opt => opt.MapFrom<TfFileUriResolver>())
|
||||||
.ForMember(dest => dest.IconUrl, opt => opt.MapFrom<TfFileIconUriResolver>());
|
.ForMember(dest => dest.IconUrl, opt => opt.MapFrom<TfFileIconUriResolver>());
|
||||||
|
|
||||||
|
CreateMap<PControlsUpdate, PControlsUpdateDto>();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
69
src/WorkFlow.Domain/Entities/PControlsUpdate.cs
Normal file
69
src/WorkFlow.Domain/Entities/PControlsUpdate.cs
Normal file
@ -0,0 +1,69 @@
|
|||||||
|
using System.ComponentModel.DataAnnotations;
|
||||||
|
using System.ComponentModel.DataAnnotations.Schema;
|
||||||
|
|
||||||
|
namespace WorkFlow.Domain.Entities;
|
||||||
|
|
||||||
|
[Table("TBMWF_PROFILE_CONTROLS_UPDATE")]
|
||||||
|
public class PControlsUpdate
|
||||||
|
{
|
||||||
|
[Column("GUID", TypeName = "bigint")]
|
||||||
|
public long Id { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Although this field is marked as <c>nullable</c> in the database schema to allow
|
||||||
|
/// for greater flexibility during database-level operations or migrations, it is
|
||||||
|
/// treated as <c>required</c> and <c>not null</c> within the application logic.
|
||||||
|
/// Validation should be enforced at the application level to ensure a value is provided.
|
||||||
|
/// </summary>
|
||||||
|
[Column("MWF_PROFILE_ID", TypeName = "int")]
|
||||||
|
public int ProfileId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Although this field is marked as <c>nullable</c> in the database schema to allow
|
||||||
|
/// for greater flexibility during database-level operations or migrations, it is
|
||||||
|
/// treated as <c>required</c> and <c>not null</c> within the application logic.
|
||||||
|
/// Validation should be enforced at the application level to ensure a value is provided.
|
||||||
|
/// </summary>
|
||||||
|
[Column("USR_ID", TypeName = "int")]
|
||||||
|
public int? UsrId { get; set; }
|
||||||
|
|
||||||
|
[Required]
|
||||||
|
[Column("OBJ_ID", TypeName = "bigint")]
|
||||||
|
public long ObjId { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Although this field is marked as <c>nullable</c> in the database schema to allow
|
||||||
|
/// for greater flexibility during database-level operations or migrations, it is
|
||||||
|
/// treated as <c>required</c> and <c>not null</c> within the application logic.
|
||||||
|
/// Validation should be enforced at the application level to ensure a value is provided.
|
||||||
|
/// </summary>
|
||||||
|
[Column("ATTR_NAME", TypeName = "nvarchar(100)")]
|
||||||
|
public string? AttrName { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Although this field is marked as <c>nullable</c> in the database schema to allow
|
||||||
|
/// for greater flexibility during database-level operations or migrations, it is
|
||||||
|
/// treated as <c>required</c> and <c>not null</c> within the application logic.
|
||||||
|
/// Validation should be enforced at the application level to ensure a value is provided.
|
||||||
|
/// </summary>
|
||||||
|
[Column("ATTR_VALUE", TypeName = "nvarchar(3000)")]
|
||||||
|
public string? AttrValue { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Although this field is marked as <c>nullable</c> in the database schema to allow
|
||||||
|
/// for greater flexibility during database-level operations or migrations, it is
|
||||||
|
/// treated as <c>required</c> and <c>not null</c> within the application logic.
|
||||||
|
/// Validation should be enforced at the application level to ensure a value is provided.
|
||||||
|
/// </summary>
|
||||||
|
[Column("ADDED_WHO", TypeName = "nvarchar(30)")]
|
||||||
|
public string? AddedWho { get; set; }
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Although this field is marked as <c>nullable</c> in the database schema to allow
|
||||||
|
/// for greater flexibility during database-level operations or migrations, it is
|
||||||
|
/// treated as <c>required</c> and <c>not null</c> within the application logic.
|
||||||
|
/// Validation should be enforced at the application level to ensure a value is provided.
|
||||||
|
/// </summary>
|
||||||
|
[Column("ADDED_WHEN", TypeName = "datetime")]
|
||||||
|
public DateTime? AddedWhen { get; set; }
|
||||||
|
}
|
||||||
@ -29,4 +29,6 @@ public class PObject
|
|||||||
public virtual PObjectState? State { get; set; }
|
public virtual PObjectState? State { get; set; }
|
||||||
|
|
||||||
public virtual IEnumerable<PObjectStateHist>? StateHistories { get; set; }
|
public virtual IEnumerable<PObjectStateHist>? StateHistories { get; set; }
|
||||||
|
|
||||||
|
public virtual IEnumerable<PControlsUpdate>? ControlsUpdates { get; set; }
|
||||||
}
|
}
|
||||||
@ -39,5 +39,6 @@ public class PObjectRepository : IProfileObjRepository
|
|||||||
.Include(obj => obj.State).ThenInclude(objState => objState != null ? objState.TFControls : null)
|
.Include(obj => obj.State).ThenInclude(objState => objState != null ? objState.TFControls : null)
|
||||||
.Include(obj => obj.State).ThenInclude(objState => objState != null ? objState.TfFiles : null)
|
.Include(obj => obj.State).ThenInclude(objState => objState != null ? objState.TfFiles : null)
|
||||||
.Include(obj => obj.StateHistories!).ThenInclude(hist => hist != null ? hist.State1 : null)
|
.Include(obj => obj.StateHistories!).ThenInclude(hist => hist != null ? hist.State1 : null)
|
||||||
|
.Include(obj => obj.ControlsUpdates)
|
||||||
.ToListAsync(cancel);
|
.ToListAsync(cancel);
|
||||||
}
|
}
|
||||||
@ -43,7 +43,6 @@ public class WFDBContext : DbContext, IUserManagerDbContext
|
|||||||
|
|
||||||
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
protected override void OnModelCreating(ModelBuilder modelBuilder)
|
||||||
{
|
{
|
||||||
//configure model builder for user manager tables
|
|
||||||
modelBuilder.ConfigureUserManager();
|
modelBuilder.ConfigureUserManager();
|
||||||
|
|
||||||
modelBuilder.Entity<PObjectState>()
|
modelBuilder.Entity<PObjectState>()
|
||||||
@ -62,6 +61,12 @@ public class WFDBContext : DbContext, IUserManagerDbContext
|
|||||||
.WithOne()
|
.WithOne()
|
||||||
.HasForeignKey(hist => hist.ObjectId);
|
.HasForeignKey(hist => hist.ObjectId);
|
||||||
|
|
||||||
|
modelBuilder.Entity<PObject>()
|
||||||
|
.HasMany(obj => obj.ControlsUpdates)
|
||||||
|
.WithOne()
|
||||||
|
.HasForeignKey(cu => cu.ObjId)
|
||||||
|
.OnDelete(DeleteBehavior.Cascade);
|
||||||
|
|
||||||
base.OnModelCreating(modelBuilder);
|
base.OnModelCreating(modelBuilder);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Loading…
x
Reference in New Issue
Block a user