Procházet zdrojové kódy

Contract with Report

zinab_elgendy před 2 týdny
rodič
revize
f06c7f5530
26 změnil soubory, kde provedl 11174 přidání a 229 odebrání
  1. 23 0
      MTWorkHR.API/Controllers/CustomWebDocumentViewerController.cs
  2. 52 0
      MTWorkHR.API/Controllers/ReportingController.cs
  3. 10 0
      MTWorkHR.API/MTWorkHR.API.csproj
  4. 20 0
      MTWorkHR.API/Program.cs
  5. 1235 0
      MTWorkHR.API/Reports/ContractReport.Designer.cs
  6. 16 0
      MTWorkHR.API/Reports/ContractReport.cs
  7. 123 0
      MTWorkHR.API/Reports/ContractReport.resx
  8. 130 0
      MTWorkHR.API/Reports/EmployeeContract.Designer.cs
  9. 16 0
      MTWorkHR.API/Reports/EmployeeContract.cs
  10. 123 0
      MTWorkHR.API/Reports/EmployeeContract.resx
  11. 85 0
      MTWorkHR.API/Reports/ReportStorageWebExtension.cs
  12. 1 1
      MTWorkHR.API/appsettings.json
  13. 3 0
      MTWorkHR.Application/Dtos/Identity/UserDto.cs
  14. 3 0
      MTWorkHR.Application/Dtos/Identity/UserUpdateDto.cs
  15. 22 0
      MTWorkHR.Application/Dtos/Lookup/NationalityDto.cs
  16. 3 0
      MTWorkHR.Application/Dtos/User/CompanyDto.cs
  17. 3 0
      MTWorkHR.Core/Entities/User/Company.cs
  18. 24 0
      MTWorkHR.Core/Entities/User/Nationality.cs
  19. 1479 0
      MTWorkHR.Infrastructure/Configurations/NationalityConfiguration.cs
  20. 1 0
      MTWorkHR.Infrastructure/DBContext/HRDataContext.cs
  21. 6 0
      MTWorkHR.Infrastructure/Entities/ApplicationUser.cs
  22. 17 0
      MTWorkHR.Infrastructure/MTWorkHR.Infrastructure.csproj
  23. 5642 0
      MTWorkHR.Infrastructure/Migrations/20241029101807_altrUserCompany_addNationality.Designer.cs
  24. 375 0
      MTWorkHR.Infrastructure/Migrations/20241029101807_altrUserCompany_addNationality.cs
  25. 1748 228
      MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs
  26. 14 0
      MTWorkHR.Infrastructure/appsettings.json

+ 23 - 0
MTWorkHR.API/Controllers/CustomWebDocumentViewerController.cs

@@ -0,0 +1,23 @@
+using DevExpress.AspNetCore.Reporting.QueryBuilder.Native.Services;
+using DevExpress.AspNetCore.Reporting.QueryBuilder;
+using DevExpress.AspNetCore.Reporting.WebDocumentViewer.Native.Services;
+using DevExpress.AspNetCore.Reporting.WebDocumentViewer;
+using Microsoft.AspNetCore.Mvc;
+
+namespace MTWorkHR.API.Controllers
+{
+    [ApiExplorerSettings(IgnoreApi = true)]
+    public class CustomWebDocumentViewerController : WebDocumentViewerController
+    {
+        public CustomWebDocumentViewerController(IWebDocumentViewerMvcControllerService controllerService) : base(controllerService)
+        {
+        }
+    }
+    [ApiExplorerSettings(IgnoreApi = true)]
+    public class CustomQueryBuilderController : QueryBuilderController
+    {
+        public CustomQueryBuilderController(IQueryBuilderMvcControllerService controllerService) : base(controllerService)
+        {
+        }
+    }
+}

+ 52 - 0
MTWorkHR.API/Controllers/ReportingController.cs

@@ -0,0 +1,52 @@
+
+using Microsoft.AspNetCore.Mvc;
+using DevExpress.XtraReports.UI;
+using DevExpress.XtraReports.Web.Extensions;
+using System.IO;
+
+namespace MTWorkHR.API.Controllers
+{
+    [ApiController]
+    [Route("api/[controller]")]
+    public class ReportController : ControllerBase
+    {
+        private readonly ReportStorageWebExtension _reportStorage;
+
+        public ReportController(ReportStorageWebExtension reportStorage)
+        {
+            _reportStorage = reportStorage;
+        }
+
+        [HttpGet("generate-pdf")]
+        public async Task<IActionResult> GeneratePdf(string reportUrl)
+        {
+            byte[] reportData = _reportStorage.GetData(reportUrl);
+
+            // Load the report from the byte array
+            using (MemoryStream ms = new MemoryStream(reportData))
+            {
+                XtraReport report = XtraReport.FromStream(ms, true);
+
+                using (MemoryStream pdfStream = new MemoryStream())
+                {
+                    try
+                    {
+                        if (report.DataSource == null)
+                        {
+                            var m = "The report's DataSource is null.";
+                        }
+                        await report.CreateDocumentAsync();
+
+                        await report.ExportToPdfAsync(pdfStream);
+                    }
+                    catch(Exception e)
+                    {
+                        var mess = e.Message;
+                    }
+                    return File(pdfStream.ToArray(), "application/pdf", "GeneratedReport.pdf");
+                }
+            }
+        }
+
+    }
+}

+ 10 - 0
MTWorkHR.API/MTWorkHR.API.csproj

@@ -11,6 +11,7 @@
 
   <ItemGroup>
     <PackageReference Include="Azure.Storage.Blobs" Version="12.20.0" />
+    <PackageReference Include="DevExpress.AspNetCore.Reporting" Version="24.1.6" />
     <PackageReference Include="dotenv.net" Version="3.2.0" />
     <PackageReference Include="Microsoft.EntityFrameworkCore.Design" Version="8.0.1">
       <PrivateAssets>all</PrivateAssets>
@@ -27,4 +28,13 @@
     <ProjectReference Include="..\MTWorkHR.Infrastructure\MTWorkHR.Infrastructure.csproj" />
   </ItemGroup>
 
+  <ItemGroup>
+    <Compile Update="Reports\ContractReport.cs">
+      <SubType>XtraReport</SubType>
+    </Compile>
+    <Compile Update="Reports\EmployeeContract.cs">
+      <SubType>XtraReport</SubType>
+    </Compile>
+  </ItemGroup>
+
 </Project>

+ 20 - 0
MTWorkHR.API/Program.cs

@@ -17,6 +17,11 @@ using Moq;
 
 
 using Microsoft.Extensions.DependencyInjection;
+using DevExpress.AspNetCore;
+using DevExpress.XtraCharts;
+using DevExpress.XtraReports.Web.Extensions;
+using DevExpress.AspNetCore.Reporting;
+using MTWorkHR.Infrastructure.Reports;
 
 var builder = WebApplication.CreateBuilder(args);
 
@@ -81,6 +86,20 @@ builder.Services.Configure<ApiBehaviorOptions>(options =>
 {
     options.SuppressModelStateInvalidFilter = true;
 });
+
+builder.Services.AddDevExpressControls(); // Add DevExpress Reporting controls
+
+//Reporting
+
+
+builder.Services.AddScoped<ReportStorageWebExtension, CustomReportStorageWebExtension>();
+
+builder.Services.ConfigureReportingServices(configurator => {
+    configurator.ConfigureWebDocumentViewer(viewerConfigurator => {
+        viewerConfigurator.UseCachedReportSourceBuilder();
+    });
+});
+
 // Learn more about configuring Swagger/OpenAPI at https://aka.ms/aspnetcore/swashbuckle
 builder.Services.AddEndpointsApiExplorer();
 //builder.Services.AddSwaggerGen();
@@ -138,6 +157,7 @@ var app = builder.Build();
 // Configure the HTTP request pipeline.
 // if (app.Environment.IsDevelopment())
 // {
+app.UseDevExpressControls(); // Required for DevExpress Reporting
 app.UseSwagger();
 //app.UseSwaggerUI();
 app.UseSwaggerUI(c => c.SwaggerEndpoint("/swagger/v1/swagger.json", "MTWorkHR.API v1"));

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1235 - 0
MTWorkHR.API/Reports/ContractReport.Designer.cs


+ 16 - 0
MTWorkHR.API/Reports/ContractReport.cs

@@ -0,0 +1,16 @@
+using DevExpress.XtraReports.UI;
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace MTWorkHR.Infrastructure.Reports
+{
+    public partial class ContractReport : DevExpress.XtraReports.UI.XtraReport
+    {
+        public ContractReport()
+        {
+            InitializeComponent();
+        }
+    }
+}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 123 - 0
MTWorkHR.API/Reports/ContractReport.resx


+ 130 - 0
MTWorkHR.API/Reports/EmployeeContract.Designer.cs

@@ -0,0 +1,130 @@
+namespace MTWorkHR.Infrastructure.Reports
+{
+    partial class EmployeeContract
+    {
+        /// <summary>
+        /// Required designer variable.
+        /// </summary>
+        private System.ComponentModel.IContainer components = null;
+
+        /// <summary> 
+        /// Clean up any resources being used.
+        /// </summary>
+        /// <param name="disposing">true if managed resources should be disposed; otherwise, false.</param>
+        protected override void Dispose(bool disposing)
+        {
+            if (disposing && (components != null))
+            {
+                components.Dispose();
+            }
+            base.Dispose(disposing);
+        }
+
+        #region Designer generated code
+
+        /// <summary>
+        /// Required method for Designer support - do not modify
+        /// the contents of this method with the code editor.
+        /// </summary>
+        private void InitializeComponent()
+        {
+            this.components = new System.ComponentModel.Container();
+            DevExpress.DataAccess.Sql.CustomSqlQuery customSqlQuery1 = new DevExpress.DataAccess.Sql.CustomSqlQuery();
+            System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(EmployeeContract));
+            this.TopMargin = new DevExpress.XtraReports.UI.TopMarginBand();
+            this.BottomMargin = new DevExpress.XtraReports.UI.BottomMarginBand();
+            this.Detail = new DevExpress.XtraReports.UI.DetailBand();
+            this.xrLabel1 = new DevExpress.XtraReports.UI.XRLabel();
+            this.sqlDataSource1 = new DevExpress.DataAccess.Sql.SqlDataSource(this.components);
+            this.xrLabel2 = new DevExpress.XtraReports.UI.XRLabel();
+            this.xrLabel3 = new DevExpress.XtraReports.UI.XRLabel();
+            ((System.ComponentModel.ISupportInitialize)(this)).BeginInit();
+            // 
+            // TopMargin
+            // 
+            this.TopMargin.Name = "TopMargin";
+            // 
+            // BottomMargin
+            // 
+            this.BottomMargin.Name = "BottomMargin";
+            // 
+            // Detail
+            // 
+            this.Detail.Controls.AddRange(new DevExpress.XtraReports.UI.XRControl[] {
+            this.xrLabel3,
+            this.xrLabel2,
+            this.xrLabel1});
+            this.Detail.Name = "Detail";
+            // 
+            // xrLabel1
+            // 
+            this.xrLabel1.Font = new DevExpress.Drawing.DXFont("Arial", 19F, DevExpress.Drawing.DXFontStyle.Bold);
+            this.xrLabel1.LocationFloat = new DevExpress.Utils.PointFloat(169.1667F, 25F);
+            this.xrLabel1.Multiline = true;
+            this.xrLabel1.Name = "xrLabel1";
+            this.xrLabel1.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 100F);
+            this.xrLabel1.SizeF = new System.Drawing.SizeF(349.1666F, 47.16666F);
+            this.xrLabel1.StylePriority.UseFont = false;
+            this.xrLabel1.Text = "Hi my friend";
+            // 
+            // sqlDataSource1
+            // 
+            this.sqlDataSource1.ConnectionName = "LocalConnectionString";
+            this.sqlDataSource1.Name = "sqlDataSource1";
+            customSqlQuery1.Name = "Query";
+            customSqlQuery1.Sql = "select * from contracts";
+            this.sqlDataSource1.Queries.AddRange(new DevExpress.DataAccess.Sql.SqlQuery[] {
+            customSqlQuery1});
+            this.sqlDataSource1.ResultSchemaSerializable = resources.GetString("sqlDataSource1.ResultSchemaSerializable");
+            // 
+            // xrLabel2
+            // 
+            this.xrLabel2.ExpressionBindings.AddRange(new DevExpress.XtraReports.UI.ExpressionBinding[] {
+            new DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[BillingCycle]")});
+            this.xrLabel2.LocationFloat = new DevExpress.Utils.PointFloat(45.83333F, 76.99999F);
+            this.xrLabel2.Multiline = true;
+            this.xrLabel2.Name = "xrLabel2";
+            this.xrLabel2.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
+            this.xrLabel2.SizeF = new System.Drawing.SizeF(100F, 23F);
+            this.xrLabel2.Text = "xrLabel2";
+            this.xrLabel2.TextAlignment = DevExpress.XtraPrinting.TextAlignment.TopRight;
+            // 
+            // xrLabel3
+            // 
+            this.xrLabel3.ExpressionBindings.AddRange(new DevExpress.XtraReports.UI.ExpressionBinding[] {
+            new DevExpress.XtraReports.UI.ExpressionBinding("BeforePrint", "Text", "[CreateDate]")});
+            this.xrLabel3.LocationFloat = new DevExpress.Utils.PointFloat(217.5F, 76.99999F);
+            this.xrLabel3.Multiline = true;
+            this.xrLabel3.Name = "xrLabel3";
+            this.xrLabel3.Padding = new DevExpress.XtraPrinting.PaddingInfo(2, 2, 0, 0, 96F);
+            this.xrLabel3.SizeF = new System.Drawing.SizeF(100F, 23F);
+            this.xrLabel3.Text = "xrLabel3";
+            this.xrLabel3.TextFormatString = "{0:d}";
+            // 
+            // EmployeeContract
+            // 
+            this.Bands.AddRange(new DevExpress.XtraReports.UI.Band[] {
+            this.TopMargin,
+            this.BottomMargin,
+            this.Detail});
+            this.ComponentStorage.AddRange(new System.ComponentModel.IComponent[] {
+            this.sqlDataSource1});
+            this.DataMember = "Query";
+            this.DataSource = this.sqlDataSource1;
+            this.Font = new DevExpress.Drawing.DXFont("Arial", 9.75F);
+            this.Version = "24.1";
+            ((System.ComponentModel.ISupportInitialize)(this)).EndInit();
+
+        }
+
+        #endregion
+
+        private DevExpress.XtraReports.UI.TopMarginBand TopMargin;
+        private DevExpress.XtraReports.UI.BottomMarginBand BottomMargin;
+        private DevExpress.XtraReports.UI.DetailBand Detail;
+        private DevExpress.XtraReports.UI.XRLabel xrLabel1;
+        private DevExpress.DataAccess.Sql.SqlDataSource sqlDataSource1;
+        private DevExpress.XtraReports.UI.XRLabel xrLabel3;
+        private DevExpress.XtraReports.UI.XRLabel xrLabel2;
+    }
+}

+ 16 - 0
MTWorkHR.API/Reports/EmployeeContract.cs

@@ -0,0 +1,16 @@
+using DevExpress.XtraReports.UI;
+using System;
+using System.Collections;
+using System.ComponentModel;
+using System.Drawing;
+
+namespace MTWorkHR.Infrastructure.Reports
+{
+    public partial class EmployeeContract : DevExpress.XtraReports.UI.XtraReport
+    {
+        public EmployeeContract()
+        {
+            InitializeComponent();
+        }
+    }
+}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 123 - 0
MTWorkHR.API/Reports/EmployeeContract.resx


+ 85 - 0
MTWorkHR.API/Reports/ReportStorageWebExtension.cs

@@ -0,0 +1,85 @@
+using DevExpress.XtraReports.UI;
+using Microsoft.AspNetCore.Hosting;
+using System;
+using System.Collections.Generic;
+using System.IO;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using System.Web;
+
+namespace MTWorkHR.Infrastructure.Reports
+{
+    public class CustomReportStorageWebExtension : DevExpress.XtraReports.Web.Extensions.ReportStorageWebExtension
+    {
+      //  private readonly GlobalInfo globalInfo;
+    //    private readonly AppSettingsConfiguration settings;
+        public CustomReportStorageWebExtension()
+        {
+        }
+        public override byte[] GetData(string url)
+        {
+            try
+            {
+                // Parse the string with the report name and parameter values.
+                string[] parts = url.Split('?');
+                string reportName = parts[0];
+                string parametersQueryString = parts.Length > 1 ? parts[1] : String.Empty;
+
+                // Create a report instance.
+
+                XtraReport report= getReport(reportName);
+              
+                if (report != null)
+                {
+                    // Apply the parameter values to the report.
+                    var parameters = HttpUtility.ParseQueryString(parametersQueryString);
+
+                    foreach (string parameterName in parameters.AllKeys)
+                    {
+                        if (parameters.Get(parameterName) != "null"&& parameters.Get(parameterName) != null)
+                        {
+                                report.Parameters[parameterName].Value = Convert.ChangeType(
+                            parameters.Get(parameterName), report.Parameters[parameterName].Type);
+                        }
+                    }
+
+                    // Disable the Visible property for all report parameters
+                    // to hide the Parameters Panel in the viewer.
+                    foreach (var parameter in report.Parameters)
+                    {
+                        parameter.Visible = false;
+                    }
+
+                    // If you do not hide the panel, disable the report's RequestParameters property.
+                    // report.RequestParameters = false;
+
+                    using (MemoryStream ms = new MemoryStream())
+                    {
+                        report.SaveLayoutToXml(ms);
+                        return ms.ToArray();
+                    }
+                }
+            }
+            catch (Exception ex)
+            {
+                throw new DevExpress.XtraReports.Web.ClientControls.FaultException(
+                    "Could not get report data.", ex);
+            }
+            throw new DevExpress.XtraReports.Web.ClientControls.FaultException(
+                string.Format("Could not find report '{0}'.", url));
+        }
+        private XtraReport getReport(string reportName)
+        {
+            switch (reportName)
+            {
+                case "ContractReport":
+                    return new ContractReport();
+                case "EmployeeContract":
+                    return new EmployeeContract();
+                default: return null;
+            }
+        }
+    
+    }
+}

+ 1 - 1
MTWorkHR.API/appsettings.json

@@ -7,7 +7,7 @@
   },
   "ConnectionStrings": {
     "MTWorkHRConnectionString": "Server=tcp:mtworksqlserver.database.windows.net,1433;Initial Catalog=MTWorkHRDB;Persist Security Info=False;User ID=MTWorkHR;Password=MTWork@12345;MultipleActiveResultSets=False;Encrypt=True;TrustServerCertificate=False;Connection Timeout=30;",
-    //"LocalConnectionString": "Server=.;Database=MTWorkHRDB;User=sa;Password=p@ssw0rd;MultipleActiveResultSets=true;Integrated Security=True;Encrypt=False",
+    "LocalConnectionString": "Server=.;Database=MTWorkHRDB;User=sa;Password=p@ssw0rd;MultipleActiveResultSets=true;Integrated Security=True;Encrypt=False",
     "BlobConnectionString": "DefaultEndpointsProtocol=https;AccountName=mtworkhrstorage;AccountKey=8EfjO3+4jHmf6QSnW5PCFDWry8oXSAM4pGtlIviImd5yCo6lxWDUpnzfT6ppHJqhKztuGU9IL4Ai+ASt16oHZA==;EndpointSuffix=core.windows.net"
     // "HRIdentityDB": "Server=localhost;Database=HRIdentityDB;User=sa;Password=p@ssw0rd;MultipleActiveResultSets=true"
     //Data Source=.;Initial Catalog=CBQ_VIVR;Integrated Security=True;Encrypt=False

+ 3 - 0
MTWorkHR.Application/Dtos/Identity/UserDto.cs

@@ -24,6 +24,8 @@ namespace MTWorkHR.Application.Models
         public string Email { get; set; }
 
         public string PassportNumber { get; set; }
+        public DateTime? PassportExpiryDate { get; set; }
+
         public string? FavoriteName { get; set; }
 
         public string PhoneNumber { get; set; }
@@ -40,6 +42,7 @@ namespace MTWorkHR.Application.Models
         public int? JobTitleId { get; set; }
         public int? IndustryId { get; set; }
         public int? CountryId { get; set; }
+        public int? NationalityId { get; set; }
         public string? QualificationName { get; set; }
         public string? UniversityName { get; set; }
         public string? JobTitleName { get; set; }

+ 3 - 0
MTWorkHR.Application/Dtos/Identity/UserUpdateDto.cs

@@ -19,6 +19,8 @@ namespace MTWorkHR.Application.Models
         public string Email { get; set; }
 
         public string PassportNumber { get; set; }
+        public DateTime? PassportExpiryDate { get; set; }
+
         public string? FavoriteName { get; set; }
 
         public string PhoneNumber { get; set; }
@@ -35,6 +37,7 @@ namespace MTWorkHR.Application.Models
         public int? JobTitleId { get; set; }
         public int? IndustryId { get; set; }
         public int? CountryId { get; set; }
+        public int? NationalityId { get; set; }
         public string? QualificationName { get; set; }
         public string? UniversityName { get; set; }
         public string? JobTitleName { get; set; }

+ 22 - 0
MTWorkHR.Application/Dtos/Lookup/NationalityDto.cs

@@ -0,0 +1,22 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using Countries.NET;
+using MTWorkHR.Application.Models;
+using MTWorkHR.Core.Entities.Base;
+using MTWorkHR.Core.Global;
+
+namespace MTWorkHR.Application.Models
+{
+    public class NationalityDto :EntityDto
+    {
+        public string NameAr { get; set; }
+        public string NameEn { get; set; }
+        public long? CountryId { get; set; }
+        public string? CountryCode { get; set; }
+
+    }
+}

+ 3 - 0
MTWorkHR.Application/Dtos/User/CompanyDto.cs

@@ -15,6 +15,9 @@ namespace MTWorkHR.Application.Models
 
         public string CRNumber { get; set; } //Commercial Registration
         public string? UserId { get; set; }
+        public int PhoneNumber { get; set; }
+        public int Address { get; set; }
+        public int Email { get; set; }
         public UserTypeEnum? UserType { get; set; }
 
         public CompanyUserDto? CompanyUser { get; set; }

+ 3 - 0
MTWorkHR.Core/Entities/User/Company.cs

@@ -16,5 +16,8 @@ namespace MTWorkHR.Core.Entities
         [Filter]
         public string CRNumber { get; set; }
         public int TaxNumber { get; set; }
+        public int PhoneNumber { get; set; }
+        public int Address { get; set; }
+        public int Email { get; set; }
     }
 }

+ 24 - 0
MTWorkHR.Core/Entities/User/Nationality.cs

@@ -0,0 +1,24 @@
+using System;
+using System.Collections.Generic;
+using System.ComponentModel.DataAnnotations;
+using System.Linq;
+using System.Text;
+using System.Threading.Tasks;
+using MTWorkHR.Core.Entities.Base;
+
+namespace MTWorkHR.Core.Entities
+{
+    public class Nationality : Entity
+    {
+        [Required]
+        [MaxLength(250)]
+        [Filter]
+        public string NameAr { get; set; }
+        [Required]
+        [MaxLength(250)]
+        [Filter]
+        public string NameEn { get; set; }
+        public string? CountryCode { get; set; }
+        public string? CountryId { get; set; }
+    }
+}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1479 - 0
MTWorkHR.Infrastructure/Configurations/NationalityConfiguration.cs


+ 1 - 0
MTWorkHR.Infrastructure/DBContext/HRDataContext.cs

@@ -52,6 +52,7 @@ namespace MTWorkHR.Infrastructure.DBContext
         public DbSet<City> Cities { get; set; }
         //-----------
         public DbSet<Contract> Contracts { get; set; }
+        public DbSet<Nationality> Nationalities{ get; set; }
 
         //------------------------Logs------------------------
         public DbSet<UserLog> UserLogs { get; set; }

+ 6 - 0
MTWorkHR.Infrastructure/Entities/ApplicationUser.cs

@@ -18,6 +18,7 @@ namespace MTWorkHR.Infrastructure.Entities
         public int UserType { get; set; }
         public string? FavoriteName { get; set; }
         public string PassportNumber { get; set; }
+        public DateTime? PassportExpiryDate { get; set; }
         public long? QualificationId { get; set; }
 
         [ForeignKey("QualificationId")]
@@ -31,6 +32,10 @@ namespace MTWorkHR.Infrastructure.Entities
         public long? IndustryId { get; set; }
         [ForeignKey("IndustryId")]
         public Industry? Industry { get; set; }
+        public long? NationalityId { get; set; }
+        [ForeignKey("NationalityId")]
+
+        public Nationality? Nationality { get; set; }
         public long? CountryId { get; set; }
         [ForeignKey("CountryId")]
 
@@ -59,6 +64,7 @@ namespace MTWorkHR.Infrastructure.Entities
         public string? LinkedInLink { get; set; }
         public string? Position { get; set; }
         public long? CompanyId { get; set; }
+        public string? CompanyRepresentativeTitle { get; set; }
 
         public ICollection<ApplicationRole> UserRoles { get; set; }
         public ICollection<UserAttachment> UserAttachments { get; set; }

+ 17 - 0
MTWorkHR.Infrastructure/MTWorkHR.Infrastructure.csproj

@@ -7,6 +7,12 @@
   </PropertyGroup>
 
   <ItemGroup>
+    <None Remove="Reports\ORMDataModel1.xpo" />
+    <None Remove="Reports\ORMDataModel1.xpo.diagram" />
+  </ItemGroup>
+
+  <ItemGroup>
+    <PackageReference Include="DevExpress.AspNetCore.Reporting" Version="24.1.6" />
     <PackageReference Include="MailKit" Version="4.3.0" />
     <PackageReference Include="Microsoft.AspNetCore.Authentication.JwtBearer" Version="8.0.1" />
     <PackageReference Include="Microsoft.AspNetCore.Identity" Version="2.2.0" />
@@ -18,6 +24,7 @@
     </PackageReference>
     <PackageReference Include="Microsoft.Extensions.Options.ConfigurationExtensions" Version="8.0.0" />
     <PackageReference Include="MimeKit" Version="4.3.0" />
+    <PackageReference Include="QuestPDF" Version="2024.10.2" />
     <PackageReference Include="System.Linq.Dynamic.Core" Version="1.3.8" />
   </ItemGroup>
 
@@ -25,4 +32,14 @@
     <ProjectReference Include="..\MTWorkHR.Core\MTWorkHR.Core.csproj" />
   </ItemGroup>
 
+  <ItemGroup>
+    <None Update="appsettings.json">
+      <CopyToOutputDirectory>Always</CopyToOutputDirectory>
+    </None>
+  </ItemGroup>
+
+  <ItemGroup>
+    <Folder Include="Reports\" />
+  </ItemGroup>
+
 </Project>

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 5642 - 0
MTWorkHR.Infrastructure/Migrations/20241029101807_altrUserCompany_addNationality.Designer.cs


+ 375 - 0
MTWorkHR.Infrastructure/Migrations/20241029101807_altrUserCompany_addNationality.cs

@@ -0,0 +1,375 @@
+using System;
+using Microsoft.EntityFrameworkCore.Migrations;
+
+#nullable disable
+
+#pragma warning disable CA1814 // Prefer jagged arrays over multidimensional
+
+namespace MTWorkHR.Infrastructure.Migrations
+{
+    /// <inheritdoc />
+    public partial class altrUserCompany_addNationality : Migration
+    {
+        /// <inheritdoc />
+        protected override void Up(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.AddColumn<int>(
+                name: "ContractStatusId",
+                table: "Contracts",
+                type: "int",
+                nullable: false,
+                defaultValue: 0);
+
+            migrationBuilder.AddColumn<int>(
+                name: "ContractorTaxResidencyId",
+                table: "Contracts",
+                type: "int",
+                nullable: false,
+                defaultValue: 0);
+
+            migrationBuilder.AddColumn<int>(
+                name: "Address",
+                table: "Companies",
+                type: "int",
+                nullable: false,
+                defaultValue: 0);
+
+            migrationBuilder.AddColumn<int>(
+                name: "Email",
+                table: "Companies",
+                type: "int",
+                nullable: false,
+                defaultValue: 0);
+
+            migrationBuilder.AddColumn<int>(
+                name: "PhoneNumber",
+                table: "Companies",
+                type: "int",
+                nullable: false,
+                defaultValue: 0);
+
+            migrationBuilder.AddColumn<string>(
+                name: "CompanyRepresentativeTitle",
+                table: "AspNetUsers",
+                type: "nvarchar(max)",
+                nullable: true);
+
+            migrationBuilder.AddColumn<long>(
+                name: "NationalityId",
+                table: "AspNetUsers",
+                type: "bigint",
+                nullable: true);
+
+            migrationBuilder.AddColumn<DateTime>(
+                name: "PassportExpiryDate",
+                table: "AspNetUsers",
+                type: "datetime2",
+                nullable: true);
+
+            migrationBuilder.CreateTable(
+                name: "Nationalities",
+                columns: table => new
+                {
+                    Id = table.Column<long>(type: "bigint", nullable: false)
+                        .Annotation("SqlServer:Identity", "1, 1"),
+                    NameAr = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
+                    NameEn = table.Column<string>(type: "nvarchar(250)", maxLength: 250, nullable: false),
+                    CountryCode = table.Column<string>(type: "nvarchar(max)", nullable: true),
+                    CountryId = table.Column<string>(type: "nvarchar(max)", nullable: true)
+                },
+                constraints: table =>
+                {
+                    table.PrimaryKey("PK_Nationalities", x => x.Id);
+                });
+
+            migrationBuilder.UpdateData(
+                table: "AspNetUsers",
+                keyColumn: "Id",
+                keyValue: "ADMB3B92-2311-48F8-9DEC-F9FAEF1F21UA",
+                columns: new[] { "CompanyRepresentativeTitle", "NationalityId", "PassportExpiryDate" },
+                values: new object[] { null, null, null });
+
+            migrationBuilder.UpdateData(
+                table: "AspNetUsers",
+                keyColumn: "Id",
+                keyValue: "AL5B3B92-2311-48F8-9DEC-F9FAEF1F21UB",
+                columns: new[] { "CompanyRepresentativeTitle", "NationalityId", "PassportExpiryDate" },
+                values: new object[] { null, null, null });
+
+            migrationBuilder.InsertData(
+                table: "Nationalities",
+                columns: new[] { "Id", "CountryCode", "CountryId", "NameAr", "NameEn" },
+                values: new object[,]
+                {
+                    { 1L, "AF", null, "أفغاني", "Afghan" },
+                    { 2L, "AL", null, "ألباني", "Albanian" },
+                    { 3L, "DZ", null, "جزائري", "Algerian" },
+                    { 4L, "AS", null, "أمريكي ساموي", "American Samoan" },
+                    { 5L, "US", null, "أمريكي", "American" },
+                    { 6L, "AD", null, "أندوري", "Andorran" },
+                    { 7L, "AO", null, "أنغولي", "Angolan" },
+                    { 8L, "AI", null, "أنغويلي", "Anguillian" },
+                    { 9L, "AG", null, "أنتيغي", "Antiguan" },
+                    { 10L, "AR", null, "أرجنتيني", "Argentinian" },
+                    { 11L, "AM", null, "أرميني", "Armenian" },
+                    { 12L, "AW", null, "أروبي", "Aruban" },
+                    { 13L, "AU", null, "أسترالي", "Australian" },
+                    { 14L, "AT", null, "نمساوي", "Austrian" },
+                    { 15L, "AZ", null, "أذربيجاني", "Azerbaijani" },
+                    { 16L, "BS", null, "باهامي", "Bahamian" },
+                    { 17L, "BH", null, "بحريني", "Bahraini" },
+                    { 18L, "BD", null, "بنغلاديشي", "Bangladeshi" },
+                    { 19L, "BB", null, "باربادوسي", "Barbadian" },
+                    { 20L, "BY", null, "بيلاروسي", "Belarusian" },
+                    { 21L, "BE", null, "بلجيكي", "Belgian" },
+                    { 22L, "BZ", null, "بليزي", "Belizean" },
+                    { 23L, "BJ", null, "بنيني", "Beninese" },
+                    { 24L, "BT", null, "بوتاني", "Bhutanese" },
+                    { 25L, "BO", null, "بوليفي", "Bolivian" },
+                    { 26L, "BA", null, "بوسني", "Bosnian" },
+                    { 27L, "BR", null, "برازيلي", "Brazilian" },
+                    { 28L, "GB", null, "بريطاني", "British" },
+                    { 29L, "BN", null, "بروني", "Bruneian" },
+                    { 30L, "BG", null, "بلغاري", "Bulgarian" },
+                    { 31L, "BF", null, "بوركيني", "Burkinabe" },
+                    { 32L, "MM", null, "بورمي", "Burmese" },
+                    { 33L, "BI", null, "بوروندي", "Burundian" },
+                    { 34L, "KH", null, "كمبودي", "Cambodian" },
+                    { 35L, "CM", null, "كاميروني", "Cameroonian" },
+                    { 36L, "CA", null, "كندي", "Canadian" },
+                    { 37L, "CV", null, "الرأس الأخضر", "Cape Verdean" },
+                    { 38L, "CF", null, "أفريقي أوسط", "Central African" },
+                    { 39L, "TD", null, "تشادي", "Chadian" },
+                    { 40L, "CL", null, "تشيلي", "Chilean" },
+                    { 41L, "CN", null, "صيني", "Chinese" },
+                    { 42L, "CO", null, "كولومبي", "Colombian" },
+                    { 43L, "KM", null, "قُمُري", "Comorian" },
+                    { 44L, "CG", null, "كونغولي", "Congolese" },
+                    { 45L, "CR", null, "كوستاريكي", "Costa Rican" },
+                    { 46L, "HR", null, "كرواتي", "Croatian" },
+                    { 47L, "CU", null, "كوبي", "Cuban" },
+                    { 48L, "CY", null, "قبرصي", "Cypriot" },
+                    { 49L, "CZ", null, "تشيكي", "Czech" },
+                    { 50L, "DK", null, "دنماركي", "Danish" },
+                    { 51L, "DJ", null, "جيبوتي", "Djiboutian" },
+                    { 52L, "DO", null, "دومينيكاني", "Dominican" },
+                    { 53L, "NL", null, "هولندي", "Dutch" },
+                    { 54L, "EC", null, "إكوادوري", "Ecuadorean" },
+                    { 55L, "EG", null, "مصري", "Egyptian" },
+                    { 56L, "AE", null, "إماراتي", "Emirati" },
+                    { 57L, "GQ", null, "غيني استوائي", "Equatorial Guinean" },
+                    { 58L, "ER", null, "إريتيري", "Eritrean" },
+                    { 59L, "EE", null, "إستوني", "Estonian" },
+                    { 60L, "ET", null, "أثيوبي", "Ethiopian" },
+                    { 61L, "FJ", null, "فيجي", "Fijian" },
+                    { 62L, "FI", null, "فنلندي", "Finnish" },
+                    { 63L, "FR", null, "فرنسي", "French" },
+                    { 64L, "GA", null, "غابوني", "Gabonese" },
+                    { 65L, "GM", null, "غامبي", "Gambian" },
+                    { 66L, "GE", null, "جورجي", "Georgian" },
+                    { 67L, "DE", null, "ألماني", "German" },
+                    { 68L, "GH", null, "غاني", "Ghanaian" },
+                    { 69L, "GI", null, "جبل طارق", "Gibraltarian" },
+                    { 70L, "GR", null, "يوناني", "Greek" },
+                    { 71L, "GL", null, "جرينلندي", "Greenlandic" },
+                    { 72L, "GD", null, "غرينادي", "Grenadian" },
+                    { 73L, "GU", null, "غوامي", "Guamanian" },
+                    { 74L, "GT", null, "غواتيمالي", "Guatemalan" },
+                    { 75L, "GN", null, "غيني", "Guinean" },
+                    { 76L, "GW", null, "غيني", "Guinean" },
+                    { 77L, "GY", null, "غياني", "Guyanese" },
+                    { 78L, "HT", null, "هايتي", "Haitian" },
+                    { 79L, "HN", null, "هندوراسي", "Honduran" },
+                    { 80L, "HK", null, "هونغ كونغي", "Hong Konger" },
+                    { 81L, "HU", null, "مجري", "Hungarian" },
+                    { 82L, "IS", null, "آيسلندي", "Icelander" },
+                    { 83L, "IN", null, "هندي", "Indian" },
+                    { 84L, "ID", null, "إندونيسي", "Indonesian" },
+                    { 85L, "IR", null, "إيراني", "Iranian" },
+                    { 86L, "IQ", null, "عراقي", "Iraqi" },
+                    { 87L, "IE", null, "إيرلندي", "Irish" },
+                    { 89L, "IT", null, "إيطالي", "Italian" },
+                    { 90L, "JM", null, "جامايكي", "Jamaican" },
+                    { 91L, "JP", null, "ياباني", "Japanese" },
+                    { 92L, "JE", null, "جيرسي", "Jersey" },
+                    { 93L, "JO", null, "أردني", "Jordanian" },
+                    { 94L, "KZ", null, "كازاخي", "Kazakh" },
+                    { 95L, "KE", null, "كيني", "Kenyan" },
+                    { 96L, "KI", null, "كيريباتي", "Kiribati" },
+                    { 97L, "KP", null, "كوري شمالي", "North Korean" },
+                    { 98L, "KR", null, "كوري جنوبي", "South Korean" },
+                    { 99L, "KW", null, "كويتي", "Kuwaiti" },
+                    { 100L, "KG", null, "قرغيزستاني", "Kyrgyzstani" },
+                    { 101L, "LA", null, "لاوي", "Lao" },
+                    { 102L, "LV", null, "لاتفي", "Latvian" },
+                    { 103L, "LB", null, "لبناني", "Lebanese" },
+                    { 104L, "LS", null, "ليسوتو", "Lesotho" },
+                    { 105L, "LR", null, "ليبيريي", "Liberian" },
+                    { 106L, "LY", null, "ليبي", "Libyan" },
+                    { 107L, "LI", null, "ليختنشتايني", "Liechtensteiner" },
+                    { 108L, "LT", null, "ليتواني", "Lithuanian" },
+                    { 109L, "LU", null, "لوكسمبورغي", "Luxembourgish" },
+                    { 110L, "MG", null, "ملغاشي", "Malagasy" },
+                    { 111L, "MW", null, "ملووي", "Malawian" },
+                    { 112L, "MY", null, "ماليزيا", "Malaysian" },
+                    { 113L, "MV", null, "مالديفي", "Maldivian" },
+                    { 114L, "ML", null, "مالي", "Malian" },
+                    { 115L, "MT", null, "مالطي", "Maltese" },
+                    { 116L, "MH", null, "مارشالي", "Marshallese" },
+                    { 117L, "MR", null, "موريتاني", "Mauritanian" },
+                    { 118L, "MU", null, "موريشيوسي", "Mauritian" },
+                    { 119L, "MX", null, "مكسيكي", "Mexican" },
+                    { 120L, "FM", null, "ماكروني", "Micronesian" },
+                    { 121L, "MD", null, "مولدوفي", "Moldovan" },
+                    { 122L, "MC", null, "موناكي", "Monacan" },
+                    { 123L, "MN", null, "منغولي", "Mongolian" },
+                    { 124L, "ME", null, "مونتينيغري", "Montenegrin" },
+                    { 125L, "MA", null, "مغربي", "Moroccan" },
+                    { 126L, "MZ", null, "موزمبيقي", "Mozambican" },
+                    { 127L, "NA", null, "ناميبي", "Namibian" },
+                    { 128L, "NR", null, "نيواروي", "Nauruan" },
+                    { 129L, "NP", null, "نيبالي", "Nepali" },
+                    { 130L, "NL", null, "هولندي", "Dutch" },
+                    { 131L, "NZ", null, "نيوزيلندي", "New Zealander" },
+                    { 132L, "NI", null, "نيكاراغوي", "Nicaraguan" },
+                    { 133L, "NE", null, "نيجيري", "Nigerien" },
+                    { 134L, "NG", null, "نيجيري", "Nigerian" },
+                    { 135L, "MK", null, "مقدوني شمالي", "North Macedonian" },
+                    { 136L, "NO", null, "نرويجي", "Norwegian" },
+                    { 137L, "OM", null, "عماني", "Omani" },
+                    { 138L, "PK", null, "باكستاني", "Pakistani" },
+                    { 139L, "PW", null, "بالاوي", "Palauan" },
+                    { 140L, "PA", null, "بنمي", "Panamanian" },
+                    { 141L, "PG", null, "بابوا غينيا الجديدة", "Papua New Guinean" },
+                    { 142L, "PY", null, "باراغواني", "Paraguayan" },
+                    { 143L, "PE", null, "بيروفي", "Peruvian" },
+                    { 144L, "PH", null, "فلبيني", "Filipino" },
+                    { 145L, "PL", null, "بولندي", "Polish" },
+                    { 146L, "PT", null, "برتغالي", "Portuguese" },
+                    { 147L, "QA", null, "قطري", "Qatari" },
+                    { 148L, "RE", null, "لا ريونيون", "Réunionese" },
+                    { 149L, "RO", null, "روماني", "Romanian" },
+                    { 150L, "RU", null, "روسي", "Russian" },
+                    { 151L, "RW", null, "رواندي", "Rwandan" },
+                    { 152L, "BL", null, "سانت بارتيليمي", "Saint Barthélemy" },
+                    { 153L, "SH", null, "سانت هيلاني", "Saint Helenian" },
+                    { 154L, "KN", null, "سانت كيتس ونيفيس", "Saint Kitts and Nevis" },
+                    { 155L, "LC", null, "سانت لوسيان", "Saint Lucian" },
+                    { 156L, "MF", null, "سانت مارتن", "Saint Martin" },
+                    { 157L, "SX", null, "سانت مارتن", "Sint Maarten" },
+                    { 158L, "WS", null, "سماوي", "Samoan" },
+                    { 159L, "SM", null, "سانماريني", "Sammarinese" },
+                    { 160L, "ST", null, "ساو توماني", "Sao Tomean" },
+                    { 161L, "SA", null, "سعودي", "Saudi" },
+                    { 162L, "SN", null, "سنغالي", "Senegalese" },
+                    { 163L, "RS", null, "صربي", "Serbian" },
+                    { 164L, "SC", null, "سيشلي", "Seychellois" },
+                    { 165L, "SL", null, "سيراليوني", "Sierra Leonean" },
+                    { 166L, "SG", null, "سنغافوري", "Singaporean" },
+                    { 167L, "SK", null, "سلوفاكي", "Slovak" },
+                    { 168L, "SI", null, "سلوفيني", "Slovenian" },
+                    { 169L, "SB", null, "سولوموني", "Solomon Islander" },
+                    { 170L, "SO", null, "صومالي", "Somali" },
+                    { 171L, "ZA", null, "جنوب أفريقي", "South African" },
+                    { 172L, "SS", null, "جنوب سوداني", "South Sudanese" },
+                    { 173L, "ES", null, "إسباني", "Spanish" },
+                    { 174L, "LK", null, "سريلانكي", "Sri Lankan" },
+                    { 175L, "SD", null, "سوداني", "Sudanese" },
+                    { 176L, "SR", null, "سورينامي", "Surinamese" },
+                    { 177L, "SZ", null, "سواتي", "Swazi" },
+                    { 178L, "SE", null, "سويدي", "Swedish" },
+                    { 179L, "CH", null, "سويسري", "Swiss" },
+                    { 180L, "SY", null, "سوري", "Syrian" },
+                    { 181L, "TW", null, "تايواني", "Taiwanese" },
+                    { 182L, "TJ", null, "طاجيكي", "Tajik" },
+                    { 183L, "TZ", null, "تنزاني", "Tanzanian" },
+                    { 184L, "TH", null, "تايلندي", "Thai" },
+                    { 185L, "TL", null, "تيموري", "Timorese" },
+                    { 186L, "TG", null, "توغولي", "Togolese" },
+                    { 187L, "TK", null, "توكلاوي", "Tokelauan" },
+                    { 188L, "TO", null, "تونغي", "Tongan" },
+                    { 189L, "TT", null, "ترينيدادي", "Trinidadian" },
+                    { 190L, "TN", null, "تونسي", "Tunisian" },
+                    { 191L, "TR", null, "تركي", "Turkish" },
+                    { 192L, "TM", null, "تركماني", "Turkmen" },
+                    { 193L, "TC", null, "تركي وكايكوسي", "Turks and Caicos Islander" },
+                    { 194L, "TV", null, "توفالي", "Tuvaluan" },
+                    { 195L, "UG", null, "أوغندي", "Ugandan" },
+                    { 196L, "UA", null, "أوكراني", "Ukrainian" },
+                    { 197L, "AE", null, "إماراتي", "Emirati" },
+                    { 198L, "GB", null, "بريطاني", "British" },
+                    { 199L, "US", null, "أمريكي", "American" },
+                    { 200L, "UY", null, "أوروغواي", "Uruguayan" },
+                    { 201L, "UZ", null, "أوزبكي", "Uzbek" },
+                    { 202L, "VU", null, "فانواتي", "Vanuatuan" },
+                    { 203L, "VE", null, "فنزويلي", "Venezuelan" },
+                    { 204L, "VN", null, "فيتنامي", "Vietnamese" },
+                    { 205L, "WF", null, "واليس وفوتونا", "Wallis and Futuna" },
+                    { 206L, "YE", null, "يمني", "Yemeni" },
+                    { 207L, "ZM", null, "زامبي", "Zambian" },
+                    { 208L, "ZW", null, "زيمبابوي", "Zimbabwean" }
+                });
+
+            migrationBuilder.CreateIndex(
+                name: "IX_AspNetUsers_NationalityId",
+                table: "AspNetUsers",
+                column: "NationalityId");
+
+            migrationBuilder.AddForeignKey(
+                name: "FK_AspNetUsers_Nationalities_NationalityId",
+                table: "AspNetUsers",
+                column: "NationalityId",
+                principalTable: "Nationalities",
+                principalColumn: "Id");
+            var sqlStm = @"update Nationalities set CountryId = (select top 1 id from CountryLookups where UPPER(CountryCode)=UPPER(code))";
+            migrationBuilder.Sql(sqlStm);
+        }
+
+        /// <inheritdoc />
+        protected override void Down(MigrationBuilder migrationBuilder)
+        {
+            migrationBuilder.DropForeignKey(
+                name: "FK_AspNetUsers_Nationalities_NationalityId",
+                table: "AspNetUsers");
+
+            migrationBuilder.DropTable(
+                name: "Nationalities");
+
+            migrationBuilder.DropIndex(
+                name: "IX_AspNetUsers_NationalityId",
+                table: "AspNetUsers");
+
+            migrationBuilder.DropColumn(
+                name: "ContractStatusId",
+                table: "Contracts");
+
+            migrationBuilder.DropColumn(
+                name: "ContractorTaxResidencyId",
+                table: "Contracts");
+
+            migrationBuilder.DropColumn(
+                name: "Address",
+                table: "Companies");
+
+            migrationBuilder.DropColumn(
+                name: "Email",
+                table: "Companies");
+
+            migrationBuilder.DropColumn(
+                name: "PhoneNumber",
+                table: "Companies");
+
+            migrationBuilder.DropColumn(
+                name: "CompanyRepresentativeTitle",
+                table: "AspNetUsers");
+
+            migrationBuilder.DropColumn(
+                name: "NationalityId",
+                table: "AspNetUsers");
+
+            migrationBuilder.DropColumn(
+                name: "PassportExpiryDate",
+                table: "AspNetUsers");
+        }
+    }
+}

Rozdílová data souboru nebyla zobrazena, protože soubor je příliš velký
+ 1748 - 228
MTWorkHR.Infrastructure/Migrations/HRDataContextModelSnapshot.cs


+ 14 - 0
MTWorkHR.Infrastructure/appsettings.json

@@ -0,0 +1,14 @@
+{
+  "connectionStrings": {
+    "localhost_MTWorkHRDB_Connection": "data source=localhost;integrated security=True;initial catalog=MTWorkHRDB;Encrypt=False;MultipleActiveResultSets=true"
+
+  },
+  "exclude": [
+    "**/bin",
+    "**/bower_components",
+    "**/jspm_packages",
+    "**/node_modules",
+    "**/obj",
+    "**/platforms"
+  ]
+}