This commit is contained in:
nadira 2026-06-16 17:31:08 +06:00
commit b71003f000
25 changed files with 5848 additions and 3095 deletions

1
.gitignore vendored
View File

@ -17,4 +17,5 @@ obj
/UpgradeLog5.htm
/UpgradeLog7.htm
/OnlineSalesAutoCrop/App_Data/RadUploadTemp
/OnlineSalesAutoCrop/App/ClientApp/node_modules
/App/ClientApp/node_modules

View File

@ -53,11 +53,12 @@ namespace OnlineSalesAutoCrop.CoreAPI.Models.Global
public string JwtAudience { get; set; }
public bool JwtValidateIssuer { get; set; }
public bool JwtValidateAudience { get; set; }
/// <summary>
/// Folder management
/// </summary>
public string UploadFolder { get; set; }
public int RefreshTokenDuration { get; set; }
/// <summary>
/// Folder management
/// </summary>
public string UploadFolder { get; set; }
public string ProfileImageFolder { get; set; }
public string ReportFolder { get; set; }
public string FileProcessFolder { get; set; }
@ -85,6 +86,7 @@ namespace OnlineSalesAutoCrop.CoreAPI.Models.Global
public string EmailSenderIp { get; set; }
public string EmailSenderId { get; set; }
private string _emailSenderPwd;
public string EmailSenderPwd
{

View File

@ -0,0 +1,57 @@
namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Integrations;
public class CustomerIntegration
{
public int CustomerId { get; set; }
public string CustomerNumber { get; set; }
public string CustomerName { get; set; }
public string AccountGroup { get; set; }
public string AccountGroupDescription { get; set; }
public string CompanyCode { get; set; }
public string CompanyCodeDescription { get; set; }
public string SalesOrganization { get; set; }
public string SalesOrganizationDescription { get; set; }
public string DistributionChannel { get; set; }
public string DistributionChannelDescription { get; set; }
public string Division { get; set; }
public string DivisionDescription { get; set; }
public string MobileNumber { get; set; }
public string EmailAddress { get; set; }
public string BusinessTaxNumber { get; set; }
public decimal? CreditLimit { get; set; }
public string SalesOffice { get; set; }
public string SalesOfficeDescription { get; set; }
public string SalesGroup { get; set; }
public string CustomerGroup { get; set; }
public string Status { get; set; }
public string PaymentTerms { get; set; }
public string SearchTerm { get; set; }
public string Region { get; set; }
public string RegionName { get; set; }
public string Area { get; set; }
public string AreaName { get; set; }
public string SalesUnit { get; set; }
public string SalesUnitName { get; set; }
public string Territory { get; set; }
public string TerritoryName { get; set; }
public string Plant { get; set; }
public string PlantName { get; set; }
}

View File

@ -0,0 +1,16 @@
using System;
namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems;
public class RefreshToken
{
public int Id { get; set; }
public int UserId { get; set; }
public string TokenHash { get; set; } = string.Empty;
public string DeviceInfo { get; set; } = string.Empty;
public string IpAddress { get; set; } = string.Empty;
public DateTime CreatedAt { get; set; }
public DateTime ExpiresAt { get; set; }
public DateTime? RevokedAt { get; set; }
public bool IsActive => RevokedAt == null && ExpiresAt > DateTime.UtcNow;
}

View File

@ -1,6 +1,4 @@
using OnlineSalesAutoCrop.CoreAPI.Models.Global;
using System;
using System.Collections.Generic;
using System;
namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems
{
@ -9,9 +7,9 @@ namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems
public const int SuperUser_Id = -9;
public const string SuperUser_LoginId = "superuser";
public int Id { get; set; }
public int UserId { get; set; }
public string LoginId { get; set; }
public int LogId { get; set; }
public string Password { get; set; }
public DateTime? LogoutTime { get; set; }
public string UserName { get; set; }
public EnumStatus Status { get; set; }
@ -19,17 +17,6 @@ namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems
public bool NeverExpires { get; set; }
public string LastPasswords { get; set; }
public DateTime? LastPassChgDate { get; set; }
public DateTime? ExpireDate { get; set; }
public DateTime? NextLoginTime { get; set; }
public DateTime SystemDate { get; set; }
public bool DbOnStartup { get; set; }
public bool ViewOwnTaskOnly { get; set; }
public int? EmployeeId { get; set; }
public string EmployeeCode { get; set; }
public EnumLoginStatus LoginStatus { get; set; }
public EnumAuthenticationMethod AuthMethod { get; set; }
public bool AuthRequiredAtLogin { get; set; }
public List<string> ModuleIds { get; set; }
public string EmailAddress { get; set; }
public string AuthKey { get; set; }
public string AuthValue { get; set; }
@ -39,18 +26,10 @@ namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems
public string SchemeName { get; set; }
public string MenuLayout { get; set; }
public bool IsLocked { get; set; }
public DateTime MinReportDate { get; set; }
public string AppId { get; set; }
public bool DisallowMultiLogin { get; set; }
public bool BatchEnabled { get; set; }
public int BmProcessId { get; set; }
public int PrProcessId { get; set; }
public int IdleTime { get; set; }
public int PingTime { get; set; }
public int TimeoutTime { get; set; }
public int NotificationCount { get; set; }
public List<int> TeamSpaceIds { get; set; }
}
public EnumLoginStatus LoginStatus { get; set; }
public DateTime? NextLoginTime { get; set; }
}
public class LoginHistory
{
@ -63,39 +42,15 @@ namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems
public class AccessLog
{
public int AccessLogId { get; set; }
public int UserId { get; set; }
public string LoginId { get; set; }
public DateTime LoginTime { get; set; }
public string LoginIp { get; set; }
public DateTime? LogoutTime { get; set; }
public string LogoutIp { get; set; }
public string LoginStatus { get; set; }
}
public class DashboardItem
{
public string DivStyleCss { get; set; }
public string Title { get; set; }
public string TitleCss { get; set; }
public string Value { get; set; }
public string ValueCss { get; set; }
public int Id { get; set; }
public string Href { get; set; }
}
public class Dashboard2Item
{
public string Title { get; set; }
public decimal Value { get; set; }
public string TitleStyle { get; set; }
public string ValueStyle { get; set; }
public string ValueFormat { get; set; }
}
public class Dashboard2Data
{
public string GroupName { get; set; }
public List<Dashboard2Item> Items { get; set; }
}
public EnumLoginStatus LoginStatus { get; set; }
}
public class UserForceLogout
{
@ -104,20 +59,6 @@ namespace OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems
public string UserName { get; set; }
}
public class UserSearch : UserForceLogout
{
public string Designation { get; set; }
public string MobileNo { get; set; }
public string EmailAddress { get; set; }
public EnumStatus Status { get; set; }
public short SeqId { get; set; }
public bool CanUseAttendanceSystem { get; set; }
public bool IsLocked { get; set; }
public string AuthId { get; set; }
public string StatusDetail => Status.GetDescription();
}
public class UserBasicInfo
{
public int UserId { get; set; }

View File

@ -0,0 +1,155 @@
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Text;
namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
public class CustomerIntegrationRequest
{
[Required(ErrorMessage = "Customer Number is required")]
[StringLength(10, MinimumLength = 1, ErrorMessage = "Customer Number must be between 1 and 10 characters")]
public string CustomerNumber { get; set; } = string.Empty;
[Required(ErrorMessage = "Customer Name is required")]
[StringLength(35, MinimumLength = 1, ErrorMessage = "Customer Name must be between 1 and 35 characters")]
public string CustomerName { get; set; } = string.Empty;
[Required(ErrorMessage = "Account Group is required")]
[StringLength(3, MinimumLength = 1, ErrorMessage = "Account Group must be between 1 and 3 characters")]
public string AccountGroup { get; set; } = string.Empty;
[Required(ErrorMessage = "Account Group Description is required")]
[StringLength(30, ErrorMessage = "Account Group Description cannot exceed 30 characters")]
public string AccountGroupDescription { get; set; } = string.Empty;
[Required(ErrorMessage = "Company Code is required")]
[StringLength(4, MinimumLength = 1, ErrorMessage = "Company Code must be between 1 and 4 characters")]
public string CompanyCode { get; set; } = string.Empty;
[Required(ErrorMessage = "Company Code Description is required")]
[StringLength(25, ErrorMessage = "Company Code Description cannot exceed 25 characters")]
public string CompanyCodeDescription { get; set; } = string.Empty;
[Required(ErrorMessage = "Sales Organization is required")]
[StringLength(4, MinimumLength = 1, ErrorMessage = "Sales Organization must be between 1 and 4 characters")]
public string SalesOrganization { get; set; } = string.Empty;
[Required(ErrorMessage = "Sales Organization Description is required")]
[StringLength(40, ErrorMessage = "Sales Organization Description cannot exceed 40 characters")]
public string SalesOrganizationDescription { get; set; } = string.Empty;
[Required(ErrorMessage = "Distribution Channel is required")]
[StringLength(2, MinimumLength = 1, ErrorMessage = "Distribution Channel must be between 1 and 2 characters")]
public string DistributionChannel { get; set; } = string.Empty;
[Required(ErrorMessage = "Distribution Channel Description is required")]
[StringLength(20, ErrorMessage = "Distribution Channel Description cannot exceed 20 characters")]
public string DistributionChannelDescription { get; set; } = string.Empty;
[Required(ErrorMessage = "Division is required")]
[StringLength(2, MinimumLength = 1, ErrorMessage = "Division must be between 1 and 2 characters")]
public string Division { get; set; } = string.Empty;
[Required(ErrorMessage = "Division Description is required")]
[StringLength(20, ErrorMessage = "Division Description cannot exceed 20 characters")]
public string DivisionDescription { get; set; } = string.Empty;
[Required(ErrorMessage = "Mobile Number is required")]
[StringLength(31, ErrorMessage = "Mobile Number cannot exceed 31 characters")]
[Phone(ErrorMessage = "Invalid mobile number format")]
public string MobileNumber { get; set; } = string.Empty;
[Required(ErrorMessage = "Email Address is required")]
[StringLength(241, ErrorMessage = "Email Address cannot exceed 241 characters")]
[EmailAddress(ErrorMessage = "Invalid email address format")]
public string EmailAddress { get; set; } = string.Empty;
[Required(ErrorMessage = "Business/Tax Number is required")]
[StringLength(16, ErrorMessage = "Business/Tax Number cannot exceed 16 characters")]
public string BusinessTaxNumber { get; set; } = string.Empty;
[Required(ErrorMessage = "Credit Limit is required")]
[Range(0, 9999999999999, ErrorMessage = "Credit Limit must be a valid number")]
public decimal CreditLimit { get; set; }
[Required(ErrorMessage = "Sales Office is required")]
[StringLength(4, MinimumLength = 1, ErrorMessage = "Sales Office must be between 1 and 4 characters")]
public string SalesOffice { get; set; } = string.Empty;
[StringLength(255, ErrorMessage = "Sales Office Description cannot exceed 255 characters")]
public string? SalesOfficeDescription { get; set; }
[Required(ErrorMessage = "Sales Group is required")]
[StringLength(3, MinimumLength = 1, ErrorMessage = "Sales Group must be between 1 and 3 characters")]
public string SalesGroup { get; set; } = string.Empty;
[Required(ErrorMessage = "Customer Group is required")]
[StringLength(2, MinimumLength = 1, ErrorMessage = "Customer Group must be between 1 and 2 characters")]
public string CustomerGroup { get; set; } = string.Empty;
[Required(ErrorMessage = "Status is required")]
[StringLength(1, MinimumLength = 1, ErrorMessage = "Status must be exactly 1 character")]
public string Status { get; set; } = string.Empty;
[Required(ErrorMessage = "Payment Terms are required")]
[StringLength(4, MinimumLength = 1, ErrorMessage = "Payment Terms must be between 1 and 4 characters")]
public string PaymentTerms { get; set; } = string.Empty;
[Required(ErrorMessage = "Search Term is required")]
[StringLength(20, ErrorMessage = "Search Term cannot exceed 20 characters")]
public string SearchTerm { get; set; } = string.Empty;
[Required(ErrorMessage = "Region is required")]
[StringLength(3, MinimumLength = 1, ErrorMessage = "Region must be between 1 and 3 characters")]
public string Region { get; set; } = string.Empty;
[Required(ErrorMessage = "Region Name is required")]
[StringLength(40, ErrorMessage = "Region Name cannot exceed 40 characters")]
public string RegionName { get; set; } = string.Empty;
[Required(ErrorMessage = "Area is required")]
[StringLength(10, MinimumLength = 1, ErrorMessage = "Area must be between 1 and 10 characters")]
public string Area { get; set; } = string.Empty;
[Required(ErrorMessage = "Area Name is required")]
[StringLength(40, ErrorMessage = "Area Name cannot exceed 40 characters")]
public string AreaName { get; set; } = string.Empty;
[Required(ErrorMessage = "Sales Unit is required")]
[StringLength(3, MinimumLength = 1, ErrorMessage = "Sales Unit must be between 1 and 3 characters")]
public string SalesUnit { get; set; } = string.Empty;
[Required(ErrorMessage = "Sales Unit Name is required")]
[StringLength(30, ErrorMessage = "Sales Unit Name cannot exceed 30 characters")]
public string SalesUnitName { get; set; } = string.Empty;
[Required(ErrorMessage = "Territory is required")]
[StringLength(3, MinimumLength = 1, ErrorMessage = "Territory must be between 1 and 3 characters")]
public string Territory { get; set; } = string.Empty;
[Required(ErrorMessage = "Territory Name is required")]
[StringLength(20, ErrorMessage = "Territory Name cannot exceed 20 characters")]
public string TerritoryName { get; set; } = string.Empty;
[Required(ErrorMessage = "Plant is required")]
[StringLength(4, MinimumLength = 1, ErrorMessage = "Plant must be between 1 and 4 characters")]
public string Plant { get; set; } = string.Empty;
[Required(ErrorMessage = "Plant Name is required")]
[StringLength(30, ErrorMessage = "Plant Name cannot exceed 30 characters")]
public string PlantName { get; set; } = string.Empty;
}
public class CustomerByCompanyCodeRequest
{
[Required(ErrorMessage = "Customer Number is required")]
[StringLength(10, MinimumLength = 1, ErrorMessage = "Customer Number must be between 1 and 10 characters")]
public string CustomerNumber { get; set; } = string.Empty;
[Required(ErrorMessage = "Company Code is required")]
[StringLength(4, MinimumLength = 1, ErrorMessage = "Company Code must be between 1 and 4 characters")]
public string CompanyCode { get; set; } = string.Empty;
}

View File

@ -0,0 +1,41 @@
using OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems;
using System;
using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
using System.Text;
namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
public class IntegrationLoginRequest
{
[Required, NotNull, StringLength(maximumLength: 150, MinimumLength = 3, ErrorMessage = "Login Id must be between 4 and 30 characters.")]
public string LoginId { get; set; }
[Required, NotNull, StringLength(maximumLength: 150, MinimumLength = 5, ErrorMessage = "Password must be between 1 and 30 characters.")]
public string Password { get; set; }
public string RefreshToken { get; set; }
}
public class IntegrationRefreshTokenRequest
{
public string RefreshToken { get; set; }
}
public class InsertRefreshTokenRequest : RefreshToken
{
public string RefreshToken { get; set; }
}
public class RevokedRefreshTokenRequest
{
public string RefreshToken { get; set; }
public int UserId { get; set; }
}
public class GenerateRefreshTokenRequest
{
public User User { get; set; }
public string IpAddress { get; set; }
public string RawRefreshToken { get; set; }
}

View File

@ -3,219 +3,219 @@ using System.Collections.Generic;
using System.ComponentModel.DataAnnotations;
using System.Diagnostics.CodeAnalysis;
namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Systems
namespace OnlineSalesAutoCrop.CoreAPI.Models.Requests.Systems;
public class FindAccountRequest
{
public class FindAccountRequest
{
[Required, NotNull, StringLength(maximumLength: 200, MinimumLength = 4, ErrorMessage = "Login Id or Email address or Mobile number must be between 4 and 100 characters.")]
public string AccountId { get; set; }
}
public class LoginRequest
{
[Required, NotNull, StringLength(maximumLength: 150, MinimumLength = 4, ErrorMessage = "Login Id must be between 4 and 30 characters.")]
public string LoginId { get; set; }
[Required, NotNull, StringLength(maximumLength: 150, MinimumLength = 1, ErrorMessage = "Password must be between 1 and 30 characters.")]
public string Password { get; set; }
public string AppId { get; set; }
[Required, NotNull, StringLength(maximumLength: 8, MinimumLength = 5, ErrorMessage = "Version must be 5 and 8 digits (Example: 0.0.0 or 99.99.99)")]
public string AppVersion { get; set; }
public bool AttendanceLogin { get; set; }
public string HostName { get; set; }
public string IpAddress { get; set; }
public string MacAddress { get; set; }
public string LoginRemarks { get; set; }
}
public class OtpValidationRequest
{
public int UserId { get; set; }
public EnumAuthenticationMethod AuthMethod { get; set; }
[Required, NotNull, StringLength(6, MinimumLength = 6, ErrorMessage = "Otp must be 6 digit number.")]
public string OtpCode { get; set; }
}
public class ByUserIdRequest
{
public int UserId { get; set; }
}
public class SendPasswordRequest
{
[Required, NotNull, StringLength(maximumLength: 300, MinimumLength = 1, ErrorMessage = "User Id is required.")]
public string UserId { get; set; }
public string MobileNo { get; set; }
public string EmailAddress { get; set; }
}
public class UserUnlockRequest : ByUserIdRequest
{
[Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Login Id must be between 1 and 30 characters.")]
public string LoginId { get; set; }
}
public class ResetPasswordRequest : ByUserIdRequest
{
[Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Password must be between 1 and 30 characters.")]
public string Password { get; set; }
[Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Confirm Password must be between 1 and 30 characters.")]
public string ConfirmPassword { get; set; }
}
public class PasswordChangeRequest : ResetPasswordRequest
{
[Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Old Password must be between 1 and 30 characters.")]
public string OldPassword { get; set; }
}
public class LogoutRequest
{
public int LogId { get; set; }
public bool AttendanceLogout { get; set; }
public string IpAddress { get; set; }
public string MacAddress { get; set; }
public string HostName { get; set; }
public string LogoutRemarks { get; set; }
}
public class UserThemeRequest
{
[Required, NotNull, StringLength(15, MinimumLength = 1, ErrorMessage = "Menu Layout must be between 1 to 15 characters.")]
public string MenuLayout { get; set; }
[Required, NotNull, StringLength(15, MinimumLength = 1, ErrorMessage = "Theme Name must be between 1 to 15 characters.")]
public string ThemeName { get; set; }
[Required, NotNull, StringLength(10, MinimumLength = 1, ErrorMessage = "Scheme Name must be between 1 to 10 characters.")]
public string SchemeName { get; set; }
}
public class UserRequestBase
{
[Required, NotNull, StringLength(30, MinimumLength = 3, ErrorMessage = "Login Id must be between 3 to 30 characters.")]
public string LoginId { get; set; }
[Required, NotNull, StringLength(75, MinimumLength = 3, ErrorMessage = "User Name must be between 3 to 75 characters.")]
public string UserName { get; set; }
[Required, NotNull, StringLength(50, MinimumLength = 0, ErrorMessage = "Designation must be between 0 to 50 characters.")]
public string Designation { get; set; }
[StringLength(15, MinimumLength = 11, ErrorMessage = "Mobile number must be 11 characters.")]
[RegularExpression(@"^[01]{2}[123456789]{1}[0-9]{8}$", ErrorMessage = "Mobile number is invalid.")]
public string MobileNo { get; set; }
[Required, NotNull, StringLength(100, MinimumLength = 5, ErrorMessage = "Email address must be between 5 to 100 characters.")]
[RegularExpression(@"^(([a-zA-Z0-9_\-\.]+)\@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)(\s*;\s*|\s*$))*$", ErrorMessage = "Email address is invalid.")]
public string EmailAddress { get; set; } = string.Empty;
public bool AuthReqAtlogin { get; set; }
public bool NeverExpire { get; set; }
public bool DbOnStartup { get; set; }
public bool DisallowMultiLogin { get; set; }
public EnumStatus Status { get; set; }
public short SeqId { get; set; }
public bool ViewToAll { get; set; }
public bool CanUseAttendanceSystem { get; set; }
public EnumAuthenticationMethod AuthMethod { get; set; }
public EnumAccessStatus AccessStatus { get; set; }
public List<int> GroupIds { get; set; }
}
public class UserRequest : UserRequestBase
{
[Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Select valid user (1 to 99999999).")]
public int UserId { get; set; }
public string AuthKey { get; set; }
}
public class NewUserRequest : UserRequestBase
{
public int? EmployeeId { get; set; }
public string EmployeeCode { get; set; }
[Required, NotNull, StringLength(30, MinimumLength = 1, ErrorMessage = "User Name must be between 1 to 30 characters.")]
public string Password { get; set; }
}
public class UserSearchRequest : ValueStatusAndPageAndSortSearchRequest
{
public bool CheckOwner { get; set; }
}
public class ForceUserLogoutRequest
{
public List<int> UserIds { get; set; }
}
public class ByUserAttributesRequest : ByUserIdRequest
{
[Required, Range(minimum: 1, maximum: 3, ConvertValueInInvariantCulture = true, ErrorMessage = "Client type must be 1 to 3")]
public int ClientType { get; set; }
}
public class UpdateMyInfoRequest
{
[Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Employee Id must be 1 to 2147483647")]
public int EmployeeId { get; set; }
[NotNull, StringLength(120, MinimumLength = 0, ErrorMessage = "Address be between 0 to 120 characters.")]
public string Address { get; set; }
public string ContactNo { get; set; }
}
public class UserAttributesRequest
{
[Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Select valid user")]
public int UserId { get; set; }
[Required, Range(minimum: 1, maximum: 3, ConvertValueInInvariantCulture = true, ErrorMessage = "Client type must be 1 to 3")]
public int ClientType { get; set; }
public List<string> UkIds { get; set; }
}
public class AccessLogSearchRequest
{
public int AccessType { get; set; }
public string LoginId { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
public class ByTeamSpaceAndBasicUserRequest
{
public int TeamSpaceId { get; set; }
public int ProjectId { get; set; }
}
public class BasicUserByTeamSpaceRequest : ByTeamSpaceAndBasicUserRequest
{
public int UserId { get; set; }
}
public class BasicUserSearchRequest : BasicUserByTeamSpaceRequest
{
public bool ApplyFilter { get; set; }
}
public class UserLimitAuthorizeRequest
{
[Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Select valid user (1 to 99999999).")]
public int UserId { get; set; }
public decimal MaxAuthorizeAmount { get; set; }
}
public class PayslipRequest
{
[Required, NotNull]
public DateTime YearMonth { get; set; }
}
[Required, NotNull, StringLength(maximumLength: 200, MinimumLength = 4, ErrorMessage = "Login Id or Email address or Mobile number must be between 4 and 100 characters.")]
public string AccountId { get; set; }
}
public class LoginRequest
{
[Required, NotNull, StringLength(maximumLength: 150, MinimumLength = 4, ErrorMessage = "Login Id must be between 4 and 30 characters.")]
public string LoginId { get; set; }
[Required, NotNull, StringLength(maximumLength: 150, MinimumLength = 1, ErrorMessage = "Password must be between 1 and 30 characters.")]
public string Password { get; set; }
public string AppId { get; set; }
[Required, NotNull, StringLength(maximumLength: 8, MinimumLength = 5, ErrorMessage = "Version must be 5 and 8 digits (Example: 0.0.0 or 99.99.99)")]
public string AppVersion { get; set; }
public bool AttendanceLogin { get; set; }
public string HostName { get; set; }
public string IpAddress { get; set; }
public string MacAddress { get; set; }
public string LoginRemarks { get; set; }
}
public class OtpValidationRequest
{
public int UserId { get; set; }
public EnumAuthenticationMethod AuthMethod { get; set; }
[Required, NotNull, StringLength(6, MinimumLength = 6, ErrorMessage = "Otp must be 6 digit number.")]
public string OtpCode { get; set; }
}
public class ByUserIdRequest
{
public int UserId { get; set; }
}
public class SendPasswordRequest
{
[Required, NotNull, StringLength(maximumLength: 300, MinimumLength = 1, ErrorMessage = "User Id is required.")]
public string UserId { get; set; }
public string MobileNo { get; set; }
public string EmailAddress { get; set; }
}
public class UserUnlockRequest : ByUserIdRequest
{
[Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Login Id must be between 1 and 30 characters.")]
public string LoginId { get; set; }
}
public class ResetPasswordRequest : ByUserIdRequest
{
[Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Password must be between 1 and 30 characters.")]
public string Password { get; set; }
[Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Confirm Password must be between 1 and 30 characters.")]
public string ConfirmPassword { get; set; }
}
public class PasswordChangeRequest : ResetPasswordRequest
{
[Required, NotNull, StringLength(maximumLength: 30, MinimumLength = 1, ErrorMessage = "Old Password must be between 1 and 30 characters.")]
public string OldPassword { get; set; }
}
public class LogoutRequest
{
public int LogId { get; set; }
public bool AttendanceLogout { get; set; }
public string IpAddress { get; set; }
public string MacAddress { get; set; }
public string HostName { get; set; }
public string LogoutRemarks { get; set; }
}
public class UserThemeRequest
{
[Required, NotNull, StringLength(15, MinimumLength = 1, ErrorMessage = "Menu Layout must be between 1 to 15 characters.")]
public string MenuLayout { get; set; }
[Required, NotNull, StringLength(15, MinimumLength = 1, ErrorMessage = "Theme Name must be between 1 to 15 characters.")]
public string ThemeName { get; set; }
[Required, NotNull, StringLength(10, MinimumLength = 1, ErrorMessage = "Scheme Name must be between 1 to 10 characters.")]
public string SchemeName { get; set; }
}
public class UserRequestBase
{
[Required, NotNull, StringLength(30, MinimumLength = 3, ErrorMessage = "Login Id must be between 3 to 30 characters.")]
public string LoginId { get; set; }
[Required, NotNull, StringLength(75, MinimumLength = 3, ErrorMessage = "User Name must be between 3 to 75 characters.")]
public string UserName { get; set; }
[Required, NotNull, StringLength(50, MinimumLength = 0, ErrorMessage = "Designation must be between 0 to 50 characters.")]
public string Designation { get; set; }
[StringLength(15, MinimumLength = 11, ErrorMessage = "Mobile number must be 11 characters.")]
[RegularExpression(@"^[01]{2}[123456789]{1}[0-9]{8}$", ErrorMessage = "Mobile number is invalid.")]
public string MobileNo { get; set; }
[Required, NotNull, StringLength(100, MinimumLength = 5, ErrorMessage = "Email address must be between 5 to 100 characters.")]
[RegularExpression(@"^(([a-zA-Z0-9_\-\.]+)\@((\[[0-9]{1,3}\.[0-9]{1,3}\.[0-9]{1,3}\.)|(([a-zA-Z0-9\-]+\.)+))([a-zA-Z]{2,4}|[0-9]{1,3})(\]?)(\s*;\s*|\s*$))*$", ErrorMessage = "Email address is invalid.")]
public string EmailAddress { get; set; } = string.Empty;
public bool AuthReqAtlogin { get; set; }
public bool NeverExpire { get; set; }
public bool DbOnStartup { get; set; }
public bool DisallowMultiLogin { get; set; }
public EnumStatus Status { get; set; }
public short SeqId { get; set; }
public bool ViewToAll { get; set; }
public bool CanUseAttendanceSystem { get; set; }
public EnumAuthenticationMethod AuthMethod { get; set; }
public EnumAccessStatus AccessStatus { get; set; }
public List<int> GroupIds { get; set; }
}
public class UserRequest : UserRequestBase
{
[Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Select valid user (1 to 99999999).")]
public int UserId { get; set; }
public string AuthKey { get; set; }
}
public class NewUserRequest : UserRequestBase
{
public int? EmployeeId { get; set; }
public string EmployeeCode { get; set; }
[Required, NotNull, StringLength(30, MinimumLength = 1, ErrorMessage = "User Name must be between 1 to 30 characters.")]
public string Password { get; set; }
}
public class UserSearchRequest : ValueStatusAndPageAndSortSearchRequest
{
public bool CheckOwner { get; set; }
}
public class ForceUserLogoutRequest
{
public List<int> UserIds { get; set; }
}
public class ByUserAttributesRequest : ByUserIdRequest
{
[Required, Range(minimum: 1, maximum: 3, ConvertValueInInvariantCulture = true, ErrorMessage = "Client type must be 1 to 3")]
public int ClientType { get; set; }
}
public class UpdateMyInfoRequest
{
[Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Employee Id must be 1 to 2147483647")]
public int EmployeeId { get; set; }
[NotNull, StringLength(120, MinimumLength = 0, ErrorMessage = "Address be between 0 to 120 characters.")]
public string Address { get; set; }
public string ContactNo { get; set; }
}
public class UserAttributesRequest
{
[Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Select valid user")]
public int UserId { get; set; }
[Required, Range(minimum: 1, maximum: 3, ConvertValueInInvariantCulture = true, ErrorMessage = "Client type must be 1 to 3")]
public int ClientType { get; set; }
public List<string> UkIds { get; set; }
}
public class AccessLogSearchRequest
{
public int AccessType { get; set; }
public string LoginId { get; set; }
public DateTime StartDate { get; set; }
public DateTime EndDate { get; set; }
}
public class ByTeamSpaceAndBasicUserRequest
{
public int TeamSpaceId { get; set; }
public int ProjectId { get; set; }
}
public class BasicUserByTeamSpaceRequest : ByTeamSpaceAndBasicUserRequest
{
public int UserId { get; set; }
}
public class BasicUserSearchRequest : BasicUserByTeamSpaceRequest
{
public bool ApplyFilter { get; set; }
}
public class UserLimitAuthorizeRequest
{
[Required, Range(minimum: 1, maximum: int.MaxValue, ConvertValueInInvariantCulture = true, ErrorMessage = "Select valid user (1 to 99999999).")]
public int UserId { get; set; }
public decimal MaxAuthorizeAmount { get; set; }
}
public class PayslipRequest
{
[Required, NotNull]
public DateTime YearMonth { get; set; }
}

View File

@ -0,0 +1,62 @@
namespace OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
public class CustomerIntegrationResponse : ResponseBase
{
}
public class CustomerByCompanyCodeResponse : ResponseBase
{
public int CustomerId { get; set; }
public string CustomerNumber { get; set; }
public string CustomerName { get; set; }
public string AccountGroup { get; set; }
public string AccountGroupDescription { get; set; }
public string CompanyCode { get; set; }
public string CompanyCodeDescription { get; set; }
public string SalesOrganization { get; set; }
public string SalesOrganizationDescription { get; set; }
public string DistributionChannel { get; set; }
public string DistributionChannelDescription { get; set; }
public string Division { get; set; }
public string DivisionDescription { get; set; }
public string MobileNumber { get; set; }
public string EmailAddress { get; set; }
public string BusinessTaxNumber { get; set; }
public decimal? CreditLimit { get; set; }
public string SalesOffice { get; set; }
public string SalesOfficeDescription { get; set; }
public string SalesGroup { get; set; }
public string CustomerGroup { get; set; }
public string Status { get; set; }
public string PaymentTerms { get; set; }
public string SearchTerm { get; set; }
public string Region { get; set; }
public string RegionName { get; set; }
public string Area { get; set; }
public string AreaName { get; set; }
public string SalesUnit { get; set; }
public string SalesUnitName { get; set; }
public string Territory { get; set; }
public string TerritoryName { get; set; }
public string Plant { get; set; }
public string PlantName { get; set; }
}

View File

@ -0,0 +1,33 @@
using OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems;
using System;
using System.Collections.Generic;
using System.Text;
namespace OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
public class IntegrationLoginResponse : ResponseBase
{
public string LoginId { get; set; }
public string AccessToken { get; set; } = string.Empty;
public string RefreshToken { get; set; } = string.Empty;
public EnumLoginStatus LoginStatus { get; set; }
public DateTime AccessTokenExpiry { get; set; }
}
public class RefreshTokenResponse : ResponseBase
{
public string UserId { get; set; }
public string TokenHash { get; set; }
public string IpAddress { get; set; }
public DateTime ExpiredAt { get; set; }
public DateTime? RevokedAt { get; set; }
public string DeviceInfo { get; set; }
public bool IsActive { get; set; }
}
public class GenerateRefreshTokenResponse : ResponseBase
{
public string RefreshToken { get; set; }
public DateTime ExpireTime { get; set; }
}

View File

@ -48,30 +48,24 @@ namespace OnlineSalesAutoCrop.CoreAPI.Models.Responses.Systems
public void Map(User source)
{
Id = source.Id;
LogId = source.LogId;
Id = source.UserId;
LoginId = source.LoginId;
IdleTime = source.IdleTime;
UserName = source.UserName;
PingTime = source.PingTime;
ThemeName = source.ThemeName;
//ModuleIds = source.ModuleIds;
LogoutTime = source.LogoutTime;
SchemeName = source.SchemeName;
AuthMethod = source.AuthMethod;
MenuLayout = source.MenuLayout;
SystemDate = source.SystemDate;
EmployeeId = source.EmployeeId;
LoginStatus = source.LoginStatus;
DbOnStartup = source.DbOnStartup;
TimeoutTime = source.TimeoutTime;
BmProcessId = source.BmProcessId;
PrProcessId = source.PrProcessId;
BatchEnabled = source.BatchEnabled;
ViewOwnTaskOnly = source.ViewOwnTaskOnly;
NotificationCount = source.NotificationCount;
AuthRequiredAtLogin = source.AuthRequiredAtLogin;
IdsValue = Newtonsoft.Json.JsonConvert.SerializeObject(source.ModuleIds);
//DbOnStartup = source.DbOnStartup;
//TimeoutTime = source.TimeoutTime;
//BmProcessId = source.BmProcessId;
//PrProcessId = source.PrProcessId;
//BatchEnabled = source.BatchEnabled;
//ViewOwnTaskOnly = source.ViewOwnTaskOnly;
//NotificationCount = source.NotificationCount;
//AuthRequiredAtLogin = source.AuthRequiredAtLogin;
//IdsValue = Newtonsoft.Json.JsonConvert.SerializeObject(source.ModuleIds);
}
}
@ -118,19 +112,7 @@ namespace OnlineSalesAutoCrop.CoreAPI.Models.Responses.Systems
public List<LoginHistory> LoginHistories { get; set; }
}
public class DashboardDataResponse : ResponseBase
{
public List<DashboardItem> GroupData { get; set; } = [];
public Dashboard2Data Group1Data { get; set; }
public Dashboard2Data Group2Data { get; set; }
public Dashboard2Data Group3Data { get; set; }
public Dashboard2Data Group4Data { get; set; }
}
public class UserSearchResponse : TotalRowsResponseBase
{
public List<UserSearch> Value { get; set; } = [];
}
public class UserForceLogoutResponse : ResponseBase
{

View File

@ -0,0 +1,14 @@
using OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
using System.Threading.Tasks;
namespace OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Auth;
public interface IRefreshTokenService
{
Task<RefreshTokenResponse?> GetByTokenHashAsync(string tokenHash);
Task<bool> AddAsync(InsertRefreshTokenRequest refreshToken);
Task<bool> RevokeAsync(RevokedRefreshTokenRequest token);
Task<bool> RevokeAllForUserAsync(int userId);
Task<GenerateRefreshTokenResponse> GenerateRefreshToken(GenerateRefreshTokenRequest request);
}

View File

@ -0,0 +1,12 @@

using OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
using System.Threading.Tasks;
namespace OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Integrations;
public interface IIntegrationService
{
Task<bool> UpsertCustomerAsync(CustomerIntegrationRequest request);
Task<CustomerByCompanyCodeResponse> GetCustomerByCompanyCodeAsync(CustomerByCompanyCodeRequest request);
}

View File

@ -1,5 +1,6 @@
using OnlineSalesAutoCrop.CoreAPI.Models.Objects.Setups;
using OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems;
using OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Models.Requests.Systems;
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Systems;
using System;
@ -12,7 +13,9 @@ namespace OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Systems
{
Task<bool> ValidateAuthValueAsync(string authValue, int userId);
Task<User> LoginAsync(LoginRequest request, string ipAddress, bool checkPwd);
Task<bool> LogoutAsync(string ipAddress, int userId, int logId, bool attendanceLogout, string loginId, string localIp, string macAddress, string hostName, string logoutRemarks);
Task<User> IntegrationLoginAsync(IntegrationLoginRequest request, string ipAddress, bool checkPwd);
Task<bool> LogoutAsync(string ipAddress, int userId, int logId, bool attendanceLogout, string loginId, string localIp, string macAddress, string hostName, string logoutRemarks);
Task<bool> DeleteUserAsync(int userId, int deletedBy);
Task<bool> ForceLogoutNowAsync(List<int> userIds, string ipAddress);
@ -34,14 +37,12 @@ namespace OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Systems
Task<FindAccountResponse> FindAccountAsync(string accountId);
Task<UserAuthorizeLimitResponse> GetAuthorizeLimitAsync(int userId);
Task<UserAttributesResponse> GetAttributesAsync(int userId, int clientType);
Task<DashboardDataResponse> GetDashboardData(int userId, bool canViewLeave, bool canViewLate, bool canViewClientVisit, bool canViewHomeOffice, bool viewAll);
Task<int> LoadNotificationCountAsync(int userId);
Task<UserBasicInfoResponse> GetAttendanceUsersAsync(int userId);
Task<UserForceLogoutResponse> GetForceLogoutUsersAsync(int createdBy);
Task<UserSearchResponse> GetUsersAsync(UserSearchRequest request, int userId);
Task<bool> SendPasswordAsync(int userId, string newPassword, string ipAddress);
Task<UserBasicInfoResponse> GetUsersByTeamSpaceAsync(string teamSpaceIds, int projectId, int userId);
Task<UserBasicInfoResponse> GetUsersBasicAsync(bool applyFilter, string teamSpaceIds, int projectId);

View File

@ -0,0 +1,283 @@
using Ease.NetCore.DataAccess;
using Ease.NetCore.DataAccess.SQL;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Options;
using OnlineSalesAutoCrop.CoreAPI.Models.Global;
using OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems;
using OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Auth;
using System;
using System.Data;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace OnlineSalesAutoCrop.CoreAPI.Services.Services.Auth;
public class RefreshTokenService : IRefreshTokenService
{
private readonly AppSettings _settings;
public RefreshTokenService(IOptions<AppSettings> settings)
{
_settings = settings.Value;
}
public async Task<bool> AddAsync(InsertRefreshTokenRequest refreshToken)
{
bool returnValue = false;
try
{
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
AddAsync(tc, refreshToken);
tc.End();
}
catch (Exception e)
{
throw new InvalidOperationException(e.Message, e);
}
return returnValue;
}
private bool AddAsync( TransactionContext tc, InsertRefreshTokenRequest refreshToken)
{
bool returnValue = false;
try
{
SqlParameter[] p =
[
SqlHelperExtension.CreateInParam(pName: "@UserId", pType: SqlDbType.VarChar, pValue: refreshToken.UserId),
SqlHelperExtension.CreateInParam(pName: "@TokenHash", pType: SqlDbType.VarChar, pValue: refreshToken.TokenHash),
SqlHelperExtension.CreateInParam(pName: "@IpAddress", pType: SqlDbType.VarChar, pValue: refreshToken.IpAddress),
SqlHelperExtension.CreateInParam(pName: "@CreatedAt", pType: SqlDbType.DateTime, pValue: DateTime.Now),
SqlHelperExtension.CreateInParam(pName: "@ExpiredAt", pType: SqlDbType.DateTime, pValue: DateTime.Now.AddMinutes(_settings.RefreshTokenDuration)),
];
_ = tc.ExecuteNonQuerySp(spName: "dbo.InsertRefreshToken", parameterValues: p);
returnValue = true;
}
catch (Exception e)
{
throw new InvalidOperationException(e.Message, e);
}
return returnValue;
}
public async Task<RefreshTokenResponse> GetByTokenHashAsync(string tokenHash)
{
RefreshTokenResponse response = new();
try
{
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
try
{
await GetByTokenHashAsync(tc, tokenHash);
tc.End();
}
catch (Exception ie)
{
tc?.HandleError();
throw DBCustomError.GenerateCustomError(ie);
}
}
catch (Exception e)
{
throw new InvalidOperationException(e.Message, e);
}
return response;
}
private async Task<RefreshTokenResponse> GetByTokenHashAsync(TransactionContext tc, string tokenHash)
{
RefreshTokenResponse response = new();
try
{
SqlParameter[] p =
[
SqlHelperExtension.CreateInParam(pName: "@RefreshToken", pType: SqlDbType.VarChar, pValue: tokenHash),
];
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetRefreshTokenByTokenHash", parameterValues: p))
{
if (dr.Read())
{
response.UserId = dr.GetString(0);
response.TokenHash = dr.GetString(1);
response.IpAddress = dr.GetString(2);
response.ExpiredAt = dr.GetDateTime(3);
response.RevokedAt = dr.IsDBNull(4) ? null : dr.GetDateTime(4);
}
dr.Close();
}
}
catch (Exception e)
{
throw new InvalidOperationException(e.Message, e);
}
return response;
}
public async Task<bool> RevokeAllForUserAsync(int userId)
{
bool returnValue = false;
try
{
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
try
{
SqlParameter[] p =
[
SqlHelperExtension.CreateInParam(pName: "@UserId", pType: SqlDbType.Int, pValue: userId)
];
_ = await tc.ExecuteNonQuerySpAsync(spName: "dbo.RevokedAllRefreshToken", parameterValues: p);
returnValue = true;
tc.End();
}
catch (Exception ie)
{
tc?.HandleError();
throw DBCustomError.GenerateCustomError(ie);
}
}
catch (Exception e)
{
throw new InvalidOperationException(e.Message, e);
}
return returnValue;
}
public async Task<bool> RevokeAsync(RevokedRefreshTokenRequest token)
{
bool returnValue = false;
try
{
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
try
{
returnValue = RevokeAsync(tc, token);
tc.End();
}
catch (Exception ie)
{
tc?.HandleError();
throw DBCustomError.GenerateCustomError(ie);
}
}
catch (Exception e)
{
throw new InvalidOperationException(e.Message, e);
}
return returnValue;
}
private bool RevokeAsync(TransactionContext tc, RevokedRefreshTokenRequest token)
{
bool returnValue = false;
try
{
SqlParameter[] p =
[
SqlHelperExtension.CreateInParam(pName: "@RefreshToken", pType: SqlDbType.NVarChar, pValue: token.RefreshToken)
];
_ = tc.ExecuteNonQuerySp(spName: "dbo.RevokedAllRefreshToken", parameterValues: p);
returnValue = true;
}
catch (Exception e)
{
throw new InvalidOperationException(e.Message, e);
}
return returnValue;
}
public async Task<GenerateRefreshTokenResponse> GenerateRefreshToken(GenerateRefreshTokenRequest request)
{
GenerateRefreshTokenResponse refreshTokenResponse = new();
try
{
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode, true);
try
{
var tokenHash = HashToken(request.RawRefreshToken);
var storedToken = await GetByTokenHashAsync(tc, tokenHash);
if (storedToken.UserId is not null && !storedToken.IsActive)
throw new UnauthorizedAccessException("Refresh token has expired or been revoked.");
// Rotate: revoke old token, issue new one
RevokeAsync(tc,new RevokedRefreshTokenRequest() { RefreshToken = storedToken.TokenHash });
refreshTokenResponse= await IssueTokensAsync(tc,request.User, request.IpAddress);
tc.End();
}
catch (Exception ie)
{
tc?.HandleError();
throw DBCustomError.GenerateCustomError(ie);
}
}
catch (Exception e)
{
throw new InvalidOperationException(e.Message, e);
}
return refreshTokenResponse;
}
// ----- private helpers -----
private async Task<GenerateRefreshTokenResponse> IssueTokensAsync(TransactionContext tc, User user, string ipAddress)
{
string rawRefreshToken = GenerateRowToken();
var refreshToken = new InsertRefreshTokenRequest
{
UserId = user.UserId,
TokenHash = HashToken(rawRefreshToken),
IpAddress = ipAddress,
CreatedAt = DateTime.UtcNow,
ExpiresAt = DateTime.UtcNow.AddDays(_settings.RefreshTokenDuration)
};
AddAsync(tc,refreshToken);
return new GenerateRefreshTokenResponse
{
RefreshToken = rawRefreshToken,
ExpireTime = DateTime.UtcNow.AddMinutes(_settings.RefreshTokenDuration)
};
}
private static string HashToken(string token)
{
var bytes = SHA256.HashData(Encoding.UTF8.GetBytes(token));
return Convert.ToBase64String(bytes);
}
private string GenerateRowToken()
{
var bytes = new byte[64];
using var rng = RandomNumberGenerator.Create();
rng.GetBytes(bytes);
return Convert.ToBase64String(bytes);
}
}

View File

@ -0,0 +1,152 @@
using Ease.NetCore.DataAccess;
using Ease.NetCore.DataAccess.SQL;
using Microsoft.Data.SqlClient;
using Microsoft.Extensions.Options;
using OnlineSalesAutoCrop.CoreAPI.Models.Global;
using OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Integrations;
using System;
using System.Data;
using System.Security.Cryptography;
using System.Text;
using System.Threading.Tasks;
namespace OnlineSalesAutoCrop.CoreAPI.Services.Services.Integrations;
public class IntegrationService : IIntegrationService
{
private readonly AppSettings _settings;
public IntegrationService(IOptions<AppSettings> options)
{
_settings = options.Value;
}
public async Task<CustomerByCompanyCodeResponse> GetCustomerByCompanyCodeAsync(CustomerByCompanyCodeRequest request)
{
CustomerByCompanyCodeResponse response = new();
try
{
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
try
{
await GetCustomerByCompanyCodeAsync(tc, request);
tc.End();
}
catch (Exception ie)
{
tc?.HandleError();
throw DBCustomError.GenerateCustomError(ie);
}
}
catch (Exception ex)
{
throw;
}
return response;
}
public async Task<bool> UpsertCustomerAsync(CustomerIntegrationRequest request)
{
bool response = false;
try
{
using TransactionContext tc = await TransactionContext.BeginAsync(_settings.DefaultConnection.ConnectionNode);
try
{
var customer = await GetCustomerByCompanyCodeAsync(tc, new CustomerByCompanyCodeRequest() { CompanyCode = request.CompanyCode, CustomerNumber = request.CustomerNumber });
if( customer != null && customer.CustomerId>0)
{
//Update Here
}
else
{
//Insert Here
}
tc.End();
}
catch (Exception ie)
{
tc?.HandleError();
throw DBCustomError.GenerateCustomError(ie);
}
}
catch (Exception ex)
{
throw;
}
return response;
}
private async Task<CustomerByCompanyCodeResponse> GetCustomerByCompanyCodeAsync(TransactionContext tc, CustomerByCompanyCodeRequest request)
{
CustomerByCompanyCodeResponse response = new CustomerByCompanyCodeResponse();
try
{
SqlParameter[] p =
[
SqlHelperExtension.CreateInParam(pName: "@CustomerNumber", pType: SqlDbType.NVarChar,pValue: request.CustomerNumber ),
SqlHelperExtension.CreateInParam(pName: "@CompanyCode", pType: SqlDbType.NVarChar,pValue: request.CompanyCode ),
];
using (IDataReader dr = await tc.ExecuteReaderSpAsync("dbo.GetCustomerByCompanyCode", parameterValues: p))
{
if (dr.Read())
{
response = new CustomerByCompanyCodeResponse()
{
CustomerNumber = dr["CustomerNumber"].ToString(),
CustomerName = dr["CustomerName"].ToString(),
AccountGroup = dr["AccountGroup"].ToString(),
AccountGroupDescription = dr["AccountGroupDescription"].ToString(),
CompanyCode = dr["CompanyCode"].ToString(),
CompanyCodeDescription = dr["CompanyCodeDescription"].ToString(),
SalesOrganization = dr["SalesOrganization"].ToString(),
SalesOrganizationDescription = dr["SalesOrganizationDescription"].ToString(),
DistributionChannel = dr["DistributionChannel"].ToString(),
DistributionChannelDescription = dr["DistributionChannelDescription"].ToString(),
Division = dr["Division"].ToString(),
DivisionDescription = dr["DivisionDescription"].ToString(),
MobileNumber = dr["MobileNumber"].ToString(),
EmailAddress = dr["EmailAddress"].ToString(),
BusinessTaxNumber = dr["BusinessTaxNumber"].ToString(),
CreditLimit = dr["CreditLimit"] == DBNull.Value ? 0 : Convert.ToDecimal(dr["CreditLimit"]),
SalesOffice = dr["SalesOffice"].ToString(),
SalesOfficeDescription = dr["SalesOfficeDescription"].ToString(),
SalesGroup = dr["SalesGroup"].ToString(),
CustomerGroup = dr["CustomerGroup"].ToString(),
Status = dr["Status"].ToString(),
PaymentTerms = dr["PaymentTerms"].ToString(),
SearchTerm = dr["SearchTerm"].ToString(),
Region = dr["Region"].ToString(),
RegionName = dr["RegionName"].ToString(),
Area = dr["Area"].ToString(),
AreaName = dr["AreaName"].ToString(),
SalesUnit = dr["SalesUnit"].ToString(),
SalesUnitName = dr["SalesUnitName"].ToString(),
Territory = dr["Territory"].ToString(),
TerritoryName = dr["TerritoryName"].ToString(),
Plant = dr["Plant"].ToString(),
PlantName = dr["PlantName"].ToString()
};
}
dr.Close();
}
}
catch(Exception ex)
{
throw;
}
return response;
}
}

View File

@ -1,8 +1,12 @@
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Setups;
using Microsoft.Extensions.DependencyInjection;
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Auth;
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Setups;
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Systems;
using OnlineSalesAutoCrop.CoreAPI.Services.Services.Auth;
using OnlineSalesAutoCrop.CoreAPI.Services.Services.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Services.Services.Setups;
using OnlineSalesAutoCrop.CoreAPI.Services.Services.Systems;
using Microsoft.Extensions.DependencyInjection;
namespace OnlineSalesAutoCrop.CoreAPI.Configuration.DI
{
@ -25,7 +29,8 @@ namespace OnlineSalesAutoCrop.CoreAPI.Configuration.DI
services.AddTransient<IParamTypeService, ParamTypeService>();
services.AddTransient<IThisSystemService, ThisSystemService>();
services.AddTransient<IAuthModulesService, AuthModulesService>();
services.AddTransient<IRefreshTokenService, RefreshTokenService>();
services.AddScoped<IIntegrationService, IntegrationService>();
}
}
}

View File

@ -0,0 +1,74 @@
using Asp.Versioning;
using Microsoft.AspNetCore.Authorization;
using Microsoft.AspNetCore.Http;
using Microsoft.AspNetCore.Mvc;
using Microsoft.Extensions.Logging;
using OnlineSalesAutoCrop.CoreAPI.Models.Requests.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Models.Responses.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Services.Contracts.Integrations;
using OnlineSalesAutoCrop.CoreAPI.Services.Services.Integrations;
using System;
using System.Threading.Tasks;
namespace OnlineSalesAutoCrop.CoreAPI.Controllers.IntegretionApi
{
/// <summary>
///
/// </summary>
/// <remarks>
///
/// </remarks>
/// <param name="logger"></param>
/// <param name="integrationService"></param>
[Authorize]
[ApiController]
[ApiVersion("1.0")]
[ValidateAntiForgeryToken]
[Route("api/v{version:apiVersion}/Integration")]
public class IntegrationController(ILogger<IntegrationAuthController> logger, IIntegrationService integrationService) : ControllerBase
{
private readonly ILogger _logger = logger;
private readonly IIntegrationService _integrationService = integrationService;
/// <summary>
/// Insert or Update Customers for SAP
/// </summary>
/// <remarks>
/// </remarks>
/// <param name="request"></param>
/// <returns>if created return 201 or if updated return 204 true</returns>
[HttpGet("Customers")]
[IgnoreAntiforgeryToken]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(IntegrationLoginResponse))]
public async Task<IActionResult> UpsertCustomers(CustomerIntegrationRequest request)
{
CustomerIntegrationResponse response = new CustomerIntegrationResponse();
try
{
bool result = await _integrationService.UpsertCustomerAsync(request);
if (result)
{
response.ReturnMessage.Add($"Customer Created Successfully for CustomerNumber :{request.CustomerNumber} & CompanyCode:{request.CompanyCode}");
response.ReturnStatus = StatusCodes.Status201Created;
return StatusCode(StatusCodes.Status201Created, response);
}
else
{
response.ReturnMessage.Add($"Customer Updated Successfully for CustomerNumber :{request.CustomerNumber} & CompanyCode:{request.CompanyCode}");
response.ReturnStatus = StatusCodes.Status204NoContent;
return StatusCode(StatusCodes.Status204NoContent, response);
}
}
catch (Exception ex)
{
string msg = $"Exception Occur in Customer Operation {request?.CustomerName}~{request?.CompanyCode}";
_logger.LogError(exception: ex, msg);
response.ReturnStatus = StatusCodes.Status500InternalServerError;
response.ReturnMessage.Add(ex.InnerException != null ? ex.InnerException.Message : ex.Message);
return StatusCode(StatusCodes.Status500InternalServerError, response);
}
}
}
}

View File

@ -3,7 +3,6 @@ using OnlineSalesAutoCrop.CoreAPI.Configurations;
using OnlineSalesAutoCrop.CoreAPI.Models;
using OnlineSalesAutoCrop.CoreAPI.Models.Global;
using OnlineSalesAutoCrop.CoreAPI.Models.Objects;
using OnlineSalesAutoCrop.CoreAPI.Models.Objects.Setups;
using OnlineSalesAutoCrop.CoreAPI.Models.Objects.Systems;
using OnlineSalesAutoCrop.CoreAPI.Models.Requests;
using OnlineSalesAutoCrop.CoreAPI.Models.Requests.Setups;
@ -19,7 +18,6 @@ using Microsoft.AspNetCore.SignalR;
using Microsoft.Extensions.Logging;
using Microsoft.Extensions.Options;
using Microsoft.IdentityModel.Tokens;
using Microsoft.Reporting.NETCore;
using System;
using System.Collections.Generic;
using System.DirectoryServices;
@ -51,7 +49,7 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.V1
[ValidateAntiForgeryToken]
[Route("api/v{version:apiVersion}/users")]
public class UserController(IUserService service, IOptions<AppSettings> appSettings, IEaseCache cache, ILogger<UserController> logger, IHubContext<NotificationHub, INotificationHub> hub) : ControllerBase
public class UserController(IUserService service, IOptions<AppSettings> appSettings, IEaseCache cache, ILogger<IntegrationAuthController> logger, IHubContext<NotificationHub, INotificationHub> hub) : ControllerBase
{
private readonly ILogger _logger = logger;
private readonly IEaseCache _cache = cache;
@ -148,7 +146,7 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.V1
ipAddress = Request.HttpContext.GetIpAddress();
User user = await _service.LoginAsync(request: request, ipAddress: ipAddress, checkPwd: checkPwd);
if (user == null || user.Id == 0)
if (user == null || user.UserId == 0)
{
response.LoginStatus = EnumLoginStatus.Error;
response.ReturnStatus = StatusCodes.Status403Forbidden;
@ -207,7 +205,7 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.V1
response.Map(user);
response.ValidUser = true;
response.ReturnStatus = StatusCodes.Status200OK;
response.PwdChangeRequired = (user.AccessStatus == EnumAccessStatus.FirstTime) || (user.ExpireDate.HasValue && user.ExpireDate.Value.Date < DateTime.Today.Date);
//response.PwdChangeRequired = (user.AccessStatus == EnumAccessStatus.FirstTime) || (user.ExpireDate.HasValue && user.ExpireDate.Value.Date < DateTime.Today.Date);
string pwdSecretKey = GlobalFunctions.ConvertFromBase64String(_appSettings.PwdSecretKey);
string userPwd = Ease.NetCore.Utility.Global.CipherFunctions.EncryptByAES(privateKey: pwdSecretKey, publicKey: pwdSecretKey, data: request.Password);
@ -217,15 +215,15 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.V1
{
Subject = new ClaimsIdentity(
[
Helper.CreateClaim("UserId", $"{user.Id}"),
Helper.CreateClaim("LoginId", user.LoginId),
Helper.CreateClaim("UserPwd", userPwd),
Helper.CreateClaim("AuthKey", $"{user.AuthKey}"),
Helper.CreateClaim("TeamSpaceIds", $"{string.Join(',',user.TeamSpaceIds)}"),
Helper.CreateClaim("BatchEnabled", user.BatchEnabled ? "1" : "0"),
Helper.CreateClaim("BmProcessId", $"{user.BmProcessId}"),
Helper.CreateClaim("PrProcessId", $"{user.PrProcessId}"),
Helper.CreateClaim("EmployeeId", $"{user.EmployeeCode}")
//Helper.CreateClaim("UserId", $"{user.Id}"),
//Helper.CreateClaim("LoginId", user.LoginId),
//Helper.CreateClaim("UserPwd", userPwd),
//Helper.CreateClaim("AuthKey", $"{user.AuthKey}"),
//Helper.CreateClaim("TeamSpaceIds", $"{string.Join(',',user.TeamSpaceIds)}"),
//Helper.CreateClaim("BatchEnabled", user.BatchEnabled ? "1" : "0"),
//Helper.CreateClaim("BmProcessId", $"{user.BmProcessId}"),
//Helper.CreateClaim("PrProcessId", $"{user.PrProcessId}"),
//Helper.CreateClaim("EmployeeId", $"{user.EmployeeCode}")
]),
Expires = DateTime.UtcNow.AddHours(12),
SigningCredentials = new SigningCredentials(new SymmetricSecurityKey(key), SecurityAlgorithms.HmacSha512Signature)
@ -248,35 +246,35 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.V1
response.AuthenticationToken = userToken;
response.LoginTime = $"{DateTime.Now:dd-MM-yy H:mm:ss}";
await HttpContext.Session.SetModulesToSession(key: userToken, value: user.ModuleIds);
if (user.LoginStatus == EnumLoginStatus.Success)
{
if (user.AuthMethod == EnumAuthenticationMethod.Email && !string.IsNullOrEmpty(user.EmailAddress) && !string.IsNullOrWhiteSpace(user.EmailAddress) && !string.IsNullOrWhiteSpace(user.AuthValue))
{
List<string> to = [.. user.EmailAddress.Split(separator: ';', options: StringSplitOptions.RemoveEmptyEntries)];
await MailHelper.SendMailMessageAsync(settings: _appSettings, to: to,
cc: null, bcc: null, attachments: null, embeddedImages: null, isHtmlBody: false, priority: System.Net.Mail.MailPriority.Normal,
subject: "Your OTP", messageBody: string.Format("Your OTP: {0} and is valid for 5 minutes only", user.AuthValue));
}
else if (user.AuthMethod == EnumAuthenticationMethod.MobileSMS && !string.IsNullOrEmpty(user.MobileNo) && !string.IsNullOrWhiteSpace(user.MobileNo) && !string.IsNullOrWhiteSpace(user.AuthValue))
{
MailHelper.SendSMSOrWhatsAppMessage(settings: _appSettings, whatsAppMsg: false, msg: string.Format("Your OTP: {0} and is valid for 5 minutes only", user.AuthValue), mobileNumber: user.MobileNo);
}
}
//await HttpContext.Session.SetModulesToSession(key: userToken, value: user.ModuleIds);
//if (user.LoginStatus == EnumLoginStatus.Success)
//{
// if (user.AuthMethod == EnumAuthenticationMethod.Email && !string.IsNullOrEmpty(user.EmailAddress) && !string.IsNullOrWhiteSpace(user.EmailAddress) && !string.IsNullOrWhiteSpace(user.AuthValue))
// {
// List<string> to = [.. user.EmailAddress.Split(separator: ';', options: StringSplitOptions.RemoveEmptyEntries)];
// await MailHelper.SendMailMessageAsync(settings: _appSettings, to: to,
// cc: null, bcc: null, attachments: null, embeddedImages: null, isHtmlBody: false, priority: System.Net.Mail.MailPriority.Normal,
// subject: "Your OTP", messageBody: string.Format("Your OTP: {0} and is valid for 5 minutes only", user.AuthValue));
// }
// else if (user.AuthMethod == EnumAuthenticationMethod.MobileSMS && !string.IsNullOrEmpty(user.MobileNo) && !string.IsNullOrWhiteSpace(user.MobileNo) && !string.IsNullOrWhiteSpace(user.AuthValue))
// {
// MailHelper.SendSMSOrWhatsAppMessage(settings: _appSettings, whatsAppMsg: false, msg: string.Format("Your OTP: {0} and is valid for 5 minutes only", user.AuthValue), mobileNumber: user.MobileNo);
// }
//}
if (user.DisallowMultiLogin)
{
await _hub.Clients.All.NotifySubscriber(userId: user.Id, msgType: 1, itemId: 0, ipAddress: ipAddress);
if (request.AttendanceLogin)
await _hub.Clients.All.NotifySubscriber(userId: user.Id, msgType: 6, itemId: 0, ipAddress: ipAddress);
}
else
{
await _hub.Clients.All.NotifySubscriber(userId: user.Id, msgType: 2, itemId: 0, ipAddress: ipAddress);
if (request.AttendanceLogin)
await _hub.Clients.All.NotifySubscriber(userId: user.Id, msgType: 6, itemId: 0, ipAddress: ipAddress);
}
response.IdsValue = Ease.NetCore.Utility.Global.CipherFunctions.EncryptByAES(data: Newtonsoft.Json.JsonConvert.SerializeObject(user.ModuleIds), privateKey: cipherSecretKey, publicKey: cipherSecretKey, output: 2);
//if (user.DisallowMultiLogin)
//{
// await _hub.Clients.All.NotifySubscriber(userId: user.Id, msgType: 1, itemId: 0, ipAddress: ipAddress);
// if (request.AttendanceLogin)
// await _hub.Clients.All.NotifySubscriber(userId: user.Id, msgType: 6, itemId: 0, ipAddress: ipAddress);
//}
//else
//{
// await _hub.Clients.All.NotifySubscriber(userId: user.Id, msgType: 2, itemId: 0, ipAddress: ipAddress);
// if (request.AttendanceLogin)
// await _hub.Clients.All.NotifySubscriber(userId: user.Id, msgType: 6, itemId: 0, ipAddress: ipAddress);
//}
//response.IdsValue = Ease.NetCore.Utility.Global.CipherFunctions.EncryptByAES(data: Newtonsoft.Json.JsonConvert.SerializeObject(user.ModuleIds), privateKey: cipherSecretKey, publicKey: cipherSecretKey, output: 2);
return Ok(response);
}
@ -998,39 +996,39 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.V1
/// </returns>
/// <response code="200">Top 50 users</response>
/// <response code="204">If the item is null.</response>
[ValidateSession]
[HttpPost("getUsers")]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(UserSearchResponse))]
[ProducesResponseType(StatusCodes.Status204NoContent, Type = typeof(UserSearchResponse))]
public async Task<IActionResult> GetUsers([FromBody] UserSearchRequest request)
{
ArgumentNullException.ThrowIfNull(request);
//[ValidateSession]
//[HttpPost("getUsers")]
//[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(UserSearchResponse))]
//[ProducesResponseType(StatusCodes.Status204NoContent, Type = typeof(UserSearchResponse))]
//public async Task<IActionResult> GetUsers([FromBody] UserSearchRequest request)
//{
// ArgumentNullException.ThrowIfNull(request);
UserSearchResponse response = new() { ReturnStatus = StatusCodes.Status200OK };
try
{
int userId = HttpContext.User.GetClaimValue<int>(Constants.UserId);
request.CheckOwner = userId != Models.Objects.Systems.User.SuperUser_Id;
// UserSearchResponse response = new() { ReturnStatus = StatusCodes.Status200OK };
// try
// {
// int userId = HttpContext.User.GetClaimValue<int>(Constants.UserId);
// request.CheckOwner = userId != Models.Objects.Systems.User.SuperUser_Id;
string key = "Users";
string key2 = $"{request.Criteria}~{request.Status}~{request.SortField}~{request.SortOrder}~{request.Skip}~{request.PageSize}~{request.CheckOwner}~{userId}";
if (!_cache.TryGetValue(key: key, key2: key2, value: out response))
{
response = await _service.GetUsersAsync(request: request, userId: userId);
_ = _cache.Set(key: key, key2: key2, value: response, options: _options);
}
// string key = "Users";
// string key2 = $"{request.Criteria}~{request.Status}~{request.SortField}~{request.SortOrder}~{request.Skip}~{request.PageSize}~{request.CheckOwner}~{userId}";
// if (!_cache.TryGetValue(key: key, key2: key2, value: out response))
// {
// response = await _service.GetUsersAsync(request: request, userId: userId);
// _ = _cache.Set(key: key, key2: key2, value: response, options: _options);
// }
response.ReturnStatus = StatusCodes.Status200OK;
return Ok(response);
}
catch (Exception ex)
{
_logger.LogError(ex);
response.ReturnStatus = StatusCodes.Status500InternalServerError;
response.ReturnMessage.Add(ex.InnerException != null ? ex.InnerException.Message : ex.Message);
return StatusCode(StatusCodes.Status500InternalServerError, response);
}
}
// response.ReturnStatus = StatusCodes.Status200OK;
// return Ok(response);
// }
// catch (Exception ex)
// {
// _logger.LogError(ex);
// response.ReturnStatus = StatusCodes.Status500InternalServerError;
// response.ReturnMessage.Add(ex.InnerException != null ? ex.InnerException.Message : ex.Message);
// return StatusCode(StatusCodes.Status500InternalServerError, response);
// }
//}
/// <summary>
///
@ -1356,41 +1354,7 @@ namespace OnlineSalesAutoCrop.CoreAPI.Controllers.V1
}
}
/// <summary>
///
/// </summary>
/// <returns></returns>
[ValidateSession]
[HttpPost("getDashboardData")]
[ProducesResponseType(StatusCodes.Status200OK, Type = typeof(DashboardDataResponse))]
[ProducesResponseType(StatusCodes.Status204NoContent, Type = typeof(DashboardDataResponse))]
public async Task<IActionResult> GetDashboardData([FromBody] NoContentRequest request)
{
ArgumentNullException.ThrowIfNull(request);
DashboardDataResponse response = new() { ReturnStatus = StatusCodes.Status200OK };
try
{
bool viewAll = await HttpContext.IsPermitted("ELIT.8.2.5_2");
bool canViewLate = await HttpContext.IsPermitted("ELIT.8.2.2");
bool canViewLeave = await HttpContext.IsPermitted("ELIT.8.2.1");
int userId = HttpContext.User.GetClaimValue<int>(Constants.UserId);
bool canViewHomeOffice = await HttpContext.IsPermitted("ELIT.8.2.4");
bool canViewClientVisit = await HttpContext.IsPermitted("ELIT.8.2.3");
response = await _service.GetDashboardData(userId: userId, canViewLeave: canViewLeave, canViewLate: canViewLate,
canViewClientVisit: canViewClientVisit, canViewHomeOffice: canViewHomeOffice, viewAll: viewAll);
response.ReturnStatus = StatusCodes.Status200OK;
return Ok(response);
}
catch (Exception ex)
{
_logger.LogError(ex);
response.ReturnStatus = StatusCodes.Status500InternalServerError;
response.ReturnMessage.Add(ex.InnerException != null ? ex.InnerException.Message : ex.Message);
return StatusCode(StatusCodes.Status500InternalServerError, response);
}
}
/// <summary>
///

View File

@ -1,33 +0,0 @@
# See https://aka.ms/customizecontainer to learn how to customize your debug container and how Visual Studio uses this Dockerfile to build your images for faster debugging.
# Depending on the operating system of the host machines(s) that will build or run the containers, the image specified in the FROM statement may need to be changed.
# For more information, please see https://aka.ms/containercompat
# This stage is used when running from VS in fast mode (Default for Debug configuration)
FROM mcr.microsoft.com/dotnet/aspnet:9.0-nanoserver-1809 AS base
WORKDIR /app
EXPOSE 8080
# This stage is used to build the service project
FROM mcr.microsoft.com/dotnet/sdk:9.0-nanoserver-1809 AS build
ARG BUILD_CONFIGURATION=Release
WORKDIR /src
COPY ["Api/OnlineSalesAutoCrop.CoreAPI/OnlineSalesAutoCrop.CoreAPI.csproj", "Api/OnlineSalesAutoCrop.CoreAPI/"]
COPY ["Api/OnlineSalesAutoCrop.CoreAPI.Models/OnlineSalesAutoCrop.CoreAPI.Models.csproj", "Api/OnlineSalesAutoCrop.CoreAPI.Models/"]
COPY ["Api/OnlineSalesAutoCrop.CoreAPI.Services/OnlineSalesAutoCrop.CoreAPI.Services.csproj", "Api/OnlineSalesAutoCrop.CoreAPI.Services/"]
RUN dotnet restore "./Api/OnlineSalesAutoCrop.CoreAPI/OnlineSalesAutoCrop.CoreAPI.csproj"
COPY . .
WORKDIR "/src/Api/OnlineSalesAutoCrop.CoreAPI"
RUN dotnet build "./OnlineSalesAutoCrop.CoreAPI.csproj" -c %BUILD_CONFIGURATION% -o /app/build
# This stage is used to publish the service project to be copied to the final stage
FROM build AS publish
ARG BUILD_CONFIGURATION=Release
RUN dotnet publish "./OnlineSalesAutoCrop.CoreAPI.csproj" -c %BUILD_CONFIGURATION% -o /app/publish /p:UseAppHost=false
# This stage is used in production or when running from VS in regular mode (Default when not using the Debug configuration)
FROM base AS final
WORKDIR /app
COPY --from=publish /app/publish .
ENTRYPOINT ["dotnet", "OnlineSalesAutoCrop.CoreAPI.dll"]

View File

@ -3,6 +3,8 @@
<PropertyGroup>
<NameOfLastUsedPublishProfile>D:\Local\EaseBilling\Api\EaseO2C.CoreAPI\Properties\PublishProfiles\Windows.Publish.pubxml</NameOfLastUsedPublishProfile>
<ActiveDebugProfile>IIS Express</ActiveDebugProfile>
<Controller_SelectedScaffolderID>ApiControllerEmptyScaffolder</Controller_SelectedScaffolderID>
<Controller_SelectedScaffolderCategoryPath>root/Common/Api</Controller_SelectedScaffolderCategoryPath>
</PropertyGroup>
<PropertyGroup Condition="'$(Configuration)|$(Platform)'=='Debug|AnyCPU'">
<DebuggerFlavor>ProjectDebugger</DebuggerFlavor>

View File

@ -57,6 +57,7 @@ namespace OnlineSalesAutoCrop.CoreAPI
_appSettings = Configuration.GetSection("AppSettings").Get<AppSettings>();
}
/// <summary>
///
/// </summary>

View File

@ -29,54 +29,9 @@
"DbConfig": [
{
"ConnectionNode": {
"ConnectionString": "Data Source=103.197.204.162,3341;Initial Catalog=OnlineSalesAutoCrop;User ID=OnlineSalesAutoCropSysUser;Password=OnlineSalesAutoCrop;Encrypt=false;",
"EncryptKey": "",
"ConnectionString": "Data Source=210.4.65.222,3341;Initial Catalog=AutoCropDB;User ID=dmsuser;Password=dMsu@er;Encrypt=false;",
"Key": "spadb1",
"Provider": "sql",
"SqlSyntax": "SQL"
}
},
{
"ConnectionNode": {
"ConnectionString": "V3DJ2Y3A4Tzp9y3WKGINJWSjQdvo7QxL+U4VfYkfrfbZB8b4sNPPgJM5J17wFLAmaOzvDmGBK0hN5TX8iOYEdntndR1isy1SqPZgoyEshX+87OQYsKVKrl85foY49BJGB75CdAuVXoizsLsDrKcNzw==",
"Key": "spadb2",
"Provider": "sql",
"SqlSyntax": "SQL",
"EncryptKey": "RWFzZURoMTk5MlRvMjAyMw=="
}
},
{
"ConnectionNode": {
"ConnectionString": "M6aE4Nur0oHi9ddFe/IC/VlXYQTfJSafpWzjFeSHfNrozfGF/ZJMBLEMLe9SwVt0SUisTwL+5v5l1TYsYkpn9Dgo+K2H2X+OMsql1pf1vww=",
"Key": "spadb3",
"Provider": "sql",
"SqlSyntax": "SQL",
"EncryptKey": "RWFzZURoMTk5MlRvMjAyMw=="
}
},
{
"ConnectionNode": {
"ConnectionString": "Server=Russel;Initial Catalog=OnlineSalesAutoCrop;Integrated Security=True;TrustServerCertificate=True;Encrypt=true;",
"Key": "spadb4",
"Provider": "sql",
"SqlSyntax": "SQL",
"EncryptKey": ""
}
},
{
"ConnectionNode": {
"ConnectionString": "Data Source=100.100.100.80;Initial Catalog=OnlineSalesAutoCrop;User ID=OnlineSalesAutoCropSysuser;Password=[password];Encrypt=false;",
"Key": "spadb6",
"Provider": "sql",
"SqlSyntax": "SQL",
"EncryptKey": ""
}
},
{
"ConnectionNode": {
"ConnectionString": "Data Source=210.4.65.222,3341;Initial Catalog=OnlineSalesAutoCrop;User ID=OnlineSalesAutoCropSysUser;Password=OnlineSalesAutoCrop;Encrypt=false;",
"Key": "spadb7",
"Provider": "sql",
"SqlSyntax": "SQL",
"EncryptKey": ""
}
@ -128,7 +83,8 @@
"WaAccountSid": "AC0138ad79a532f653c35072dad10e52b9",
"WaAuthToken": "024a6897584671d9f9fa588d7c94aa96",
"WaMsgSvcSid": "MG8401d33a9a3b2aea95619bda3e5757b5",
"WaSenderId": "+8801326755660"
"WaSenderId": "+8801326755660",
"RefreshTokenDuration": "15"
},
"MenuSettings": {