Ashutosh_Task#513 #96

Merged
ashutosh.nehete merged 58 commits from Ashutosh_Task#513 into Issues_June_3W 2025-06-28 04:27:28 +00:00
6 changed files with 70 additions and 9 deletions
Showing only changes of commit 8814dc59d9 - Show all commits

View File

@ -7,11 +7,13 @@ using Marco.Pms.Model.Mapper;
using Marco.Pms.Model.Projects;
using Marco.Pms.Model.Utilities;
using Marco.Pms.Model.ViewModels.AttendanceVM;
using Marco.Pms.Services.Hubs;
using Marco.Pms.Services.Service;
using MarcoBMS.Services.Helpers;
using MarcoBMS.Services.Service;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Mvc;
using Microsoft.AspNetCore.SignalR;
using Microsoft.CodeAnalysis;
using Microsoft.EntityFrameworkCore;
using Document = Marco.Pms.Model.DocumentManager.Document;
@ -30,10 +32,11 @@ namespace MarcoBMS.Services.Controllers
private readonly S3UploadService _s3Service;
private readonly PermissionServices _permission;
private readonly ILoggingService _logger;
private readonly IHubContext<MarcoHub> _signalR;
public AttendanceController(
ApplicationDbContext context, EmployeeHelper employeeHelper, ProjectsHelper projectsHelper, UserHelper userHelper, S3UploadService s3Service, ILoggingService logger, PermissionServices permission)
ApplicationDbContext context, EmployeeHelper employeeHelper, ProjectsHelper projectsHelper, UserHelper userHelper, S3UploadService s3Service, ILoggingService logger, PermissionServices permission, IHubContext<MarcoHub> signalR)
{
_context = context;
_employeeHelper = employeeHelper;
@ -42,6 +45,7 @@ namespace MarcoBMS.Services.Controllers
_s3Service = s3Service;
_logger = logger;
_permission = permission;
_signalR = signalR;
}
private Guid GetTenantId()
@ -558,6 +562,7 @@ namespace MarcoBMS.Services.Controllers
Activity = attendance.Activity,
JobRoleName = employee.JobRole.Name
};
await _signalR.Clients.All.SendAsync("Attendance", new { LoggedInUserId = currentEmployee.Id, ProjectId = recordAttendanceDot.ProjectID, Response = vm });
_logger.LogInfo("Attendance for employee {FirstName} {LastName} has been marked", employee.FirstName ?? string.Empty, employee.LastName ?? string.Empty);
return Ok(ApiResponse<object>.SuccessResponse(vm, "Attendance marked successfully.", 200));
}

View File

@ -749,11 +749,11 @@ namespace Marco.Pms.Services.Controllers
return Ok(response);
}
[HttpGet("contact-tag/{id}")]
public async Task<IActionResult> GetContactTagMaster(Guid id)
{
return Ok();
}
//[HttpGet("contact-tag/{id}")]
//public async Task<IActionResult> GetContactTagMaster(Guid id)
//{
// return Ok();
//}
[HttpPost("contact-tag")]
public async Task<IActionResult> CreateContactTagMaster([FromBody] CreateContactTagDto contactTagDto)

View File

@ -0,0 +1,35 @@
using MarcoBMS.Services.Service;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.SignalR;
namespace Marco.Pms.Services.Hubs
{
[Authorize]
public class MarcoHub : Hub
{
private readonly ILoggingService _logger;
public MarcoHub(ILoggingService logger)
{
_logger = logger;
}
public async Task SendMessage(string user, string message)
{
_logger.LogInfo($"User: {user} Message : {message}");
await Clients.All.SendAsync("ReceiveMessage", user, message);
}
public override async Task OnConnectedAsync()
{
await base.OnConnectedAsync();
_logger.LogInfo($"Connected successfully");
await Clients.All.SendAsync("Connected successfully");
}
// Optional: override OnDisconnectedAsync
public override async Task OnDisconnectedAsync(Exception? exception)
{
await base.OnDisconnectedAsync(exception);
_logger.LogInfo($"DIsonnected successfully");
await Clients.All.SendAsync("Disonnected successfully");
}
}
}

View File

@ -17,6 +17,7 @@
<PackageReference Include="Microsoft.AspNetCore.Identity.EntityFrameworkCore" Version="8.0.12" />
<PackageReference Include="Microsoft.AspNetCore.Identity.UI" Version="8.0.12" />
<PackageReference Include="Microsoft.AspNetCore.OpenApi" Version="7.0.7" />
<PackageReference Include="Microsoft.AspNetCore.SignalR" Version="1.2.0" />
<PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.12">
<PrivateAssets>all</PrivateAssets>
<IncludeAssets>runtime; build; native; contentfiles; analyzers; buildtransitive</IncludeAssets>

View File

@ -4,6 +4,7 @@ using Marco.Pms.Model.Authentication;
using Marco.Pms.Model.Entitlements;
using Marco.Pms.Model.Utilities;
using Marco.Pms.Services.Helpers;
using Marco.Pms.Services.Hubs;
using Marco.Pms.Services.Service;
using MarcoBMS.Services.Helpers;
using MarcoBMS.Services.Middleware;
@ -59,7 +60,8 @@ builder.Services.AddCors(options =>
{
policy.AllowAnyOrigin()
.AllowAnyMethod()
.AllowAnyHeader();
.AllowAnyHeader()
.WithExposedHeaders("Authorization");
});
});
@ -161,10 +163,28 @@ if (jwtSettings != null && jwtSettings.Key != null)
ValidAudience = jwtSettings.Audience,
IssuerSigningKey = new SymmetricSecurityKey(Encoding.UTF8.GetBytes(jwtSettings.Key))
};
options.Events = new JwtBearerEvents
{
OnMessageReceived = context =>
{
var accessToken = context.Request.Query["access_token"];
var path = context.HttpContext.Request.Path;
// Match your hub route here
if (!string.IsNullOrEmpty(accessToken) && path.StartsWithSegments("/hubs/marco"))
{
context.Token = accessToken;
}
return Task.CompletedTask;
}
};
});
builder.Services.AddSingleton(jwtSettings);
}
builder.Services.AddSignalR();
builder.WebHost.ConfigureKestrel(options =>
{
options.AddServerHeader = false; // Disable the "Server" header
@ -207,7 +227,7 @@ app.UseHttpsRedirection();
app.UseAuthorization();
app.MapHub<MarcoHub>("/hubs/marco");
app.MapControllers();
app.Run();

View File

@ -9,7 +9,7 @@
"Title": "Dev"
},
"ConnectionStrings": {
"DefaultConnectionString": "Server=147.93.98.152;User ID=devuser;Password=AppUser@123$;Database=MarcoBMSGuid"
"DefaultConnectionString": "Server=147.93.98.152;User ID=devuser;Password=AppUser@123$;Database=MarcoBMS1"
},
"SmtpSettings": {
"SmtpServer": "smtp.gmail.com",